ext-modern-debug.js 2.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605
  1. /*
  2. This file is part of Ext JS 6.6.0.258
  3. Copyright (c) 2011-2018 Sencha Inc
  4. license: http://www.sencha.com/legal/sencha-software-license-agreement
  5. Contact: http://www.sencha.com/contact
  6. Commercial Usage
  7. Licensees holding valid commercial licenses may use this file in accordance with the Commercial
  8. Software License Agreement referenced above or, alternatively, in accordance with the
  9. terms contained in a written agreement between you and Sencha.
  10. If you are unsure which license is appropriate for your use, please contact the sales department
  11. at http://www.sencha.com/contact.
  12. Version: 6.6.0.258 Build date: 2018-06-19 05:16:53 (a26fc5ffb54acf6e1afd5f18c467b14161985898)
  13. */
  14. // @tag core
  15. var Ext = Ext || {};
  16. Ext.Boot = Ext.Boot || (function(emptyFn) {
  17. var doc = document,
  18. _emptyArray = [],
  19. _config = {
  20. disableCaching: (/[?&](?:cache|disableCacheBuster)\b/i.test(location.search) || !(/http[s]?\:/i.test(location.href)) || /(^|[ ;])ext-cache=1/.test(doc.cookie)) ? false : true,
  21. disableCachingParam: '_dc',
  22. loadDelay: false,
  23. preserveScripts: true,
  24. charset: 'UTF-8'
  25. },
  26. _assetConfig = {},
  27. cssRe = /\.css(?:\?|$)/i,
  28. resolverEl = doc.createElement('a'),
  29. isBrowser = typeof window !== 'undefined',
  30. _environment = {
  31. browser: isBrowser,
  32. node: !isBrowser && (typeof require === 'function'),
  33. phantom: (window && (window._phantom || window.callPhantom)) || /PhantomJS/.test(window.navigator.userAgent)
  34. },
  35. _tags = (Ext.platformTags = {}),
  36. _debug = function(message) {},
  37. _apply = function(object, config, defaults) {
  38. if (defaults) {
  39. _apply(object, defaults);
  40. }
  41. if (object && config && typeof config === 'object') {
  42. for (var i in config) {
  43. object[i] = config[i];
  44. }
  45. }
  46. return object;
  47. },
  48. _merge = function() {
  49. var lowerCase = false,
  50. obj = Array.prototype.shift.call(arguments),
  51. index, i, len, value;
  52. if (typeof arguments[arguments.length - 1] === 'boolean') {
  53. lowerCase = Array.prototype.pop.call(arguments);
  54. }
  55. len = arguments.length;
  56. for (index = 0; index < len; index++) {
  57. value = arguments[index];
  58. if (typeof value === 'object') {
  59. for (i in value) {
  60. obj[lowerCase ? i.toLowerCase() : i] = value[i];
  61. }
  62. }
  63. }
  64. return obj;
  65. },
  66. _getKeys = (typeof Object.keys == 'function') ? function(object) {
  67. if (!object) {
  68. return [];
  69. }
  70. return Object.keys(object);
  71. } : function(object) {
  72. var keys = [],
  73. property;
  74. for (property in object) {
  75. if (object.hasOwnProperty(property)) {
  76. keys.push(property);
  77. }
  78. }
  79. return keys;
  80. },
  81. Boot = {
  82. loading: 0,
  83. loaded: 0,
  84. apply: _apply,
  85. env: _environment,
  86. config: _config,
  87. assetConfig: _assetConfig,
  88. scripts: {},
  89. currentFile: null,
  90. suspendedQueue: [],
  91. currentRequest: null,
  92. syncMode: false,
  93. debug: _debug,
  94. useElements: true,
  95. listeners: [],
  96. Request: Request,
  97. Entry: Entry,
  98. allowMultipleBrowsers: false,
  99. browserNames: {
  100. ie: 'IE',
  101. firefox: 'Firefox',
  102. safari: 'Safari',
  103. chrome: 'Chrome',
  104. opera: 'Opera',
  105. dolfin: 'Dolfin',
  106. edge: 'Edge',
  107. webosbrowser: 'webOSBrowser',
  108. chromeMobile: 'ChromeMobile',
  109. chromeiOS: 'ChromeiOS',
  110. silk: 'Silk',
  111. other: 'Other'
  112. },
  113. osNames: {
  114. ios: 'iOS',
  115. android: 'Android',
  116. windowsPhone: 'WindowsPhone',
  117. webos: 'webOS',
  118. blackberry: 'BlackBerry',
  119. rimTablet: 'RIMTablet',
  120. mac: 'MacOS',
  121. win: 'Windows',
  122. tizen: 'Tizen',
  123. linux: 'Linux',
  124. bada: 'Bada',
  125. chromeOS: 'ChromeOS',
  126. other: 'Other'
  127. },
  128. browserPrefixes: {
  129. ie: 'MSIE ',
  130. edge: 'Edge/',
  131. firefox: 'Firefox/',
  132. chrome: 'Chrome/',
  133. safari: 'Version/',
  134. opera: 'OPR/',
  135. dolfin: 'Dolfin/',
  136. webosbrowser: 'wOSBrowser/',
  137. chromeMobile: 'CrMo/',
  138. chromeiOS: 'CriOS/',
  139. silk: 'Silk/'
  140. },
  141. browserPriority: [
  142. 'edge',
  143. 'opera',
  144. 'dolfin',
  145. 'webosbrowser',
  146. 'silk',
  147. 'chromeiOS',
  148. 'chromeMobile',
  149. 'ie',
  150. 'firefox',
  151. 'safari',
  152. 'chrome'
  153. ],
  154. osPrefixes: {
  155. tizen: '(Tizen )',
  156. ios: 'i(?:Pad|Phone|Pod)(?:.*)CPU(?: iPhone)? OS ',
  157. android: '(Android |HTC_|Silk/)',
  158. windowsPhone: 'Windows Phone ',
  159. blackberry: '(?:BlackBerry|BB)(?:.*)Version/',
  160. rimTablet: 'RIM Tablet OS ',
  161. webos: '(?:webOS|hpwOS)/',
  162. bada: 'Bada/',
  163. chromeOS: 'CrOS '
  164. },
  165. fallbackOSPrefixes: {
  166. windows: 'win',
  167. mac: 'mac',
  168. linux: 'linux'
  169. },
  170. devicePrefixes: {
  171. iPhone: 'iPhone',
  172. iPod: 'iPod',
  173. iPad: 'iPad'
  174. },
  175. maxIEVersion: 12,
  176. detectPlatformTags: function() {
  177. var me = this,
  178. ua = navigator.userAgent,
  179. isMobile = /Mobile(\/|\s)/.test(ua),
  180. element = document.createElement('div'),
  181. isEventSupported = function(name, tag) {
  182. if (tag === undefined) {
  183. tag = window;
  184. }
  185. var eventName = 'on' + name.toLowerCase(),
  186. isSupported = (eventName in element);
  187. if (!isSupported) {
  188. if (element.setAttribute && element.removeAttribute) {
  189. element.setAttribute(eventName, '');
  190. isSupported = typeof element[eventName] === 'function';
  191. if (typeof element[eventName] !== 'undefined') {
  192. element[eventName] = undefined;
  193. }
  194. element.removeAttribute(eventName);
  195. }
  196. }
  197. return isSupported;
  198. },
  199. getBrowsers = function() {
  200. var browsers = {},
  201. maxIEVersion, prefix, value, key, index, len, match, version, matched;
  202. len = me.browserPriority.length;
  203. for (index = 0; index < len; index++) {
  204. key = me.browserPriority[index];
  205. if (!matched) {
  206. value = me.browserPrefixes[key];
  207. match = ua.match(new RegExp('(' + value + ')([\\w\\._]+)'));
  208. version = match && match.length > 1 ? parseInt(match[2]) : 0;
  209. if (version) {
  210. matched = true;
  211. }
  212. } else {
  213. version = 0;
  214. }
  215. browsers[key] = version;
  216. }
  217. if (browsers.ie) {
  218. var mode = document.documentMode;
  219. if (mode >= 8) {
  220. browsers.ie = mode;
  221. }
  222. }
  223. version = browsers.ie || false;
  224. maxIEVersion = Math.max(version, me.maxIEVersion);
  225. for (index = 8; index <= maxIEVersion; ++index) {
  226. prefix = 'ie' + index;
  227. browsers[prefix + 'm'] = version ? version <= index : 0;
  228. browsers[prefix] = version ? version === index : 0;
  229. browsers[prefix + 'p'] = version ? version >= index : 0;
  230. }
  231. return browsers;
  232. },
  233. getOperatingSystems = function() {
  234. var systems = {},
  235. value, key, keys, index, len, match, matched, version, activeCount;
  236. keys = _getKeys(me.osPrefixes);
  237. len = keys.length;
  238. for (index = 0 , activeCount = 0; index < len; index++) {
  239. key = keys[index];
  240. value = me.osPrefixes[key];
  241. match = ua.match(new RegExp('(' + value + ')([^\\s;]+)'));
  242. matched = match ? match[1] : null;
  243. if (matched && (matched === 'HTC_' || matched === 'Silk/')) {
  244. version = 2.3;
  245. } else {
  246. version = match && match.length > 1 ? parseFloat(match[match.length - 1]) : 0;
  247. }
  248. if (version) {
  249. activeCount++;
  250. }
  251. systems[key] = version;
  252. }
  253. keys = _getKeys(me.fallbackOSPrefixes);
  254. len = keys.length;
  255. for (index = 0; index < len; index++) {
  256. key = keys[index];
  257. if (activeCount === 0) {
  258. value = me.fallbackOSPrefixes[key];
  259. match = ua.toLowerCase().match(new RegExp(value));
  260. systems[key] = match ? true : 0;
  261. } else {
  262. systems[key] = 0;
  263. }
  264. }
  265. return systems;
  266. },
  267. getDevices = function() {
  268. var devices = {},
  269. value, key, keys, index, len, match;
  270. keys = _getKeys(me.devicePrefixes);
  271. len = keys.length;
  272. for (index = 0; index < len; index++) {
  273. key = keys[index];
  274. value = me.devicePrefixes[key];
  275. match = ua.match(new RegExp(value));
  276. devices[key] = match ? true : 0;
  277. }
  278. return devices;
  279. },
  280. browsers = getBrowsers(),
  281. systems = getOperatingSystems(),
  282. devices = getDevices(),
  283. platformParams = Boot.loadPlatformsParam();
  284. _merge(_tags, browsers, systems, devices, platformParams, true);
  285. _tags.phone = !!((_tags.iphone || _tags.ipod) || (!_tags.silk && (_tags.android && (_tags.android < 3 || isMobile))) || (_tags.blackberry && isMobile) || (_tags.windowsphone));
  286. _tags.tablet = !!(!_tags.phone && (_tags.ipad || _tags.android || _tags.silk || _tags.rimtablet || (_tags.ie10 && /; Touch/.test(ua))));
  287. _tags.touch =
  288. isEventSupported('touchend') ||
  289. navigator.maxTouchPoints ||
  290. navigator.msMaxTouchPoints;
  291. _tags.desktop = !_tags.phone && !_tags.tablet;
  292. _tags.cordova = _tags.phonegap = !!(window.PhoneGap || window.Cordova || window.cordova);
  293. _tags.webview = /(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)(?!.*FBAN)/i.test(ua);
  294. _tags.androidstock = (_tags.android <= 4.3) && (_tags.safari || _tags.silk);
  295. _merge(_tags, platformParams, true);
  296. },
  297. loadPlatformsParam: function() {
  298. var paramsString = window.location.search.substr(1),
  299. paramsArray = paramsString.split("&"),
  300. params = {},
  301. i,
  302. platforms = {},
  303. tmpArray, tmplen, platform, name, enabled;
  304. for (i = 0; i < paramsArray.length; i++) {
  305. tmpArray = paramsArray[i].split("=");
  306. params[tmpArray[0]] = tmpArray[1];
  307. }
  308. if (params.platformTags) {
  309. tmpArray = params.platformTags.split(",");
  310. for (tmplen = tmpArray.length , i = 0; i < tmplen; i++) {
  311. platform = tmpArray[i].split(":");
  312. name = platform[0];
  313. enabled = true;
  314. if (platform.length > 1) {
  315. enabled = platform[1];
  316. if (enabled === 'false' || enabled === '0') {
  317. enabled = false;
  318. }
  319. }
  320. platforms[name] = enabled;
  321. }
  322. }
  323. return platforms;
  324. },
  325. filterPlatform: function(platform, excludes) {
  326. platform = _emptyArray.concat(platform || _emptyArray);
  327. excludes = _emptyArray.concat(excludes || _emptyArray);
  328. var plen = platform.length,
  329. elen = excludes.length,
  330. include = (!plen && elen),
  331. i, tag;
  332. for (i = 0; i < plen && !include; i++) {
  333. tag = platform[i];
  334. include = !!_tags[tag];
  335. }
  336. for (i = 0; i < elen && include; i++) {
  337. tag = excludes[i];
  338. include = !_tags[tag];
  339. }
  340. return include;
  341. },
  342. init: function() {
  343. var scriptEls = doc.getElementsByTagName('script'),
  344. script = scriptEls[0],
  345. len = scriptEls.length,
  346. re = /\/ext(\-[a-z\-]+)?\.js$/,
  347. entry, src, state, baseUrl, key, n, origin;
  348. Boot.hasReadyState = ("readyState" in script);
  349. Boot.hasAsync = ("async" in script);
  350. Boot.hasDefer = ("defer" in script);
  351. Boot.hasOnLoad = ("onload" in script);
  352. Boot.isIE8 = Boot.hasReadyState && !Boot.hasAsync && Boot.hasDefer && !Boot.hasOnLoad;
  353. Boot.isIE9 = Boot.hasReadyState && !Boot.hasAsync && Boot.hasDefer && Boot.hasOnLoad;
  354. Boot.isIE10p = Boot.hasReadyState && Boot.hasAsync && Boot.hasDefer && Boot.hasOnLoad;
  355. if (Boot.isIE8) {
  356. Boot.isIE10 = false;
  357. Boot.isIE10m = true;
  358. } else {
  359. Boot.isIE10 = (new Function('/*@cc_on return @_jscript_version @*/')()) === 10;
  360. Boot.isIE10m = Boot.isIE10 || Boot.isIE9 || Boot.isIE8;
  361. }
  362. Boot.isIE11 = Boot.isIE10p && !Boot.isIE10;
  363. for (n = 0; n < len; n++) {
  364. src = (script = scriptEls[n]).src;
  365. if (!src) {
  366. continue;
  367. }
  368. state = script.readyState || null;
  369. if (!baseUrl && re.test(src)) {
  370. baseUrl = src;
  371. }
  372. if (!Boot.scripts[key = Boot.canonicalUrl(src)]) {
  373. entry = new Entry({
  374. key: key,
  375. url: src,
  376. done: state === null ||
  377. state === 'loaded' || state === 'complete',
  378. el: script,
  379. prop: 'src'
  380. });
  381. }
  382. }
  383. if (!baseUrl) {
  384. script = scriptEls[scriptEls.length - 1];
  385. baseUrl = script.src;
  386. }
  387. Boot.baseUrl = baseUrl.substring(0, baseUrl.lastIndexOf('/') + 1);
  388. origin = window.location.origin || window.location.protocol + "//" + window.location.hostname + (window.location.port ? ':' + window.location.port : '');
  389. Boot.origin = origin;
  390. Boot.detectPlatformTags();
  391. Ext.filterPlatform = Boot.filterPlatform;
  392. },
  393. canonicalUrl: function(url) {
  394. resolverEl.href = url;
  395. var ret = resolverEl.href,
  396. dc = _config.disableCachingParam,
  397. pos = dc ? ret.indexOf(dc + '=') : -1,
  398. c, end;
  399. if (pos > 0 && ((c = ret.charAt(pos - 1)) === '?' || c === '&')) {
  400. end = ret.indexOf('&', pos);
  401. end = (end < 0) ? '' : ret.substring(end);
  402. if (end && c === '?') {
  403. ++pos;
  404. end = end.substring(1);
  405. }
  406. ret = ret.substring(0, pos - 1) + end;
  407. }
  408. return ret;
  409. },
  410. getConfig: function(name) {
  411. return name ? Boot.config[name] : Boot.config;
  412. },
  413. setConfig: function(name, value) {
  414. if (typeof name === 'string') {
  415. Boot.config[name] = value;
  416. } else {
  417. for (var s in name) {
  418. Boot.setConfig(s, name[s]);
  419. }
  420. }
  421. return Boot;
  422. },
  423. getHead: function() {
  424. return Boot.docHead || (Boot.docHead = doc.head || doc.getElementsByTagName('head')[0]);
  425. },
  426. create: function(url, key, cfg) {
  427. var config = cfg || {};
  428. config.url = url;
  429. config.key = key;
  430. return Boot.scripts[key] = new Entry(config);
  431. },
  432. getEntry: function(url, cfg, canonicalPath) {
  433. var key, entry;
  434. key = canonicalPath ? url : Boot.canonicalUrl(url);
  435. entry = Boot.scripts[key];
  436. if (!entry) {
  437. entry = Boot.create(url, key, cfg);
  438. if (canonicalPath) {
  439. entry.canonicalPath = true;
  440. }
  441. }
  442. return entry;
  443. },
  444. registerContent: function(url, type, content) {
  445. var cfg = {
  446. content: content,
  447. loaded: true,
  448. css: type === 'css'
  449. };
  450. return Boot.getEntry(url, cfg);
  451. },
  452. processRequest: function(request, sync) {
  453. request.loadEntries(sync);
  454. },
  455. load: function(request) {
  456. var request = new Request(request);
  457. if (request.sync || Boot.syncMode) {
  458. return Boot.loadSync(request);
  459. }
  460. if (Boot.currentRequest) {
  461. request.getEntries();
  462. Boot.suspendedQueue.push(request);
  463. } else {
  464. Boot.currentRequest = request;
  465. Boot.processRequest(request, false);
  466. }
  467. return Boot;
  468. },
  469. loadSync: function(request) {
  470. var request = new Request(request);
  471. Boot.syncMode++;
  472. Boot.processRequest(request, true);
  473. Boot.syncMode--;
  474. return Boot;
  475. },
  476. loadBasePrefix: function(request) {
  477. request = new Request(request);
  478. request.prependBaseUrl = true;
  479. return Boot.load(request);
  480. },
  481. loadSyncBasePrefix: function(request) {
  482. request = new Request(request);
  483. request.prependBaseUrl = true;
  484. return Boot.loadSync(request);
  485. },
  486. requestComplete: function(request) {
  487. var next;
  488. if (Boot.currentRequest === request) {
  489. Boot.currentRequest = null;
  490. while (Boot.suspendedQueue.length > 0) {
  491. next = Boot.suspendedQueue.shift();
  492. if (!next.done) {
  493. Boot.load(next);
  494. break;
  495. }
  496. }
  497. }
  498. if (!Boot.currentRequest && Boot.suspendedQueue.length == 0) {
  499. Boot.fireListeners();
  500. }
  501. },
  502. isLoading: function() {
  503. return !Boot.currentRequest && Boot.suspendedQueue.length == 0;
  504. },
  505. fireListeners: function() {
  506. var listener;
  507. while (Boot.isLoading() && (listener = Boot.listeners.shift())) {
  508. listener();
  509. }
  510. },
  511. onBootReady: function(listener) {
  512. if (!Boot.isLoading()) {
  513. listener();
  514. } else {
  515. Boot.listeners.push(listener);
  516. }
  517. },
  518. getPathsFromIndexes: function(indexMap, loadOrder) {
  519. if (!('length' in indexMap)) {
  520. var indexArray = [],
  521. index;
  522. for (index in indexMap) {
  523. if (!isNaN(+index)) {
  524. indexArray[+index] = indexMap[index];
  525. }
  526. }
  527. indexMap = indexArray;
  528. }
  529. return Request.prototype.getPathsFromIndexes(indexMap, loadOrder);
  530. },
  531. createLoadOrderMap: function(loadOrder) {
  532. return Request.prototype.createLoadOrderMap(loadOrder);
  533. },
  534. fetch: function(url, complete, scope, async) {
  535. async = (async === undefined) ? !!complete : async;
  536. var xhr = new XMLHttpRequest(),
  537. result, status, content,
  538. exception = false,
  539. readyStateChange = function() {
  540. if (xhr && xhr.readyState == 4) {
  541. status = (xhr.status === 1223) ? 204 : (xhr.status === 0 && ((self.location || {}).protocol === 'file:' || (self.location || {}).protocol === 'ionp:')) ? 200 : xhr.status;
  542. content = xhr.responseText;
  543. result = {
  544. content: content,
  545. status: status,
  546. exception: exception
  547. };
  548. if (complete) {
  549. complete.call(scope, result);
  550. }
  551. xhr.onreadystatechange = emptyFn;
  552. xhr = null;
  553. }
  554. };
  555. if (async) {
  556. xhr.onreadystatechange = readyStateChange;
  557. }
  558. try {
  559. xhr.open('GET', url, async);
  560. xhr.send(null);
  561. } catch (err) {
  562. exception = err;
  563. readyStateChange();
  564. return result;
  565. }
  566. if (!async) {
  567. readyStateChange();
  568. }
  569. return result;
  570. },
  571. notifyAll: function(entry) {
  572. entry.notifyRequests();
  573. }
  574. };
  575. function Request(cfg) {
  576. if (cfg.$isRequest) {
  577. return cfg;
  578. }
  579. var cfg = cfg.url ? cfg : {
  580. url: cfg
  581. },
  582. url = cfg.url,
  583. urls = url.charAt ? [
  584. url
  585. ] : url,
  586. charset = cfg.charset || Boot.config.charset;
  587. _apply(this, cfg);
  588. delete this.url;
  589. this.urls = urls;
  590. this.charset = charset;
  591. }
  592. Request.prototype = {
  593. $isRequest: true,
  594. createLoadOrderMap: function(loadOrder) {
  595. var len = loadOrder.length,
  596. loadOrderMap = {},
  597. i, element;
  598. for (i = 0; i < len; i++) {
  599. element = loadOrder[i];
  600. loadOrderMap[element.path] = element;
  601. }
  602. return loadOrderMap;
  603. },
  604. getLoadIndexes: function(item, indexMap, loadOrder, includeUses, skipLoaded) {
  605. var resolved = [],
  606. queue = [
  607. item
  608. ],
  609. itemIndex = item.idx,
  610. queue, entry, dependencies, depIndex, i, len;
  611. if (indexMap[itemIndex]) {
  612. return resolved;
  613. }
  614. indexMap[itemIndex] = resolved[itemIndex] = true;
  615. while (item = queue.shift()) {
  616. if (item.canonicalPath) {
  617. entry = Boot.getEntry(item.path, null, true);
  618. } else {
  619. entry = Boot.getEntry(this.prepareUrl(item.path));
  620. }
  621. if (!(skipLoaded && entry.done)) {
  622. if (includeUses && item.uses && item.uses.length) {
  623. dependencies = item.requires.concat(item.uses);
  624. } else {
  625. dependencies = item.requires;
  626. }
  627. for (i = 0 , len = dependencies.length; i < len; i++) {
  628. depIndex = dependencies[i];
  629. if (!indexMap[depIndex]) {
  630. indexMap[depIndex] = resolved[depIndex] = true;
  631. queue.push(loadOrder[depIndex]);
  632. }
  633. }
  634. }
  635. }
  636. return resolved;
  637. },
  638. getPathsFromIndexes: function(indexes, loadOrder) {
  639. var paths = [],
  640. index, len;
  641. for (index = 0 , len = indexes.length; index < len; index++) {
  642. if (indexes[index]) {
  643. paths.push(loadOrder[index].path);
  644. }
  645. }
  646. return paths;
  647. },
  648. expandUrl: function(url, loadOrder, loadOrderMap, indexMap, includeUses, skipLoaded) {
  649. var item, resolved;
  650. if (loadOrder) {
  651. item = loadOrderMap[url];
  652. if (item) {
  653. resolved = this.getLoadIndexes(item, indexMap, loadOrder, includeUses, skipLoaded);
  654. if (resolved.length) {
  655. return this.getPathsFromIndexes(resolved, loadOrder);
  656. }
  657. }
  658. }
  659. return [
  660. url
  661. ];
  662. },
  663. expandUrls: function(urls, includeUses) {
  664. var me = this,
  665. loadOrder = me.loadOrder,
  666. expanded = [],
  667. expandMap = {},
  668. indexMap = [],
  669. loadOrderMap, tmpExpanded, i, len, t, tlen, tUrl;
  670. if (typeof urls === "string") {
  671. urls = [
  672. urls
  673. ];
  674. }
  675. if (loadOrder) {
  676. loadOrderMap = me.loadOrderMap;
  677. if (!loadOrderMap) {
  678. loadOrderMap = me.loadOrderMap = me.createLoadOrderMap(loadOrder);
  679. }
  680. }
  681. for (i = 0 , len = urls.length; i < len; i++) {
  682. tmpExpanded = this.expandUrl(urls[i], loadOrder, loadOrderMap, indexMap, includeUses, false);
  683. for (t = 0 , tlen = tmpExpanded.length; t < tlen; t++) {
  684. tUrl = tmpExpanded[t];
  685. if (!expandMap[tUrl]) {
  686. expandMap[tUrl] = true;
  687. expanded.push(tUrl);
  688. }
  689. }
  690. }
  691. if (expanded.length === 0) {
  692. expanded = urls;
  693. }
  694. return expanded;
  695. },
  696. expandLoadOrder: function() {
  697. var me = this,
  698. urls = me.urls,
  699. expanded;
  700. if (!me.expanded) {
  701. expanded = this.expandUrls(urls, true);
  702. me.expanded = true;
  703. } else {
  704. expanded = urls;
  705. }
  706. me.urls = expanded;
  707. if (urls.length != expanded.length) {
  708. me.sequential = true;
  709. }
  710. return me;
  711. },
  712. getUrls: function() {
  713. this.expandLoadOrder();
  714. return this.urls;
  715. },
  716. prepareUrl: function(url) {
  717. if (this.prependBaseUrl) {
  718. return Boot.baseUrl + url;
  719. }
  720. return url;
  721. },
  722. getEntries: function() {
  723. var me = this,
  724. entries = me.entries,
  725. loadOrderMap, item, i, entry, urls, url;
  726. if (!entries) {
  727. entries = [];
  728. urls = me.getUrls();
  729. if (me.loadOrder) {
  730. loadOrderMap = me.loadOrderMap;
  731. }
  732. for (i = 0; i < urls.length; i++) {
  733. url = me.prepareUrl(urls[i]);
  734. if (loadOrderMap) {
  735. item = loadOrderMap[url];
  736. }
  737. entry = Boot.getEntry(url, {
  738. buster: me.buster,
  739. charset: me.charset
  740. }, item && item.canonicalPath);
  741. entry.requests.push(me);
  742. entries.push(entry);
  743. }
  744. me.entries = entries;
  745. }
  746. return entries;
  747. },
  748. loadEntries: function(sync) {
  749. var me = this,
  750. entries = me.getEntries(),
  751. len = entries.length,
  752. start = me.loadStart || 0,
  753. continueLoad, entries, entry, i;
  754. if (sync !== undefined) {
  755. me.sync = sync;
  756. }
  757. me.loaded = me.loaded || 0;
  758. me.loading = me.loading || len;
  759. for (i = start; i < len; i++) {
  760. entry = entries[i];
  761. if (!entry.loaded) {
  762. continueLoad = entries[i].load(me.sync);
  763. } else {
  764. continueLoad = true;
  765. }
  766. if (!continueLoad) {
  767. me.loadStart = i;
  768. entry.onDone(function() {
  769. me.loadEntries(sync);
  770. });
  771. break;
  772. }
  773. }
  774. me.processLoadedEntries();
  775. },
  776. processLoadedEntries: function() {
  777. var me = this,
  778. entries = me.getEntries(),
  779. len = entries.length,
  780. start = me.startIndex || 0,
  781. i, entry;
  782. if (!me.done) {
  783. for (i = start; i < len; i++) {
  784. entry = entries[i];
  785. if (!entry.loaded) {
  786. me.startIndex = i;
  787. return;
  788. }
  789. if (!entry.evaluated) {
  790. entry.evaluate();
  791. }
  792. if (entry.error) {
  793. me.error = true;
  794. }
  795. }
  796. me.notify();
  797. }
  798. },
  799. notify: function() {
  800. var me = this;
  801. if (!me.done) {
  802. var error = me.error,
  803. fn = me[error ? 'failure' : 'success'],
  804. delay = ('delay' in me) ? me.delay : (error ? 1 : Boot.config.chainDelay),
  805. scope = me.scope || me;
  806. me.done = true;
  807. if (fn) {
  808. if (delay === 0 || delay > 0) {
  809. setTimeout(function() {
  810. fn.call(scope, me);
  811. }, delay);
  812. } else {
  813. fn.call(scope, me);
  814. }
  815. }
  816. me.fireListeners();
  817. Boot.requestComplete(me);
  818. }
  819. },
  820. onDone: function(listener) {
  821. var me = this,
  822. listeners = me.listeners || (me.listeners = []);
  823. if (me.done) {
  824. listener(me);
  825. } else {
  826. listeners.push(listener);
  827. }
  828. },
  829. fireListeners: function() {
  830. var listeners = this.listeners,
  831. listener;
  832. if (listeners) {
  833. while ((listener = listeners.shift())) {
  834. listener(this);
  835. }
  836. }
  837. }
  838. };
  839. function Entry(cfg) {
  840. if (cfg.$isEntry) {
  841. return cfg;
  842. }
  843. var charset = cfg.charset || Boot.config.charset,
  844. manifest = Ext.manifest,
  845. loader = manifest && manifest.loader,
  846. cache = (cfg.cache !== undefined) ? cfg.cache : (loader && loader.cache),
  847. buster, busterParam;
  848. if (Boot.config.disableCaching) {
  849. if (cache === undefined) {
  850. cache = !Boot.config.disableCaching;
  851. }
  852. if (cache === false) {
  853. buster = +new Date();
  854. } else if (cache !== true) {
  855. buster = cache;
  856. }
  857. if (buster) {
  858. busterParam = (loader && loader.cacheParam) || Boot.config.disableCachingParam;
  859. buster = busterParam + "=" + buster;
  860. }
  861. }
  862. _apply(this, cfg);
  863. this.charset = charset;
  864. this.buster = buster;
  865. this.requests = [];
  866. }
  867. Entry.prototype = {
  868. $isEntry: true,
  869. done: false,
  870. evaluated: false,
  871. loaded: false,
  872. isCrossDomain: function() {
  873. var me = this;
  874. if (me.crossDomain === undefined) {
  875. me.crossDomain = (me.getLoadUrl().indexOf(Boot.origin) !== 0);
  876. }
  877. return me.crossDomain;
  878. },
  879. isCss: function() {
  880. var me = this;
  881. if (me.css === undefined) {
  882. if (me.url) {
  883. var assetConfig = Boot.assetConfig[me.url];
  884. me.css = assetConfig ? assetConfig.type === "css" : cssRe.test(me.url);
  885. } else {
  886. me.css = false;
  887. }
  888. }
  889. return this.css;
  890. },
  891. getElement: function(tag) {
  892. var me = this,
  893. el = me.el;
  894. if (!el) {
  895. if (me.isCss()) {
  896. tag = tag || "link";
  897. el = doc.createElement(tag);
  898. if (tag == "link") {
  899. el.rel = 'stylesheet';
  900. me.prop = 'href';
  901. } else {
  902. me.prop = "textContent";
  903. }
  904. el.type = "text/css";
  905. } else {
  906. tag = tag || "script";
  907. el = doc.createElement(tag);
  908. el.type = 'text/javascript';
  909. me.prop = 'src';
  910. if (me.charset) {
  911. el.charset = me.charset;
  912. }
  913. if (Boot.hasAsync) {
  914. el.async = false;
  915. }
  916. }
  917. me.el = el;
  918. }
  919. return el;
  920. },
  921. getLoadUrl: function() {
  922. var me = this,
  923. url;
  924. url = me.canonicalPath ? me.url : Boot.canonicalUrl(me.url);
  925. if (!me.loadUrl) {
  926. me.loadUrl = !!me.buster ? (url + (url.indexOf('?') === -1 ? '?' : '&') + me.buster) : url;
  927. }
  928. return me.loadUrl;
  929. },
  930. fetch: function(req) {
  931. var url = this.getLoadUrl(),
  932. async = !!req.async,
  933. complete = req.complete;
  934. Boot.fetch(url, complete, this, async);
  935. },
  936. onContentLoaded: function(response) {
  937. var me = this,
  938. status = response.status,
  939. content = response.content,
  940. exception = response.exception,
  941. url = this.getLoadUrl();
  942. me.loaded = true;
  943. if ((exception || status === 0) && !_environment.phantom) {
  944. me.error =
  945. ("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.") ||
  946. true;
  947. me.evaluated = true;
  948. } else if ((status >= 200 && status < 300) || status === 304 || _environment.phantom || (status === 0 && content.length > 0)) {
  949. me.content = content;
  950. } else {
  951. me.error =
  952. ("Failed loading synchronously via XHR: '" + url + "'. Please verify that the file exists. XHR status code: " + status) ||
  953. true;
  954. me.evaluated = true;
  955. }
  956. },
  957. createLoadElement: function(callback) {
  958. var me = this,
  959. el = me.getElement();
  960. me.preserve = true;
  961. el.onerror = function() {
  962. me.error = true;
  963. if (callback) {
  964. callback();
  965. callback = null;
  966. }
  967. };
  968. if (Boot.isIE10m) {
  969. el.onreadystatechange = function() {
  970. if (this.readyState === 'loaded' || this.readyState === 'complete') {
  971. if (callback) {
  972. callback();
  973. callback = this.onreadystatechange = this.onerror = null;
  974. }
  975. }
  976. };
  977. } else {
  978. el.onload = function() {
  979. callback();
  980. callback = this.onload = this.onerror = null;
  981. };
  982. }
  983. el[me.prop] = me.getLoadUrl();
  984. },
  985. onLoadElementReady: function() {
  986. Boot.getHead().appendChild(this.getElement());
  987. this.evaluated = true;
  988. },
  989. inject: function(content, asset) {
  990. var me = this,
  991. head = Boot.getHead(),
  992. url = me.url,
  993. key = me.key,
  994. base, el, ieMode, basePath;
  995. if (me.isCss()) {
  996. me.preserve = true;
  997. basePath = key.substring(0, key.lastIndexOf("/") + 1);
  998. base = doc.createElement('base');
  999. base.href = basePath;
  1000. if (head.firstChild) {
  1001. head.insertBefore(base, head.firstChild);
  1002. } else {
  1003. head.appendChild(base);
  1004. }
  1005. base.href = base.href;
  1006. if (url) {
  1007. content += "\n/*# sourceURL=" + key + " */";
  1008. }
  1009. el = me.getElement("style");
  1010. ieMode = ('styleSheet' in el);
  1011. head.appendChild(base);
  1012. if (ieMode) {
  1013. head.appendChild(el);
  1014. el.styleSheet.cssText = content;
  1015. } else {
  1016. el.textContent = content;
  1017. head.appendChild(el);
  1018. }
  1019. head.removeChild(base);
  1020. } else {
  1021. if (url) {
  1022. content += "\n//# sourceURL=" + key;
  1023. }
  1024. Ext.globalEval(content);
  1025. }
  1026. return me;
  1027. },
  1028. loadCrossDomain: function() {
  1029. var me = this,
  1030. complete = function() {
  1031. me.el.onerror = me.el.onload = emptyFn;
  1032. me.el = null;
  1033. me.loaded = me.evaluated = me.done = true;
  1034. me.notifyRequests();
  1035. };
  1036. me.createLoadElement(function() {
  1037. complete();
  1038. });
  1039. me.evaluateLoadElement();
  1040. return false;
  1041. },
  1042. loadElement: function() {
  1043. var me = this,
  1044. complete = function() {
  1045. me.el.onerror = me.el.onload = emptyFn;
  1046. me.el = null;
  1047. me.loaded = me.evaluated = me.done = true;
  1048. me.notifyRequests();
  1049. };
  1050. me.createLoadElement(function() {
  1051. complete();
  1052. });
  1053. me.evaluateLoadElement();
  1054. return true;
  1055. },
  1056. loadSync: function() {
  1057. var me = this;
  1058. me.fetch({
  1059. async: false,
  1060. complete: function(response) {
  1061. me.onContentLoaded(response);
  1062. }
  1063. });
  1064. me.evaluate();
  1065. me.notifyRequests();
  1066. },
  1067. load: function(sync) {
  1068. var me = this;
  1069. if (!me.loaded) {
  1070. if (me.loading) {
  1071. return false;
  1072. }
  1073. me.loading = true;
  1074. if (!sync) {
  1075. if (Boot.isIE10 || me.isCrossDomain()) {
  1076. return me.loadCrossDomain();
  1077. }
  1078. else if (!me.isCss() && Boot.hasReadyState) {
  1079. me.createLoadElement(function() {
  1080. me.loaded = true;
  1081. me.notifyRequests();
  1082. });
  1083. } else if (Boot.useElements &&
  1084. !(me.isCss() && _environment.phantom)) {
  1085. return me.loadElement();
  1086. } else
  1087. {
  1088. me.fetch({
  1089. async: !sync,
  1090. complete: function(response) {
  1091. me.onContentLoaded(response);
  1092. me.notifyRequests();
  1093. }
  1094. });
  1095. }
  1096. } else
  1097. {
  1098. me.loadSync();
  1099. }
  1100. }
  1101. return true;
  1102. },
  1103. evaluateContent: function() {
  1104. this.inject(this.content);
  1105. this.content = null;
  1106. },
  1107. evaluateLoadElement: function() {
  1108. Boot.getHead().appendChild(this.getElement());
  1109. },
  1110. evaluate: function() {
  1111. var me = this;
  1112. if (!me.evaluated) {
  1113. if (me.evaluating) {
  1114. return;
  1115. }
  1116. me.evaluating = true;
  1117. if (me.content !== undefined) {
  1118. me.evaluateContent();
  1119. } else if (!me.error) {
  1120. me.evaluateLoadElement();
  1121. }
  1122. me.evaluated = me.done = true;
  1123. me.cleanup();
  1124. }
  1125. },
  1126. cleanup: function() {
  1127. var me = this,
  1128. el = me.el,
  1129. prop;
  1130. if (!el) {
  1131. return;
  1132. }
  1133. if (!me.preserve) {
  1134. me.el = null;
  1135. el.parentNode.removeChild(el);
  1136. for (prop in el) {
  1137. try {
  1138. if (prop !== me.prop) {
  1139. el[prop] = null;
  1140. }
  1141. delete el[prop];
  1142. }
  1143. catch (cleanEx) {}
  1144. }
  1145. }
  1146. el.onload = el.onerror = el.onreadystatechange = emptyFn;
  1147. },
  1148. notifyRequests: function() {
  1149. var requests = this.requests,
  1150. len = requests.length,
  1151. i, request;
  1152. for (i = 0; i < len; i++) {
  1153. request = requests[i];
  1154. request.processLoadedEntries();
  1155. }
  1156. if (this.done) {
  1157. this.fireListeners();
  1158. }
  1159. },
  1160. onDone: function(listener) {
  1161. var me = this,
  1162. listeners = me.listeners || (me.listeners = []);
  1163. if (me.done) {
  1164. listener(me);
  1165. } else {
  1166. listeners.push(listener);
  1167. }
  1168. },
  1169. fireListeners: function() {
  1170. var listeners = this.listeners,
  1171. listener;
  1172. if (listeners && listeners.length > 0) {
  1173. while ((listener = listeners.shift())) {
  1174. listener(this);
  1175. }
  1176. }
  1177. }
  1178. };
  1179. Ext.disableCacheBuster = function(disable, path) {
  1180. var date = new Date();
  1181. date.setTime(date.getTime() + (disable ? 10 * 365 : -1) * 24 * 60 * 60 * 1000);
  1182. date = date.toGMTString();
  1183. doc.cookie = 'ext-cache=1; expires=' + date + '; path=' + (path || '/');
  1184. };
  1185. Boot.init();
  1186. return Boot;
  1187. }(
  1188. function() {}));
  1189. Ext.globalEval = Ext.globalEval || (this.execScript ? function(code) {
  1190. execScript(code);
  1191. } : function($$code) {
  1192. eval.call(window, $$code);
  1193. });
  1194. if (!Function.prototype.bind) {
  1195. (function() {
  1196. var slice = Array.prototype.slice,
  1197. bind = function(me) {
  1198. var args = slice.call(arguments, 1),
  1199. method = this;
  1200. if (args.length) {
  1201. return function() {
  1202. var t = arguments;
  1203. return method.apply(me, t.length ? args.concat(slice.call(t)) : args);
  1204. };
  1205. }
  1206. args = null;
  1207. return function() {
  1208. return method.apply(me, arguments);
  1209. };
  1210. };
  1211. Function.prototype.bind = bind;
  1212. bind.$extjs = true;
  1213. }());
  1214. }
  1215. Ext.setResourcePath = function(poolName, path) {
  1216. var manifest = Ext.manifest || (Ext.manifest = {}),
  1217. paths = manifest.resources || (manifest.resources = {});
  1218. if (manifest) {
  1219. if (typeof poolName !== 'string') {
  1220. Ext.apply(paths, poolName);
  1221. } else {
  1222. paths[poolName] = path;
  1223. }
  1224. manifest.resources = paths;
  1225. }
  1226. };
  1227. Ext.getResourcePath = function(path, poolName, packageName) {
  1228. if (typeof path !== 'string') {
  1229. poolName = path.pool;
  1230. packageName = path.packageName;
  1231. path = path.path;
  1232. }
  1233. var manifest = Ext.manifest,
  1234. paths = manifest && manifest.resources,
  1235. poolPath = paths[poolName],
  1236. output = [];
  1237. if (poolPath == null) {
  1238. poolPath = paths.path;
  1239. if (poolPath == null) {
  1240. poolPath = 'resources';
  1241. }
  1242. }
  1243. if (poolPath) {
  1244. output.push(poolPath);
  1245. }
  1246. if (packageName) {
  1247. output.push(packageName);
  1248. }
  1249. output.push(path);
  1250. return output.join('/');
  1251. };
  1252. var Ext = Ext || {};
  1253. (function() {
  1254. var global = this,
  1255. objectPrototype = Object.prototype,
  1256. toString = objectPrototype.toString,
  1257. enumerables = [
  1258. 'valueOf',
  1259. 'toLocaleString',
  1260. 'toString',
  1261. 'constructor'
  1262. ],
  1263. emptyFn = Ext.fireIdle = function() {},
  1264. privateFn = function() {},
  1265. identityFn = function(o) {
  1266. return o;
  1267. },
  1268. callOverrideParent = function() {
  1269. var method = callOverrideParent.caller.caller;
  1270. return method.$owner.prototype[method.$name].apply(this, arguments);
  1271. },
  1272. manifest = Ext.manifest || {},
  1273. i,
  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;
  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. } :
  1285. Ext.now;
  1286. Ext._startTime = Ext.ticks();
  1287. emptyFn.$nullFn = identityFn.$nullFn = emptyFn.$emptyFn = identityFn.$identityFn = privateFn.$nullFn = true;
  1288. privateFn.$privacy = 'framework';
  1289. emptyFn.$noClearOnDestroy = identityFn.$noClearOnDestroy = true;
  1290. privateFn.$noClearOnDestroy = true;
  1291. Ext['suspendLayouts'] = Ext['resumeLayouts'] = emptyFn;
  1292. for (i in {
  1293. toString: 1
  1294. }) {
  1295. enumerables = null;
  1296. }
  1297. Ext.enumerables = enumerables;
  1298. Ext.apply = function(object, config, defaults) {
  1299. if (object) {
  1300. if (defaults) {
  1301. Ext.apply(object, defaults);
  1302. }
  1303. if (config && typeof config === 'object') {
  1304. var i, j, k;
  1305. for (i in config) {
  1306. object[i] = config[i];
  1307. }
  1308. if (enumerables) {
  1309. for (j = enumerables.length; j--; ) {
  1310. k = enumerables[j];
  1311. if (config.hasOwnProperty(k)) {
  1312. object[k] = config[k];
  1313. }
  1314. }
  1315. }
  1316. }
  1317. }
  1318. return object;
  1319. };
  1320. function addInstanceOverrides(target, owner, overrides) {
  1321. var name, value;
  1322. for (name in overrides) {
  1323. if (overrides.hasOwnProperty(name)) {
  1324. value = overrides[name];
  1325. if (typeof value === 'function') {
  1326. if (owner.$className) {
  1327. value.name = owner.$className + '#' + name;
  1328. }
  1329. value.$name = name;
  1330. value.$owner = owner;
  1331. value.$previous = target.hasOwnProperty(name) ? target[name] :
  1332. callOverrideParent;
  1333. }
  1334. target[name] = value;
  1335. }
  1336. }
  1337. }
  1338. Ext.buildSettings = Ext.apply({
  1339. baseCSSPrefix: 'x-'
  1340. }, Ext.buildSettings || {});
  1341. Ext.apply(Ext, {
  1342. idSeed: 0,
  1343. idPrefix: 'ext-',
  1344. isRobot: false,
  1345. isSecure: /^https/i.test(window.location.protocol),
  1346. enableGarbageCollector: false,
  1347. enableListenerCollection: true,
  1348. name: Ext.sandboxName || 'Ext',
  1349. privateFn: privateFn,
  1350. emptyFn: emptyFn,
  1351. identityFn: identityFn,
  1352. frameStartTime: Ext.now(),
  1353. manifest: manifest,
  1354. debugConfig: Ext.debugConfig || manifest.debug || {
  1355. hooks: {
  1356. '*': true
  1357. }
  1358. },
  1359. enableAria: true,
  1360. startsWithHashRe: /^#/,
  1361. validIdRe: /^[a-z_][a-z0-9\-_]*$/i,
  1362. BLANK_IMAGE_URL: 'data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==',
  1363. makeIdSelector: function(id) {
  1364. if (!Ext.validIdRe.test(id)) {
  1365. Ext.raise('Invalid id selector: "' + id + '"');
  1366. }
  1367. return '#' + id;
  1368. },
  1369. id: function(o, prefix) {
  1370. if (o && o.id) {
  1371. return o.id;
  1372. }
  1373. var id = (prefix || Ext.idPrefix) + (++Ext.idSeed);
  1374. if (o) {
  1375. o.id = id;
  1376. }
  1377. return id;
  1378. },
  1379. returnId: function(o) {
  1380. return o.getId();
  1381. },
  1382. returnTrue: function() {
  1383. return true;
  1384. },
  1385. emptyString: new String(),
  1386. emptyArray: Object.freeze ? Object.freeze([]) : [],
  1387. baseCSSPrefix: Ext.buildSettings.baseCSSPrefix,
  1388. $eventNameMap: {},
  1389. $vendorEventRe: /^(DOMMouse|Moz.+|MS.+|webkit.+)/,
  1390. canonicalEventName: function(name) {
  1391. return Ext.$eventNameMap[name] || (Ext.$eventNameMap[name] = (Ext.$vendorEventRe.test(name) ? name : name.toLowerCase()));
  1392. },
  1393. applyIf: function(object, config) {
  1394. if (object && config && typeof config === 'object') {
  1395. for (var 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. var timer = timers && timers[id];
  1771. if (timer) {
  1772. timer.cancelled = true;
  1773. delete timers[id];
  1774. }
  1775. },
  1776. tick: function() {
  1777. if (Ext.Timer.firing) {
  1778. Ext.log.error('Previous timer state not cleaned up properly: ' + Ext.Timer.firing.creator);
  1779. }
  1780. if (this.kind !== 'interval') {
  1781. this.done = true;
  1782. delete Ext.Timer.all[this.kind][this.id];
  1783. }
  1784. this.firing = true;
  1785. Ext.Timer.firing = this;
  1786. },
  1787. tock: function() {
  1788. this.firing = false;
  1789. if (Ext.Timer.firing === this) {
  1790. Ext.Timer.firing = null;
  1791. }
  1792. }
  1793. },
  1794. getExpando: function(target, id) {
  1795. var expandos = target.$expandos;
  1796. return expandos && expandos[id] || null;
  1797. },
  1798. setExpando: function(target, id, value) {
  1799. var expandos = target.$expandos;
  1800. if (value !== undefined) {
  1801. (expandos || (target.$expandos = {}))[id] = value;
  1802. } else if (expandos) {
  1803. delete expandos[id];
  1804. }
  1805. }
  1806. });
  1807. Ext.returnTrue.$nullFn = Ext.returnId.$nullFn = true;
  1808. }());
  1809. (function() {
  1810. function toString() {
  1811. var me = this,
  1812. cls = me.sourceClass,
  1813. method = me.sourceMethod,
  1814. msg = me.msg;
  1815. if (method) {
  1816. if (msg) {
  1817. method += '(): ';
  1818. method += msg;
  1819. } else {
  1820. method += '()';
  1821. }
  1822. }
  1823. if (cls) {
  1824. method = method ? (cls + '.' + method) : cls;
  1825. }
  1826. return method || msg || '';
  1827. }
  1828. Ext.Error = function(config) {
  1829. if (Ext.isString(config)) {
  1830. config = {
  1831. msg: config
  1832. };
  1833. }
  1834. var error = new Error();
  1835. Ext.apply(error, config);
  1836. error.message = error.message || error.msg;
  1837. error.toString = toString;
  1838. return error;
  1839. };
  1840. Ext.apply(Ext.Error, {
  1841. ignore: false,
  1842. raise: function(err) {
  1843. err = err || {};
  1844. if (Ext.isString(err)) {
  1845. err = {
  1846. msg: err
  1847. };
  1848. }
  1849. var me = this,
  1850. method = me.raise.caller,
  1851. msg, name;
  1852. if (method === Ext.raise) {
  1853. method = method.caller;
  1854. }
  1855. if (method) {
  1856. if (!err.sourceMethod && (name = method.$name)) {
  1857. err.sourceMethod = name;
  1858. }
  1859. if (!err.sourceClass && (name = method.$owner) && (name = name.$className)) {
  1860. err.sourceClass = name;
  1861. }
  1862. }
  1863. if (me.handle(err) !== true) {
  1864. msg = toString.call(err);
  1865. Ext.log({
  1866. msg: msg,
  1867. level: 'error',
  1868. dump: err,
  1869. stack: true
  1870. });
  1871. throw new Ext.Error(err);
  1872. }
  1873. },
  1874. handle: function() {
  1875. return this.ignore;
  1876. }
  1877. });
  1878. })();
  1879. Ext.deprecated = function(suggestion) {
  1880. if (!suggestion) {
  1881. suggestion = '';
  1882. }
  1883. function fail() {
  1884. Ext.raise('The method "' + fail.$owner.$className + '.' + fail.$name + '" has been removed. ' + suggestion);
  1885. }
  1886. return fail;
  1887. return Ext.emptyFn;
  1888. };
  1889. Ext.raise = function() {
  1890. Ext.Error.raise.apply(Ext.Error, arguments);
  1891. };
  1892. (function(skipNotify) {
  1893. if (skipNotify || typeof window === 'undefined') {
  1894. return;
  1895. }
  1896. var last = 0,
  1897. notify = function() {
  1898. var cnt = Ext.log && Ext.log.counters,
  1899. n = cnt && (cnt.error + cnt.warn + cnt.info + cnt.log),
  1900. msg;
  1901. if (n && last !== n) {
  1902. msg = [];
  1903. if (cnt.error) {
  1904. msg.push('Errors: ' + cnt.error);
  1905. }
  1906. if (cnt.warn) {
  1907. msg.push('Warnings: ' + cnt.warn);
  1908. }
  1909. if (cnt.info) {
  1910. msg.push('Info: ' + cnt.info);
  1911. }
  1912. if (cnt.log) {
  1913. msg.push('Log: ' + cnt.log);
  1914. }
  1915. window.status = '*** ' + msg.join(' -- ');
  1916. last = n;
  1917. }
  1918. };
  1919. notify.$skipTimerCheck = true;
  1920. setInterval(notify, 1000);
  1921. }(!!window.__UNIT_TESTING__));
  1922. Ext.Array = (function() {
  1923. var arrayPrototype = Array.prototype,
  1924. slice = arrayPrototype.slice,
  1925. supportsSplice = (function() {
  1926. var array = [],
  1927. lengthBefore,
  1928. j = 20;
  1929. if (!array.splice) {
  1930. return false;
  1931. }
  1932. while (j--) {
  1933. array.push("A");
  1934. }
  1935. 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");
  1936. lengthBefore = array.length;
  1937. array.splice(13, 0, "XXX");
  1938. if (lengthBefore + 1 !== array.length) {
  1939. return false;
  1940. }
  1941. return true;
  1942. }()),
  1943. supportsIndexOf = 'indexOf' in arrayPrototype,
  1944. supportsSliceOnNodeList = true;
  1945. function stableSort(array, userComparator) {
  1946. var len = array.length,
  1947. indices = new Array(len),
  1948. i;
  1949. for (i = 0; i < len; i++) {
  1950. indices[i] = i;
  1951. }
  1952. indices.sort(function(index1, index2) {
  1953. return userComparator(array[index1], array[index2]) || (index1 - index2);
  1954. });
  1955. for (i = 0; i < len; i++) {
  1956. indices[i] = array[indices[i]];
  1957. }
  1958. for (i = 0; i < len; i++) {
  1959. array[i] = indices[i];
  1960. }
  1961. return array;
  1962. }
  1963. try {
  1964. if (typeof document !== 'undefined') {
  1965. slice.call(document.getElementsByTagName('body'));
  1966. }
  1967. } catch (e) {
  1968. supportsSliceOnNodeList = false;
  1969. }
  1970. var fixArrayIndex = function(array, index) {
  1971. return (index < 0) ? Math.max(0, array.length + index) : Math.min(array.length, index);
  1972. },
  1973. replaceSim = function(array, index, removeCount, insert) {
  1974. var add = insert ? insert.length : 0,
  1975. length = array.length,
  1976. pos = fixArrayIndex(array, index);
  1977. if (pos === length) {
  1978. if (add) {
  1979. array.push.apply(array, insert);
  1980. }
  1981. } else {
  1982. var remove = Math.min(removeCount, length - pos),
  1983. tailOldPos = pos + remove,
  1984. tailNewPos = tailOldPos + add - remove,
  1985. tailCount = length - tailOldPos,
  1986. lengthAfterRemove = length - remove,
  1987. i;
  1988. if (tailNewPos < tailOldPos) {
  1989. for (i = 0; i < tailCount; ++i) {
  1990. array[tailNewPos + i] = array[tailOldPos + i];
  1991. }
  1992. } else if (tailNewPos > tailOldPos) {
  1993. for (i = tailCount; i--; ) {
  1994. array[tailNewPos + i] = array[tailOldPos + i];
  1995. }
  1996. }
  1997. if (add && pos === lengthAfterRemove) {
  1998. array.length = lengthAfterRemove;
  1999. array.push.apply(array, insert);
  2000. } else {
  2001. array.length = lengthAfterRemove + add;
  2002. for (i = 0; i < add; ++i) {
  2003. array[pos + i] = insert[i];
  2004. }
  2005. }
  2006. }
  2007. return array;
  2008. },
  2009. replaceNative = function(array, index, removeCount, insert) {
  2010. if (insert && insert.length) {
  2011. if (index === 0 && !removeCount) {
  2012. array.unshift.apply(array, insert);
  2013. }
  2014. else if (index < array.length) {
  2015. array.splice.apply(array, [
  2016. index,
  2017. removeCount
  2018. ].concat(insert));
  2019. } else
  2020. {
  2021. array.push.apply(array, insert);
  2022. }
  2023. } else {
  2024. array.splice(index, removeCount);
  2025. }
  2026. return array;
  2027. },
  2028. eraseSim = function(array, index, removeCount) {
  2029. return replaceSim(array, index, removeCount);
  2030. },
  2031. eraseNative = function(array, index, removeCount) {
  2032. array.splice(index, removeCount);
  2033. return array;
  2034. },
  2035. spliceSim = function(array, index, removeCount) {
  2036. var len = arguments.length,
  2037. pos = fixArrayIndex(array, index),
  2038. removed;
  2039. if (len < 3) {
  2040. removeCount = array.length - pos;
  2041. }
  2042. removed = array.slice(index, fixArrayIndex(array, pos + removeCount));
  2043. if (len < 4) {
  2044. replaceSim(array, pos, removeCount);
  2045. } else {
  2046. replaceSim(array, pos, removeCount, slice.call(arguments, 3));
  2047. }
  2048. return removed;
  2049. },
  2050. spliceNative = function(array) {
  2051. return array.splice.apply(array, slice.call(arguments, 1));
  2052. },
  2053. erase = supportsSplice ? eraseNative : eraseSim,
  2054. replace = supportsSplice ? replaceNative : replaceSim,
  2055. splice = supportsSplice ? spliceNative : spliceSim,
  2056. ExtArray = {
  2057. binarySearch: function(array, item, begin, end, compareFn) {
  2058. var length = array.length,
  2059. middle, comparison;
  2060. if (begin instanceof Function) {
  2061. compareFn = begin;
  2062. begin = 0;
  2063. end = length;
  2064. } else if (end instanceof Function) {
  2065. compareFn = end;
  2066. end = length;
  2067. } else {
  2068. if (begin === undefined) {
  2069. begin = 0;
  2070. }
  2071. if (end === undefined) {
  2072. end = length;
  2073. }
  2074. compareFn = compareFn || ExtArray.lexicalCompare;
  2075. }
  2076. --end;
  2077. while (begin <= end) {
  2078. middle = (begin + end) >> 1;
  2079. comparison = compareFn(item, array[middle]);
  2080. if (comparison >= 0) {
  2081. begin = middle + 1;
  2082. } else if (comparison < 0) {
  2083. end = middle - 1;
  2084. }
  2085. }
  2086. return begin;
  2087. },
  2088. defaultCompare: function(lhs, rhs) {
  2089. return (lhs < rhs) ? -1 : ((lhs > rhs) ? 1 : 0);
  2090. },
  2091. lexicalCompare: function(lhs, rhs) {
  2092. lhs = String(lhs);
  2093. rhs = String(rhs);
  2094. return (lhs < rhs) ? -1 : ((lhs > rhs) ? 1 : 0);
  2095. },
  2096. each: function(array, fn, scope, reverse) {
  2097. array = ExtArray.from(array);
  2098. var i,
  2099. ln = array.length;
  2100. if (reverse !== true) {
  2101. for (i = 0; i < ln; i++) {
  2102. if (fn.call(scope || array[i], array[i], i, array) === false) {
  2103. return i;
  2104. }
  2105. }
  2106. } else {
  2107. for (i = ln - 1; i > -1; i--) {
  2108. if (fn.call(scope || array[i], array[i], i, array) === false) {
  2109. return i;
  2110. }
  2111. }
  2112. }
  2113. return true;
  2114. },
  2115. findInsertionIndex: function(item, items, comparatorFn, index) {
  2116. var len = items.length,
  2117. beforeCheck, afterCheck;
  2118. comparatorFn = comparatorFn || ExtArray.lexicalCompare;
  2119. if (index < len) {
  2120. beforeCheck = index > 0 ? comparatorFn(items[index - 1], item) : 0;
  2121. afterCheck = index < len - 1 ? comparatorFn(item, items[index]) : 0;
  2122. if (beforeCheck < 1 && afterCheck < 1) {
  2123. return index;
  2124. }
  2125. }
  2126. return ExtArray.binarySearch(items, item, comparatorFn);
  2127. },
  2128. forEach: ('forEach' in arrayPrototype) ? function(array, fn, scope) {
  2129. array.forEach(fn, scope);
  2130. } : function(array, fn, scope) {
  2131. for (var i = 0,
  2132. ln = array.length; i < ln; i++) {
  2133. fn.call(scope, array[i], i, array);
  2134. }
  2135. },
  2136. indexOf: supportsIndexOf ? function(array, item, from) {
  2137. return array ? arrayPrototype.indexOf.call(array, item, from) : -1;
  2138. } : function(array, item, from) {
  2139. var i,
  2140. length = array ? array.length : 0;
  2141. for (i = (from < 0) ? Math.max(0, length + from) : from || 0; i < length; i++) {
  2142. if (array[i] === item) {
  2143. return i;
  2144. }
  2145. }
  2146. return -1;
  2147. },
  2148. contains: supportsIndexOf ? function(array, item) {
  2149. return arrayPrototype.indexOf.call(array, item) !== -1;
  2150. } : function(array, item) {
  2151. var i, ln;
  2152. for (i = 0 , ln = array.length; i < ln; i++) {
  2153. if (array[i] === item) {
  2154. return true;
  2155. }
  2156. }
  2157. return false;
  2158. },
  2159. toArray: function(iterable, start, end) {
  2160. if (!iterable || !iterable.length) {
  2161. return [];
  2162. }
  2163. if (typeof iterable === 'string') {
  2164. iterable = iterable.split('');
  2165. }
  2166. if (supportsSliceOnNodeList) {
  2167. return slice.call(iterable, start || 0, end || iterable.length);
  2168. }
  2169. var array = [],
  2170. i;
  2171. start = start || 0;
  2172. end = end ? ((end < 0) ? iterable.length + end : end) : iterable.length;
  2173. for (i = start; i < end; i++) {
  2174. array.push(iterable[i]);
  2175. }
  2176. return array;
  2177. },
  2178. pluck: function(array, propertyName) {
  2179. var ret = [],
  2180. i, ln, item;
  2181. for (i = 0 , ln = array.length; i < ln; i++) {
  2182. item = array[i];
  2183. ret.push(item[propertyName]);
  2184. }
  2185. return ret;
  2186. },
  2187. map: ('map' in arrayPrototype) ? function(array, fn, scope) {
  2188. Ext.Assert.isFunction(fn, 'Ext.Array.map must have a callback function passed as second argument.');
  2189. return array.map(fn, scope);
  2190. } : function(array, fn, scope) {
  2191. Ext.Assert.isFunction(fn, 'Ext.Array.map must have a callback function passed as second argument.');
  2192. var len = array.length,
  2193. results = new Array(len),
  2194. i;
  2195. for (i = 0; i < len; i++) {
  2196. results[i] = fn.call(scope, array[i], i, array);
  2197. }
  2198. return results;
  2199. },
  2200. every: ('every' in arrayPrototype) ? function(array, fn, scope) {
  2201. Ext.Assert.isFunction(fn, 'Ext.Array.every must have a callback function passed as second argument.');
  2202. return array.every(fn, scope);
  2203. } : function(array, fn, scope) {
  2204. Ext.Assert.isFunction(fn, 'Ext.Array.every must have a callback function passed as second argument.');
  2205. var i = 0,
  2206. ln = array.length;
  2207. for (; i < ln; ++i) {
  2208. if (!fn.call(scope, array[i], i, array)) {
  2209. return false;
  2210. }
  2211. }
  2212. return true;
  2213. },
  2214. some: ('some' in arrayPrototype) ? function(array, fn, scope) {
  2215. Ext.Assert.isFunction(fn, 'Ext.Array.some must have a callback function passed as second argument.');
  2216. return array.some(fn, scope);
  2217. } : function(array, fn, scope) {
  2218. Ext.Assert.isFunction(fn, 'Ext.Array.some must have a callback function passed as second argument.');
  2219. var i = 0,
  2220. ln = array.length;
  2221. for (; i < ln; ++i) {
  2222. if (fn.call(scope, array[i], i, array)) {
  2223. return true;
  2224. }
  2225. }
  2226. return false;
  2227. },
  2228. equals: function(array1, array2) {
  2229. var len1 = array1.length,
  2230. len2 = array2.length,
  2231. i;
  2232. if (array1 === array2) {
  2233. return true;
  2234. }
  2235. if (len1 !== len2) {
  2236. return false;
  2237. }
  2238. for (i = 0; i < len1; ++i) {
  2239. if (array1[i] !== array2[i]) {
  2240. return false;
  2241. }
  2242. }
  2243. return true;
  2244. },
  2245. clean: function(array) {
  2246. var results = [],
  2247. i = 0,
  2248. ln = array.length,
  2249. item;
  2250. for (; i < ln; i++) {
  2251. item = array[i];
  2252. if (!Ext.isEmpty(item)) {
  2253. results.push(item);
  2254. }
  2255. }
  2256. return results;
  2257. },
  2258. unique: function(array) {
  2259. var clone = [],
  2260. i = 0,
  2261. ln = array.length,
  2262. item;
  2263. for (; i < ln; i++) {
  2264. item = array[i];
  2265. if (ExtArray.indexOf(clone, item) === -1) {
  2266. clone.push(item);
  2267. }
  2268. }
  2269. return clone;
  2270. },
  2271. filter: ('filter' in arrayPrototype) ? function(array, fn, scope) {
  2272. Ext.Assert.isFunction(fn, 'Ext.Array.filter must have a filter function passed as second argument.');
  2273. return array.filter(fn, scope);
  2274. } : function(array, fn, scope) {
  2275. Ext.Assert.isFunction(fn, 'Ext.Array.filter must have a filter function passed as second argument.');
  2276. var results = [],
  2277. i = 0,
  2278. ln = array.length;
  2279. for (; i < ln; i++) {
  2280. if (fn.call(scope, array[i], i, array)) {
  2281. results.push(array[i]);
  2282. }
  2283. }
  2284. return results;
  2285. },
  2286. findBy: function(array, fn, scope) {
  2287. var i = 0,
  2288. len = array.length;
  2289. for (; i < len; i++) {
  2290. if (fn.call(scope || array, array[i], i)) {
  2291. return array[i];
  2292. }
  2293. }
  2294. return null;
  2295. },
  2296. from: function(value, newReference) {
  2297. if (value === undefined || value === null) {
  2298. return [];
  2299. }
  2300. if (Ext.isArray(value)) {
  2301. return (newReference) ? slice.call(value) : value;
  2302. }
  2303. var type = typeof value;
  2304. if (value && value.length !== undefined && type !== 'string' && (type !== 'function' || !value.apply)) {
  2305. return ExtArray.toArray(value);
  2306. }
  2307. return [
  2308. value
  2309. ];
  2310. },
  2311. remove: function(array, item) {
  2312. var index = ExtArray.indexOf(array, item);
  2313. if (index !== -1) {
  2314. erase(array, index, 1);
  2315. }
  2316. return array;
  2317. },
  2318. removeAt: function(array, index, count) {
  2319. var len = array.length;
  2320. if (index >= 0 && index < len) {
  2321. count = count || 1;
  2322. count = Math.min(count, len - index);
  2323. erase(array, index, count);
  2324. }
  2325. return array;
  2326. },
  2327. include: function(array, item) {
  2328. if (!ExtArray.contains(array, item)) {
  2329. array.push(item);
  2330. }
  2331. },
  2332. clone: function(array) {
  2333. return slice.call(array);
  2334. },
  2335. merge: function() {
  2336. var args = slice.call(arguments),
  2337. array = [],
  2338. i, ln;
  2339. for (i = 0 , ln = args.length; i < ln; i++) {
  2340. array = array.concat(args[i]);
  2341. }
  2342. return ExtArray.unique(array);
  2343. },
  2344. intersect: function() {
  2345. var intersection = [],
  2346. arrays = slice.call(arguments),
  2347. arraysLength, array, arrayLength, minArray, minArrayIndex, minArrayCandidate, minArrayLength, element, elementCandidate, elementCount, i, j, k;
  2348. if (!arrays.length) {
  2349. return intersection;
  2350. }
  2351. arraysLength = arrays.length;
  2352. for (i = minArrayIndex = 0; i < arraysLength; i++) {
  2353. minArrayCandidate = arrays[i];
  2354. if (!minArray || minArrayCandidate.length < minArray.length) {
  2355. minArray = minArrayCandidate;
  2356. minArrayIndex = i;
  2357. }
  2358. }
  2359. minArray = ExtArray.unique(minArray);
  2360. erase(arrays, minArrayIndex, 1);
  2361. minArrayLength = minArray.length;
  2362. arraysLength = arrays.length;
  2363. for (i = 0; i < minArrayLength; i++) {
  2364. element = minArray[i];
  2365. elementCount = 0;
  2366. for (j = 0; j < arraysLength; j++) {
  2367. array = arrays[j];
  2368. arrayLength = array.length;
  2369. for (k = 0; k < arrayLength; k++) {
  2370. elementCandidate = array[k];
  2371. if (element === elementCandidate) {
  2372. elementCount++;
  2373. break;
  2374. }
  2375. }
  2376. }
  2377. if (elementCount === arraysLength) {
  2378. intersection.push(element);
  2379. }
  2380. }
  2381. return intersection;
  2382. },
  2383. difference: function(arrayA, arrayB) {
  2384. var clone = slice.call(arrayA),
  2385. ln = clone.length,
  2386. i, j, lnB;
  2387. for (i = 0 , lnB = arrayB.length; i < lnB; i++) {
  2388. for (j = 0; j < ln; j++) {
  2389. if (clone[j] === arrayB[i]) {
  2390. erase(clone, j, 1);
  2391. j--;
  2392. ln--;
  2393. }
  2394. }
  2395. }
  2396. return clone;
  2397. },
  2398. reduce: Array.prototype.reduce ? function(array, reduceFn, initialValue) {
  2399. if (arguments.length === 3) {
  2400. return Array.prototype.reduce.call(array, reduceFn, initialValue);
  2401. }
  2402. return Array.prototype.reduce.call(array, reduceFn);
  2403. } : function(array, reduceFn, initialValue) {
  2404. array = Object(array);
  2405. if (!Ext.isFunction(reduceFn)) {
  2406. Ext.raise('Invalid parameter: expected a function.');
  2407. }
  2408. var index = 0,
  2409. length = array.length >>> 0,
  2410. reduced = initialValue;
  2411. if (arguments.length < 3) {
  2412. while (true) {
  2413. if (index in array) {
  2414. reduced = array[index++];
  2415. break;
  2416. }
  2417. if (++index >= length) {
  2418. throw new TypeError('Reduce of empty array with no initial value');
  2419. }
  2420. }
  2421. }
  2422. for (; index < length; ++index) {
  2423. if (index in array) {
  2424. reduced = reduceFn(reduced, array[index], index, array);
  2425. }
  2426. }
  2427. return reduced;
  2428. },
  2429. slice: ([
  2430. 1,
  2431. 2
  2432. ].slice(1, undefined).length ? function(array, begin, end) {
  2433. return slice.call(array, begin, end);
  2434. } : function(array, begin, end) {
  2435. if (typeof begin === 'undefined') {
  2436. return slice.call(array);
  2437. }
  2438. if (typeof end === 'undefined') {
  2439. return slice.call(array, begin);
  2440. }
  2441. return slice.call(array, begin, end);
  2442. }),
  2443. sort: function(array, sortFn) {
  2444. return stableSort(array, sortFn || ExtArray.lexicalCompare);
  2445. },
  2446. flatten: function(array) {
  2447. var worker = [];
  2448. function rFlatten(a) {
  2449. var i, ln, v;
  2450. for (i = 0 , ln = a.length; i < ln; i++) {
  2451. v = a[i];
  2452. if (Ext.isArray(v)) {
  2453. rFlatten(v);
  2454. } else {
  2455. worker.push(v);
  2456. }
  2457. }
  2458. return worker;
  2459. }
  2460. return rFlatten(array);
  2461. },
  2462. min: function(array, comparisonFn) {
  2463. var min = array[0],
  2464. i, ln, item;
  2465. for (i = 0 , ln = array.length; i < ln; i++) {
  2466. item = array[i];
  2467. if (comparisonFn) {
  2468. if (comparisonFn(min, item) === 1) {
  2469. min = item;
  2470. }
  2471. } else {
  2472. if (item < min) {
  2473. min = item;
  2474. }
  2475. }
  2476. }
  2477. return min;
  2478. },
  2479. max: function(array, comparisonFn) {
  2480. var max = array[0],
  2481. i, ln, item;
  2482. for (i = 0 , ln = array.length; i < ln; i++) {
  2483. item = array[i];
  2484. if (comparisonFn) {
  2485. if (comparisonFn(max, item) === -1) {
  2486. max = item;
  2487. }
  2488. } else {
  2489. if (item > max) {
  2490. max = item;
  2491. }
  2492. }
  2493. }
  2494. return max;
  2495. },
  2496. mean: function(array) {
  2497. return array.length > 0 ? ExtArray.sum(array) / array.length : undefined;
  2498. },
  2499. sum: function(array) {
  2500. var sum = 0,
  2501. i, ln, item;
  2502. for (i = 0 , ln = array.length; i < ln; i++) {
  2503. item = array[i];
  2504. sum += item;
  2505. }
  2506. return sum;
  2507. },
  2508. toMap: function(strings, getKey, scope) {
  2509. if (!strings) {
  2510. return null;
  2511. }
  2512. var map = {},
  2513. i = strings.length;
  2514. if (typeof strings === 'string') {
  2515. map[strings] = 1;
  2516. } else if (!getKey) {
  2517. while (i--) {
  2518. map[strings[i]] = i + 1;
  2519. }
  2520. } else if (typeof getKey === 'string') {
  2521. while (i--) {
  2522. map[strings[i][getKey]] = i + 1;
  2523. }
  2524. } else {
  2525. while (i--) {
  2526. map[getKey.call(scope, strings[i])] = i + 1;
  2527. }
  2528. }
  2529. return map;
  2530. },
  2531. toValueMap: function(array, getKey, scope, arrayify) {
  2532. var map = {},
  2533. i = array.length,
  2534. autoArray, alwaysArray, entry, fn, key, value;
  2535. if (!getKey) {
  2536. while (i--) {
  2537. value = array[i];
  2538. map[value] = value;
  2539. }
  2540. } else {
  2541. if (!(fn = (typeof getKey !== 'string'))) {
  2542. arrayify = scope;
  2543. }
  2544. alwaysArray = arrayify === 1;
  2545. autoArray = arrayify === 2;
  2546. while (i--) {
  2547. value = array[i];
  2548. key = fn ? getKey.call(scope, value) : value[getKey];
  2549. if (alwaysArray) {
  2550. if (key in map) {
  2551. map[key].push(value);
  2552. } else {
  2553. map[key] = [
  2554. value
  2555. ];
  2556. }
  2557. } else if (autoArray && (key in map)) {
  2558. if ((entry = map[key]) instanceof Array) {
  2559. entry.push(value);
  2560. } else {
  2561. map[key] = [
  2562. entry,
  2563. value
  2564. ];
  2565. }
  2566. } else {
  2567. map[key] = value;
  2568. }
  2569. }
  2570. }
  2571. return map;
  2572. },
  2573. _replaceSim: replaceSim,
  2574. _spliceSim: spliceSim,
  2575. erase: erase,
  2576. insert: function(array, index, items) {
  2577. return replace(array, index, 0, items);
  2578. },
  2579. move: function(array, fromIdx, toIdx) {
  2580. if (toIdx === fromIdx) {
  2581. return;
  2582. }
  2583. var item = array[fromIdx],
  2584. incr = toIdx > fromIdx ? 1 : -1,
  2585. i;
  2586. for (i = fromIdx; i != toIdx; i += incr) {
  2587. array[i] = array[i + incr];
  2588. }
  2589. array[toIdx] = item;
  2590. },
  2591. replace: replace,
  2592. splice: splice,
  2593. push: function(target) {
  2594. var args = arguments,
  2595. len = args.length,
  2596. i, newItem;
  2597. if (target === undefined) {
  2598. target = [];
  2599. } else if (!Ext.isArray(target)) {
  2600. target = [
  2601. target
  2602. ];
  2603. }
  2604. for (i = 1; i < len; i++) {
  2605. newItem = args[i];
  2606. Array.prototype.push[Ext.isIterable(newItem) ? 'apply' : 'call'](target, newItem);
  2607. }
  2608. return target;
  2609. },
  2610. numericSortFn: function(a, b) {
  2611. return a - b;
  2612. }
  2613. };
  2614. Ext.each = ExtArray.each;
  2615. ExtArray.union = ExtArray.merge;
  2616. Ext.min = ExtArray.min;
  2617. Ext.max = ExtArray.max;
  2618. Ext.sum = ExtArray.sum;
  2619. Ext.mean = ExtArray.mean;
  2620. Ext.flatten = ExtArray.flatten;
  2621. Ext.clean = ExtArray.clean;
  2622. Ext.unique = ExtArray.unique;
  2623. Ext.pluck = ExtArray.pluck;
  2624. Ext.toArray = function() {
  2625. return ExtArray.toArray.apply(ExtArray, arguments);
  2626. };
  2627. return ExtArray;
  2628. }());
  2629. Ext.Assert = {
  2630. falsey: function(b, msg) {
  2631. if (b) {
  2632. Ext.raise(msg || ('Expected a falsey value but was ' + b));
  2633. }
  2634. },
  2635. falseyProp: function(object, property) {
  2636. Ext.Assert.truthy(object);
  2637. var b = object[property];
  2638. if (b) {
  2639. if (object.$className) {
  2640. property = object.$className + '#' + property;
  2641. }
  2642. Ext.raise('Expected a falsey value for ' + property + ' but was ' + b);
  2643. }
  2644. },
  2645. truthy: function(b, msg) {
  2646. if (!b) {
  2647. Ext.raise(msg || ('Expected a truthy value but was ' + typeof b));
  2648. }
  2649. },
  2650. truthyProp: function(object, property) {
  2651. Ext.Assert.truthy(object);
  2652. var b = object[property];
  2653. if (!b) {
  2654. if (object.$className) {
  2655. property = object.$className + '#' + property;
  2656. }
  2657. Ext.raise('Expected a truthy value for ' + property + ' but was ' + typeof b);
  2658. }
  2659. }
  2660. };
  2661. (function() {
  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 (var name in Ext) {
  2701. if (name.substring(0, 2) == "is" && Ext.isFunction(Ext[name])) {
  2702. var 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. if (!s) {
  2763. return value;
  2764. }
  2765. if (!value) {
  2766. return s;
  2767. }
  2768. var len = s.length;
  2769. if (!index && index !== 0) {
  2770. index = len;
  2771. }
  2772. if (index < 0) {
  2773. index *= -1;
  2774. if (index >= len) {
  2775. index = 0;
  2776. } else {
  2777. index = len - index;
  2778. }
  2779. }
  2780. if (index === 0) {
  2781. s = value + s;
  2782. } else if (index >= s.length) {
  2783. s += value;
  2784. } else {
  2785. s = s.substr(0, index) + value + s.substr(index);
  2786. }
  2787. return s;
  2788. },
  2789. startsWith: function(s, start, ignoreCase) {
  2790. var result = boundsCheck(s, start);
  2791. if (result) {
  2792. if (ignoreCase) {
  2793. s = s.toLowerCase();
  2794. start = start.toLowerCase();
  2795. }
  2796. result = s.lastIndexOf(start, 0) === 0;
  2797. }
  2798. return result;
  2799. },
  2800. endsWith: function(s, end, ignoreCase) {
  2801. var result = boundsCheck(s, end);
  2802. if (result) {
  2803. if (ignoreCase) {
  2804. s = s.toLowerCase();
  2805. end = end.toLowerCase();
  2806. }
  2807. result = s.indexOf(end, s.length - end.length) !== -1;
  2808. }
  2809. return result;
  2810. },
  2811. createVarName: function(s) {
  2812. return s.replace(varReplace, '');
  2813. },
  2814. htmlEncode: function(value) {
  2815. return (!value) ? value : String(value).replace(charToEntityRegex, htmlEncodeReplaceFn);
  2816. },
  2817. htmlDecode: function(value) {
  2818. return (!value) ? value : String(value).replace(entityToCharRegex, htmlDecodeReplaceFn);
  2819. },
  2820. hasHtmlCharacters: function(s) {
  2821. return charToEntityRegex.test(s);
  2822. },
  2823. addCharacterEntities: function(newEntities) {
  2824. var charKeys = [],
  2825. entityKeys = [],
  2826. key, echar;
  2827. for (key in newEntities) {
  2828. echar = newEntities[key];
  2829. entityToChar[key] = echar;
  2830. charToEntity[echar] = key;
  2831. charKeys.push(echar);
  2832. entityKeys.push(key);
  2833. }
  2834. charToEntityRegex = new RegExp('(' + charKeys.join('|') + ')', 'g');
  2835. entityToCharRegex = new RegExp('(' + entityKeys.join('|') + '|&#[0-9]{1,5};' + ')', 'g');
  2836. },
  2837. resetCharacterEntities: function() {
  2838. charToEntity = {};
  2839. entityToChar = {};
  2840. this.addCharacterEntities({
  2841. '&amp;': '&',
  2842. '&gt;': '>',
  2843. '&lt;': '<',
  2844. '&quot;': '"',
  2845. '&#39;': "'"
  2846. });
  2847. },
  2848. urlAppend: function(url, string) {
  2849. if (!Ext.isEmpty(string)) {
  2850. return url + (url.indexOf('?') === -1 ? '?' : '&') + string;
  2851. }
  2852. return url;
  2853. },
  2854. trim: function(string) {
  2855. if (string) {
  2856. string = string.replace(trimRegex, "");
  2857. }
  2858. return string || '';
  2859. },
  2860. capitalize: function(string) {
  2861. if (string) {
  2862. string = string.charAt(0).toUpperCase() + string.substr(1);
  2863. }
  2864. return string || '';
  2865. },
  2866. uncapitalize: function(string) {
  2867. if (string) {
  2868. string = string.charAt(0).toLowerCase() + string.substr(1);
  2869. }
  2870. return string || '';
  2871. },
  2872. ellipsis: function(value, length, word) {
  2873. if (value && value.length > length) {
  2874. if (word) {
  2875. var vs = value.substr(0, length - 2),
  2876. index = Math.max(vs.lastIndexOf(' '), vs.lastIndexOf('.'), vs.lastIndexOf('!'), vs.lastIndexOf('?'));
  2877. if (index !== -1 && index >= (length - 15)) {
  2878. return vs.substr(0, index) + "...";
  2879. }
  2880. }
  2881. return value.substr(0, length - 3) + "...";
  2882. }
  2883. return value;
  2884. },
  2885. escapeRegex: function(string) {
  2886. return string.replace(escapeRegexRe, "\\$1");
  2887. },
  2888. createRegex: function(value, startsWith, endsWith, ignoreCase) {
  2889. var ret = value;
  2890. if (value != null && !value.exec) {
  2891. ret = ExtString.escapeRegex(String(value));
  2892. if (startsWith !== false) {
  2893. ret = '^' + ret;
  2894. }
  2895. if (endsWith !== false) {
  2896. ret += '$';
  2897. }
  2898. ret = new RegExp(ret, (ignoreCase !== false) ? 'i' : '');
  2899. }
  2900. return ret;
  2901. },
  2902. escape: function(string) {
  2903. return string.replace(escapeRe, "\\$1");
  2904. },
  2905. toggle: function(string, value, other) {
  2906. return string === value ? other : value;
  2907. },
  2908. leftPad: function(string, size, character) {
  2909. var result = String(string);
  2910. character = character || " ";
  2911. while (result.length < size) {
  2912. result = character + result;
  2913. }
  2914. return result;
  2915. },
  2916. repeat: function(pattern, count, sep) {
  2917. if (count < 1) {
  2918. count = 0;
  2919. }
  2920. for (var buf = [],
  2921. i = count; i--; ) {
  2922. buf.push(pattern);
  2923. }
  2924. return buf.join(sep || '');
  2925. },
  2926. splitWords: function(words) {
  2927. if (words && typeof words == 'string') {
  2928. return words.replace(basicTrimRe, '').split(whitespaceRe);
  2929. }
  2930. return words || [];
  2931. }
  2932. };
  2933. }());
  2934. Ext.String.resetCharacterEntities();
  2935. Ext.htmlEncode = Ext.String.htmlEncode;
  2936. Ext.htmlDecode = Ext.String.htmlDecode;
  2937. Ext.urlAppend = Ext.String.urlAppend;
  2938. Ext.Date = (function() {
  2939. var utilDate,
  2940. nativeDate = Date,
  2941. stripEscapeRe = /(\\.)/g,
  2942. hourInfoRe = /([gGhHisucUOPZ]|MS)/,
  2943. dateInfoRe = /([djzmnYycU]|MS)/,
  2944. slashRe = /\\/gi,
  2945. numberTokenRe = /\{(\d+)\}/g,
  2946. MSFormatRe = new RegExp('\\/Date\\(([-+])?(\\d+)(?:[+-]\\d{4})?\\)\\/'),
  2947. pad = Ext.String.leftPad,
  2948. monthInfo = {
  2949. F: true,
  2950. m: true,
  2951. M: true,
  2952. n: true
  2953. },
  2954. yearInfo = {
  2955. o: true,
  2956. Y: true,
  2957. y: true
  2958. },
  2959. code = [
  2960. "var me = this, dt, y, m, d, h, i, s, ms, o, O, z, zz, u, v, W, year, jan4, week1monday, daysInMonth, dayMatched,",
  2961. "def = me.defaults,",
  2962. "from = Ext.Number.from,",
  2963. "results = String(input).match(me.parseRegexes[{0}]);",
  2964. "if(results){",
  2965. "{1}",
  2966. "if(u != null){",
  2967. "v = new Date(u * 1000);",
  2968. "}else{",
  2969. "dt = me.clearTime(new Date);",
  2970. "y = from(y, from(def.y, dt.getFullYear()));",
  2971. "m = from(m, from(def.m - 1, dt.getMonth()));",
  2972. "dayMatched = d !== undefined;",
  2973. "d = from(d, from(def.d, dt.getDate()));",
  2974. "if (!dayMatched) {",
  2975. "dt.setDate(1);",
  2976. "dt.setMonth(m);",
  2977. "dt.setFullYear(y);",
  2978. "daysInMonth = me.getDaysInMonth(dt);",
  2979. "if (d > daysInMonth) {",
  2980. "d = daysInMonth;",
  2981. "}",
  2982. "}",
  2983. "h = from(h, from(def.h, dt.getHours()));",
  2984. "i = from(i, from(def.i, dt.getMinutes()));",
  2985. "s = from(s, from(def.s, dt.getSeconds()));",
  2986. "ms = from(ms, from(def.ms, dt.getMilliseconds()));",
  2987. "if(z >= 0 && y >= 0){",
  2988. "v = me.add(new Date(y < 100 ? 100 : y, 0, 1, h, i, s, ms), me.YEAR, y < 100 ? y - 100 : 0);",
  2989. "v = !strict? v : (strict === true && (z <= 364 || (me.isLeapYear(v) && z <= 365))? me.add(v, me.DAY, z) : null);",
  2990. "}else if(strict === true && !me.isValid(y, m + 1, d, h, i, s, ms)){",
  2991. "v = null;",
  2992. "}else{",
  2993. "if (W) {",
  2994. "year = y || (new Date()).getFullYear();",
  2995. "jan4 = new Date(year, 0, 4, 0, 0, 0);",
  2996. "d = jan4.getDay();",
  2997. "week1monday = new Date(jan4.getTime() - ((d === 0 ? 6 : d - 1) * 86400000));",
  2998. "v = Ext.Date.clearTime(new Date(week1monday.getTime() + ((W - 1) * 604800000 + 43200000)));",
  2999. "} else {",
  3000. "v = me.add(new Date(y < 100 ? 100 : y, m, d, h, i, s, ms), me.YEAR, y < 100 ? y - 100 : 0);",
  3001. "}",
  3002. "}",
  3003. "}",
  3004. "}",
  3005. "if(v){",
  3006. "if(zz != null){",
  3007. "v = me.add(v, me.SECOND, -v.getTimezoneOffset() * 60 - zz);",
  3008. "}else if(o){",
  3009. "v = me.add(v, me.MINUTE, -v.getTimezoneOffset() + (sn == '+'? -1 : 1) * (hr * 60 + mn));",
  3010. "}",
  3011. "}",
  3012. "return (v != null) ? v : null;"
  3013. ].join('\n');
  3014. if (!Date.prototype.toISOString) {
  3015. Date.prototype.toISOString = function() {
  3016. var me = this;
  3017. 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';
  3018. };
  3019. }
  3020. function xf(format) {
  3021. var args = Array.prototype.slice.call(arguments, 1);
  3022. return format.replace(numberTokenRe, function(m, i) {
  3023. return args[i];
  3024. });
  3025. }
  3026. utilDate = {
  3027. now: nativeDate.now,
  3028. toString: function(date) {
  3029. if (!date) {
  3030. date = new nativeDate();
  3031. }
  3032. 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');
  3033. },
  3034. getElapsed: function(dateA, dateB) {
  3035. return Math.abs(dateA - (dateB || utilDate.now()));
  3036. },
  3037. useStrict: false,
  3038. formatCodeToRegex: function(character, currentGroup) {
  3039. var p = utilDate.parseCodes[character];
  3040. if (p) {
  3041. p = typeof p === 'function' ? p() : p;
  3042. utilDate.parseCodes[character] = p;
  3043. }
  3044. return p ? Ext.applyIf({
  3045. c: p.c ? xf(p.c, currentGroup || "{0}") : p.c
  3046. }, p) : {
  3047. g: 0,
  3048. c: null,
  3049. s: Ext.String.escapeRegex(character)
  3050. };
  3051. },
  3052. parseFunctions: {
  3053. "MS": function(input, strict) {
  3054. var r = (input || '').match(MSFormatRe);
  3055. return r ? new nativeDate(((r[1] || '') + r[2]) * 1) : null;
  3056. },
  3057. "time": function(input, strict) {
  3058. var num = parseInt(input, 10);
  3059. if (num || num === 0) {
  3060. return new nativeDate(num);
  3061. }
  3062. return null;
  3063. },
  3064. "timestamp": function(input, strict) {
  3065. var num = parseInt(input, 10);
  3066. if (num || num === 0) {
  3067. return new nativeDate(num * 1000);
  3068. }
  3069. return null;
  3070. }
  3071. },
  3072. parseRegexes: [],
  3073. formatFunctions: {
  3074. "MS": function() {
  3075. return '\\/Date(' + this.getTime() + ')\\/';
  3076. },
  3077. "time": function() {
  3078. return this.getTime().toString();
  3079. },
  3080. "timestamp": function() {
  3081. return utilDate.format(this, 'U');
  3082. }
  3083. },
  3084. y2kYear: 50,
  3085. MILLI: "ms",
  3086. SECOND: "s",
  3087. MINUTE: "mi",
  3088. HOUR: "h",
  3089. DAY: "d",
  3090. MONTH: "mo",
  3091. YEAR: "y",
  3092. DAYS_IN_WEEK: 7,
  3093. MONTHS_IN_YEAR: 12,
  3094. MAX_DAYS_IN_MONTH: 31,
  3095. SUNDAY: 0,
  3096. MONDAY: 1,
  3097. TUESDAY: 2,
  3098. WEDNESDAY: 3,
  3099. THURSDAY: 4,
  3100. FRIDAY: 5,
  3101. SATURDAY: 6,
  3102. defaults: {},
  3103. dayNames: [
  3104. "Sunday",
  3105. "Monday",
  3106. "Tuesday",
  3107. "Wednesday",
  3108. "Thursday",
  3109. "Friday",
  3110. "Saturday"
  3111. ],
  3112. monthNames: [
  3113. "January",
  3114. "February",
  3115. "March",
  3116. "April",
  3117. "May",
  3118. "June",
  3119. "July",
  3120. "August",
  3121. "September",
  3122. "October",
  3123. "November",
  3124. "December"
  3125. ],
  3126. monthNumbers: {
  3127. January: 0,
  3128. Jan: 0,
  3129. February: 1,
  3130. Feb: 1,
  3131. March: 2,
  3132. Mar: 2,
  3133. April: 3,
  3134. Apr: 3,
  3135. May: 4,
  3136. June: 5,
  3137. Jun: 5,
  3138. July: 6,
  3139. Jul: 6,
  3140. August: 7,
  3141. Aug: 7,
  3142. September: 8,
  3143. Sep: 8,
  3144. October: 9,
  3145. Oct: 9,
  3146. November: 10,
  3147. Nov: 10,
  3148. December: 11,
  3149. Dec: 11
  3150. },
  3151. defaultFormat: 'm/d/Y',
  3152. defaultTimeFormat: 'h:i A',
  3153. firstDayOfWeek: 0,
  3154. weekendDays: [
  3155. 0,
  3156. 6
  3157. ],
  3158. getShortMonthName: function(month) {
  3159. return utilDate.monthNames[month].substring(0, 3);
  3160. },
  3161. getShortDayName: function(day) {
  3162. return utilDate.dayNames[day].substring(0, 3);
  3163. },
  3164. getMonthNumber: function(name) {
  3165. return utilDate.monthNumbers[name.substring(0, 1).toUpperCase() + name.substring(1, 3).toLowerCase()];
  3166. },
  3167. formatContainsHourInfo: function(format) {
  3168. return hourInfoRe.test(format.replace(stripEscapeRe, ''));
  3169. },
  3170. formatContainsDateInfo: function(format) {
  3171. return dateInfoRe.test(format.replace(stripEscapeRe, ''));
  3172. },
  3173. isMonthFormat: function(format) {
  3174. return !!monthInfo[format];
  3175. },
  3176. isYearFormat: function(format) {
  3177. return !!yearInfo[format];
  3178. },
  3179. unescapeFormat: function(format) {
  3180. return format.replace(slashRe, '');
  3181. },
  3182. formatCodes: {
  3183. d: "Ext.String.leftPad(m.getDate(), 2, '0')",
  3184. D: "Ext.Date.getShortDayName(m.getDay())",
  3185. j: "m.getDate()",
  3186. l: "Ext.Date.dayNames[m.getDay()]",
  3187. N: "(m.getDay() ? m.getDay() : 7)",
  3188. S: "Ext.Date.getSuffix(m)",
  3189. w: "m.getDay()",
  3190. z: "Ext.Date.getDayOfYear(m)",
  3191. W: "Ext.String.leftPad(Ext.Date.getWeekOfYear(m), 2, '0')",
  3192. F: "Ext.Date.monthNames[m.getMonth()]",
  3193. m: "Ext.String.leftPad(m.getMonth() + 1, 2, '0')",
  3194. M: "Ext.Date.getShortMonthName(m.getMonth())",
  3195. n: "(m.getMonth() + 1)",
  3196. t: "Ext.Date.getDaysInMonth(m)",
  3197. L: "(Ext.Date.isLeapYear(m) ? 1 : 0)",
  3198. o: "(m.getFullYear() + (Ext.Date.getWeekOfYear(m) == 1 && m.getMonth() > 0 ? +1 : (Ext.Date.getWeekOfYear(m) >= 52 && m.getMonth() < 11 ? -1 : 0)))",
  3199. Y: "Ext.String.leftPad(m.getFullYear(), 4, '0')",
  3200. y: "('' + m.getFullYear()).substring(2, 4)",
  3201. a: "(m.getHours() < 12 ? 'am' : 'pm')",
  3202. A: "(m.getHours() < 12 ? 'AM' : 'PM')",
  3203. g: "((m.getHours() % 12) ? m.getHours() % 12 : 12)",
  3204. G: "m.getHours()",
  3205. h: "Ext.String.leftPad((m.getHours() % 12) ? m.getHours() % 12 : 12, 2, '0')",
  3206. H: "Ext.String.leftPad(m.getHours(), 2, '0')",
  3207. i: "Ext.String.leftPad(m.getMinutes(), 2, '0')",
  3208. s: "Ext.String.leftPad(m.getSeconds(), 2, '0')",
  3209. u: "Ext.String.leftPad(m.getMilliseconds(), 3, '0')",
  3210. O: "Ext.Date.getGMTOffset(m)",
  3211. P: "Ext.Date.getGMTOffset(m, true)",
  3212. T: "Ext.Date.getTimezone(m)",
  3213. Z: "(m.getTimezoneOffset() * -60)",
  3214. c: function() {
  3215. var c = "Y-m-dTH:i:sP",
  3216. code = [],
  3217. i,
  3218. l = c.length,
  3219. e;
  3220. for (i = 0; i < l; ++i) {
  3221. e = c.charAt(i);
  3222. code.push(e === "T" ? "'T'" : utilDate.getFormatCode(e));
  3223. }
  3224. return code.join(" + ");
  3225. },
  3226. C: function() {
  3227. return 'm.toISOString()';
  3228. },
  3229. U: "Math.round(m.getTime() / 1000)"
  3230. },
  3231. isValid: function(year, month, day, hour, minute, second, millisecond) {
  3232. hour = hour || 0;
  3233. minute = minute || 0;
  3234. second = second || 0;
  3235. millisecond = millisecond || 0;
  3236. var dt = utilDate.add(new nativeDate(year < 100 ? 100 : year, month - 1, day, hour, minute, second, millisecond), utilDate.YEAR, year < 100 ? year - 100 : 0);
  3237. return year === dt.getFullYear() && month === dt.getMonth() + 1 && day === dt.getDate() && hour === dt.getHours() && minute === dt.getMinutes() && second === dt.getSeconds() && millisecond === dt.getMilliseconds();
  3238. },
  3239. parse: function(input, format, strict) {
  3240. var p = utilDate.parseFunctions;
  3241. if (p[format] == null) {
  3242. utilDate.createParser(format);
  3243. }
  3244. return p[format].call(utilDate, input, Ext.isDefined(strict) ? strict : utilDate.useStrict);
  3245. },
  3246. parseDate: function(input, format, strict) {
  3247. return utilDate.parse(input, format, strict);
  3248. },
  3249. getFormatCode: function(character) {
  3250. var f = utilDate.formatCodes[character];
  3251. if (f) {
  3252. f = typeof f === 'function' ? f() : f;
  3253. utilDate.formatCodes[character] = f;
  3254. }
  3255. return f || ("'" + Ext.String.escape(character) + "'");
  3256. },
  3257. createFormat: function(format) {
  3258. var code = [],
  3259. special = false,
  3260. ch = '',
  3261. i;
  3262. for (i = 0; i < format.length; ++i) {
  3263. ch = format.charAt(i);
  3264. if (!special && ch === "\\") {
  3265. special = true;
  3266. } else if (special) {
  3267. special = false;
  3268. code.push("'" + Ext.String.escape(ch) + "'");
  3269. } else {
  3270. if (ch === '\n') {
  3271. code.push("'\\n'");
  3272. } else {
  3273. code.push(utilDate.getFormatCode(ch));
  3274. }
  3275. }
  3276. }
  3277. utilDate.formatFunctions[format] = Ext.functionFactory("var m=this;return " + code.join('+'));
  3278. },
  3279. createParser: function(format) {
  3280. var regexNum = utilDate.parseRegexes.length,
  3281. currentGroup = 1,
  3282. calc = [],
  3283. regex = [],
  3284. special = false,
  3285. ch = "",
  3286. i = 0,
  3287. len = format.length,
  3288. atEnd = [],
  3289. obj;
  3290. for (; i < len; ++i) {
  3291. ch = format.charAt(i);
  3292. if (!special && ch === "\\") {
  3293. special = true;
  3294. } else if (special) {
  3295. special = false;
  3296. regex.push(Ext.String.escape(ch));
  3297. } else {
  3298. obj = utilDate.formatCodeToRegex(ch, currentGroup);
  3299. currentGroup += obj.g;
  3300. regex.push(obj.s);
  3301. if (obj.g && obj.c) {
  3302. if (obj.calcAtEnd) {
  3303. atEnd.push(obj.c);
  3304. } else {
  3305. calc.push(obj.c);
  3306. }
  3307. }
  3308. }
  3309. }
  3310. calc = calc.concat(atEnd);
  3311. utilDate.parseRegexes[regexNum] = new RegExp("^" + regex.join('') + "$", 'i');
  3312. utilDate.parseFunctions[format] = Ext.functionFactory("input", "strict", xf(code, regexNum, calc.join('')));
  3313. },
  3314. parseCodes: {
  3315. d: {
  3316. g: 1,
  3317. c: "d = parseInt(results[{0}], 10);\n",
  3318. s: "(3[0-1]|[1-2][0-9]|0[1-9])"
  3319. },
  3320. j: {
  3321. g: 1,
  3322. c: "d = parseInt(results[{0}], 10);\n",
  3323. s: "(3[0-1]|[1-2][0-9]|[1-9])"
  3324. },
  3325. D: function() {
  3326. for (var a = [],
  3327. i = 0; i < 7; a.push(utilDate.getShortDayName(i)) , ++i){}
  3328. return {
  3329. g: 0,
  3330. c: null,
  3331. s: "(?:" + a.join("|") + ")"
  3332. };
  3333. },
  3334. l: function() {
  3335. return {
  3336. g: 0,
  3337. c: null,
  3338. s: "(?:" + utilDate.dayNames.join("|") + ")"
  3339. };
  3340. },
  3341. N: {
  3342. g: 0,
  3343. c: null,
  3344. s: "[1-7]"
  3345. },
  3346. S: {
  3347. g: 0,
  3348. c: null,
  3349. s: "(?:st|nd|rd|th)"
  3350. },
  3351. w: {
  3352. g: 0,
  3353. c: null,
  3354. s: "[0-6]"
  3355. },
  3356. z: {
  3357. g: 1,
  3358. c: "z = parseInt(results[{0}], 10);\n",
  3359. s: "(\\d{1,3})"
  3360. },
  3361. W: {
  3362. g: 1,
  3363. c: "W = parseInt(results[{0}], 10);\n",
  3364. s: "(\\d{2})"
  3365. },
  3366. F: function() {
  3367. return {
  3368. g: 1,
  3369. c: "m = parseInt(me.getMonthNumber(results[{0}]), 10);\n",
  3370. s: "(" + utilDate.monthNames.join("|") + ")"
  3371. };
  3372. },
  3373. M: function() {
  3374. for (var a = [],
  3375. i = 0; i < 12; a.push(utilDate.getShortMonthName(i)) , ++i){}
  3376. return Ext.applyIf({
  3377. s: "(" + a.join("|") + ")"
  3378. }, utilDate.formatCodeToRegex("F"));
  3379. },
  3380. m: {
  3381. g: 1,
  3382. c: "m = parseInt(results[{0}], 10) - 1;\n",
  3383. s: "(1[0-2]|0[1-9])"
  3384. },
  3385. n: {
  3386. g: 1,
  3387. c: "m = parseInt(results[{0}], 10) - 1;\n",
  3388. s: "(1[0-2]|[1-9])"
  3389. },
  3390. t: {
  3391. g: 0,
  3392. c: null,
  3393. s: "(?:\\d{2})"
  3394. },
  3395. L: {
  3396. g: 0,
  3397. c: null,
  3398. s: "(?:1|0)"
  3399. },
  3400. o: {
  3401. g: 1,
  3402. c: "y = parseInt(results[{0}], 10);\n",
  3403. s: "(\\d{4})"
  3404. },
  3405. Y: {
  3406. g: 1,
  3407. c: "y = parseInt(results[{0}], 10);\n",
  3408. s: "(\\d{4})"
  3409. },
  3410. y: {
  3411. g: 1,
  3412. c: "var ty = parseInt(results[{0}], 10);\n" + "y = ty > me.y2kYear ? 1900 + ty : 2000 + ty;\n",
  3413. s: "(\\d{2})"
  3414. },
  3415. a: {
  3416. g: 1,
  3417. c: "if (/(am)/i.test(results[{0}])) {\n" + "if (!h || h == 12) { h = 0; }\n" + "} else { if (!h || h < 12) { h = (h || 0) + 12; }}",
  3418. s: "(am|pm|AM|PM)",
  3419. calcAtEnd: true
  3420. },
  3421. A: {
  3422. g: 1,
  3423. c: "if (/(am)/i.test(results[{0}])) {\n" + "if (!h || h == 12) { h = 0; }\n" + "} else { if (!h || h < 12) { h = (h || 0) + 12; }}",
  3424. s: "(AM|PM|am|pm)",
  3425. calcAtEnd: true
  3426. },
  3427. g: {
  3428. g: 1,
  3429. c: "h = parseInt(results[{0}], 10);\n",
  3430. s: "(1[0-2]|[1-9])"
  3431. },
  3432. G: {
  3433. g: 1,
  3434. c: "h = parseInt(results[{0}], 10);\n",
  3435. s: "(2[0-3]|1[0-9]|[0-9])"
  3436. },
  3437. h: {
  3438. g: 1,
  3439. c: "h = parseInt(results[{0}], 10);\n",
  3440. s: "(1[0-2]|0[1-9])"
  3441. },
  3442. H: {
  3443. g: 1,
  3444. c: "h = parseInt(results[{0}], 10);\n",
  3445. s: "(2[0-3]|[0-1][0-9])"
  3446. },
  3447. i: {
  3448. g: 1,
  3449. c: "i = parseInt(results[{0}], 10);\n",
  3450. s: "([0-5][0-9])"
  3451. },
  3452. s: {
  3453. g: 1,
  3454. c: "s = parseInt(results[{0}], 10);\n",
  3455. s: "([0-5][0-9])"
  3456. },
  3457. u: {
  3458. g: 1,
  3459. c: "ms = results[{0}]; ms = parseInt(ms, 10)/Math.pow(10, ms.length - 3);\n",
  3460. s: "(\\d+)"
  3461. },
  3462. O: {
  3463. g: 1,
  3464. c: [
  3465. "o = results[{0}];",
  3466. "var sn = o.substring(0,1),",
  3467. "hr = o.substring(1,3)*1 + Math.floor(o.substring(3,5) / 60),",
  3468. "mn = o.substring(3,5) % 60;",
  3469. "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"
  3470. ].
  3471. join("\n"),
  3472. s: "([+-]\\d{4})"
  3473. },
  3474. P: {
  3475. g: 1,
  3476. c: [
  3477. "o = results[{0}];",
  3478. "var sn = o.substring(0,1),",
  3479. "hr = o.substring(1,3)*1 + Math.floor(o.substring(4,6) / 60),",
  3480. "mn = o.substring(4,6) % 60;",
  3481. "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"
  3482. ].
  3483. join("\n"),
  3484. s: "([+-]\\d{2}:\\d{2})"
  3485. },
  3486. T: {
  3487. g: 0,
  3488. c: null,
  3489. s: "[A-Z]{1,5}"
  3490. },
  3491. Z: {
  3492. g: 1,
  3493. c: "zz = results[{0}] * 1;\n" +
  3494. "zz = (-43200 <= zz && zz <= 50400)? zz : null;\n",
  3495. s: "([+-]?\\d{1,5})"
  3496. },
  3497. c: function() {
  3498. var calc = [],
  3499. arr = [
  3500. utilDate.formatCodeToRegex("Y", 1),
  3501. utilDate.formatCodeToRegex("m", 2),
  3502. utilDate.formatCodeToRegex("d", 3),
  3503. utilDate.formatCodeToRegex("H", 4),
  3504. utilDate.formatCodeToRegex("i", 5),
  3505. utilDate.formatCodeToRegex("s", 6),
  3506. {
  3507. c: "ms = results[7] || '0'; ms = parseInt(ms, 10)/Math.pow(10, ms.length - 3);\n"
  3508. },
  3509. {
  3510. c: [
  3511. "if(results[8]) {",
  3512. "if(results[8] == 'Z'){",
  3513. "zz = 0;",
  3514. "}else if (results[8].indexOf(':') > -1){",
  3515. utilDate.formatCodeToRegex("P", 8).c,
  3516. "}else{",
  3517. utilDate.formatCodeToRegex("O", 8).c,
  3518. "}",
  3519. "}"
  3520. ].join('\n')
  3521. }
  3522. ],
  3523. i, l;
  3524. for (i = 0 , l = arr.length; i < l; ++i) {
  3525. calc.push(arr[i].c);
  3526. }
  3527. return {
  3528. g: 1,
  3529. c: calc.join(""),
  3530. s: [
  3531. arr[0].s,
  3532. "(?:",
  3533. "-",
  3534. arr[1].s,
  3535. "(?:",
  3536. "-",
  3537. arr[2].s,
  3538. "(?:",
  3539. "(?:T| )?",
  3540. arr[3].s,
  3541. ":",
  3542. arr[4].s,
  3543. "(?::",
  3544. arr[5].s,
  3545. ")?",
  3546. "(?:(?:\\.|,)(\\d+))?",
  3547. "(Z|(?:[-+]\\d{2}(?::)?\\d{2}))?",
  3548. ")?",
  3549. ")?",
  3550. ")?"
  3551. ].join("")
  3552. };
  3553. },
  3554. U: {
  3555. g: 1,
  3556. c: "u = parseInt(results[{0}], 10);\n",
  3557. s: "(-?\\d+)"
  3558. }
  3559. },
  3560. dateFormat: function(date, format) {
  3561. return utilDate.format(date, format);
  3562. },
  3563. isEqual: function(date1, date2) {
  3564. if (date1 && date2) {
  3565. return (date1.getTime() === date2.getTime());
  3566. }
  3567. return !(date1 || date2);
  3568. },
  3569. format: function(date, format) {
  3570. var formatFunctions = utilDate.formatFunctions;
  3571. if (!Ext.isDate(date)) {
  3572. return '';
  3573. }
  3574. if (formatFunctions[format] == null) {
  3575. utilDate.createFormat(format);
  3576. }
  3577. return formatFunctions[format].call(date) + '';
  3578. },
  3579. getTimezone: function(date) {
  3580. return date.toString().replace(/^.* (?:\((.*)\)|([A-Z]{1,5})(?:[\-+][0-9]{4})?(?: -?\d+)?)$/, "$1$2").replace(/[^A-Z]/g, "");
  3581. },
  3582. getGMTOffset: function(date, colon) {
  3583. var offset = date.getTimezoneOffset();
  3584. return (offset > 0 ? "-" : "+") + Ext.String.leftPad(Math.floor(Math.abs(offset) / 60), 2, "0") + (colon ? ":" : "") + Ext.String.leftPad(Math.abs(offset % 60), 2, "0");
  3585. },
  3586. getDayOfYear: function(date) {
  3587. var num = 0,
  3588. d = utilDate.clone(date),
  3589. m = date.getMonth(),
  3590. i;
  3591. for (i = 0 , d.setDate(1) , d.setMonth(0); i < m; d.setMonth(++i)) {
  3592. num += utilDate.getDaysInMonth(d);
  3593. }
  3594. return num + date.getDate() - 1;
  3595. },
  3596. getWeekOfYear: (function() {
  3597. var ms1d = 86400000,
  3598. ms7d = 7 * ms1d;
  3599. return function(date) {
  3600. var DC3 = nativeDate.UTC(date.getFullYear(), date.getMonth(), date.getDate() + 3) / ms1d,
  3601. AWN = Math.floor(DC3 / 7),
  3602. Wyr = new nativeDate(AWN * ms7d).getUTCFullYear();
  3603. return AWN - Math.floor(nativeDate.UTC(Wyr, 0, 7) / ms7d) + 1;
  3604. };
  3605. }()),
  3606. isLeapYear: function(date) {
  3607. var year = date.getFullYear();
  3608. return !!((year & 3) === 0 && (year % 100 || (year % 400 === 0 && year)));
  3609. },
  3610. getFirstDayOfMonth: function(date) {
  3611. var day = (date.getDay() - (date.getDate() - 1)) % 7;
  3612. return (day < 0) ? (day + 7) : day;
  3613. },
  3614. getLastDayOfMonth: function(date) {
  3615. return utilDate.getLastDateOfMonth(date).getDay();
  3616. },
  3617. getFirstDateOfMonth: function(date) {
  3618. return new nativeDate(date.getFullYear(), date.getMonth(), 1);
  3619. },
  3620. getLastDateOfMonth: function(date) {
  3621. return new nativeDate(date.getFullYear(), date.getMonth(), utilDate.getDaysInMonth(date));
  3622. },
  3623. getDaysInMonth: (function() {
  3624. var daysInMonth = [
  3625. 31,
  3626. 28,
  3627. 31,
  3628. 30,
  3629. 31,
  3630. 30,
  3631. 31,
  3632. 31,
  3633. 30,
  3634. 31,
  3635. 30,
  3636. 31
  3637. ];
  3638. return function(date) {
  3639. var m = date.getMonth();
  3640. return m === 1 && utilDate.isLeapYear(date) ? 29 : daysInMonth[m];
  3641. };
  3642. }()),
  3643. getSuffix: function(date) {
  3644. switch (date.getDate()) {
  3645. case 1:
  3646. case 21:
  3647. case 31:
  3648. return "st";
  3649. case 2:
  3650. case 22:
  3651. return "nd";
  3652. case 3:
  3653. case 23:
  3654. return "rd";
  3655. default:
  3656. return "th";
  3657. }
  3658. },
  3659. clone: function(date) {
  3660. return new nativeDate(date.getTime());
  3661. },
  3662. isDST: function(date) {
  3663. return new nativeDate(date.getFullYear(), 0, 1).getTimezoneOffset() !== date.getTimezoneOffset();
  3664. },
  3665. clearTime: function(date, clone) {
  3666. if (isNaN(date.getTime())) {
  3667. return date;
  3668. }
  3669. if (clone) {
  3670. return utilDate.clearTime(utilDate.clone(date));
  3671. }
  3672. var d = date.getDate(),
  3673. hr, c;
  3674. date.setHours(0);
  3675. date.setMinutes(0);
  3676. date.setSeconds(0);
  3677. date.setMilliseconds(0);
  3678. if (date.getDate() !== d) {
  3679. for (hr = 1 , c = utilDate.add(date, utilDate.HOUR, hr); c.getDate() !== d; hr++ , c = utilDate.add(date, utilDate.HOUR, hr)){}
  3680. date.setDate(d);
  3681. date.setHours(c.getHours());
  3682. }
  3683. return date;
  3684. },
  3685. add: function(date, interval, value, preventDstAdjust) {
  3686. var d = utilDate.clone(date),
  3687. base = 0,
  3688. day, decimalValue;
  3689. if (!interval || value === 0) {
  3690. return d;
  3691. }
  3692. decimalValue = value - parseInt(value, 10);
  3693. value = parseInt(value, 10);
  3694. if (value) {
  3695. switch (interval.toLowerCase()) {
  3696. case utilDate.MILLI:
  3697. if (preventDstAdjust) {
  3698. d.setMilliseconds(d.getMilliseconds() + value);
  3699. } else {
  3700. d.setTime(d.getTime() + value);
  3701. };
  3702. break;
  3703. case utilDate.SECOND:
  3704. if (preventDstAdjust) {
  3705. d.setSeconds(d.getSeconds() + value);
  3706. } else {
  3707. d.setTime(d.getTime() + value * 1000);
  3708. };
  3709. break;
  3710. case utilDate.MINUTE:
  3711. if (preventDstAdjust) {
  3712. d.setMinutes(d.getMinutes() + value);
  3713. } else {
  3714. d.setTime(d.getTime() + value * 60 * 1000);
  3715. };
  3716. break;
  3717. case utilDate.HOUR:
  3718. if (preventDstAdjust) {
  3719. d.setHours(d.getHours() + value);
  3720. } else {
  3721. d.setTime(d.getTime() + value * 60 * 60 * 1000);
  3722. };
  3723. break;
  3724. case utilDate.DAY:
  3725. if (preventDstAdjust) {
  3726. d.setDate(d.getDate() + value);
  3727. } else {
  3728. d.setTime(d.getTime() + value * 24 * 60 * 60 * 1000);
  3729. };
  3730. break;
  3731. case utilDate.MONTH:
  3732. day = date.getDate();
  3733. if (day > 28) {
  3734. day = Math.min(day, utilDate.getLastDateOfMonth(utilDate.add(utilDate.getFirstDateOfMonth(date), utilDate.MONTH, value)).getDate());
  3735. };
  3736. d.setDate(day);
  3737. d.setMonth(date.getMonth() + value);
  3738. break;
  3739. case utilDate.YEAR:
  3740. day = date.getDate();
  3741. if (day > 28) {
  3742. day = Math.min(day, utilDate.getLastDateOfMonth(utilDate.add(utilDate.getFirstDateOfMonth(date), utilDate.YEAR, value)).getDate());
  3743. };
  3744. d.setDate(day);
  3745. d.setFullYear(date.getFullYear() + value);
  3746. break;
  3747. }
  3748. }
  3749. if (decimalValue) {
  3750. switch (interval.toLowerCase()) {
  3751. case utilDate.MILLI:
  3752. base = 1;
  3753. break;
  3754. case utilDate.SECOND:
  3755. base = 1000;
  3756. break;
  3757. case utilDate.MINUTE:
  3758. base = 1000 * 60;
  3759. break;
  3760. case utilDate.HOUR:
  3761. base = 1000 * 60 * 60;
  3762. break;
  3763. case utilDate.DAY:
  3764. base = 1000 * 60 * 60 * 24;
  3765. break;
  3766. case utilDate.MONTH:
  3767. day = utilDate.getDaysInMonth(d);
  3768. base = 1000 * 60 * 60 * 24 * day;
  3769. break;
  3770. case utilDate.YEAR:
  3771. day = (utilDate.isLeapYear(d) ? 366 : 365);
  3772. base = 1000 * 60 * 60 * 24 * day;
  3773. break;
  3774. }
  3775. if (base) {
  3776. d.setTime(d.getTime() + base * decimalValue);
  3777. }
  3778. }
  3779. return d;
  3780. },
  3781. subtract: function(date, interval, value, preventDstAdjust) {
  3782. return utilDate.add(date, interval, -value, preventDstAdjust);
  3783. },
  3784. between: function(date, start, end) {
  3785. var t = date.getTime();
  3786. return start.getTime() <= t && t <= end.getTime();
  3787. },
  3788. isWeekend: function(date) {
  3789. return Ext.Array.indexOf(this.weekendDays, date.getDay()) > -1;
  3790. },
  3791. utcToLocal: function(d) {
  3792. return new Date(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate(), d.getUTCHours(), d.getUTCMinutes(), d.getUTCSeconds(), d.getUTCMilliseconds());
  3793. },
  3794. localToUtc: function(d) {
  3795. return utilDate.utc(d.getFullYear(), d.getMonth(), d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds(), d.getMilliseconds());
  3796. },
  3797. utc: function(year, month, day, hour, min, s, ms) {
  3798. return new Date(Date.UTC(year, month, day, hour || 0, min || 0, s || 0, ms || 0));
  3799. },
  3800. compat: function() {
  3801. var p,
  3802. statics = [
  3803. 'useStrict',
  3804. 'formatCodeToRegex',
  3805. 'parseFunctions',
  3806. 'parseRegexes',
  3807. 'formatFunctions',
  3808. 'y2kYear',
  3809. 'MILLI',
  3810. 'SECOND',
  3811. 'MINUTE',
  3812. 'HOUR',
  3813. 'DAY',
  3814. 'MONTH',
  3815. 'YEAR',
  3816. 'defaults',
  3817. 'dayNames',
  3818. 'monthNames',
  3819. 'monthNumbers',
  3820. 'getShortMonthName',
  3821. 'getShortDayName',
  3822. 'getMonthNumber',
  3823. 'formatCodes',
  3824. 'isValid',
  3825. 'parseDate',
  3826. 'getFormatCode',
  3827. 'createFormat',
  3828. 'createParser',
  3829. 'parseCodes'
  3830. ],
  3831. proto = [
  3832. 'dateFormat',
  3833. 'format',
  3834. 'getTimezone',
  3835. 'getGMTOffset',
  3836. 'getDayOfYear',
  3837. 'getWeekOfYear',
  3838. 'isLeapYear',
  3839. 'getFirstDayOfMonth',
  3840. 'getLastDayOfMonth',
  3841. 'getDaysInMonth',
  3842. 'getSuffix',
  3843. 'clone',
  3844. 'isDST',
  3845. 'clearTime',
  3846. 'add',
  3847. 'between'
  3848. ],
  3849. sLen = statics.length,
  3850. pLen = proto.length,
  3851. stat, prot, s;
  3852. for (s = 0; s < sLen; s++) {
  3853. stat = statics[s];
  3854. nativeDate[stat] = utilDate[stat];
  3855. }
  3856. for (p = 0; p < pLen; p++) {
  3857. prot = proto[p];
  3858. nativeDate.prototype[prot] = function() {
  3859. var args = Array.prototype.slice.call(arguments);
  3860. args.unshift(this);
  3861. return utilDate[prot].apply(utilDate, args);
  3862. };
  3863. }
  3864. },
  3865. diff: function(min, max, unit) {
  3866. var est,
  3867. diff = +max - min;
  3868. switch (unit) {
  3869. case utilDate.MILLI:
  3870. return diff;
  3871. case utilDate.SECOND:
  3872. return Math.floor(diff / 1000);
  3873. case utilDate.MINUTE:
  3874. return Math.floor(diff / 60000);
  3875. case utilDate.HOUR:
  3876. return Math.floor(diff / 3600000);
  3877. case utilDate.DAY:
  3878. return Math.floor(diff / 86400000);
  3879. case 'w':
  3880. return Math.floor(diff / 604800000);
  3881. case utilDate.MONTH:
  3882. est = (max.getFullYear() * 12 + max.getMonth()) - (min.getFullYear() * 12 + min.getMonth());
  3883. if (utilDate.add(min, unit, est) > max) {
  3884. return est - 1;
  3885. };
  3886. return est;
  3887. case utilDate.YEAR:
  3888. est = max.getFullYear() - min.getFullYear();
  3889. if (utilDate.add(min, unit, est) > max) {
  3890. return est - 1;
  3891. } else {
  3892. return est;
  3893. };
  3894. }
  3895. },
  3896. align: function(date, unit, step) {
  3897. var num = new nativeDate(+date);
  3898. switch (unit.toLowerCase()) {
  3899. case utilDate.MILLI:
  3900. return num;
  3901. case utilDate.SECOND:
  3902. num.setUTCSeconds(num.getUTCSeconds() - num.getUTCSeconds() % step);
  3903. num.setUTCMilliseconds(0);
  3904. return num;
  3905. case utilDate.MINUTE:
  3906. num.setUTCMinutes(num.getUTCMinutes() - num.getUTCMinutes() % step);
  3907. num.setUTCSeconds(0);
  3908. num.setUTCMilliseconds(0);
  3909. return num;
  3910. case utilDate.HOUR:
  3911. num.setUTCHours(num.getUTCHours() - num.getUTCHours() % step);
  3912. num.setUTCMinutes(0);
  3913. num.setUTCSeconds(0);
  3914. num.setUTCMilliseconds(0);
  3915. return num;
  3916. case utilDate.DAY:
  3917. if (step === 7 || step === 14) {
  3918. num.setUTCDate(num.getUTCDate() - num.getUTCDay() + 1);
  3919. };
  3920. num.setUTCHours(0);
  3921. num.setUTCMinutes(0);
  3922. num.setUTCSeconds(0);
  3923. num.setUTCMilliseconds(0);
  3924. return num;
  3925. case utilDate.MONTH:
  3926. num.setUTCMonth(num.getUTCMonth() - (num.getUTCMonth() - 1) % step, 1);
  3927. num.setUTCHours(0);
  3928. num.setUTCMinutes(0);
  3929. num.setUTCSeconds(0);
  3930. num.setUTCMilliseconds(0);
  3931. return num;
  3932. case utilDate.YEAR:
  3933. num.setUTCFullYear(num.getUTCFullYear() - num.getUTCFullYear() % step, 1, 1);
  3934. num.setUTCHours(0);
  3935. num.setUTCMinutes(0);
  3936. num.setUTCSeconds(0);
  3937. num.setUTCMilliseconds(0);
  3938. return date;
  3939. }
  3940. }
  3941. };
  3942. utilDate.parseCodes.C = utilDate.parseCodes.c;
  3943. return utilDate;
  3944. }());
  3945. Ext.Function = (function() {
  3946. var lastTime = 0,
  3947. animFrameId,
  3948. animFrameHandlers = [],
  3949. animFrameNoArgs = [],
  3950. idSource = 0,
  3951. animFrameMap = {},
  3952. slice = Array.prototype.slice,
  3953. win = window,
  3954. global = Ext.global,
  3955. hasImmediate = !Ext.disableImmediate && !!(global.setImmediate && global.clearImmediate),
  3956. requestAnimFrame = win.requestAnimationFrame || win.webkitRequestAnimationFrame || win.mozRequestAnimationFrame || win.oRequestAnimationFrame || function(callback) {
  3957. var currTime = Ext.now(),
  3958. timeToCall = Math.max(0, 16 - (currTime - lastTime)),
  3959. timerFn = function() {
  3960. callback(currTime + timeToCall);
  3961. },
  3962. id;
  3963. timerFn.$origFn = callback.$origFn || callback;
  3964. timerFn.$skipTimerCheck = timerFn.$origFn.$skipTimerCheck;
  3965. id = win.setTimeout(timerFn, timeToCall);
  3966. lastTime = currTime + timeToCall;
  3967. return id;
  3968. },
  3969. fireHandlers = function() {
  3970. var len = animFrameHandlers.length,
  3971. id, i, handler;
  3972. animFrameId = null;
  3973. var timer;
  3974. for (i = 0; i < len; i++) {
  3975. handler = animFrameHandlers[i];
  3976. id = handler[3];
  3977. if (animFrameMap[id]) {
  3978. delete animFrameMap[id];
  3979. timer = Ext.Timer.get(id, 'raf');
  3980. if (timer) {
  3981. timer.tick();
  3982. }
  3983. handler[0].apply(handler[1] || global, handler[2] || animFrameNoArgs);
  3984. if (timer) {
  3985. timer.tock();
  3986. }
  3987. }
  3988. }
  3989. animFrameHandlers = animFrameHandlers.slice(len);
  3990. },
  3991. fireElevatedHandlers = function() {
  3992. Ext.elevate(fireHandlers);
  3993. },
  3994. ExtFunction = {
  3995. flexSetter: function(setter) {
  3996. return function(name, value) {
  3997. var k, i;
  3998. if (name !== null) {
  3999. if (typeof name !== 'string') {
  4000. for (k in name) {
  4001. if (name.hasOwnProperty(k)) {
  4002. setter.call(this, k, name[k]);
  4003. }
  4004. }
  4005. if (Ext.enumerables) {
  4006. for (i = Ext.enumerables.length; i--; ) {
  4007. k = Ext.enumerables[i];
  4008. if (name.hasOwnProperty(k)) {
  4009. setter.call(this, k, name[k]);
  4010. }
  4011. }
  4012. }
  4013. } else {
  4014. setter.call(this, name, value);
  4015. }
  4016. }
  4017. return this;
  4018. };
  4019. },
  4020. bind: function(fn, scope, args, appendArgs) {
  4021. if (arguments.length <= 2) {
  4022. return fn.bind(scope);
  4023. }
  4024. var method = fn;
  4025. return function() {
  4026. var callArgs = args || arguments;
  4027. if (appendArgs === true) {
  4028. callArgs = slice.call(arguments, 0);
  4029. callArgs = callArgs.concat(args);
  4030. } else if (typeof appendArgs === 'number') {
  4031. callArgs = slice.call(arguments, 0);
  4032. Ext.Array.insert(callArgs, appendArgs, args);
  4033. }
  4034. return method.apply(scope || global, callArgs);
  4035. };
  4036. },
  4037. bindCallback: function(callback, scope, args, delay, caller) {
  4038. return function() {
  4039. var a = slice.call(arguments);
  4040. return Ext.callback(callback, scope, args ? args.concat(a) : a, delay, caller);
  4041. };
  4042. },
  4043. pass: function(fn, args, scope) {
  4044. if (!Ext.isArray(args)) {
  4045. if (Ext.isIterable(args)) {
  4046. args = Ext.Array.clone(args);
  4047. } else {
  4048. args = args !== undefined ? [
  4049. args
  4050. ] : [];
  4051. }
  4052. }
  4053. return function() {
  4054. var fnArgs = args.slice();
  4055. fnArgs.push.apply(fnArgs, arguments);
  4056. return fn.apply(scope || this, fnArgs);
  4057. };
  4058. },
  4059. alias: function(object, methodName) {
  4060. return function() {
  4061. return object[methodName].apply(object, arguments);
  4062. };
  4063. },
  4064. clone: function(method) {
  4065. var newMethod, prop;
  4066. newMethod = function() {
  4067. return method.apply(this, arguments);
  4068. };
  4069. for (prop in method) {
  4070. if (method.hasOwnProperty(prop)) {
  4071. newMethod[prop] = method[prop];
  4072. }
  4073. }
  4074. return newMethod;
  4075. },
  4076. createInterceptor: function(origFn, newFn, scope, returnValue) {
  4077. if (!Ext.isFunction(newFn)) {
  4078. return origFn;
  4079. } else {
  4080. returnValue = Ext.isDefined(returnValue) ? returnValue : null;
  4081. return function() {
  4082. var me = this,
  4083. args = arguments;
  4084. return (newFn.apply(scope || me || global, args) !== false) ? origFn.apply(me || global, args) : returnValue;
  4085. };
  4086. }
  4087. },
  4088. createDelayed: function(fn, delay, scope, args, appendArgs) {
  4089. var boundFn = fn;
  4090. if (scope || args) {
  4091. boundFn = Ext.Function.bind(fn, scope, args, appendArgs);
  4092. }
  4093. return function() {
  4094. var me = this,
  4095. args = slice.call(arguments),
  4096. timerFn, timerId;
  4097. var timer;
  4098. timerFn = function() {
  4099. Ext.elevate(boundFn, me, args,
  4100. timer);
  4101. };
  4102. timerId = setTimeout(timerFn, delay);
  4103. timerFn.$origFn = fn.$origFn || fn;
  4104. timerFn.$skipTimerCheck = timerFn.$origFn.$skipTimerCheck;
  4105. timer = Ext.Timer.created('timeout', timerId, {
  4106. type: 'createDelayed',
  4107. fn: fn,
  4108. timerFn: timerFn
  4109. });
  4110. };
  4111. },
  4112. defer: function(fn, millis, scope, args, appendArgs) {
  4113. var timerId = 0,
  4114. timerFn, boundFn;
  4115. var timer;
  4116. if (!scope && !args && !appendArgs) {
  4117. boundFn = fn;
  4118. } else {
  4119. boundFn = Ext.Function.bind(fn, scope, args, appendArgs);
  4120. }
  4121. if (millis > 0) {
  4122. timerFn = function() {
  4123. Ext.elevate(boundFn,
  4124. null, null, timer);
  4125. };
  4126. timerId = setTimeout(timerFn, millis);
  4127. timerFn.$origFn = fn.$origFn || fn;
  4128. timerFn.$skipTimerCheck = timerFn.$origFn.$skipTimerCheck;
  4129. timer = Ext.Timer.created('timeout', timerId, {
  4130. type: 'defer',
  4131. fn: fn,
  4132. timerFn: timerFn
  4133. });
  4134. } else
  4135. {
  4136. boundFn();
  4137. }
  4138. return timerId;
  4139. },
  4140. interval: function(fn, millis, scope, args, appendArgs) {
  4141. var timerFn, timerId, boundFn;
  4142. var timer;
  4143. boundFn = Ext.Function.bind(fn, scope, args, appendArgs);
  4144. timerFn = function() {
  4145. Ext.elevate(boundFn,
  4146. null, null, timer);
  4147. };
  4148. timerId = setInterval(timerFn, millis);
  4149. timerFn.$origFn = boundFn.$origFn || fn;
  4150. timerFn.$skipTimerCheck = timerFn.$origFn.$skipTimerCheck;
  4151. timer = Ext.Timer.created('interval', timerId, {
  4152. type: 'interval',
  4153. fn: fn,
  4154. timerFn: timerFn
  4155. });
  4156. return timerId;
  4157. },
  4158. createSequence: function(originalFn, newFn, scope) {
  4159. if (!newFn) {
  4160. return originalFn;
  4161. } else {
  4162. return function() {
  4163. var result = originalFn.apply(this, arguments);
  4164. newFn.apply(scope || this, arguments);
  4165. return result;
  4166. };
  4167. }
  4168. },
  4169. createBuffered: function(fn, buffer, scope, args) {
  4170. var timerId,
  4171. result = function() {
  4172. var callArgs = args || slice.call(arguments, 0),
  4173. me = scope || this,
  4174. timerFn;
  4175. var timer;
  4176. if (timerId) {
  4177. Ext.undefer(timerId);
  4178. }
  4179. timerFn = function() {
  4180. Ext.elevate(fn, me, callArgs,
  4181. timer);
  4182. };
  4183. result.timer = timerId = setTimeout(timerFn, buffer);
  4184. timerFn.$origFn = fn.$origFn || fn;
  4185. timerFn.$skipTimerCheck = timerFn.$origFn.$skipTimerCheck;
  4186. timer = Ext.Timer.created('timeout', timerId, {
  4187. type: 'createBuffered',
  4188. fn: fn,
  4189. timerFn: timerFn
  4190. });
  4191. };
  4192. return result;
  4193. },
  4194. createAnimationFrame: function(fn, scope, args, queueStrategy) {
  4195. var boundFn, timerId;
  4196. queueStrategy = queueStrategy || 3;
  4197. boundFn = function() {
  4198. var timerFn,
  4199. callArgs = args || slice.call(arguments, 0);
  4200. scope = scope || this;
  4201. if (queueStrategy === 3 && timerId) {
  4202. ExtFunction.cancelAnimationFrame(timerId);
  4203. }
  4204. if ((queueStrategy & 1) || !timerId) {
  4205. timerFn = function() {
  4206. timerId = boundFn.timerId = null;
  4207. fn.apply(scope, callArgs);
  4208. };
  4209. timerFn.$origFn = fn.$origFn || fn;
  4210. timerFn.$skipTimerCheck = timerFn.$origFn.$skipTimerCheck;
  4211. timerId = boundFn.timerId = ExtFunction.requestAnimationFrame(timerFn);
  4212. }
  4213. };
  4214. return boundFn;
  4215. },
  4216. requestAnimationFrame: function(fn, scope, args) {
  4217. var id = ++idSource,
  4218. handler = slice.call(arguments, 0);
  4219. handler[3] = id;
  4220. animFrameMap[id] = 1;
  4221. Ext.Timer.created('raf', id, {
  4222. type: 'raf',
  4223. fn: fn
  4224. });
  4225. animFrameHandlers.push(handler);
  4226. if (!animFrameId) {
  4227. animFrameId = requestAnimFrame(fireElevatedHandlers);
  4228. }
  4229. return id;
  4230. },
  4231. cancelAnimationFrame: function(id) {
  4232. delete animFrameMap[id];
  4233. Ext.Timer.cancel('raf', id);
  4234. },
  4235. createThrottled: function(fn, interval, scope) {
  4236. var lastCallTime = 0,
  4237. elapsed, lastArgs, timerId,
  4238. execute = function() {
  4239. fn.apply(scope, lastArgs);
  4240. lastCallTime = Ext.now();
  4241. lastArgs = timerId = null;
  4242. };
  4243. execute.$origFn = fn.$origFn || fn;
  4244. execute.$skipTimerCheck = execute.$origFn.$skipTimerCheck;
  4245. return function() {
  4246. if (!scope) {
  4247. scope = this;
  4248. }
  4249. elapsed = Ext.now() - lastCallTime;
  4250. lastArgs = Ext.Array.slice(arguments);
  4251. if (elapsed >= interval) {
  4252. Ext.undefer(timerId);
  4253. execute();
  4254. }
  4255. else if (!timerId) {
  4256. timerId = Ext.defer(execute, interval - elapsed);
  4257. }
  4258. };
  4259. },
  4260. createBarrier: function(count, fn, scope) {
  4261. var barrierFn = function() {
  4262. if (!--count) {
  4263. fn.apply(scope, arguments);
  4264. }
  4265. };
  4266. barrierFn.$origFn = fn.$origFn || fn;
  4267. barrierFn.$skipTimerCheck = barrierFn.$origFn.$skipTimerCheck;
  4268. return barrierFn;
  4269. },
  4270. interceptBefore: function(object, methodName, fn, scope) {
  4271. var method = object[methodName] || Ext.emptyFn;
  4272. return (object[methodName] = function() {
  4273. var ret = fn.apply(scope || this, arguments);
  4274. method.apply(this, arguments);
  4275. return ret;
  4276. });
  4277. },
  4278. interceptAfter: function(object, methodName, fn, scope) {
  4279. var method = object[methodName] || Ext.emptyFn;
  4280. return (object[methodName] = function() {
  4281. method.apply(this, arguments);
  4282. return fn.apply(scope || this, arguments);
  4283. });
  4284. },
  4285. interceptAfterOnce: function(object, methodName, fn, scope) {
  4286. var origMethod = object[methodName],
  4287. newMethod;
  4288. newMethod = function() {
  4289. var ret;
  4290. if (origMethod) {
  4291. origMethod.apply(this, arguments);
  4292. }
  4293. ret = fn.apply(scope || this, arguments);
  4294. object[methodName] = origMethod;
  4295. object = methodName = fn = scope = origMethod = newMethod = null;
  4296. return ret;
  4297. };
  4298. object[methodName] = newMethod;
  4299. return newMethod;
  4300. },
  4301. makeCallback: function(callback, scope) {
  4302. if (!scope[callback]) {
  4303. if (scope.$className) {
  4304. Ext.raise('No method "' + callback + '" on ' + scope.$className);
  4305. }
  4306. Ext.raise('No method "' + callback + '"');
  4307. }
  4308. return function() {
  4309. return scope[callback].apply(scope, arguments);
  4310. };
  4311. },
  4312. memoize: function(fn, scope, hashFn) {
  4313. var memo = {},
  4314. isFunc = hashFn && Ext.isFunction(hashFn);
  4315. return function(value) {
  4316. var key = isFunc ? hashFn.apply(scope, arguments) : value;
  4317. if (!(key in memo)) {
  4318. memo[key] = fn.apply(scope, arguments);
  4319. }
  4320. return memo[key];
  4321. };
  4322. },
  4323. _stripCommentRe: /(\/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+\/)|(\/\/.*)/g,
  4324. toCode: function(fn) {
  4325. var s = fn ? fn.toString() : '';
  4326. s = s.replace(ExtFunction._stripCommentRe, '');
  4327. return s;
  4328. },
  4329. fireElevatedHandlers: function() {
  4330. fireElevatedHandlers();
  4331. }
  4332. };
  4333. Ext.asap = hasImmediate ? function(fn, scope, parameters) {
  4334. var boundFn = fn,
  4335. timerFn, timerId;
  4336. var timer;
  4337. if (scope != null || parameters != null) {
  4338. boundFn = ExtFunction.bind(fn, scope, parameters);
  4339. }
  4340. timerFn = function() {
  4341. Ext.elevate(boundFn,
  4342. null, null, timer);
  4343. };
  4344. timerId = setImmediate(timerFn);
  4345. timerFn.$origFn = fn.$origFn || fn;
  4346. timerFn.$skipTimerCheck = timerFn.$origFn.$skipTimerCheck;
  4347. timer = Ext.Timer.created('asap', timerId, {
  4348. type: 'asap',
  4349. fn: fn,
  4350. timerFn: timerFn
  4351. });
  4352. return timerId;
  4353. } : function(fn, scope, parameters) {
  4354. var boundFn = fn,
  4355. timerFn, timerId;
  4356. var timer;
  4357. if (scope != null || parameters != null) {
  4358. boundFn = ExtFunction.bind(fn, scope, parameters);
  4359. }
  4360. timerFn = function() {
  4361. Ext.elevate(boundFn,
  4362. null, null, timer);
  4363. };
  4364. timerId = setTimeout(timerFn, 0, true);
  4365. timerFn.$origFn = fn.$origFn || fn;
  4366. timerFn.$skipTimerCheck = timerFn.$origFn.$skipTimerCheck;
  4367. timer = Ext.Timer.created('timeout', timerId, {
  4368. type: 'asap',
  4369. fn: fn,
  4370. timerFn: timerFn
  4371. });
  4372. return timerId;
  4373. };
  4374. Ext.unasap = hasImmediate ? function(id) {
  4375. if (id) {
  4376. clearImmediate(id);
  4377. Ext.Timer.cancel('asap', id);
  4378. }
  4379. return null;
  4380. } : function(id) {
  4381. return Ext.undefer(id);
  4382. };
  4383. Ext.asapCancel = function(id) {
  4384. return Ext.unasap(id);
  4385. };
  4386. Ext.defer = ExtFunction.defer;
  4387. Ext.undefer = function(id) {
  4388. if (id) {
  4389. clearTimeout(id);
  4390. Ext.Timer.cancel('timeout', id);
  4391. }
  4392. return null;
  4393. };
  4394. Ext.interval = ExtFunction.interval;
  4395. Ext.uninterval = function(id) {
  4396. if (id) {
  4397. clearInterval(id);
  4398. Ext.Timer.cancel('interval', id);
  4399. }
  4400. return null;
  4401. };
  4402. Ext.pass = ExtFunction.pass;
  4403. Ext.bind = ExtFunction.bind;
  4404. Ext.raf = function() {
  4405. return ExtFunction.requestAnimationFrame.apply(ExtFunction, arguments);
  4406. };
  4407. Ext.unraf = function(id) {
  4408. ExtFunction.cancelAnimationFrame(id);
  4409. };
  4410. return ExtFunction;
  4411. })();
  4412. Ext.Number = (new function() {
  4413. var ExtNumber = this,
  4414. isToFixedBroken = (0.9).toFixed() !== '1',
  4415. math = Math,
  4416. ClipDefault = {
  4417. count: false,
  4418. inclusive: false,
  4419. wrap: true
  4420. };
  4421. Number.MIN_SAFE_INTEGER = Number.MIN_SAFE_INTEGER || -(math.pow(2, 53) - 1);
  4422. Number.MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || math.pow(2, 53) - 1;
  4423. Ext.apply(ExtNumber, {
  4424. MIN_SAFE_INTEGER: Number.MIN_SAFE_INTEGER,
  4425. MAX_SAFE_INTEGER: Number.MAX_SAFE_INTEGER,
  4426. floatRe: /^[-+]?(?:\d+|\d*\.\d*)(?:[Ee][+-]?\d+)?$/,
  4427. intRe: /^[-+]?\d+(?:[Ee]\+?\d+)?$/,
  4428. Clip: {
  4429. DEFAULT: ClipDefault,
  4430. COUNT: Ext.applyIf({
  4431. count: true
  4432. }, ClipDefault),
  4433. INCLUSIVE: Ext.applyIf({
  4434. inclusive: true
  4435. }, ClipDefault),
  4436. NOWRAP: Ext.applyIf({
  4437. wrap: false
  4438. }, ClipDefault)
  4439. },
  4440. parseFloat: function(value) {
  4441. if (value === undefined) {
  4442. value = null;
  4443. }
  4444. if (value !== null && typeof value !== 'number') {
  4445. value = String(value);
  4446. value = ExtNumber.floatRe.test(value) ? +value : null;
  4447. if (isNaN(value)) {
  4448. value = null;
  4449. }
  4450. }
  4451. return value;
  4452. },
  4453. parseInt: function(value) {
  4454. if (value === undefined) {
  4455. value = null;
  4456. }
  4457. if (typeof value === 'number') {
  4458. value = Math.floor(value);
  4459. } else if (value !== null) {
  4460. value = String(value);
  4461. value = ExtNumber.intRe.test(value) ? +value : null;
  4462. }
  4463. return value;
  4464. },
  4465. binarySearch: function(array, value, begin, end) {
  4466. if (begin === undefined) {
  4467. begin = 0;
  4468. }
  4469. if (end === undefined) {
  4470. end = array.length;
  4471. }
  4472. --end;
  4473. var middle, midVal;
  4474. while (begin <= end) {
  4475. middle = (begin + end) >>> 1;
  4476. midVal = array[middle];
  4477. if (value === midVal) {
  4478. return middle;
  4479. }
  4480. if (midVal < value) {
  4481. begin = middle + 1;
  4482. } else {
  4483. end = middle - 1;
  4484. }
  4485. }
  4486. return begin;
  4487. },
  4488. bisectTuples: function(array, value, index, begin, end) {
  4489. if (begin === undefined) {
  4490. begin = 0;
  4491. }
  4492. if (end === undefined) {
  4493. end = array.length;
  4494. }
  4495. --end;
  4496. var middle, midVal;
  4497. while (begin <= end) {
  4498. middle = (begin + end) >>> 1;
  4499. midVal = array[middle][index];
  4500. if (value === midVal) {
  4501. return middle;
  4502. }
  4503. if (midVal < value) {
  4504. begin = middle + 1;
  4505. } else {
  4506. end = middle - 1;
  4507. }
  4508. }
  4509. return begin;
  4510. },
  4511. clipIndices: function(length, indices, options) {
  4512. options = options || ClipDefault;
  4513. var defaultValue = 0,
  4514. wrap = options.wrap,
  4515. begin, end, i;
  4516. indices = indices || [];
  4517. for (i = 0; i < 2; ++i) {
  4518. begin = end;
  4519. end = indices[i];
  4520. if (end == null) {
  4521. end = defaultValue;
  4522. } else if (i && options.count) {
  4523. end += begin;
  4524. end = (end > length) ? length : end;
  4525. } else {
  4526. if (wrap) {
  4527. end = (end < 0) ? (length + end) : end;
  4528. }
  4529. if (i && options.inclusive) {
  4530. ++end;
  4531. }
  4532. end = (end < 0) ? 0 : ((end > length) ? length : end);
  4533. }
  4534. defaultValue = length;
  4535. }
  4536. indices[0] = begin;
  4537. indices[1] = (end < begin) ? begin : end;
  4538. return indices;
  4539. },
  4540. constrain: function(number, min, max) {
  4541. var x = parseFloat(number);
  4542. if (min === null) {
  4543. min = number;
  4544. }
  4545. if (max === null) {
  4546. max = number;
  4547. }
  4548. return (x < min) ? min : ((x > max) ? max : x);
  4549. },
  4550. snap: function(value, increment, minValue, maxValue) {
  4551. var m;
  4552. if (value === undefined || value < minValue) {
  4553. return minValue || 0;
  4554. }
  4555. if (increment) {
  4556. m = value % increment;
  4557. if (m !== 0) {
  4558. value -= m;
  4559. if (m * 2 >= increment) {
  4560. value += increment;
  4561. } else if (m * 2 < -increment) {
  4562. value -= increment;
  4563. }
  4564. }
  4565. }
  4566. return ExtNumber.constrain(value, minValue, maxValue);
  4567. },
  4568. snapInRange: function(value, increment, minValue, maxValue) {
  4569. var tween;
  4570. minValue = (minValue || 0);
  4571. if (value === undefined || value < minValue) {
  4572. return minValue;
  4573. }
  4574. if (increment && (tween = ((value - minValue) % increment))) {
  4575. value -= tween;
  4576. tween *= 2;
  4577. if (tween >= increment) {
  4578. value += increment;
  4579. }
  4580. }
  4581. if (maxValue !== undefined) {
  4582. if (value > (maxValue = ExtNumber.snapInRange(maxValue, increment, minValue))) {
  4583. value = maxValue;
  4584. }
  4585. }
  4586. return value;
  4587. },
  4588. roundToNearest: function(value, interval) {
  4589. interval = interval || 1;
  4590. return interval * math.round(value / interval);
  4591. },
  4592. roundToPrecision: function(value, precision) {
  4593. var factor = math.pow(10, precision || 1);
  4594. return math.round(value * factor) / factor;
  4595. },
  4596. truncateToPrecision: function(value, precision) {
  4597. var factor = math.pow(10, precision || 1);
  4598. return parseInt(value * factor, 10) / factor;
  4599. },
  4600. sign: math.sign || function(x) {
  4601. x = +x;
  4602. if (x === 0 || isNaN(x)) {
  4603. return x;
  4604. }
  4605. return (x > 0) ? 1 : -1;
  4606. },
  4607. log10: math.log10 || function(x) {
  4608. return math.log(x) * math.LOG10E;
  4609. },
  4610. isEqual: function(n1, n2, epsilon) {
  4611. if (!(typeof n1 === 'number' && typeof n2 === 'number' && typeof epsilon === 'number')) {
  4612. Ext.raise("All parameters should be valid numbers.");
  4613. }
  4614. return math.abs(n1 - n2) < epsilon;
  4615. },
  4616. isFinite: Number.isFinite || function(value) {
  4617. return typeof value === 'number' && isFinite(value);
  4618. },
  4619. isInteger: Number.isInteger || function(value) {
  4620. return ~~(value + 0) === value;
  4621. },
  4622. toFixed: isToFixedBroken ? function(value, precision) {
  4623. precision = precision || 0;
  4624. var pow = math.pow(10, precision);
  4625. return (math.round(value * pow) / pow).toFixed(precision);
  4626. } : function(value, precision) {
  4627. return value.toFixed(precision);
  4628. },
  4629. from: function(value, defaultValue) {
  4630. if (isFinite(value)) {
  4631. value = parseFloat(value);
  4632. }
  4633. return !isNaN(value) ? value : defaultValue;
  4634. },
  4635. randomInt: function(from, to) {
  4636. return math.floor(math.random() * (to - from + 1) + from);
  4637. },
  4638. correctFloat: function(n) {
  4639. return parseFloat(n.toPrecision(14));
  4640. }
  4641. });
  4642. Ext.num = function() {
  4643. return ExtNumber.from.apply(this, arguments);
  4644. };
  4645. }());
  4646. (function() {
  4647. var TemplateClass = function() {},
  4648. queryRe = /^\?/,
  4649. keyRe = /(\[):?([^\]]*)\]/g,
  4650. nameRe = /^([^\[]+)/,
  4651. plusRe = /\+/g,
  4652. ExtObject = Ext.Object = {
  4653. chain: Object.create || function(object) {
  4654. TemplateClass.prototype = object;
  4655. var result = new TemplateClass();
  4656. TemplateClass.prototype = null;
  4657. return result;
  4658. },
  4659. clear: function(object) {
  4660. for (var key in object) {
  4661. delete object[key];
  4662. }
  4663. return object;
  4664. },
  4665. freeze: Object.freeze ? function(obj, deep) {
  4666. if (obj && typeof obj === 'object' && !Object.isFrozen(obj)) {
  4667. Object.freeze(obj);
  4668. if (deep) {
  4669. for (var name in obj) {
  4670. ExtObject.freeze(obj[name], deep);
  4671. }
  4672. }
  4673. }
  4674. return obj;
  4675. } : Ext.identityFn,
  4676. toQueryObjects: function(name, value, recursive) {
  4677. var self = ExtObject.toQueryObjects,
  4678. objects = [],
  4679. i, ln;
  4680. if (Ext.isArray(value)) {
  4681. for (i = 0 , ln = value.length; i < ln; i++) {
  4682. if (recursive) {
  4683. objects = objects.concat(self(name + '[' + i + ']', value[i], true));
  4684. } else {
  4685. objects.push({
  4686. name: name,
  4687. value: value[i]
  4688. });
  4689. }
  4690. }
  4691. } else if (Ext.isObject(value)) {
  4692. for (i in value) {
  4693. if (value.hasOwnProperty(i)) {
  4694. if (recursive) {
  4695. objects = objects.concat(self(name + '[' + i + ']', value[i], true));
  4696. } else {
  4697. objects.push({
  4698. name: name,
  4699. value: value[i]
  4700. });
  4701. }
  4702. }
  4703. }
  4704. } else {
  4705. objects.push({
  4706. name: name,
  4707. value: value
  4708. });
  4709. }
  4710. return objects;
  4711. },
  4712. toQueryString: function(object, recursive) {
  4713. var paramObjects = [],
  4714. params = [],
  4715. i, j, ln, paramObject, value;
  4716. for (i in object) {
  4717. if (object.hasOwnProperty(i)) {
  4718. paramObjects = paramObjects.concat(ExtObject.toQueryObjects(i, object[i], recursive));
  4719. }
  4720. }
  4721. for (j = 0 , ln = paramObjects.length; j < ln; j++) {
  4722. paramObject = paramObjects[j];
  4723. value = paramObject.value;
  4724. if (Ext.isEmpty(value)) {
  4725. value = '';
  4726. } else if (Ext.isDate(value)) {
  4727. value = Ext.Date.toString(value);
  4728. }
  4729. params.push(encodeURIComponent(paramObject.name) + '=' + encodeURIComponent(String(value)));
  4730. }
  4731. return params.join('&');
  4732. },
  4733. fromQueryString: function(queryString, recursive) {
  4734. var parts = queryString.replace(queryRe, '').split('&'),
  4735. object = {},
  4736. temp, components, name, value, i, ln, part, j, subLn, matchedKeys, matchedName, keys, key, nextKey;
  4737. for (i = 0 , ln = parts.length; i < ln; i++) {
  4738. part = parts[i];
  4739. if (part.length > 0) {
  4740. components = part.split('=');
  4741. name = components[0];
  4742. name = name.replace(plusRe, '%20');
  4743. name = decodeURIComponent(name);
  4744. value = components[1];
  4745. if (value !== undefined) {
  4746. value = value.replace(plusRe, '%20');
  4747. value = decodeURIComponent(value);
  4748. } else {
  4749. value = '';
  4750. }
  4751. if (!recursive) {
  4752. if (object.hasOwnProperty(name)) {
  4753. if (!Ext.isArray(object[name])) {
  4754. object[name] = [
  4755. object[name]
  4756. ];
  4757. }
  4758. object[name].push(value);
  4759. } else {
  4760. object[name] = value;
  4761. }
  4762. } else {
  4763. matchedKeys = name.match(keyRe);
  4764. matchedName = name.match(nameRe);
  4765. if (!matchedName) {
  4766. throw new Error('[Ext.Object.fromQueryString] Malformed query string given, failed parsing name from "' + part + '"');
  4767. }
  4768. name = matchedName[0];
  4769. keys = [];
  4770. if (matchedKeys === null) {
  4771. object[name] = value;
  4772. continue;
  4773. }
  4774. for (j = 0 , subLn = matchedKeys.length; j < subLn; j++) {
  4775. key = matchedKeys[j];
  4776. key = (key.length === 2) ? '' : key.substring(1, key.length - 1);
  4777. keys.push(key);
  4778. }
  4779. keys.unshift(name);
  4780. temp = object;
  4781. for (j = 0 , subLn = keys.length; j < subLn; j++) {
  4782. key = keys[j];
  4783. if (j === subLn - 1) {
  4784. if (Ext.isArray(temp) && key === '') {
  4785. temp.push(value);
  4786. } else {
  4787. temp[key] = value;
  4788. }
  4789. } else {
  4790. if (temp[key] === undefined || typeof temp[key] === 'string') {
  4791. nextKey = keys[j + 1];
  4792. temp[key] = (Ext.isNumeric(nextKey) || nextKey === '') ? [] : {};
  4793. }
  4794. temp = temp[key];
  4795. }
  4796. }
  4797. }
  4798. }
  4799. }
  4800. return object;
  4801. },
  4802. each: function(object, fn, scope) {
  4803. var enumerables = Ext.enumerables,
  4804. i, property;
  4805. if (object) {
  4806. scope = scope || object;
  4807. for (property in object) {
  4808. if (object.hasOwnProperty(property)) {
  4809. if (fn.call(scope, property, object[property], object) === false) {
  4810. return;
  4811. }
  4812. }
  4813. }
  4814. if (enumerables) {
  4815. for (i = enumerables.length; i--; ) {
  4816. if (object.hasOwnProperty(property = enumerables[i])) {
  4817. if (fn.call(scope, property, object[property], object) === false) {
  4818. return;
  4819. }
  4820. }
  4821. }
  4822. }
  4823. }
  4824. },
  4825. eachValue: function(object, fn, scope) {
  4826. var enumerables = Ext.enumerables,
  4827. i, property;
  4828. scope = scope || object;
  4829. for (property in object) {
  4830. if (object.hasOwnProperty(property)) {
  4831. if (fn.call(scope, object[property]) === false) {
  4832. return;
  4833. }
  4834. }
  4835. }
  4836. if (enumerables) {
  4837. for (i = enumerables.length; i--; ) {
  4838. if (object.hasOwnProperty(property = enumerables[i])) {
  4839. if (fn.call(scope, object[property]) === false) {
  4840. return;
  4841. }
  4842. }
  4843. }
  4844. }
  4845. },
  4846. merge: function(destination) {
  4847. var i = 1,
  4848. args = arguments,
  4849. ln = args.length,
  4850. mergeFn = ExtObject.merge,
  4851. cloneFn = Ext.clone,
  4852. object, key, value, sourceKey;
  4853. for (; i < ln; i++) {
  4854. object = args[i];
  4855. for (key in object) {
  4856. value = object[key];
  4857. if (value && value.constructor === Object) {
  4858. sourceKey = destination[key];
  4859. if (sourceKey && sourceKey.constructor === Object) {
  4860. mergeFn(sourceKey, value);
  4861. } else {
  4862. destination[key] = cloneFn(value);
  4863. }
  4864. } else {
  4865. destination[key] = value;
  4866. }
  4867. }
  4868. }
  4869. return destination;
  4870. },
  4871. mergeIf: function(destination) {
  4872. var i = 1,
  4873. ln = arguments.length,
  4874. cloneFn = Ext.clone,
  4875. object, key, value;
  4876. for (; i < ln; i++) {
  4877. object = arguments[i];
  4878. for (key in object) {
  4879. if (!(key in destination)) {
  4880. value = object[key];
  4881. if (value && value.constructor === Object) {
  4882. destination[key] = cloneFn(value);
  4883. } else {
  4884. destination[key] = value;
  4885. }
  4886. }
  4887. }
  4888. }
  4889. return destination;
  4890. },
  4891. getAllKeys: function(object) {
  4892. var keys = [],
  4893. property;
  4894. for (property in object) {
  4895. keys.push(property);
  4896. }
  4897. return keys;
  4898. },
  4899. getKey: function(object, value) {
  4900. for (var property in object) {
  4901. if (object.hasOwnProperty(property) && object[property] === value) {
  4902. return property;
  4903. }
  4904. }
  4905. return null;
  4906. },
  4907. getValues: function(object) {
  4908. var values = [],
  4909. property;
  4910. for (property in object) {
  4911. if (object.hasOwnProperty(property)) {
  4912. values.push(object[property]);
  4913. }
  4914. }
  4915. return values;
  4916. },
  4917. getKeys: (typeof Object.keys == 'function') ? function(object) {
  4918. if (!object) {
  4919. return [];
  4920. }
  4921. return Object.keys(object);
  4922. } : function(object) {
  4923. var keys = [],
  4924. property;
  4925. for (property in object) {
  4926. if (object.hasOwnProperty(property)) {
  4927. keys.push(property);
  4928. }
  4929. }
  4930. return keys;
  4931. },
  4932. getSize: function(object) {
  4933. var size = 0,
  4934. property;
  4935. for (property in object) {
  4936. if (object.hasOwnProperty(property)) {
  4937. size++;
  4938. }
  4939. }
  4940. return size;
  4941. },
  4942. isEmpty: function(object) {
  4943. for (var key in object) {
  4944. if (object.hasOwnProperty(key)) {
  4945. return false;
  4946. }
  4947. }
  4948. return true;
  4949. },
  4950. equals: (function() {
  4951. var check = function(o1, o2) {
  4952. var key;
  4953. for (key in o1) {
  4954. if (o1.hasOwnProperty(key)) {
  4955. if (o1[key] !== o2[key]) {
  4956. return false;
  4957. }
  4958. }
  4959. }
  4960. return true;
  4961. };
  4962. return function(object1, object2) {
  4963. if (object1 === object2) {
  4964. return true;
  4965. }
  4966. if (object1 && object2) {
  4967. return check(object1, object2) && check(object2, object1);
  4968. } else if (!object1 && !object2) {
  4969. return object1 === object2;
  4970. } else {
  4971. return false;
  4972. }
  4973. };
  4974. })(),
  4975. fork: function(obj) {
  4976. var ret, key, value;
  4977. if (obj && obj.constructor === Object) {
  4978. ret = ExtObject.chain(obj);
  4979. for (key in obj) {
  4980. value = obj[key];
  4981. if (value) {
  4982. if (value.constructor === Object) {
  4983. ret[key] = ExtObject.fork(value);
  4984. } else if (value instanceof Array) {
  4985. ret[key] = Ext.Array.clone(value);
  4986. }
  4987. }
  4988. }
  4989. } else {
  4990. ret = obj;
  4991. }
  4992. return ret;
  4993. },
  4994. defineProperty: ('defineProperty' in Object) ? Object.defineProperty : function(object, name, descriptor) {
  4995. if (!Object.prototype.__defineGetter__) {
  4996. return;
  4997. }
  4998. if (descriptor.get) {
  4999. object.__defineGetter__(name, descriptor.get);
  5000. }
  5001. if (descriptor.set) {
  5002. object.__defineSetter__(name, descriptor.set);
  5003. }
  5004. },
  5005. classify: function(object) {
  5006. var prototype = object,
  5007. objectProperties = [],
  5008. propertyClassesMap = {},
  5009. objectClass = function() {
  5010. var i = 0,
  5011. ln = objectProperties.length,
  5012. property;
  5013. for (; i < ln; i++) {
  5014. property = objectProperties[i];
  5015. this[property] = new propertyClassesMap[property]();
  5016. }
  5017. },
  5018. key, value;
  5019. for (key in object) {
  5020. if (object.hasOwnProperty(key)) {
  5021. value = object[key];
  5022. if (value && value.constructor === Object) {
  5023. objectProperties.push(key);
  5024. propertyClassesMap[key] = ExtObject.classify(value);
  5025. }
  5026. }
  5027. }
  5028. objectClass.prototype = prototype;
  5029. return objectClass;
  5030. }
  5031. };
  5032. Ext.merge = Ext.Object.merge;
  5033. Ext.mergeIf = Ext.Object.mergeIf;
  5034. }());
  5035. Ext.apply(Ext, {
  5036. _namedScopes: {
  5037. 'this': {
  5038. isThis: 1
  5039. },
  5040. controller: {
  5041. isController: 1
  5042. },
  5043. owner: {
  5044. isOwner: 1
  5045. },
  5046. self: {
  5047. isSelf: 1
  5048. },
  5049. 'self.controller': {
  5050. isSelf: 1,
  5051. isController: 1
  5052. }
  5053. },
  5054. escapeId: (function() {
  5055. var validIdRe = /^[a-zA-Z_][a-zA-Z0-9_\-]*$/i,
  5056. escapeRx = /([\W]{1})/g,
  5057. leadingNumRx = /^(\d)/g,
  5058. escapeFn = function(match, capture) {
  5059. return "\\" + capture;
  5060. },
  5061. numEscapeFn = function(match, capture) {
  5062. return '\\00' + capture.charCodeAt(0).toString(16) + ' ';
  5063. };
  5064. return function(id) {
  5065. return validIdRe.test(id) ? id :
  5066. id.replace(escapeRx, escapeFn).replace(leadingNumRx, numEscapeFn);
  5067. };
  5068. }()),
  5069. callback: function(callback, scope, args, delay, caller, defaultScope) {
  5070. if (!callback) {
  5071. return;
  5072. }
  5073. var namedScope = (scope in Ext._namedScopes);
  5074. if (callback.charAt) {
  5075. if (callback[2] === '.') {
  5076. if (callback.substr(0, 2) !== 'up') {
  5077. Ext.raise('Invalid callback method name "' + callback + '"');
  5078. }
  5079. if (scope) {
  5080. Ext.raise('Callback "up" syntax is incompatible with scopes');
  5081. }
  5082. if (!caller || !Ext.isFunction(caller.up)) {
  5083. Ext.raise('Callback "up" syntax requires a caller with "up" method');
  5084. }
  5085. callback = callback.substr(3);
  5086. for (scope = caller.up(); scope && !scope[callback]; scope = scope.up()) {}
  5087. if (!scope || !Ext.isFunction(scope[callback])) {
  5088. Ext.raise('No such method "' + callback + '" found up() from ' + scope.getId ? scope.getId() : scope.id);
  5089. }
  5090. }
  5091. else if ((!scope || namedScope) && caller) {
  5092. scope = caller.resolveListenerScope(namedScope ? scope : defaultScope);
  5093. }
  5094. if (!scope || !Ext.isObject(scope)) {
  5095. Ext.raise('Named method "' + callback + '" requires a scope object');
  5096. }
  5097. if (!Ext.isFunction(scope[callback])) {
  5098. Ext.raise('No method named "' + callback + '" on ' + (scope.$className || 'scope object'));
  5099. }
  5100. callback = scope[callback];
  5101. } else if (namedScope) {
  5102. scope = defaultScope || caller;
  5103. } else if (!scope) {
  5104. scope = caller;
  5105. }
  5106. var ret;
  5107. if (callback && Ext.isFunction(callback)) {
  5108. scope = scope || Ext.global;
  5109. if (delay) {
  5110. Ext.defer(callback, delay, scope, args);
  5111. } else {
  5112. ret = args ? callback.apply(scope, args) : callback.call(scope);
  5113. }
  5114. }
  5115. return ret;
  5116. },
  5117. coerce: function(from, to) {
  5118. var fromType = Ext.typeOf(from),
  5119. toType = Ext.typeOf(to),
  5120. isString = typeof from === 'string';
  5121. if (fromType !== toType) {
  5122. switch (toType) {
  5123. case 'string':
  5124. return String(from);
  5125. case 'number':
  5126. return Number(from);
  5127. case 'boolean':
  5128. return isString && (!from || from === 'false' || from === '0') ? false : Boolean(from);
  5129. case 'null':
  5130. return isString && (!from || from === 'null') ? null : false;
  5131. case 'undefined':
  5132. return isString && (!from || from === 'undefined') ? undefined : false;
  5133. case 'date':
  5134. return isString && isNaN(from) ? Ext.Date.parse(from, Ext.Date.defaultFormat) : Date(Number(from));
  5135. }
  5136. }
  5137. return from;
  5138. },
  5139. copyTo: function(dest, source, names, usePrototypeKeys) {
  5140. if (typeof names === 'string') {
  5141. names = names.split(Ext.propertyNameSplitRe);
  5142. }
  5143. for (var name,
  5144. i = 0,
  5145. n = names ? names.length : 0; i < n; i++) {
  5146. name = names[i];
  5147. if (usePrototypeKeys || source.hasOwnProperty(name)) {
  5148. dest[name] = source[name];
  5149. }
  5150. }
  5151. return dest;
  5152. },
  5153. copy: function(dest, source, names, usePrototypeKeys) {
  5154. if (typeof names === 'string') {
  5155. names = names.split(Ext.propertyNameSplitRe);
  5156. }
  5157. for (var name,
  5158. i = 0,
  5159. n = names ? names.length : 0; i < n; i++) {
  5160. name = names[i];
  5161. if (source.hasOwnProperty(name) || (usePrototypeKeys && name in source)) {
  5162. dest[name] = source[name];
  5163. }
  5164. }
  5165. return dest;
  5166. },
  5167. propertyNameSplitRe: /[,;\s]+/,
  5168. copyToIf: function(destination, source, names) {
  5169. if (typeof names === 'string') {
  5170. names = names.split(Ext.propertyNameSplitRe);
  5171. }
  5172. for (var name,
  5173. i = 0,
  5174. n = names ? names.length : 0; i < n; i++) {
  5175. name = names[i];
  5176. if (destination[name] === undefined) {
  5177. destination[name] = source[name];
  5178. }
  5179. }
  5180. return destination;
  5181. },
  5182. copyIf: function(destination, source, names) {
  5183. if (typeof names === 'string') {
  5184. names = names.split(Ext.propertyNameSplitRe);
  5185. }
  5186. for (var name,
  5187. i = 0,
  5188. n = names ? names.length : 0; i < n; i++) {
  5189. name = names[i];
  5190. if (!(name in destination) && (name in source)) {
  5191. destination[name] = source[name];
  5192. }
  5193. }
  5194. return destination;
  5195. },
  5196. extend: (function() {
  5197. var objectConstructor = Object.prototype.constructor,
  5198. inlineOverrides = function(o) {
  5199. var m;
  5200. for (m in o) {
  5201. if (!o.hasOwnProperty(m)) {
  5202. continue;
  5203. }
  5204. this[m] = o[m];
  5205. }
  5206. };
  5207. return function(subclass, superclass, overrides) {
  5208. if (Ext.isObject(superclass)) {
  5209. overrides = superclass;
  5210. superclass = subclass;
  5211. subclass = overrides.constructor !== objectConstructor ? overrides.constructor : function() {
  5212. superclass.apply(this, arguments);
  5213. };
  5214. }
  5215. if (!superclass) {
  5216. Ext.raise({
  5217. sourceClass: 'Ext',
  5218. sourceMethod: 'extend',
  5219. msg: 'Attempting to extend from a class which has not been loaded on the page.'
  5220. });
  5221. }
  5222. var F = function() {},
  5223. subclassProto,
  5224. superclassProto = superclass.prototype;
  5225. F.prototype = superclassProto;
  5226. subclassProto = subclass.prototype = new F();
  5227. subclassProto.constructor = subclass;
  5228. subclass.superclass = superclassProto;
  5229. if (superclassProto.constructor === objectConstructor) {
  5230. superclassProto.constructor = superclass;
  5231. }
  5232. subclass.override = function(overrides) {
  5233. Ext.override(subclass, overrides);
  5234. };
  5235. subclassProto.override = inlineOverrides;
  5236. subclassProto.proto = subclassProto;
  5237. subclass.override(overrides);
  5238. subclass.extend = function(o) {
  5239. return Ext.extend(subclass, o);
  5240. };
  5241. return subclass;
  5242. };
  5243. }()),
  5244. isOnline: function() {
  5245. return Ext.global.navigator.onLine;
  5246. },
  5247. iterate: function(object, fn, scope) {
  5248. if (Ext.isEmpty(object)) {
  5249. return;
  5250. }
  5251. if (scope === undefined) {
  5252. scope = object;
  5253. }
  5254. if (Ext.isIterable(object)) {
  5255. Ext.Array.each.call(Ext.Array, object, fn, scope);
  5256. } else {
  5257. Ext.Object.each.call(Ext.Object, object, fn, scope);
  5258. }
  5259. },
  5260. _resourcePoolRe: /^[<]([^<>@:]*)(?:[@]([^<>@:]+))?[>](.+)$/,
  5261. resolveResource: function(url) {
  5262. var ret = url,
  5263. m;
  5264. if (url && url.charAt(0) === '<') {
  5265. m = Ext._resourcePoolRe.exec(url);
  5266. if (m) {
  5267. ret = Ext.getResourcePath(m[3], m[1], m[2]);
  5268. }
  5269. }
  5270. return ret;
  5271. },
  5272. urlEncode: function() {
  5273. var args = Ext.Array.from(arguments),
  5274. prefix = '';
  5275. if (Ext.isString(args[1])) {
  5276. prefix = args[1] + '&';
  5277. args[1] = false;
  5278. }
  5279. return prefix + Ext.Object.toQueryString.apply(Ext.Object, args);
  5280. },
  5281. urlDecode: function() {
  5282. return Ext.Object.fromQueryString.apply(Ext.Object, arguments);
  5283. },
  5284. getScrollbarSize: function(force) {
  5285. if (!Ext.isDomReady) {
  5286. Ext.raise("getScrollbarSize called before DomReady");
  5287. }
  5288. var scrollbarSize = Ext._scrollbarSize;
  5289. if (force || !scrollbarSize) {
  5290. var db = document.body,
  5291. div = document.createElement('div'),
  5292. h, w;
  5293. div.style.width = div.style.height = '100px';
  5294. div.style.overflow = 'scroll';
  5295. div.style.position = 'absolute';
  5296. db.appendChild(div);
  5297. Ext._scrollbarSize = scrollbarSize = {
  5298. width: w = div.offsetWidth - div.clientWidth,
  5299. height: h = div.offsetHeight - div.clientHeight
  5300. };
  5301. scrollbarSize.reservedWidth = w ? 'calc(100% - ' + w + 'px)' : '';
  5302. scrollbarSize.reservedHeight = h ? 'calc(100% - ' + h + 'px)' : '';
  5303. db.removeChild(div);
  5304. }
  5305. return scrollbarSize;
  5306. },
  5307. typeOf: (function() {
  5308. var nonWhitespaceRe = /\S/,
  5309. toString = Object.prototype.toString,
  5310. typeofTypes = {
  5311. number: 1,
  5312. string: 1,
  5313. 'boolean': 1,
  5314. 'undefined': 1
  5315. },
  5316. toStringTypes = {
  5317. '[object Array]': 'array',
  5318. '[object Date]': 'date',
  5319. '[object Boolean]': 'boolean',
  5320. '[object Number]': 'number',
  5321. '[object RegExp]': 'regexp'
  5322. };
  5323. return function(value) {
  5324. if (value === null) {
  5325. return 'null';
  5326. }
  5327. var type = typeof value,
  5328. ret, typeToString;
  5329. if (typeofTypes[type]) {
  5330. return type;
  5331. }
  5332. ret = toStringTypes[typeToString = toString.call(value)];
  5333. if (ret) {
  5334. return ret;
  5335. }
  5336. if (type === 'function') {
  5337. return 'function';
  5338. }
  5339. if (type === 'object') {
  5340. if (value.nodeType !== undefined) {
  5341. if (value.nodeType === 3) {
  5342. return nonWhitespaceRe.test(value.nodeValue) ? 'textnode' : 'whitespace';
  5343. } else {
  5344. return 'element';
  5345. }
  5346. }
  5347. return 'object';
  5348. }
  5349. Ext.raise({
  5350. sourceClass: 'Ext',
  5351. sourceMethod: 'typeOf',
  5352. msg: 'Failed to determine the type of "' + value + '".'
  5353. });
  5354. return typeToString;
  5355. };
  5356. }()),
  5357. factory: function(config, classReference, instance, aliasNamespace) {
  5358. var manager = Ext.ClassManager,
  5359. newInstance;
  5360. if (!config || config.isInstance) {
  5361. if (instance && instance !== config) {
  5362. instance.destroy();
  5363. }
  5364. return config;
  5365. }
  5366. if (aliasNamespace) {
  5367. if (typeof config === 'string') {
  5368. return manager.instantiateByAlias(aliasNamespace + '.' + config);
  5369. }
  5370. else if (Ext.isObject(config) && 'type' in config) {
  5371. return manager.instantiateByAlias(aliasNamespace + '.' + config.type, config);
  5372. }
  5373. }
  5374. if (config === true) {
  5375. if (!instance && !classReference) {
  5376. Ext.raise('[Ext.factory] Cannot determine type of class to create');
  5377. }
  5378. return instance || Ext.create(classReference);
  5379. }
  5380. if (!Ext.isObject(config)) {
  5381. Ext.raise("Invalid config, must be a valid config object");
  5382. }
  5383. if ('xtype' in config) {
  5384. newInstance = manager.instantiateByAlias('widget.' + config.xtype, config);
  5385. } else if ('xclass' in config) {
  5386. newInstance = Ext.create(config.xclass, config);
  5387. }
  5388. if (newInstance) {
  5389. if (instance) {
  5390. instance.destroy();
  5391. }
  5392. return newInstance;
  5393. }
  5394. if (instance) {
  5395. return instance.setConfig(config);
  5396. }
  5397. return Ext.create(classReference, config);
  5398. },
  5399. convertKeyedItems: function(items, defaultProperty, functionProperty) {
  5400. if (items && !items.isInstance && Ext.isObject(items)) {
  5401. var obj = items,
  5402. item, itemId, value;
  5403. items = [];
  5404. if (obj.xtype || obj.xclass || obj.itemId || obj.id) {
  5405. items.push(obj);
  5406. } else {
  5407. for (itemId in obj) {
  5408. item = obj[itemId];
  5409. if (item) {
  5410. if (item === true) {
  5411. item = {};
  5412. } else if (typeof item === 'function') {
  5413. if (!functionProperty) {
  5414. Ext.raise('Function not expected here');
  5415. }
  5416. value = item;
  5417. item = {};
  5418. item[functionProperty] = value;
  5419. } else if (typeof item === 'string') {
  5420. value = item;
  5421. item = {};
  5422. item[defaultProperty || 'xtype'] = value;
  5423. } else {
  5424. item = Ext.apply({}, item);
  5425. }
  5426. item.itemId = itemId;
  5427. items.push(item);
  5428. }
  5429. }
  5430. }
  5431. }
  5432. return items;
  5433. },
  5434. weightSortFn: function(lhs, rhs) {
  5435. return (lhs.weight || 0) - (rhs.weight || 0);
  5436. },
  5437. concat: function(a, b) {
  5438. var noB = b == null,
  5439. E = Ext.emptyArray;
  5440. return (a == null) ? (noB ? a : E.concat(b)) : (noB ? E.concat(a) : E.concat(a, b));
  5441. },
  5442. log:
  5443. (function() {
  5444. var primitiveRe = /string|number|boolean/;
  5445. function dumpObject(object, level, maxLevel, withFunctions) {
  5446. var member, type, value, name, prefix, suffix,
  5447. members = [];
  5448. if (Ext.isArray(object)) {
  5449. prefix = '[';
  5450. suffix = ']';
  5451. } else if (Ext.isObject(object)) {
  5452. prefix = '{';
  5453. suffix = '}';
  5454. }
  5455. if (!maxLevel) {
  5456. maxLevel = 3;
  5457. }
  5458. if (level > maxLevel) {
  5459. return prefix + '...' + suffix;
  5460. }
  5461. level = level || 1;
  5462. var spacer = (new Array(level)).join(' ');
  5463. for (name in object) {
  5464. if (object.hasOwnProperty(name)) {
  5465. value = object[name];
  5466. type = typeof value;
  5467. if (type === 'function') {
  5468. if (!withFunctions) {
  5469. continue;
  5470. }
  5471. member = type;
  5472. } else if (type === 'undefined') {
  5473. member = type;
  5474. } else if (value === null || primitiveRe.test(type) || Ext.isDate(value)) {
  5475. member = Ext.encode(value);
  5476. } else if (Ext.isArray(value)) {
  5477. member = dumpObject(value, level + 1, maxLevel, withFunctions);
  5478. } else if (Ext.isObject(value)) {
  5479. member = dumpObject(value, level + 1, maxLevel, withFunctions);
  5480. } else {
  5481. member = type;
  5482. }
  5483. members.push(spacer + name + ': ' + member);
  5484. }
  5485. }
  5486. if (members.length) {
  5487. return prefix + '\n ' + members.join(',\n ') + '\n' + spacer + suffix;
  5488. }
  5489. return prefix + suffix;
  5490. }
  5491. function log(message) {
  5492. var options, dump,
  5493. con = Ext.global.console,
  5494. level = 'log',
  5495. indent = log.indent || 0,
  5496. prefix, stack, fn, out, max;
  5497. log.indent = indent;
  5498. if (typeof message !== 'string') {
  5499. options = message;
  5500. message = options.msg || '';
  5501. level = options.level || level;
  5502. dump = options.dump;
  5503. stack = options.stack;
  5504. prefix = options.prefix;
  5505. fn = options.fn;
  5506. if (options.indent) {
  5507. ++log.indent;
  5508. } else if (options.outdent) {
  5509. log.indent = indent = Math.max(indent - 1, 0);
  5510. }
  5511. if (dump && !(con && con.dir)) {
  5512. message += dumpObject(dump);
  5513. dump = null;
  5514. }
  5515. }
  5516. if (arguments.length > 1) {
  5517. message += Array.prototype.slice.call(arguments, 1).join('');
  5518. }
  5519. if (prefix) {
  5520. message = prefix + ' - ' + message;
  5521. }
  5522. message = indent ? Ext.String.repeat(' ', log.indentSize * indent) + message : message;
  5523. if (level !== 'log') {
  5524. message = '[' + level.charAt(0).toUpperCase() + '] ' + message;
  5525. }
  5526. if (fn) {
  5527. message += '\nCaller: ' + fn.toString();
  5528. }
  5529. if (con) {
  5530. if (con[level]) {
  5531. con[level](message);
  5532. } else {
  5533. con.log(message);
  5534. }
  5535. if (dump) {
  5536. con.dir(dump);
  5537. }
  5538. if (stack && con.trace) {
  5539. if (!con.firebug || level !== 'error') {
  5540. con.trace();
  5541. }
  5542. }
  5543. } else if (Ext.isOpera) {
  5544. opera.postError(message);
  5545. } else
  5546. {
  5547. out = log.out;
  5548. max = log.max;
  5549. if (out.length >= max) {
  5550. Ext.Array.erase(out, 0, out.length - 3 * Math.floor(max / 4));
  5551. }
  5552. out.push(message);
  5553. }
  5554. ++log.count;
  5555. ++log.counters[level];
  5556. }
  5557. function logx(level, args) {
  5558. if (typeof args[0] === 'string') {
  5559. args.unshift({});
  5560. }
  5561. args[0].level = level;
  5562. log.apply(this, args);
  5563. }
  5564. log.error = function() {
  5565. logx('error', Array.prototype.slice.call(arguments));
  5566. };
  5567. log.info = function() {
  5568. logx('info', Array.prototype.slice.call(arguments));
  5569. };
  5570. log.warn = function() {
  5571. logx('warn', Array.prototype.slice.call(arguments));
  5572. };
  5573. log.count = 0;
  5574. log.counters = {
  5575. error: 0,
  5576. warn: 0,
  5577. info: 0,
  5578. log: 0
  5579. };
  5580. log.indentSize = 2;
  5581. log.out = [];
  5582. log.max = 750;
  5583. return log;
  5584. }()) || (
  5585. function() {
  5586. var nullLog = function() {};
  5587. nullLog.info = nullLog.warn = nullLog.error = Ext.emptyFn;
  5588. return nullLog;
  5589. }())
  5590. });
  5591. (function() {
  5592. var
  5593. checkVerTemp = [
  5594. ''
  5595. ],
  5596. endOfVersionRe = /([^\d\.])/,
  5597. notDigitsRe = /[^\d]/g,
  5598. plusMinusRe = /[\-+]/g,
  5599. stripRe = /\s/g,
  5600. underscoreRe = /_/g,
  5601. toolkitNames = {
  5602. classic: 1,
  5603. modern: 1
  5604. },
  5605. Version;
  5606. Ext.Version = Version = function(version, defaultMode) {
  5607. var me = this,
  5608. padModes = me.padModes,
  5609. ch, i, pad, parts, release, releaseStartIndex, ver;
  5610. if (version.isVersion) {
  5611. version = version.version;
  5612. }
  5613. me.version = ver = String(version).toLowerCase().replace(underscoreRe, '.').replace(plusMinusRe, '');
  5614. ch = ver.charAt(0);
  5615. if (ch in padModes) {
  5616. ver = ver.substring(1);
  5617. pad = padModes[ch];
  5618. } else {
  5619. pad = defaultMode ? padModes[defaultMode] : 0;
  5620. }
  5621. me.pad = pad;
  5622. releaseStartIndex = ver.search(endOfVersionRe);
  5623. me.shortVersion = ver;
  5624. if (releaseStartIndex !== -1) {
  5625. me.release = release = ver.substr(releaseStartIndex, version.length);
  5626. me.shortVersion = ver.substr(0, releaseStartIndex);
  5627. release = Version.releaseValueMap[release] || release;
  5628. }
  5629. me.releaseValue = release || pad;
  5630. me.shortVersion = me.shortVersion.replace(notDigitsRe, '');
  5631. me.parts = parts = ver.split('.');
  5632. for (i = parts.length; i--; ) {
  5633. parts[i] = parseInt(parts[i], 10);
  5634. }
  5635. if (pad === Infinity) {
  5636. parts.push(pad);
  5637. }
  5638. me.major = parts[0] || pad;
  5639. me.minor = parts[1] || pad;
  5640. me.patch = parts[2] || pad;
  5641. me.build = parts[3] || pad;
  5642. return me;
  5643. };
  5644. Version.prototype = {
  5645. isVersion: true,
  5646. padModes: {
  5647. '~': NaN,
  5648. '^': Infinity
  5649. },
  5650. release: '',
  5651. compareTo: function(other) {
  5652. var me = this,
  5653. lhsPad = me.pad,
  5654. lhsParts = me.parts,
  5655. lhsLength = lhsParts.length,
  5656. rhsVersion = other.isVersion ? other : new Version(other),
  5657. rhsPad = rhsVersion.pad,
  5658. rhsParts = rhsVersion.parts,
  5659. rhsLength = rhsParts.length,
  5660. length = Math.max(lhsLength, rhsLength),
  5661. i, lhs, rhs;
  5662. for (i = 0; i < length; i++) {
  5663. lhs = (i < lhsLength) ? lhsParts[i] : lhsPad;
  5664. rhs = (i < rhsLength) ? rhsParts[i] : rhsPad;
  5665. if (lhs < rhs) {
  5666. return -1;
  5667. }
  5668. if (lhs > rhs) {
  5669. return 1;
  5670. }
  5671. }
  5672. lhs = me.releaseValue;
  5673. rhs = rhsVersion.releaseValue;
  5674. if (lhs < rhs) {
  5675. return -1;
  5676. }
  5677. if (lhs > rhs) {
  5678. return 1;
  5679. }
  5680. return 0;
  5681. },
  5682. toString: function() {
  5683. return this.version;
  5684. },
  5685. valueOf: function() {
  5686. return this.version;
  5687. },
  5688. getMajor: function() {
  5689. return this.major;
  5690. },
  5691. getMinor: function() {
  5692. return this.minor;
  5693. },
  5694. getPatch: function() {
  5695. return this.patch;
  5696. },
  5697. getBuild: function() {
  5698. return this.build;
  5699. },
  5700. getRelease: function() {
  5701. return this.release;
  5702. },
  5703. getReleaseValue: function() {
  5704. return this.releaseValue;
  5705. },
  5706. isGreaterThan: function(target) {
  5707. return this.compareTo(target) > 0;
  5708. },
  5709. isGreaterThanOrEqual: function(target) {
  5710. return this.compareTo(target) >= 0;
  5711. },
  5712. isLessThan: function(target) {
  5713. return this.compareTo(target) < 0;
  5714. },
  5715. isLessThanOrEqual: function(target) {
  5716. return this.compareTo(target) <= 0;
  5717. },
  5718. equals: function(target) {
  5719. return this.compareTo(target) === 0;
  5720. },
  5721. match: function(target) {
  5722. target = String(target);
  5723. return this.version.substr(0, target.length) === target;
  5724. },
  5725. toArray: function() {
  5726. var me = this;
  5727. return [
  5728. me.getMajor(),
  5729. me.getMinor(),
  5730. me.getPatch(),
  5731. me.getBuild(),
  5732. me.getRelease()
  5733. ];
  5734. },
  5735. getShortVersion: function() {
  5736. return this.shortVersion;
  5737. },
  5738. gt: function(target) {
  5739. return this.compareTo(target) > 0;
  5740. },
  5741. lt: function(target) {
  5742. return this.compareTo(target) < 0;
  5743. },
  5744. gtEq: function(target) {
  5745. return this.compareTo(target) >= 0;
  5746. },
  5747. ltEq: function(target) {
  5748. return this.compareTo(target) <= 0;
  5749. }
  5750. };
  5751. Ext.apply(Version, {
  5752. aliases: {
  5753. from: {
  5754. extjs: 'ext',
  5755. core: 'core',
  5756. touch: 'modern'
  5757. },
  5758. to: {
  5759. ext: [
  5760. 'extjs'
  5761. ],
  5762. 'core': [
  5763. 'core'
  5764. ],
  5765. modern: [
  5766. 'touch'
  5767. ]
  5768. }
  5769. },
  5770. releaseValueMap: {
  5771. dev: -6,
  5772. alpha: -5,
  5773. a: -5,
  5774. beta: -4,
  5775. b: -4,
  5776. rc: -3,
  5777. '#': -2,
  5778. p: -1,
  5779. pl: -1
  5780. },
  5781. getComponentValue: function(value) {
  5782. return !value ? 0 : (isNaN(value) ? this.releaseValueMap[value] || value : parseInt(value, 10));
  5783. },
  5784. compare: function(current, target) {
  5785. var ver = current.isVersion ? current : new Version(current);
  5786. return ver.compareTo(target);
  5787. },
  5788. set: function(collection, packageName, version) {
  5789. var aliases = Version.aliases.to[packageName],
  5790. ver = version.isVersion ? version : new Version(version),
  5791. i;
  5792. collection[packageName] = ver;
  5793. if (aliases) {
  5794. for (i = aliases.length; i-- > 0; ) {
  5795. collection[aliases[i]] = ver;
  5796. }
  5797. }
  5798. return ver;
  5799. }
  5800. });
  5801. Ext.apply(Ext, {
  5802. compatVersions: {},
  5803. versions: {},
  5804. lastRegisteredVersion: null,
  5805. getCompatVersion: function(packageName) {
  5806. var versions = Ext.compatVersions,
  5807. compat;
  5808. if (!packageName) {
  5809. compat = versions.ext || versions.touch || versions.core;
  5810. } else {
  5811. compat = versions[Version.aliases.from[packageName] || packageName];
  5812. }
  5813. return compat || Ext.getVersion(packageName);
  5814. },
  5815. setCompatVersion: function(packageName, version) {
  5816. Version.set(Ext.compatVersions, packageName, version);
  5817. },
  5818. setVersion: function(packageName, version) {
  5819. if (packageName in toolkitNames) {
  5820. Ext.toolkit = packageName;
  5821. }
  5822. Ext.lastRegisteredVersion = Version.set(Ext.versions, packageName, version);
  5823. return this;
  5824. },
  5825. getVersion: function(packageName) {
  5826. var versions = Ext.versions;
  5827. if (!packageName) {
  5828. return versions.ext || versions.touch || versions.core;
  5829. }
  5830. return versions[Version.aliases.from[packageName] || packageName];
  5831. },
  5832. checkVersion: function(specs, matchAll) {
  5833. var isArray = Ext.isArray(specs),
  5834. aliases = Version.aliases.from,
  5835. compat = isArray ? specs : checkVerTemp,
  5836. length = compat.length,
  5837. versions = Ext.versions,
  5838. frameworkVer = versions.ext || versions.touch,
  5839. i, index, matches, minVer, maxVer, packageName, spec, range, ver;
  5840. if (!isArray) {
  5841. checkVerTemp[0] = specs;
  5842. }
  5843. for (i = 0; i < length; ++i) {
  5844. if (!Ext.isString(spec = compat[i])) {
  5845. matches = Ext.checkVersion(spec.and || spec.or, !spec.or);
  5846. if (spec.not) {
  5847. matches = !matches;
  5848. }
  5849. } else {
  5850. if (spec.indexOf(' ') >= 0) {
  5851. spec = spec.replace(stripRe, '');
  5852. }
  5853. index = spec.indexOf('@');
  5854. if (index < 0) {
  5855. range = spec;
  5856. ver = frameworkVer;
  5857. } else {
  5858. packageName = spec.substring(0, index);
  5859. if (!(ver = versions[aliases[packageName] || packageName])) {
  5860. if (matchAll) {
  5861. return false;
  5862. }
  5863. continue;
  5864. }
  5865. range = spec.substring(index + 1);
  5866. }
  5867. index = range.indexOf('-');
  5868. if (index < 0) {
  5869. if (range.charAt(index = range.length - 1) === '+') {
  5870. minVer = range.substring(0, index);
  5871. maxVer = null;
  5872. } else {
  5873. minVer = maxVer = range;
  5874. }
  5875. } else if (index > 0) {
  5876. minVer = range.substring(0, index);
  5877. maxVer = range.substring(index + 1);
  5878. } else
  5879. {
  5880. minVer = null;
  5881. maxVer = range.substring(index + 1);
  5882. }
  5883. matches = true;
  5884. if (minVer) {
  5885. minVer = new Version(minVer, '~');
  5886. matches = minVer.ltEq(ver);
  5887. }
  5888. if (matches && maxVer) {
  5889. maxVer = new Version(maxVer, '~');
  5890. matches = maxVer.gtEq(ver);
  5891. }
  5892. }
  5893. if (matches) {
  5894. if (!matchAll) {
  5895. return true;
  5896. }
  5897. } else if (matchAll) {
  5898. return false;
  5899. }
  5900. }
  5901. return !!matchAll;
  5902. },
  5903. deprecate: function(packageName, since, closure, scope) {
  5904. if (Version.compare(Ext.getVersion(packageName), since) < 1) {
  5905. closure.call(scope);
  5906. }
  5907. }
  5908. });
  5909. }());
  5910. (function(manifest) {
  5911. var packages = (manifest && manifest.packages) || {},
  5912. compat = manifest && manifest.compatibility,
  5913. name, pkg;
  5914. for (name in packages) {
  5915. pkg = packages[name];
  5916. if (pkg && pkg.version) {
  5917. Ext.setVersion(name, pkg.version);
  5918. }
  5919. }
  5920. if (compat) {
  5921. if (Ext.isString(compat)) {
  5922. Ext.setCompatVersion('core', compat);
  5923. } else {
  5924. for (name in compat) {
  5925. Ext.setCompatVersion(name, compat[name]);
  5926. }
  5927. }
  5928. }
  5929. if (!packages.ext && !packages.touch) {
  5930. Ext.setVersion('ext', '6.6.0.258');
  5931. Ext.setVersion('core', '6.6.0.258');
  5932. }
  5933. })(Ext.manifest);
  5934. Ext.Config = function(name) {
  5935. var me = this,
  5936. capitalizedName = name.charAt(0).toUpperCase() + name.substr(1);
  5937. me.name = name;
  5938. me.names = {
  5939. internal: '_' + name,
  5940. initializing: 'is' + capitalizedName + 'Initializing',
  5941. apply: 'apply' + capitalizedName,
  5942. update: 'update' + capitalizedName,
  5943. get: 'get' + capitalizedName,
  5944. set: 'set' + capitalizedName,
  5945. initGet: 'initGet' + capitalizedName,
  5946. changeEvent: name.toLowerCase() + 'change'
  5947. };
  5948. me.root = me;
  5949. };
  5950. Ext.Config.map = {};
  5951. Ext.Config.get = function(name) {
  5952. var map = Ext.Config.map,
  5953. ret = map[name] || (map[name] = new Ext.Config(name));
  5954. return ret;
  5955. };
  5956. Ext.Config.prototype = {
  5957. self: Ext.Config,
  5958. isConfig: true,
  5959. getGetter: function() {
  5960. return this.getter || (this.root.getter = this.makeGetter());
  5961. },
  5962. getInitGetter: function() {
  5963. return this.initGetter || (this.root.initGetter = this.makeInitGetter());
  5964. },
  5965. getSetter: function() {
  5966. return this.setter || (this.root.setter = this.makeSetter());
  5967. },
  5968. getEventedSetter: function() {
  5969. return this.eventedSetter || (this.root.eventedSetter = this.makeEventedSetter());
  5970. },
  5971. getInternalName: function(target) {
  5972. return target.$configPrefixed ? this.names.internal : this.name;
  5973. },
  5974. mergeNew: function(newValue, oldValue, target, mixinClass) {
  5975. var ret, key;
  5976. if (!oldValue) {
  5977. ret = newValue;
  5978. } else if (!newValue) {
  5979. ret = oldValue;
  5980. } else {
  5981. ret = Ext.Object.chain(oldValue);
  5982. for (key in newValue) {
  5983. if (!mixinClass || !(key in ret)) {
  5984. ret[key] = newValue[key];
  5985. }
  5986. }
  5987. }
  5988. return ret;
  5989. },
  5990. mergeSets: function(newValue, oldValue, preserveExisting) {
  5991. var ret = oldValue ? Ext.Object.chain(oldValue) : {},
  5992. i, val;
  5993. if (newValue instanceof Array) {
  5994. for (i = newValue.length; i--; ) {
  5995. val = newValue[i];
  5996. if (!preserveExisting || !(val in ret)) {
  5997. ret[val] = true;
  5998. }
  5999. }
  6000. } else if (newValue) {
  6001. if (newValue.constructor === Object) {
  6002. for (i in newValue) {
  6003. val = newValue[i];
  6004. if (!preserveExisting || !(i in ret)) {
  6005. ret[i] = val;
  6006. }
  6007. }
  6008. } else if (!preserveExisting || !(newValue in ret)) {
  6009. ret[newValue] = true;
  6010. }
  6011. }
  6012. return ret;
  6013. },
  6014. makeGetter: function() {
  6015. var name = this.name,
  6016. prefixedName = this.names.internal;
  6017. return function() {
  6018. var internalName = this.$configPrefixed ? prefixedName : name;
  6019. return this[internalName];
  6020. };
  6021. },
  6022. makeInitGetter: function() {
  6023. var name = this.name,
  6024. names = this.names,
  6025. setName = names.set,
  6026. getName = names.get,
  6027. initializingName = names.initializing;
  6028. return function() {
  6029. var me = this;
  6030. me[initializingName] = true;
  6031. delete me[getName];
  6032. me[setName](me.config[name]);
  6033. delete me[initializingName];
  6034. return me[getName].apply(me, arguments);
  6035. };
  6036. },
  6037. makeSetter: function() {
  6038. var name = this.name,
  6039. names = this.names,
  6040. prefixedName = names.internal,
  6041. getName = names.get,
  6042. applyName = names.apply,
  6043. updateName = names.update,
  6044. setter;
  6045. setter = function(value) {
  6046. var me = this,
  6047. internalName = me.$configPrefixed ? prefixedName : name,
  6048. oldValue = me[internalName];
  6049. delete me[getName];
  6050. if (!me[applyName] || (value = me[applyName](value, oldValue)) !== undefined) {
  6051. if (value !== (oldValue = me[internalName])) {
  6052. me[internalName] = value;
  6053. if (me[updateName]) {
  6054. me[updateName](value, oldValue);
  6055. }
  6056. }
  6057. }
  6058. return me;
  6059. };
  6060. setter.$isDefault = true;
  6061. return setter;
  6062. },
  6063. makeEventedSetter: function() {
  6064. var name = this.name,
  6065. names = this.names,
  6066. prefixedName = names.internal,
  6067. getName = names.get,
  6068. applyName = names.apply,
  6069. updateName = names.update,
  6070. changeEventName = names.changeEvent,
  6071. updateFn = function(me, value, oldValue, internalName) {
  6072. me[internalName] = value;
  6073. if (me[updateName]) {
  6074. me[updateName](value, oldValue);
  6075. }
  6076. },
  6077. setter;
  6078. setter = function(value) {
  6079. var me = this,
  6080. internalName = me.$configPrefixed ? prefixedName : name,
  6081. oldValue = me[internalName];
  6082. delete me[getName];
  6083. if (!me[applyName] || (value = me[applyName](value, oldValue)) !== undefined) {
  6084. if (value !== (oldValue = me[internalName])) {
  6085. if (me.isConfiguring) {
  6086. me[internalName] = value;
  6087. if (me[updateName]) {
  6088. me[updateName](value, oldValue);
  6089. }
  6090. } else {
  6091. me.fireEventedAction(changeEventName, [
  6092. me,
  6093. value,
  6094. oldValue
  6095. ], updateFn, me, [
  6096. me,
  6097. value,
  6098. oldValue,
  6099. internalName
  6100. ]);
  6101. }
  6102. }
  6103. }
  6104. return me;
  6105. };
  6106. setter.$isDefault = true;
  6107. return setter;
  6108. }
  6109. };
  6110. (function() {
  6111. var ExtConfig = Ext.Config,
  6112. configPropMap = ExtConfig.map,
  6113. ExtObject = Ext.Object;
  6114. Ext.Configurator = function(cls) {
  6115. var me = this,
  6116. prototype = cls.prototype,
  6117. superCfg = cls.superclass ? cls.superclass.self.$config : null;
  6118. me.cls = cls;
  6119. me.superCfg = superCfg;
  6120. if (superCfg) {
  6121. me.configs = ExtObject.chain(superCfg.configs);
  6122. me.cachedConfigs = ExtObject.chain(superCfg.cachedConfigs);
  6123. me.initMap = ExtObject.chain(superCfg.initMap);
  6124. me.values = ExtObject.chain(superCfg.values);
  6125. me.needsFork = superCfg.needsFork;
  6126. me.deprecations = ExtObject.chain(superCfg.deprecations);
  6127. } else
  6128. {
  6129. me.configs = {};
  6130. me.cachedConfigs = {};
  6131. me.initMap = {};
  6132. me.values = {};
  6133. me.deprecations = {};
  6134. }
  6135. prototype.config = prototype.defaultConfig = me.values;
  6136. cls.$config = me;
  6137. };
  6138. Ext.Configurator.prototype = {
  6139. self: Ext.Configurator,
  6140. needsFork: false,
  6141. initList: null,
  6142. add: function(config, mixinClass) {
  6143. var me = this,
  6144. Cls = me.cls,
  6145. configs = me.configs,
  6146. cachedConfigs = me.cachedConfigs,
  6147. initMap = me.initMap,
  6148. prototype = Cls.prototype,
  6149. mixinConfigs = mixinClass && mixinClass.$config.configs,
  6150. values = me.values,
  6151. isObject, meta, isCached, merge, cfg, currentValue, name, names, s, value;
  6152. for (name in config) {
  6153. value = config[name];
  6154. isObject = value && value.constructor === Object;
  6155. meta = isObject && '$value' in value ? value : null;
  6156. isCached = false;
  6157. if (meta) {
  6158. isCached = !!meta.cached;
  6159. value = meta.$value;
  6160. isObject = value && value.constructor === Object;
  6161. }
  6162. merge = meta && meta.merge;
  6163. cfg = configs[name];
  6164. if (cfg) {
  6165. if (mixinClass) {
  6166. merge = cfg.merge;
  6167. if (!merge) {
  6168. continue;
  6169. }
  6170. meta = null;
  6171. } else {
  6172. merge = merge || cfg.merge;
  6173. }
  6174. if (!mixinClass && isCached && !cachedConfigs[name]) {
  6175. Ext.raise('Redefining config as cached: ' + name + ' in class: ' + Cls.$className);
  6176. }
  6177. currentValue = values[name];
  6178. if (merge) {
  6179. value = merge.call(cfg, value, currentValue, Cls, mixinClass);
  6180. } else if (isObject) {
  6181. if (currentValue && currentValue.constructor === Object) {
  6182. value = ExtObject.merge({}, currentValue, value);
  6183. }
  6184. }
  6185. } else
  6186. {
  6187. if (mixinConfigs) {
  6188. cfg = mixinConfigs[name];
  6189. meta = null;
  6190. } else {
  6191. cfg = ExtConfig.get(name);
  6192. }
  6193. configs[name] = cfg;
  6194. if (cfg.cached || isCached) {
  6195. cachedConfigs[name] = true;
  6196. }
  6197. names = cfg.names;
  6198. if (!prototype[s = names.get]) {
  6199. prototype[s] = cfg.getter || cfg.getGetter();
  6200. }
  6201. if (!prototype[s = names.set]) {
  6202. prototype[s] = (meta && meta.evented) ? (cfg.eventedSetter || cfg.getEventedSetter()) : (cfg.setter || cfg.getSetter());
  6203. }
  6204. }
  6205. if (meta) {
  6206. if (cfg.owner !== Cls) {
  6207. configs[name] = cfg = Ext.Object.chain(cfg);
  6208. cfg.owner = Cls;
  6209. }
  6210. Ext.apply(cfg, meta);
  6211. delete cfg.$value;
  6212. }
  6213. if (!me.needsFork && value && (value.constructor === Object || value instanceof Array)) {
  6214. me.needsFork = true;
  6215. }
  6216. if (value !== null) {
  6217. initMap[name] = true;
  6218. } else {
  6219. if (prototype.$configPrefixed) {
  6220. prototype[configs[name].names.internal] = null;
  6221. } else {
  6222. prototype[configs[name].name] = null;
  6223. }
  6224. if (name in initMap) {
  6225. initMap[name] = false;
  6226. }
  6227. }
  6228. values[name] = value;
  6229. }
  6230. },
  6231. addDeprecations: function(configs) {
  6232. var me = this,
  6233. deprecations = me.deprecations,
  6234. className = (me.cls.$className || '') + '#',
  6235. message, newName, oldName;
  6236. for (oldName in configs) {
  6237. newName = configs[oldName];
  6238. if (!newName) {
  6239. message = 'This config has been removed.';
  6240. } else if (!(message = newName.message)) {
  6241. message = 'This config has been renamed to "' + newName + '"';
  6242. }
  6243. deprecations[oldName] = className + oldName + ': ' + message;
  6244. }
  6245. },
  6246. configure: function(instance, instanceConfig) {
  6247. var me = this,
  6248. configs = me.configs,
  6249. deprecations = me.deprecations,
  6250. initMap = me.initMap,
  6251. initListMap = me.initListMap,
  6252. initList = me.initList,
  6253. prototype = me.cls.prototype,
  6254. values = me.values,
  6255. remaining = 0,
  6256. firstInstance = !initList,
  6257. cachedInitList, cfg, getter, i, internalName, ln, names, name, value, isCached, valuesKey, field;
  6258. values = me.needsFork ? ExtObject.fork(values) : ExtObject.chain(values);
  6259. instance.isConfiguring = true;
  6260. if (firstInstance) {
  6261. me.initList = initList = [];
  6262. me.initListMap = initListMap = {};
  6263. instance.isFirstInstance = true;
  6264. for (name in initMap) {
  6265. cfg = configs[name];
  6266. isCached = cfg.cached;
  6267. if (initMap[name]) {
  6268. names = cfg.names;
  6269. value = values[name];
  6270. if (!prototype[names.set].$isDefault || prototype[names.apply] || prototype[names.update] || typeof value === 'object') {
  6271. if (isCached) {
  6272. (cachedInitList || (cachedInitList = [])).push(cfg);
  6273. } else {
  6274. initList.push(cfg);
  6275. initListMap[name] = true;
  6276. }
  6277. instance[names.get] = cfg.initGetter || cfg.getInitGetter();
  6278. } else {
  6279. prototype[cfg.getInternalName(prototype)] = value;
  6280. }
  6281. } else if (isCached) {
  6282. prototype[cfg.getInternalName(prototype)] = undefined;
  6283. }
  6284. }
  6285. }
  6286. ln = cachedInitList && cachedInitList.length;
  6287. if (ln) {
  6288. for (i = 0; i < ln; ++i) {
  6289. internalName = cachedInitList[i].getInternalName(prototype);
  6290. instance[internalName] = null;
  6291. }
  6292. for (i = 0; i < ln; ++i) {
  6293. names = (cfg = cachedInitList[i]).names;
  6294. getter = names.get;
  6295. if (instance.hasOwnProperty(getter)) {
  6296. instance[names.set](values[cfg.name]);
  6297. delete instance[getter];
  6298. }
  6299. }
  6300. for (i = 0; i < ln; ++i) {
  6301. internalName = cachedInitList[i].getInternalName(prototype);
  6302. prototype[internalName] = instance[internalName];
  6303. delete instance[internalName];
  6304. }
  6305. }
  6306. if (instanceConfig && instanceConfig.platformConfig) {
  6307. instanceConfig = me.resolvePlatformConfig(instance, instanceConfig);
  6308. }
  6309. if (firstInstance) {
  6310. if (instance.afterCachedConfig && !instance.afterCachedConfig.$nullFn) {
  6311. instance.afterCachedConfig(instanceConfig);
  6312. }
  6313. }
  6314. instance.config = values;
  6315. for (i = 0 , ln = initList.length; i < ln; ++i) {
  6316. cfg = initList[i];
  6317. instance[cfg.names.get] = cfg.initGetter || cfg.getInitGetter();
  6318. }
  6319. if (instance.transformInstanceConfig) {
  6320. instanceConfig = instance.transformInstanceConfig(instanceConfig);
  6321. }
  6322. if (instanceConfig) {
  6323. for (name in instanceConfig) {
  6324. value = instanceConfig[name];
  6325. cfg = configs[name];
  6326. if (deprecations[name]) {
  6327. Ext.log.warn(deprecations[name]);
  6328. if (!cfg) {
  6329. continue;
  6330. }
  6331. }
  6332. if (!cfg) {
  6333. field = instance.self.prototype[name];
  6334. if (instance.$configStrict && (typeof field === 'function') && !field.$nullFn) {
  6335. Ext.raise('Cannot override method ' + name + ' on ' + instance.$className + ' instance.');
  6336. }
  6337. instance[name] = value;
  6338. } else {
  6339. if (!cfg.lazy) {
  6340. ++remaining;
  6341. }
  6342. if (!initListMap[name]) {
  6343. instance[cfg.names.get] = cfg.initGetter || cfg.getInitGetter();
  6344. }
  6345. if (cfg.merge) {
  6346. value = cfg.merge(value, values[name], instance);
  6347. } else if (value && value.constructor === Object) {
  6348. valuesKey = values[name];
  6349. if (valuesKey && valuesKey.constructor === Object) {
  6350. value = ExtObject.merge(values[name], value);
  6351. } else {
  6352. value = Ext.clone(value, false);
  6353. }
  6354. }
  6355. }
  6356. values[name] = value;
  6357. }
  6358. }
  6359. if (instance.beforeInitConfig && !instance.beforeInitConfig.$nullFn) {
  6360. if (instance.beforeInitConfig(instanceConfig) === false) {
  6361. return;
  6362. }
  6363. }
  6364. if (instanceConfig) {
  6365. for (name in instanceConfig) {
  6366. if (!remaining) {
  6367. break;
  6368. }
  6369. cfg = configs[name];
  6370. if (cfg && !cfg.lazy) {
  6371. --remaining;
  6372. names = cfg.names;
  6373. getter = names.get;
  6374. if (instance.hasOwnProperty(getter)) {
  6375. instance[names.set](values[name]);
  6376. delete instance[names.get];
  6377. }
  6378. }
  6379. }
  6380. }
  6381. for (i = 0 , ln = initList.length; i < ln; ++i) {
  6382. cfg = initList[i];
  6383. names = cfg.names;
  6384. getter = names.get;
  6385. if (!cfg.lazy && instance.hasOwnProperty(getter)) {
  6386. instance[names.set](values[cfg.name]);
  6387. delete instance[getter];
  6388. }
  6389. }
  6390. delete instance.isConfiguring;
  6391. },
  6392. getCurrentConfig: function(instance) {
  6393. var defaultConfig = instance.defaultConfig,
  6394. config = {},
  6395. name;
  6396. for (name in defaultConfig) {
  6397. config[name] = instance[configPropMap[name].names.get]();
  6398. }
  6399. return config;
  6400. },
  6401. merge: function(instance, baseConfig, config) {
  6402. var configs = this.configs,
  6403. name, value, baseValue, cfg;
  6404. for (name in config) {
  6405. value = config[name];
  6406. cfg = configs[name];
  6407. if (cfg) {
  6408. if (cfg.merge) {
  6409. value = cfg.merge(value, baseConfig[name], instance);
  6410. } else if (value && value.constructor === Object) {
  6411. baseValue = baseConfig[name];
  6412. if (baseValue && baseValue.constructor === Object) {
  6413. value = Ext.Object.merge(baseValue, value);
  6414. } else {
  6415. value = Ext.clone(value, false);
  6416. }
  6417. }
  6418. }
  6419. baseConfig[name] = value;
  6420. }
  6421. return baseConfig;
  6422. },
  6423. reconfigure: function(instance, instanceConfig, options) {
  6424. var currentConfig = instance.config,
  6425. configList = [],
  6426. strict = instance.$configStrict && !(options && options.strict === false),
  6427. configs = this.configs,
  6428. defaults = options && options.defaults,
  6429. cfg, getter, i, len, name, names, prop;
  6430. for (name in instanceConfig) {
  6431. cfg = configs[name];
  6432. if (defaults && instance.hasOwnProperty(cfg && instance.$configPrefixed ? cfg.names.internal : name)) {
  6433. continue;
  6434. }
  6435. currentConfig[name] = instanceConfig[name];
  6436. if (this.deprecations[name]) {
  6437. Ext.log.warn(this.deprecations[name]);
  6438. if (!cfg) {
  6439. continue;
  6440. }
  6441. }
  6442. if (cfg) {
  6443. instance[cfg.names.get] = cfg.initGetter || cfg.getInitGetter();
  6444. } else {
  6445. prop = instance.self.prototype[name];
  6446. if (strict) {
  6447. if ((typeof prop === 'function') && !prop.$nullFn) {
  6448. Ext.Error.raise("Cannot override method " + name + " on " + instance.$className + " instance.");
  6449. continue;
  6450. } else
  6451. {
  6452. if (name !== 'type') {
  6453. Ext.log.warn('No such config "' + name + '" for class ' + instance.$className);
  6454. }
  6455. }
  6456. }
  6457. }
  6458. configList.push(name);
  6459. }
  6460. for (i = 0 , len = configList.length; i < len; i++) {
  6461. name = configList[i];
  6462. cfg = configs[name];
  6463. if (cfg) {
  6464. names = cfg.names;
  6465. getter = names.get;
  6466. if (instance.hasOwnProperty(getter)) {
  6467. instance[names.set](instanceConfig[name]);
  6468. delete instance[getter];
  6469. }
  6470. } else {
  6471. cfg = configPropMap[name] || Ext.Config.get(name);
  6472. names = cfg.names;
  6473. if (instance[names.set]) {
  6474. instance[names.set](instanceConfig[name]);
  6475. } else {
  6476. instance[name] = instanceConfig[name];
  6477. }
  6478. }
  6479. }
  6480. },
  6481. resolvePlatformConfig: function(instance, instanceConfig) {
  6482. var platformConfig = instanceConfig && instanceConfig.platformConfig,
  6483. ret = instanceConfig,
  6484. i, keys, n;
  6485. if (platformConfig) {
  6486. keys = Ext.getPlatformConfigKeys(platformConfig);
  6487. n = keys.length;
  6488. if (n) {
  6489. ret = Ext.merge({}, ret);
  6490. for (i = 0 , n = keys.length; i < n; ++i) {
  6491. this.merge(instance, ret, platformConfig[keys[i]]);
  6492. }
  6493. }
  6494. }
  6495. return ret;
  6496. }
  6497. };
  6498. }());
  6499. Ext.Base = (function(flexSetter) {
  6500. var noArgs = [],
  6501. baseStaticMember,
  6502. baseStaticMembers = [],
  6503. makeDeprecatedMethod = function(oldName, newName, msg) {
  6504. var message = '"' + oldName + '" is deprecated.';
  6505. if (msg) {
  6506. message += ' ' + msg;
  6507. } else if (newName) {
  6508. message += ' Please use "' + newName + '" instead.';
  6509. }
  6510. return function() {
  6511. Ext.raise(message);
  6512. };
  6513. },
  6514. addDeprecatedProperty = function(object, oldName, newName, message) {
  6515. if (!message) {
  6516. message = '"' + oldName + '" is deprecated.';
  6517. }
  6518. if (newName) {
  6519. message += ' Please use "' + newName + '" instead.';
  6520. }
  6521. if (message) {
  6522. Ext.Object.defineProperty(object, oldName, {
  6523. get: function() {
  6524. Ext.raise(message);
  6525. },
  6526. set: function(value) {
  6527. Ext.raise(message);
  6528. },
  6529. configurable: true
  6530. });
  6531. }
  6532. },
  6533. makeAliasFn = function(name) {
  6534. return function() {
  6535. return this[name].apply(this, arguments);
  6536. };
  6537. },
  6538. Version = Ext.Version,
  6539. leadingDigitRe = /^\d/,
  6540. oneMember = {},
  6541. aliasOneMember = {},
  6542. Base = function() {},
  6543. BasePrototype = Base.prototype,
  6544. Reaper;
  6545. Ext.Reaper = Reaper = {
  6546. delay: 100,
  6547. queue: [],
  6548. timer: null,
  6549. add: function(obj) {
  6550. if (!Reaper.timer) {
  6551. Reaper.timer = Ext.defer(Reaper.tick, Reaper.delay);
  6552. }
  6553. Reaper.queue.push(obj);
  6554. },
  6555. flush: function() {
  6556. if (Reaper.timer) {
  6557. Ext.undefer(Reaper.timer);
  6558. Reaper.timer = null;
  6559. }
  6560. var queue = Reaper.queue,
  6561. n = queue.length,
  6562. i, obj;
  6563. Reaper.queue = [];
  6564. for (i = 0; i < n; ++i) {
  6565. obj = queue[i];
  6566. if (obj && obj.$reap) {
  6567. obj.$reap();
  6568. }
  6569. }
  6570. },
  6571. tick: function() {
  6572. Reaper.timer = null;
  6573. Reaper.flush();
  6574. }
  6575. };
  6576. Ext.apply(Base, {
  6577. $className: 'Ext.Base',
  6578. $isClass: true,
  6579. create: function() {
  6580. return Ext.create.apply(Ext, [
  6581. this
  6582. ].concat(Array.prototype.slice.call(arguments, 0)));
  6583. },
  6584. addDeprecations: function(deprecations) {
  6585. var me = this,
  6586. all = [],
  6587. compatVersion = Ext.getCompatVersion(deprecations.name),
  6588. configurator = me.getConfigurator(),
  6589. displayName = (me.$className || '') + '#',
  6590. deprecate, versionSpec, index, message, target, enabled, existing, fn, names, oldName, newName, member, statics, version;
  6591. for (versionSpec in deprecations) {
  6592. if (leadingDigitRe.test(versionSpec)) {
  6593. version = new Ext.Version(versionSpec);
  6594. version.deprecations = deprecations[versionSpec];
  6595. all.push(version);
  6596. }
  6597. }
  6598. all.sort(Version.compare);
  6599. for (index = all.length; index--; ) {
  6600. deprecate = (version = all[index]).deprecations;
  6601. target = me.prototype;
  6602. statics = deprecate.statics;
  6603. enabled = compatVersion && compatVersion.lt(version);
  6604. if (!enabled) {}
  6605. else if (!enabled) {
  6606. break;
  6607. }
  6608. while (deprecate) {
  6609. names = deprecate.methods;
  6610. if (names) {
  6611. for (oldName in names) {
  6612. member = names[oldName];
  6613. fn = null;
  6614. if (!member) {
  6615. Ext.Assert.isNotDefinedProp(target, oldName);
  6616. fn = makeDeprecatedMethod(displayName + oldName);
  6617. }
  6618. else if (Ext.isString(member)) {
  6619. Ext.Assert.isNotDefinedProp(target, oldName);
  6620. Ext.Assert.isDefinedProp(target, member);
  6621. if (enabled) {
  6622. fn = makeAliasFn(member);
  6623. } else
  6624. {
  6625. fn = makeDeprecatedMethod(displayName + oldName, member);
  6626. }
  6627. } else
  6628. {
  6629. message = '';
  6630. if (member.message || member.fn) {
  6631. message = member.message;
  6632. member = member.fn;
  6633. }
  6634. existing = target.hasOwnProperty(oldName) && target[oldName];
  6635. if (enabled && member) {
  6636. member.$owner = me;
  6637. member.$name = oldName;
  6638. member.name = displayName + oldName;
  6639. if (existing) {
  6640. member.$previous = existing;
  6641. }
  6642. fn = member;
  6643. }
  6644. else if (!existing) {
  6645. fn = makeDeprecatedMethod(displayName + oldName, null, message);
  6646. }
  6647. }
  6648. if (fn) {
  6649. target[oldName] = fn;
  6650. }
  6651. }
  6652. }
  6653. names = deprecate.configs;
  6654. if (names) {
  6655. configurator.addDeprecations(names);
  6656. }
  6657. names = deprecate.properties;
  6658. if (names && !enabled) {
  6659. for (oldName in names) {
  6660. newName = names[oldName];
  6661. if (Ext.isString(newName)) {
  6662. addDeprecatedProperty(target, displayName + oldName, newName);
  6663. } else if (newName && newName.message) {
  6664. addDeprecatedProperty(target, displayName + oldName, null, newName.message);
  6665. } else {
  6666. addDeprecatedProperty(target, displayName + oldName);
  6667. }
  6668. }
  6669. }
  6670. deprecate = statics;
  6671. statics = null;
  6672. target = me;
  6673. }
  6674. }
  6675. },
  6676. extend: function(parentClass) {
  6677. var me = this,
  6678. parentPrototype = parentClass.prototype,
  6679. prototype, name, statics;
  6680. prototype = me.prototype = Ext.Object.chain(parentPrototype);
  6681. prototype.self = me;
  6682. me.superclass = prototype.superclass = parentPrototype;
  6683. if (!parentClass.$isClass) {
  6684. for (name in BasePrototype) {
  6685. if (name in prototype) {
  6686. prototype[name] = BasePrototype[name];
  6687. }
  6688. }
  6689. }
  6690. statics = parentPrototype.$inheritableStatics;
  6691. if (statics) {
  6692. for (name in statics) {
  6693. if (!me.hasOwnProperty(name)) {
  6694. me[name] = parentClass[name];
  6695. }
  6696. }
  6697. }
  6698. if (parentClass.$onExtended) {
  6699. me.$onExtended = parentClass.$onExtended.slice();
  6700. }
  6701. me.getConfigurator();
  6702. },
  6703. $onExtended: [],
  6704. triggerExtended: function() {
  6705. Ext.classSystemMonitor && Ext.classSystemMonitor(this, 'Ext.Base#triggerExtended', arguments);
  6706. var callbacks = this.$onExtended,
  6707. ln = callbacks.length,
  6708. i, callback;
  6709. if (ln > 0) {
  6710. for (i = 0; i < ln; i++) {
  6711. callback = callbacks[i];
  6712. callback.fn.apply(callback.scope || this, arguments);
  6713. }
  6714. }
  6715. },
  6716. onExtended: function(fn, scope) {
  6717. this.$onExtended.push({
  6718. fn: fn,
  6719. scope: scope
  6720. });
  6721. return this;
  6722. },
  6723. addStatics: function(members) {
  6724. this.addMembers(members, true);
  6725. return this;
  6726. },
  6727. addInheritableStatics: function(members) {
  6728. var me = this,
  6729. proto = me.prototype,
  6730. inheritableStatics = me.$inheritableStatics,
  6731. name, member, current;
  6732. if (!inheritableStatics) {
  6733. inheritableStatics = Ext.apply({}, proto.$inheritableStatics);
  6734. me.$inheritableStatics = proto.$inheritableStatics = inheritableStatics;
  6735. }
  6736. var className = Ext.getClassName(me) + '.';
  6737. for (name in members) {
  6738. if (members.hasOwnProperty(name)) {
  6739. member = members[name];
  6740. current = me[name];
  6741. if (typeof member == 'function') {
  6742. member.name = className + name;
  6743. }
  6744. if (typeof current === 'function' && !current.$isClass && !current.$nullFn) {
  6745. member.$previous = current;
  6746. }
  6747. me[name] = member;
  6748. inheritableStatics[name] = true;
  6749. }
  6750. }
  6751. return me;
  6752. },
  6753. addMembers: function(members, isStatic, privacy) {
  6754. var me = this,
  6755. cloneFunction = Ext.Function.clone,
  6756. target = isStatic ? me : me.prototype,
  6757. defaultConfig = !isStatic && target.defaultConfig,
  6758. enumerables = Ext.enumerables,
  6759. privates = members.privates,
  6760. configs, i, ln, member, name, subPrivacy, privateStatics;
  6761. var displayName = (me.$className || '') + '#';
  6762. if (privates) {
  6763. delete members.privates;
  6764. if (!isStatic) {
  6765. privateStatics = privates.statics;
  6766. delete privates.statics;
  6767. }
  6768. subPrivacy = privates.privacy || privacy || 'framework';
  6769. me.addMembers(privates, isStatic, subPrivacy);
  6770. if (privateStatics) {
  6771. me.addMembers(privateStatics, true, subPrivacy);
  6772. }
  6773. }
  6774. for (name in members) {
  6775. if (members.hasOwnProperty(name)) {
  6776. member = members[name];
  6777. if (privacy === true) {
  6778. privacy = 'framework';
  6779. }
  6780. if (member && member.$nullFn && privacy !== member.$privacy) {
  6781. Ext.raise('Cannot use stock function for private method ' + (me.$className ? me.$className + '#' : '') + name);
  6782. }
  6783. if (typeof member === 'function' && !member.$isClass && !member.$nullFn) {
  6784. if (member.$owner) {
  6785. member = cloneFunction(member);
  6786. }
  6787. if (target.hasOwnProperty(name)) {
  6788. member.$previous = target[name];
  6789. }
  6790. member.$owner = me;
  6791. member.$name = name;
  6792. member.name = displayName + name;
  6793. var existing = target[name];
  6794. if (privacy) {
  6795. member.$privacy = privacy;
  6796. if (existing && existing.$privacy && existing.$privacy !== privacy) {
  6797. Ext.privacyViolation(me, existing, member, isStatic);
  6798. }
  6799. } else if (existing && existing.$privacy) {
  6800. Ext.privacyViolation(me, existing, member, isStatic);
  6801. }
  6802. }
  6803. else if (defaultConfig && (name in defaultConfig) && !target.config.hasOwnProperty(name)) {
  6804. (configs || (configs = {}))[name] = member;
  6805. continue;
  6806. }
  6807. target[name] = member;
  6808. }
  6809. }
  6810. if (configs) {
  6811. me.addConfig(configs);
  6812. }
  6813. if (enumerables) {
  6814. for (i = 0 , ln = enumerables.length; i < ln; ++i) {
  6815. if (members.hasOwnProperty(name = enumerables[i])) {
  6816. member = members[name];
  6817. if (member && !member.$nullFn) {
  6818. if (member.$owner) {
  6819. member = cloneFunction(member);
  6820. }
  6821. member.$owner = me;
  6822. member.$name = name;
  6823. member.name = displayName + name;
  6824. if (target.hasOwnProperty(name)) {
  6825. member.$previous = target[name];
  6826. }
  6827. }
  6828. target[name] = member;
  6829. }
  6830. }
  6831. }
  6832. return this;
  6833. },
  6834. addMember: function(name, member) {
  6835. oneMember[name] = member;
  6836. this.addMembers(oneMember);
  6837. delete oneMember[name];
  6838. return this;
  6839. },
  6840. borrow: function(fromClass, members) {
  6841. Ext.classSystemMonitor && Ext.classSystemMonitor(this, 'Ext.Base#borrow', arguments);
  6842. var prototype = fromClass.prototype,
  6843. membersObj = {},
  6844. i, ln, name;
  6845. members = Ext.Array.from(members);
  6846. for (i = 0 , ln = members.length; i < ln; i++) {
  6847. name = members[i];
  6848. membersObj[name] = prototype[name];
  6849. }
  6850. return this.addMembers(membersObj);
  6851. },
  6852. override: function(members) {
  6853. var me = this,
  6854. statics = members.statics,
  6855. inheritableStatics = members.inheritableStatics,
  6856. config = members.config,
  6857. mixins = members.mixins,
  6858. cachedConfig = members.cachedConfig;
  6859. if (statics || inheritableStatics || config) {
  6860. members = Ext.apply({}, members);
  6861. }
  6862. if (statics) {
  6863. me.addMembers(statics, true);
  6864. delete members.statics;
  6865. }
  6866. if (inheritableStatics) {
  6867. me.addInheritableStatics(inheritableStatics);
  6868. delete members.inheritableStatics;
  6869. }
  6870. if (members.platformConfig) {
  6871. me.addPlatformConfig(members);
  6872. }
  6873. if (config) {
  6874. me.addConfig(config);
  6875. delete members.config;
  6876. }
  6877. if (cachedConfig) {
  6878. me.addCachedConfig(cachedConfig);
  6879. delete members.cachedConfig;
  6880. }
  6881. delete members.mixins;
  6882. me.addMembers(members);
  6883. if (mixins) {
  6884. me.mixin(mixins);
  6885. }
  6886. return me;
  6887. },
  6888. addPlatformConfig: function(data) {
  6889. var me = this,
  6890. prototype = me.prototype,
  6891. platformConfigs = data.platformConfig,
  6892. added, classConfigs, configs, configurator, keys, name, value, i, ln;
  6893. delete prototype.platformConfig;
  6894. if (platformConfigs instanceof Array) {
  6895. throw new Error('platformConfigs must be specified as an object.');
  6896. }
  6897. configurator = me.getConfigurator();
  6898. classConfigs = configurator.configs;
  6899. keys = Ext.getPlatformConfigKeys(platformConfigs);
  6900. for (i = 0 , ln = keys.length; i < ln; ++i) {
  6901. configs = platformConfigs[keys[i]];
  6902. added = null;
  6903. for (name in configs) {
  6904. value = configs[name];
  6905. if (name in classConfigs) {
  6906. (added || (added = {}))[name] = value;
  6907. } else {
  6908. prototype[name] = value;
  6909. }
  6910. }
  6911. if (added) {
  6912. configurator.add(added);
  6913. }
  6914. }
  6915. },
  6916. callParent: function(args) {
  6917. var method;
  6918. return (method = this.callParent.caller) && (method.$previous || ((method = method.$owner ? method : method.caller) && method.$owner.superclass.self[method.$name])).apply(this, args || noArgs);
  6919. },
  6920. callSuper: function(args) {
  6921. var method;
  6922. return (method = this.callSuper.caller) && ((method = method.$owner ? method : method.caller) && method.$owner.superclass.self[method.$name]).apply(this, args || noArgs);
  6923. },
  6924. mixin: function(name, mixinClass) {
  6925. var me = this,
  6926. mixin, prototype, key, statics, i, ln, mixinName, mixinValue, mixins, mixinStatics, staticName;
  6927. if (typeof name !== 'string') {
  6928. mixins = name;
  6929. if (mixins instanceof Array) {
  6930. for (i = 0 , ln = mixins.length; i < ln; i++) {
  6931. mixin = mixins[i];
  6932. me.mixin(mixin.prototype.mixinId || mixin.$className, mixin);
  6933. }
  6934. } else {
  6935. for (mixinName in mixins) {
  6936. me.mixin(mixinName, mixins[mixinName]);
  6937. }
  6938. }
  6939. return;
  6940. }
  6941. mixin = mixinClass.prototype;
  6942. prototype = me.prototype;
  6943. if (mixin.onClassMixedIn) {
  6944. mixin.onClassMixedIn.call(mixinClass, me);
  6945. }
  6946. if (!prototype.hasOwnProperty('mixins')) {
  6947. if ('mixins' in prototype) {
  6948. prototype.mixins = Ext.Object.chain(prototype.mixins);
  6949. } else {
  6950. prototype.mixins = {};
  6951. }
  6952. }
  6953. for (key in mixin) {
  6954. mixinValue = mixin[key];
  6955. if (key === 'mixins') {
  6956. Ext.applyIf(prototype.mixins, mixinValue);
  6957. } else if (!(key === 'mixinId' || key === 'config' || key === '$inheritableStatics') && (prototype[key] === undefined)) {
  6958. prototype[key] = mixinValue;
  6959. }
  6960. }
  6961. statics = mixin.$inheritableStatics;
  6962. if (statics) {
  6963. mixinStatics = {};
  6964. for (staticName in statics) {
  6965. if (!me.hasOwnProperty(staticName)) {
  6966. mixinStatics[staticName] = mixinClass[staticName];
  6967. }
  6968. }
  6969. me.addInheritableStatics(mixinStatics);
  6970. }
  6971. if ('config' in mixin) {
  6972. me.addConfig(mixin.config, mixinClass);
  6973. }
  6974. prototype.mixins[name] = mixin;
  6975. if (mixin.afterClassMixedIn) {
  6976. mixin.afterClassMixedIn.call(mixinClass, me);
  6977. }
  6978. return me;
  6979. },
  6980. addConfig: function(config, mixinClass) {
  6981. var cfg = this.$config || this.getConfigurator();
  6982. cfg.add(config, mixinClass);
  6983. },
  6984. addCachedConfig: function(config, isMixin) {
  6985. var cached = {},
  6986. key;
  6987. for (key in config) {
  6988. cached[key] = {
  6989. cached: true,
  6990. $value: config[key]
  6991. };
  6992. }
  6993. this.addConfig(cached, isMixin);
  6994. },
  6995. getConfigurator: function() {
  6996. return this.$config || new Ext.Configurator(this);
  6997. },
  6998. getName: function() {
  6999. return Ext.getClassName(this);
  7000. },
  7001. createAlias: flexSetter(function(alias, origin) {
  7002. aliasOneMember[alias] = function() {
  7003. return this[origin].apply(this, arguments);
  7004. };
  7005. this.override(aliasOneMember);
  7006. delete aliasOneMember[alias];
  7007. })
  7008. });
  7009. for (baseStaticMember in Base) {
  7010. if (Base.hasOwnProperty(baseStaticMember)) {
  7011. baseStaticMembers.push(baseStaticMember);
  7012. }
  7013. }
  7014. Base.$staticMembers = baseStaticMembers;
  7015. Base.getConfigurator();
  7016. Base.addMembers({
  7017. $className: 'Ext.Base',
  7018. isInstance: true,
  7019. $configPrefixed: true,
  7020. $configStrict: true,
  7021. isConfiguring: false,
  7022. isFirstInstance: false,
  7023. destroyed: false,
  7024. clearPropertiesOnDestroy: true,
  7025. clearPrototypeOnDestroy: false,
  7026. statics: function() {
  7027. var method = this.statics.caller,
  7028. self = this.self;
  7029. if (!method) {
  7030. return self;
  7031. }
  7032. return method.$owner;
  7033. },
  7034. callParent: function(args) {
  7035. var method,
  7036. superMethod = (method = this.callParent.caller) && (method.$previous || ((method = method.$owner ? method : method.caller) && method.$owner.superclass[method.$name]));
  7037. if (!superMethod) {
  7038. method = this.callParent.caller;
  7039. var parentClass, methodName;
  7040. if (!method.$owner) {
  7041. if (!method.caller) {
  7042. throw new Error("Attempting to call a protected method from the public scope, which is not allowed");
  7043. }
  7044. method = method.caller;
  7045. }
  7046. parentClass = method.$owner.superclass;
  7047. methodName = method.$name;
  7048. if (!(methodName in parentClass)) {
  7049. throw new Error("this.callParent() was called but there's no such method (" + methodName + ") found in the parent class (" + (Ext.getClassName(parentClass) || 'Object') + ")");
  7050. }
  7051. }
  7052. return superMethod.apply(this, args || noArgs);
  7053. },
  7054. callSuper: function(args) {
  7055. var method,
  7056. superMethod = (method = this.callSuper.caller) && ((method = method.$owner ? method : method.caller) && method.$owner.superclass[method.$name]);
  7057. if (!superMethod) {
  7058. method = this.callSuper.caller;
  7059. var parentClass, methodName;
  7060. if (!method.$owner) {
  7061. if (!method.caller) {
  7062. throw new Error("Attempting to call a protected method from the public scope, which is not allowed");
  7063. }
  7064. method = method.caller;
  7065. }
  7066. parentClass = method.$owner.superclass;
  7067. methodName = method.$name;
  7068. if (!(methodName in parentClass)) {
  7069. throw new Error("this.callSuper() was called but there's no such method (" + methodName + ") found in the parent class (" + (Ext.getClassName(parentClass) || 'Object') + ")");
  7070. }
  7071. }
  7072. return superMethod.apply(this, args || noArgs);
  7073. },
  7074. self: Base,
  7075. constructor: function() {
  7076. return this;
  7077. },
  7078. initConfig: function(instanceConfig) {
  7079. var me = this,
  7080. cfg = me.self.getConfigurator();
  7081. me.initConfig = Ext.emptyFn;
  7082. me.initialConfig = instanceConfig || {};
  7083. cfg.configure(me, instanceConfig);
  7084. return me;
  7085. },
  7086. beforeInitConfig: Ext.emptyFn,
  7087. getConfig: function(name, peek, ifInitialized) {
  7088. var me = this,
  7089. ret, cfg, propName;
  7090. if (name) {
  7091. cfg = me.self.$config.configs[name];
  7092. if (cfg) {
  7093. propName = me.$configPrefixed ? cfg.names.internal : name;
  7094. if (ifInitialized) {
  7095. ret = me.hasOwnProperty(propName) ? me[propName] : null;
  7096. } else if (peek) {
  7097. ret = me.hasOwnProperty(propName) ? me[propName] : me.config[name];
  7098. } else {
  7099. ret = me[cfg.names.get]();
  7100. }
  7101. } else {
  7102. ret = me[name];
  7103. }
  7104. } else {
  7105. ret = me.getCurrentConfig();
  7106. }
  7107. return ret;
  7108. },
  7109. destroyMembers: function() {
  7110. var me = this,
  7111. configs = me.self.$config.configs,
  7112. len = arguments.length,
  7113. cfg, name, value, i;
  7114. for (i = 0; i < len; i++) {
  7115. name = arguments[i];
  7116. cfg = configs[name];
  7117. name = cfg && me.$configPrefixed ? cfg.names.internal : name;
  7118. value = me.hasOwnProperty(name) && me[name];
  7119. if (value) {
  7120. Ext.destroy(value);
  7121. me[name] = null;
  7122. }
  7123. }
  7124. },
  7125. freezeConfig: function(name) {
  7126. var me = this,
  7127. config = Ext.Config.get(name),
  7128. names = config.names,
  7129. value = me[names.get]();
  7130. me[names.set] = function(v) {
  7131. if (v !== value) {
  7132. Ext.raise('Cannot change frozen config "' + name + '"');
  7133. }
  7134. return me;
  7135. };
  7136. if (!Ext.isIE8) {
  7137. Object.defineProperty(me, me.$configPrefixed ? names.internal : name, {
  7138. get: function() {
  7139. return value;
  7140. },
  7141. set: function(v) {
  7142. if (v !== value) {
  7143. Ext.raise('Cannot change frozen config "' + name + '"');
  7144. }
  7145. }
  7146. });
  7147. }
  7148. },
  7149. setConfig: function(name, value, options) {
  7150. var me = this,
  7151. configurator, config, prop;
  7152. if (name) {
  7153. configurator = me.self.getConfigurator();
  7154. if (typeof name === 'string') {
  7155. config = configurator.configs[name];
  7156. if (!config) {
  7157. if (me.$configStrict) {
  7158. prop = me.self.prototype[name];
  7159. if ((typeof prop === 'function') && !prop.$nullFn) {
  7160. Ext.Error.raise("Cannot override method " + name + " on " + me.$className + " instance.");
  7161. return me;
  7162. } else
  7163. {
  7164. if (name !== 'type') {
  7165. Ext.log.warn('No such config "' + name + '" for class ' + me.$className);
  7166. }
  7167. }
  7168. }
  7169. config = Ext.Config.map[name] || Ext.Config.get(name);
  7170. }
  7171. if (me[config.names.set]) {
  7172. me[config.names.set](value);
  7173. } else {
  7174. me[name] = value;
  7175. }
  7176. } else {
  7177. configurator.reconfigure(me, name, options || value);
  7178. }
  7179. }
  7180. return me;
  7181. },
  7182. getCurrentConfig: function() {
  7183. var cfg = this.self.getConfigurator();
  7184. return cfg.getCurrentConfig(this);
  7185. },
  7186. hasConfig: function(name) {
  7187. return name in this.defaultConfig;
  7188. },
  7189. getInitialConfig: function(name) {
  7190. var config = this.config;
  7191. if (!name) {
  7192. return config;
  7193. }
  7194. return config[name];
  7195. },
  7196. $links: null,
  7197. link: function(name, value) {
  7198. var me = this,
  7199. links = me.$links || (me.$links = {});
  7200. links[name] = true;
  7201. me[name] = value;
  7202. return value;
  7203. },
  7204. unlink: function(names) {
  7205. var me = this,
  7206. i, ln, link, value;
  7207. if (!Ext.isArray(names)) {
  7208. Ext.raise('Invalid argument - expected array of strings');
  7209. }
  7210. for (i = 0 , ln = names.length; i < ln; i++) {
  7211. link = names[i];
  7212. value = me[link];
  7213. if (value) {
  7214. if (value.isInstance && !value.destroyed) {
  7215. value.destroy();
  7216. } else if (value.parentNode && 'nodeType' in value) {
  7217. value.parentNode.removeChild(value);
  7218. }
  7219. }
  7220. me[link] = null;
  7221. }
  7222. return me;
  7223. },
  7224. $reap: function() {
  7225. var me = this,
  7226. protectedProps = me.$noClearOnDestroy,
  7227. props, prop, value, type, i, len;
  7228. props = Ext.Object.getKeys(me);
  7229. for (i = 0 , len = props.length; i < len; i++) {
  7230. prop = props[i];
  7231. if (!protectedProps || !protectedProps[prop]) {
  7232. value = me[prop];
  7233. type = typeof value;
  7234. if (type === 'object' || (type === 'function' && !value.$noClearOnDestroy)) {
  7235. me[prop] = null;
  7236. }
  7237. }
  7238. }
  7239. me.$nulled = true;
  7240. if (Object.setPrototypeOf) {
  7241. if (me.clearPrototypeOnDestroy && !me.$vetoClearingPrototypeOnDestroy) {
  7242. props = me.$preservePrototypeProperties;
  7243. if (props) {
  7244. for (i = 0 , len = props.length; i < len; i++) {
  7245. prop = props[i];
  7246. if (!me.hasOwnProperty(prop)) {
  7247. me[prop] = me[prop];
  7248. }
  7249. }
  7250. }
  7251. Object.setPrototypeOf(me, null);
  7252. }
  7253. }
  7254. },
  7255. destroy: function() {
  7256. var me = this,
  7257. links = me.$links,
  7258. clearPropertiesOnDestroy = me.clearPropertiesOnDestroy;
  7259. if (links) {
  7260. me.$links = null;
  7261. me.unlink(Ext.Object.getKeys(links));
  7262. }
  7263. me.destroy = Ext.emptyFn;
  7264. me.isDestroyed = me.destroyed = true;
  7265. if (clearPropertiesOnDestroy === true) {
  7266. if (!me.isObservable) {
  7267. me.$reap();
  7268. }
  7269. } else if (clearPropertiesOnDestroy) {
  7270. if (clearPropertiesOnDestroy !== 'async') {
  7271. Ext.raise('Invalid value for clearPropertiesOnDestroy');
  7272. }
  7273. Reaper.add(me);
  7274. }
  7275. }
  7276. });
  7277. BasePrototype.callOverridden = BasePrototype.callParent;
  7278. Ext.privacyViolation = function(cls, existing, member, isStatic) {
  7279. var name = member.$name,
  7280. conflictCls = existing.$owner && existing.$owner.$className,
  7281. s = isStatic ? 'static ' : '',
  7282. msg = member.$privacy ? 'Private ' + s + member.$privacy + ' method "' + name + '"' : 'Public ' + s + 'method "' + name + '"';
  7283. if (cls.$className) {
  7284. msg = cls.$className + ': ' + msg;
  7285. }
  7286. if (!existing.$privacy) {
  7287. msg += conflictCls ? ' hides public method inherited from ' + conflictCls : ' hides inherited public method.';
  7288. } else {
  7289. msg += conflictCls ? ' conflicts with private ' + existing.$privacy + ' method declared by ' + conflictCls : ' conflicts with inherited private ' + existing.$privacy + ' method.';
  7290. }
  7291. var compat = Ext.getCompatVersion();
  7292. var ver = Ext.getVersion();
  7293. if (ver && compat && compat.lt(ver)) {
  7294. Ext.log.error(msg);
  7295. } else {
  7296. Ext.raise(msg);
  7297. }
  7298. };
  7299. Ext.Reaper.tick.$skipTimerCheck = true;
  7300. return Base;
  7301. }(Ext.Function.flexSetter));
  7302. (function(LRU, prototype) {
  7303. (Ext.util || (Ext.util = {})).LRU = LRU = function(config) {
  7304. var me = this,
  7305. head;
  7306. if (config) {
  7307. Ext.apply(me, config);
  7308. }
  7309. me.head = head = {
  7310. id: (me.seed = 0),
  7311. key: null,
  7312. value: null
  7313. };
  7314. me.map = {};
  7315. head.next = head.prev = head;
  7316. };
  7317. LRU.prototype = prototype = {
  7318. count: 0,
  7319. add: function(key, value) {
  7320. var me = this,
  7321. map = me.map,
  7322. entry = map[key];
  7323. if (entry) {
  7324. me.unlink(entry);
  7325. --me.count;
  7326. }
  7327. map[key] = entry = {
  7328. id: ++me.seed,
  7329. key: key,
  7330. value: value
  7331. };
  7332. me.link(entry);
  7333. ++me.count;
  7334. return entry;
  7335. },
  7336. clear: function(fn, scope) {
  7337. var me = this,
  7338. head = me.head,
  7339. entry = head.next;
  7340. head.next = head.prev = head;
  7341. me.count = 0;
  7342. if (fn && !fn.$nullFn) {
  7343. for (; entry !== head; entry = entry.next) {
  7344. fn.call(scope || me, entry.key, entry.value);
  7345. }
  7346. }
  7347. },
  7348. each: function(fn, scope) {
  7349. scope = scope || this;
  7350. for (var head = this.head,
  7351. ent = head.next; ent !== head; ent = ent.next) {
  7352. if (fn.call(scope, ent.key, ent.value)) {
  7353. break;
  7354. }
  7355. }
  7356. },
  7357. prune: function(fn, scope) {
  7358. var me = this,
  7359. entry = me.head.prev,
  7360. ret;
  7361. if (me.count) {
  7362. ret = entry.value;
  7363. me.unlink(entry);
  7364. --me.count;
  7365. if (fn) {
  7366. fn.call(scope || me, entry.key, ret);
  7367. }
  7368. }
  7369. return ret;
  7370. },
  7371. remove: function(key) {
  7372. var me = this,
  7373. map = me.map,
  7374. entry = map[key],
  7375. value;
  7376. if (entry) {
  7377. me.unlink(entry);
  7378. value = entry.value;
  7379. delete map[key];
  7380. --me.count;
  7381. }
  7382. return value;
  7383. },
  7384. touch: function(key) {
  7385. var me = this,
  7386. head = me.head,
  7387. entry = me.map[key];
  7388. if (entry && entry.prev !== head) {
  7389. me.unlink(entry);
  7390. me.link(entry);
  7391. }
  7392. },
  7393. trim: function(size, fn, scope) {
  7394. while (this.count > size) {
  7395. this.prune(fn, scope);
  7396. }
  7397. },
  7398. link: function(entry) {
  7399. var head = this.head,
  7400. first = head.next;
  7401. entry.next = first;
  7402. entry.prev = head;
  7403. head.next = entry;
  7404. first.prev = entry;
  7405. },
  7406. unlink: function(entry) {
  7407. var next = entry.next,
  7408. prev = entry.prev;
  7409. prev.next = next;
  7410. next.prev = prev;
  7411. }
  7412. };
  7413. prototype.destroy = function() {
  7414. this.clear.apply(this, arguments);
  7415. };
  7416. }());
  7417. (function(LRU, fn, Cache) {
  7418. Ext.util.Cache = Cache = function(config) {
  7419. LRU.call(this, config);
  7420. };
  7421. fn.prototype = LRU.prototype;
  7422. Cache.prototype = Ext.apply(new fn(), {
  7423. maxSize: 100,
  7424. clear: function() {
  7425. LRU.prototype.clear.call(this, this.evict);
  7426. },
  7427. get: function(key) {
  7428. var me = this,
  7429. entry = me.map[key],
  7430. value;
  7431. if (entry) {
  7432. value = entry.value;
  7433. me.touch(key);
  7434. } else {
  7435. value = me.miss.apply(me, arguments);
  7436. me.add(key, value);
  7437. me.trim(me.maxSize, me.evict);
  7438. }
  7439. return value;
  7440. },
  7441. evict: Ext.emptyFn
  7442. });
  7443. }(Ext.util.LRU, function() {}));
  7444. (function() {
  7445. var ExtClass,
  7446. Base = Ext.Base,
  7447. baseStaticMembers = Base.$staticMembers,
  7448. ruleKeySortFn = function(a, b) {
  7449. return (a.length - b.length) || ((a < b) ? -1 : ((a > b) ? 1 : 0));
  7450. };
  7451. function makeCtor(className) {
  7452. function constructor() {
  7453. return this.constructor.apply(this, arguments) || null;
  7454. }
  7455. if (className) {
  7456. constructor.name = className;
  7457. }
  7458. return constructor;
  7459. }
  7460. Ext.Class = ExtClass = function(Class, data, onCreated) {
  7461. if (typeof Class != 'function') {
  7462. onCreated = data;
  7463. data = Class;
  7464. Class = null;
  7465. }
  7466. if (!data) {
  7467. data = {};
  7468. }
  7469. Class = ExtClass.create(Class, data);
  7470. ExtClass.process(Class, data, onCreated);
  7471. return Class;
  7472. };
  7473. Ext.apply(ExtClass, {
  7474. makeCtor: makeCtor,
  7475. onBeforeCreated: function(Class, data, hooks) {
  7476. Ext.classSystemMonitor && Ext.classSystemMonitor(Class, '>> Ext.Class#onBeforeCreated', arguments);
  7477. Class.addMembers(data);
  7478. hooks.onCreated.call(Class, Class);
  7479. Ext.classSystemMonitor && Ext.classSystemMonitor(Class, '<< Ext.Class#onBeforeCreated', arguments);
  7480. },
  7481. create: function(Class, data) {
  7482. var i = baseStaticMembers.length,
  7483. name;
  7484. if (!Class) {
  7485. Class = makeCtor(
  7486. data.$className);
  7487. }
  7488. while (i--) {
  7489. name = baseStaticMembers[i];
  7490. Class[name] = Base[name];
  7491. }
  7492. return Class;
  7493. },
  7494. process: function(Class, data, onCreated) {
  7495. var preprocessorStack = data.preprocessors || ExtClass.defaultPreprocessors,
  7496. registeredPreprocessors = this.preprocessors,
  7497. hooks = {
  7498. onBeforeCreated: this.onBeforeCreated
  7499. },
  7500. preprocessors = [],
  7501. preprocessor, preprocessorsProperties, i, ln, j, subLn, preprocessorProperty;
  7502. delete data.preprocessors;
  7503. Class._classHooks = hooks;
  7504. for (i = 0 , ln = preprocessorStack.length; i < ln; i++) {
  7505. preprocessor = preprocessorStack[i];
  7506. if (typeof preprocessor == 'string') {
  7507. preprocessor = registeredPreprocessors[preprocessor];
  7508. preprocessorsProperties = preprocessor.properties;
  7509. if (preprocessorsProperties === true) {
  7510. preprocessors.push(preprocessor.fn);
  7511. } else if (preprocessorsProperties) {
  7512. for (j = 0 , subLn = preprocessorsProperties.length; j < subLn; j++) {
  7513. preprocessorProperty = preprocessorsProperties[j];
  7514. if (data.hasOwnProperty(preprocessorProperty)) {
  7515. preprocessors.push(preprocessor.fn);
  7516. break;
  7517. }
  7518. }
  7519. }
  7520. } else {
  7521. preprocessors.push(preprocessor);
  7522. }
  7523. }
  7524. hooks.onCreated = onCreated ? onCreated : Ext.emptyFn;
  7525. hooks.preprocessors = preprocessors;
  7526. this.doProcess(Class, data, hooks);
  7527. },
  7528. doProcess: function(Class, data, hooks) {
  7529. var me = this,
  7530. preprocessors = hooks.preprocessors,
  7531. preprocessor = preprocessors.shift(),
  7532. doProcess = me.doProcess;
  7533. for (; preprocessor; preprocessor = preprocessors.shift()) {
  7534. if (preprocessor.call(me, Class, data, hooks, doProcess) === false) {
  7535. return;
  7536. }
  7537. }
  7538. hooks.onBeforeCreated.apply(me, arguments);
  7539. },
  7540. preprocessors: {},
  7541. registerPreprocessor: function(name, fn, properties, position, relativeTo) {
  7542. if (!position) {
  7543. position = 'last';
  7544. }
  7545. if (!properties) {
  7546. properties = [
  7547. name
  7548. ];
  7549. }
  7550. this.preprocessors[name] = {
  7551. name: name,
  7552. properties: properties || false,
  7553. fn: fn
  7554. };
  7555. this.setDefaultPreprocessorPosition(name, position, relativeTo);
  7556. return this;
  7557. },
  7558. getPreprocessor: function(name) {
  7559. return this.preprocessors[name];
  7560. },
  7561. getPreprocessors: function() {
  7562. return this.preprocessors;
  7563. },
  7564. defaultPreprocessors: [],
  7565. getDefaultPreprocessors: function() {
  7566. return this.defaultPreprocessors;
  7567. },
  7568. setDefaultPreprocessors: function(preprocessors) {
  7569. this.defaultPreprocessors = Ext.Array.from(preprocessors);
  7570. return this;
  7571. },
  7572. setDefaultPreprocessorPosition: function(name, offset, relativeName) {
  7573. var defaultPreprocessors = this.defaultPreprocessors,
  7574. index;
  7575. if (typeof offset == 'string') {
  7576. if (offset === 'first') {
  7577. defaultPreprocessors.unshift(name);
  7578. return this;
  7579. } else if (offset === 'last') {
  7580. defaultPreprocessors.push(name);
  7581. return this;
  7582. }
  7583. offset = (offset === 'after') ? 1 : -1;
  7584. }
  7585. index = Ext.Array.indexOf(defaultPreprocessors, relativeName);
  7586. if (index !== -1) {
  7587. Ext.Array.splice(defaultPreprocessors, Math.max(0, index + offset), 0, name);
  7588. }
  7589. return this;
  7590. }
  7591. });
  7592. ExtClass.registerPreprocessor('extend', function(Class, data, hooks) {
  7593. Ext.classSystemMonitor && Ext.classSystemMonitor(Class, 'Ext.Class#extendPreProcessor', arguments);
  7594. var Base = Ext.Base,
  7595. basePrototype = Base.prototype,
  7596. extend = data.extend,
  7597. Parent, parentPrototype, i;
  7598. delete data.extend;
  7599. if (extend && extend !== Object) {
  7600. Parent = extend;
  7601. } else {
  7602. Parent = Base;
  7603. }
  7604. parentPrototype = Parent.prototype;
  7605. if (!Parent.$isClass) {
  7606. for (i in basePrototype) {
  7607. if (!parentPrototype[i]) {
  7608. parentPrototype[i] = basePrototype[i];
  7609. }
  7610. }
  7611. }
  7612. Class.extend(Parent);
  7613. Class.triggerExtended.apply(Class, arguments);
  7614. if (data.onClassExtended) {
  7615. Class.onExtended(data.onClassExtended, Class);
  7616. delete data.onClassExtended;
  7617. }
  7618. }, true);
  7619. ExtClass.registerPreprocessor('privates', function(Class, data) {
  7620. Ext.classSystemMonitor && Ext.classSystemMonitor(Class, 'Ext.Class#privatePreprocessor', arguments);
  7621. var privates = data.privates,
  7622. statics = privates.statics,
  7623. privacy = privates.privacy || true;
  7624. delete data.privates;
  7625. delete privates.statics;
  7626. Class.addMembers(privates, false, privacy);
  7627. if (statics) {
  7628. Class.addMembers(statics, true, privacy);
  7629. }
  7630. });
  7631. ExtClass.registerPreprocessor('statics', function(Class, data) {
  7632. Ext.classSystemMonitor && Ext.classSystemMonitor(Class, 'Ext.Class#staticsPreprocessor', arguments);
  7633. Class.addStatics(data.statics);
  7634. delete data.statics;
  7635. });
  7636. ExtClass.registerPreprocessor('inheritableStatics', function(Class, data) {
  7637. Ext.classSystemMonitor && Ext.classSystemMonitor(Class, 'Ext.Class#inheritableStaticsPreprocessor', arguments);
  7638. Class.addInheritableStatics(data.inheritableStatics);
  7639. delete data.inheritableStatics;
  7640. });
  7641. Ext.createRuleFn = function(code) {
  7642. return new Function('$c', 'with($c) { try { return (' + code + '); } catch(e) { return false;}}');
  7643. };
  7644. Ext.expressionCache = new Ext.util.Cache({
  7645. miss: Ext.createRuleFn
  7646. });
  7647. Ext.ruleKeySortFn = ruleKeySortFn;
  7648. Ext.getPlatformConfigKeys = function(platformConfig) {
  7649. var ret = [],
  7650. platform, rule;
  7651. for (platform in platformConfig) {
  7652. rule = Ext.expressionCache.get(platform);
  7653. if (rule(Ext.platformTags)) {
  7654. ret.push(platform);
  7655. }
  7656. }
  7657. ret.sort(ruleKeySortFn);
  7658. return ret;
  7659. };
  7660. ExtClass.registerPreprocessor('config', function(Class, data) {
  7661. if (data.hasOwnProperty('$configPrefixed')) {
  7662. Class.prototype.$configPrefixed = data.$configPrefixed;
  7663. }
  7664. Class.addConfig(data.config);
  7665. delete data.config;
  7666. });
  7667. ExtClass.registerPreprocessor('cachedConfig', function(Class, data) {
  7668. if (data.hasOwnProperty('$configPrefixed')) {
  7669. Class.prototype.$configPrefixed = data.$configPrefixed;
  7670. }
  7671. Class.addCachedConfig(data.cachedConfig);
  7672. delete data.cachedConfig;
  7673. });
  7674. ExtClass.registerPreprocessor('mixins', function(Class, data, hooks) {
  7675. Ext.classSystemMonitor && Ext.classSystemMonitor(Class, 'Ext.Class#mixinsPreprocessor', arguments);
  7676. var mixins = data.mixins,
  7677. onCreated = hooks.onCreated;
  7678. delete data.mixins;
  7679. hooks.onCreated = function() {
  7680. Ext.classSystemMonitor && Ext.classSystemMonitor(Class, 'Ext.Class#mixinsPreprocessor#beforeCreated', arguments);
  7681. hooks.onCreated = onCreated;
  7682. Class.mixin(mixins);
  7683. return hooks.onCreated.apply(this, arguments);
  7684. };
  7685. });
  7686. Ext.extend = function(Class, Parent, members) {
  7687. Ext.classSystemMonitor && Ext.classSystemMonitor(Class, 'Ext.Class#extend-backwards-compatible', arguments);
  7688. if (arguments.length === 2 && Ext.isObject(Parent)) {
  7689. members = Parent;
  7690. Parent = Class;
  7691. Class = null;
  7692. }
  7693. var cls;
  7694. if (!Parent) {
  7695. throw new Error("[Ext.extend] Attempting to extend from a class which has not been loaded on the page.");
  7696. }
  7697. members.extend = Parent;
  7698. members.preprocessors = [
  7699. 'extend',
  7700. 'statics',
  7701. 'inheritableStatics',
  7702. 'mixins',
  7703. 'config'
  7704. ];
  7705. if (Class) {
  7706. cls = new ExtClass(Class, members);
  7707. cls.prototype.constructor = Class;
  7708. } else {
  7709. cls = new ExtClass(members);
  7710. }
  7711. cls.prototype.override = function(o) {
  7712. for (var m in o) {
  7713. if (o.hasOwnProperty(m)) {
  7714. this[m] = o[m];
  7715. }
  7716. }
  7717. };
  7718. return cls;
  7719. };
  7720. }());
  7721. Ext.Inventory = function() {
  7722. var me = this;
  7723. me.names = [];
  7724. me.paths = {};
  7725. me.alternateToName = {};
  7726. me.aliasToName = {};
  7727. me.nameToAliases = {};
  7728. me.nameToAlternates = {};
  7729. me.nameToPrefix = {};
  7730. };
  7731. Ext.Inventory.prototype = {
  7732. _array1: [
  7733. 0
  7734. ],
  7735. prefixes: null,
  7736. dotRe: /\./g,
  7737. wildcardRe: /\*/g,
  7738. addAlias: function(className, alias, update) {
  7739. return this.addMapping(className, alias, this.aliasToName, this.nameToAliases, update);
  7740. },
  7741. addAlternate: function(className, alternate) {
  7742. return this.addMapping(className, alternate, this.alternateToName, this.nameToAlternates);
  7743. },
  7744. addMapping: function(className, alternate, toName, nameTo, update) {
  7745. var name = className.$className || className,
  7746. mappings = name,
  7747. array = this._array1,
  7748. a, aliases, cls, i, length, nameMapping;
  7749. if (Ext.isString(name)) {
  7750. mappings = {};
  7751. mappings[name] = alternate;
  7752. }
  7753. for (cls in mappings) {
  7754. aliases = mappings[cls];
  7755. if (Ext.isString(aliases)) {
  7756. array[0] = aliases;
  7757. aliases = array;
  7758. }
  7759. length = aliases.length;
  7760. nameMapping = nameTo[cls] || (nameTo[cls] = []);
  7761. for (i = 0; i < length; ++i) {
  7762. if (!(a = aliases[i])) {
  7763. continue;
  7764. }
  7765. if (toName[a] !== cls) {
  7766. if (!update && toName[a] && ('Ext.Gadget' !== a)) {
  7767. Ext.log.warn("Overriding existing mapping: '" + a + "' From '" + toName[a] + "' to '" + cls + "'. Is this intentional?");
  7768. }
  7769. toName[a] = cls;
  7770. nameMapping.push(a);
  7771. }
  7772. }
  7773. }
  7774. },
  7775. getAliasesByName: function(name) {
  7776. return this.nameToAliases[name] || null;
  7777. },
  7778. getAlternatesByName: function(name) {
  7779. return this.nameToAlternates[name] || null;
  7780. },
  7781. getNameByAlias: function(alias) {
  7782. return this.aliasToName[alias] || '';
  7783. },
  7784. getNameByAlternate: function(alternate) {
  7785. return this.alternateToName[alternate] || '';
  7786. },
  7787. getNamesByExpression: function(expression, exclude, accumulate) {
  7788. var me = this,
  7789. aliasToName = me.aliasToName,
  7790. alternateToName = me.alternateToName,
  7791. nameToAliases = me.nameToAliases,
  7792. nameToAlternates = me.nameToAlternates,
  7793. map = accumulate ? exclude : {},
  7794. names = [],
  7795. expressions = Ext.isString(expression) ? [
  7796. expression
  7797. ] : expression,
  7798. length = expressions.length,
  7799. wildcardRe = me.wildcardRe,
  7800. expr, i, list, match, n, name, regex;
  7801. for (i = 0; i < length; ++i) {
  7802. if ((expr = expressions[i]).indexOf('*') < 0) {
  7803. if (!(name = aliasToName[expr])) {
  7804. if (!(name = alternateToName[expr])) {
  7805. name = expr;
  7806. }
  7807. }
  7808. if (!(name in map) && !(exclude && (name in exclude))) {
  7809. map[name] = 1;
  7810. names.push(name);
  7811. }
  7812. } else {
  7813. regex = new RegExp('^' + expr.replace(wildcardRe, '(.*?)') + '$');
  7814. for (name in nameToAliases) {
  7815. if (!(name in map) && !(exclude && (name in exclude))) {
  7816. if (!(match = regex.test(name))) {
  7817. n = (list = nameToAliases[name]).length;
  7818. while (!match && n-- > 0) {
  7819. match = regex.test(list[n]);
  7820. }
  7821. list = nameToAlternates[name];
  7822. if (list && !match) {
  7823. n = list.length;
  7824. while (!match && n-- > 0) {
  7825. match = regex.test(list[n]);
  7826. }
  7827. }
  7828. }
  7829. if (match) {
  7830. map[name] = 1;
  7831. names.push(name);
  7832. }
  7833. }
  7834. }
  7835. }
  7836. }
  7837. return names;
  7838. },
  7839. getPath: function(className) {
  7840. var me = this,
  7841. paths = me.paths,
  7842. ret = '',
  7843. prefix;
  7844. if (className in paths) {
  7845. ret = paths[className];
  7846. } else {
  7847. prefix = me.nameToPrefix[className] || (me.nameToPrefix[className] = me.getPrefix(className));
  7848. if (prefix) {
  7849. className = className.substring(prefix.length + 1);
  7850. ret = paths[prefix];
  7851. if (ret) {
  7852. ret += '/';
  7853. }
  7854. }
  7855. ret += className.replace(me.dotRe, '/') + '.js';
  7856. }
  7857. return ret;
  7858. },
  7859. getPrefix: function(className) {
  7860. if (className in this.paths) {
  7861. return className;
  7862. } else if (className in this.nameToPrefix) {
  7863. return this.nameToPrefix[className];
  7864. }
  7865. var prefixes = this.getPrefixes(),
  7866. length = className.length,
  7867. items, currChar, currSubstr, prefix, j, jlen;
  7868. while (length-- > 0) {
  7869. items = prefixes[length];
  7870. if (items) {
  7871. currChar = className.charAt(length);
  7872. if (currChar !== '.') {
  7873. continue;
  7874. }
  7875. currSubstr = className.substring(0, length);
  7876. for (j = 0 , jlen = items.length; j < jlen; j++) {
  7877. prefix = items[j];
  7878. if (prefix === className.substring(0, length)) {
  7879. return prefix;
  7880. }
  7881. }
  7882. }
  7883. }
  7884. return '';
  7885. },
  7886. getPrefixes: function() {
  7887. var me = this,
  7888. prefixes = me.prefixes,
  7889. names, name, nameLength, items, i, len;
  7890. if (!prefixes) {
  7891. names = me.names.slice(0);
  7892. me.prefixes = prefixes = [];
  7893. for (i = 0 , len = names.length; i < len; i++) {
  7894. name = names[i];
  7895. nameLength = name.length;
  7896. items = prefixes[nameLength] || (prefixes[nameLength] = []);
  7897. items.push(name);
  7898. }
  7899. }
  7900. return prefixes;
  7901. },
  7902. removeName: function(name) {
  7903. var me = this,
  7904. aliasToName = me.aliasToName,
  7905. alternateToName = me.alternateToName,
  7906. nameToAliases = me.nameToAliases,
  7907. nameToAlternates = me.nameToAlternates,
  7908. aliases = nameToAliases[name],
  7909. alternates = nameToAlternates[name],
  7910. i, a;
  7911. delete nameToAliases[name];
  7912. delete nameToAlternates[name];
  7913. delete me.nameToPrefix[name];
  7914. if (aliases) {
  7915. for (i = aliases.length; i--; ) {
  7916. if (name === aliasToName[a = aliases[i]]) {
  7917. delete aliasToName[a];
  7918. }
  7919. }
  7920. }
  7921. if (alternates) {
  7922. for (i = alternates.length; i--; ) {
  7923. if (name === alternateToName[a = alternates[i]]) {
  7924. delete alternateToName[a];
  7925. }
  7926. }
  7927. }
  7928. },
  7929. resolveName: function(name) {
  7930. var me = this,
  7931. trueName;
  7932. if (!(name in me.nameToAliases)) {
  7933. if (!(trueName = me.aliasToName[name])) {
  7934. trueName = me.alternateToName[name];
  7935. }
  7936. }
  7937. return trueName || name;
  7938. },
  7939. select: function(receiver, scope) {
  7940. var me = this,
  7941. excludes = {},
  7942. ret = {
  7943. excludes: excludes,
  7944. exclude: function() {
  7945. me.getNamesByExpression(arguments[0], excludes, true);
  7946. return this;
  7947. }
  7948. },
  7949. name;
  7950. for (name in receiver) {
  7951. ret[name] = me.selectMethod(excludes, receiver[name], scope || receiver);
  7952. }
  7953. return ret;
  7954. },
  7955. selectMethod: function(excludes, fn, scope) {
  7956. var me = this;
  7957. return function(include) {
  7958. var args = Ext.Array.slice(arguments, 1);
  7959. args.unshift(me.getNamesByExpression(include, excludes));
  7960. return fn.apply(scope, args);
  7961. };
  7962. },
  7963. setPath: Ext.Function.flexSetter(function(name, path) {
  7964. var me = this;
  7965. me.paths[name] = path;
  7966. me.names.push(name);
  7967. me.prefixes = null;
  7968. me.nameToPrefix = {};
  7969. return me;
  7970. })
  7971. };
  7972. Ext.ClassManager = (function(Class, alias, arraySlice, arrayFrom, global) {
  7973. var makeCtor = Ext.Class.makeCtor,
  7974. nameLookupStack = [],
  7975. namespaceCache = {
  7976. Ext: {
  7977. name: 'Ext',
  7978. value: Ext
  7979. }
  7980. },
  7981. Manager = Ext.apply(new Ext.Inventory(), {
  7982. classes: {},
  7983. classCount: 0,
  7984. classState: {},
  7985. existCache: {},
  7986. instantiators: [],
  7987. isCreated: function(className) {
  7988. if (typeof className !== 'string' || className.length < 1) {
  7989. throw new Error("[Ext.ClassManager] Invalid classname, must be a string and must not be empty");
  7990. }
  7991. if (Manager.classes[className] || Manager.existCache[className]) {
  7992. return true;
  7993. }
  7994. if (!Manager.lookupName(className, false)) {
  7995. return false;
  7996. }
  7997. Manager.triggerCreated(className);
  7998. return true;
  7999. },
  8000. createdListeners: [],
  8001. nameCreatedListeners: {},
  8002. existsListeners: [],
  8003. nameExistsListeners: {},
  8004. overrideMap: {},
  8005. triggerCreated: function(className, state) {
  8006. Manager.existCache[className] = state || 1;
  8007. Manager.classState[className] += 40;
  8008. Manager.notify(className, Manager.createdListeners, Manager.nameCreatedListeners);
  8009. },
  8010. onCreated: function(fn, scope, className) {
  8011. Manager.addListener(fn, scope, className, Manager.createdListeners, Manager.nameCreatedListeners);
  8012. },
  8013. notify: function(className, listeners, nameListeners) {
  8014. var alternateNames = Manager.getAlternatesByName(className),
  8015. names = [
  8016. className
  8017. ],
  8018. i, ln, j, subLn, listener, name;
  8019. for (i = 0 , ln = listeners.length; i < ln; i++) {
  8020. listener = listeners[i];
  8021. listener.fn.call(listener.scope, className);
  8022. }
  8023. while (names) {
  8024. for (i = 0 , ln = names.length; i < ln; i++) {
  8025. name = names[i];
  8026. listeners = nameListeners[name];
  8027. if (listeners) {
  8028. for (j = 0 , subLn = listeners.length; j < subLn; j++) {
  8029. listener = listeners[j];
  8030. listener.fn.call(listener.scope, name);
  8031. }
  8032. delete nameListeners[name];
  8033. }
  8034. }
  8035. names = alternateNames;
  8036. alternateNames = null;
  8037. }
  8038. },
  8039. addListener: function(fn, scope, className, listeners, nameListeners) {
  8040. if (Ext.isArray(className)) {
  8041. fn = Ext.Function.createBarrier(className.length, fn, scope);
  8042. for (i = 0; i < className.length; i++) {
  8043. this.addListener(fn, null, className[i], listeners, nameListeners);
  8044. }
  8045. return;
  8046. }
  8047. var i,
  8048. listener = {
  8049. fn: fn,
  8050. scope: scope
  8051. };
  8052. if (className) {
  8053. if (this.isCreated(className)) {
  8054. fn.call(scope, className);
  8055. return;
  8056. }
  8057. if (!nameListeners[className]) {
  8058. nameListeners[className] = [];
  8059. }
  8060. nameListeners[className].push(listener);
  8061. } else {
  8062. listeners.push(listener);
  8063. }
  8064. },
  8065. $namespaceCache: namespaceCache,
  8066. addRootNamespaces: function(namespaces) {
  8067. for (var name in namespaces) {
  8068. namespaceCache[name] = {
  8069. name: name,
  8070. value: namespaces[name]
  8071. };
  8072. }
  8073. },
  8074. clearNamespaceCache: function() {
  8075. nameLookupStack.length = 0;
  8076. for (var name in namespaceCache) {
  8077. if (!namespaceCache[name].value) {
  8078. delete namespaceCache[name];
  8079. }
  8080. }
  8081. },
  8082. getNamespaceEntry: function(namespace) {
  8083. if (typeof namespace !== 'string') {
  8084. return namespace;
  8085. }
  8086. var entry = namespaceCache[namespace],
  8087. i;
  8088. if (!entry) {
  8089. i = namespace.lastIndexOf('.');
  8090. if (i < 0) {
  8091. entry = {
  8092. name: namespace
  8093. };
  8094. } else {
  8095. entry = {
  8096. name: namespace.substring(i + 1),
  8097. parent: Manager.getNamespaceEntry(namespace.substring(0, i))
  8098. };
  8099. }
  8100. namespaceCache[namespace] = entry;
  8101. }
  8102. return entry;
  8103. },
  8104. lookupName: function(namespace, autoCreate) {
  8105. var entry = Manager.getNamespaceEntry(namespace),
  8106. scope = Ext.global,
  8107. i = 0,
  8108. e, parent;
  8109. for (e = entry; e; e = e.parent) {
  8110. nameLookupStack[i++] = e;
  8111. }
  8112. while (scope && i-- > 0) {
  8113. e = nameLookupStack[i];
  8114. parent = scope;
  8115. scope = e.value || scope[e.name];
  8116. if (!scope && autoCreate) {
  8117. parent[e.name] = scope = {};
  8118. }
  8119. }
  8120. return scope;
  8121. },
  8122. setNamespace: function(namespace, value) {
  8123. var entry = Manager.getNamespaceEntry(namespace),
  8124. scope = Ext.global;
  8125. if (entry.parent) {
  8126. scope = Manager.lookupName(entry.parent, true);
  8127. }
  8128. scope[entry.name] = value;
  8129. return value;
  8130. },
  8131. setXType: function(cls, xtype) {
  8132. var className = cls.$className,
  8133. C = className ? cls : Manager.get(className = cls),
  8134. proto = C.prototype,
  8135. xtypes = proto.xtypes,
  8136. xtypesChain = proto.xtypesChain,
  8137. xtypesMap = proto.xtypesMap;
  8138. if (!proto.hasOwnProperty('xtypes')) {
  8139. proto.xtypes = xtypes = [];
  8140. proto.xtypesChain = xtypesChain = xtypesChain ? xtypesChain.slice(0) : [];
  8141. proto.xtypesMap = xtypesMap = Ext.apply({}, xtypesMap);
  8142. }
  8143. Manager.addAlias(className, 'widget.' + xtype, true);
  8144. xtypes.push(xtype);
  8145. xtypesChain.push(xtype);
  8146. xtypesMap[xtype] = true;
  8147. },
  8148. set: function(name, value) {
  8149. var targetName = Manager.getName(value);
  8150. Manager.classes[name] = Manager.setNamespace(name, value);
  8151. Manager.classCount++;
  8152. if (targetName && targetName !== name) {
  8153. Manager.addAlternate(targetName, name);
  8154. }
  8155. return Manager;
  8156. },
  8157. get: function(name) {
  8158. return Manager.classes[name] || Manager.lookupName(name, false);
  8159. },
  8160. addNameAliasMappings: function(aliases) {
  8161. Manager.addAlias(aliases);
  8162. },
  8163. addNameAlternateMappings: function(alternates) {
  8164. Manager.addAlternate(alternates);
  8165. },
  8166. getByAlias: function(alias) {
  8167. return Manager.get(Manager.getNameByAlias(alias));
  8168. },
  8169. getByConfig: function(config, aliasPrefix) {
  8170. var xclass = config.xclass,
  8171. name;
  8172. if (xclass) {
  8173. name = xclass;
  8174. } else {
  8175. name = config.xtype;
  8176. if (name) {
  8177. aliasPrefix = 'widget.';
  8178. } else {
  8179. name = config.type;
  8180. }
  8181. name = Manager.getNameByAlias(aliasPrefix + name);
  8182. }
  8183. return Manager.get(name);
  8184. },
  8185. getName: function(object) {
  8186. return object && object.$className || '';
  8187. },
  8188. getClass: function(object) {
  8189. return object && object.self || null;
  8190. },
  8191. create: function(className, data, createdFn) {
  8192. if (className != null && typeof className !== 'string') {
  8193. throw new Error("[Ext.define] Invalid class name '" + className + "' specified, must be a non-empty string");
  8194. }
  8195. var ctor = makeCtor(className);
  8196. if (typeof data === 'function') {
  8197. data = data(ctor);
  8198. }
  8199. if (className) {
  8200. if (Manager.classes[className]) {
  8201. Ext.log.warn("[Ext.define] Duplicate class name '" + className + "' specified, must be a non-empty string");
  8202. }
  8203. ctor.name = className;
  8204. }
  8205. data.$className = className;
  8206. return new Class(ctor, data, function() {
  8207. var postprocessorStack = data.postprocessors || Manager.defaultPostprocessors,
  8208. registeredPostprocessors = Manager.postprocessors,
  8209. postprocessors = [],
  8210. postprocessor, i, ln, j, subLn, postprocessorProperties, postprocessorProperty;
  8211. delete data.postprocessors;
  8212. for (i = 0 , ln = postprocessorStack.length; i < ln; i++) {
  8213. postprocessor = postprocessorStack[i];
  8214. if (typeof postprocessor === 'string') {
  8215. postprocessor = registeredPostprocessors[postprocessor];
  8216. postprocessorProperties = postprocessor.properties;
  8217. if (postprocessorProperties === true) {
  8218. postprocessors.push(postprocessor.fn);
  8219. } else if (postprocessorProperties) {
  8220. for (j = 0 , subLn = postprocessorProperties.length; j < subLn; j++) {
  8221. postprocessorProperty = postprocessorProperties[j];
  8222. if (data.hasOwnProperty(postprocessorProperty)) {
  8223. postprocessors.push(postprocessor.fn);
  8224. break;
  8225. }
  8226. }
  8227. }
  8228. } else {
  8229. postprocessors.push(postprocessor);
  8230. }
  8231. }
  8232. data.postprocessors = postprocessors;
  8233. data.createdFn = createdFn;
  8234. Manager.processCreate(className, this, data);
  8235. });
  8236. },
  8237. processCreate: function(className, cls, clsData) {
  8238. var me = this,
  8239. postprocessor = clsData.postprocessors.shift(),
  8240. createdFn = clsData.createdFn;
  8241. if (!postprocessor) {
  8242. Ext.classSystemMonitor && Ext.classSystemMonitor(className, 'Ext.ClassManager#classCreated', arguments);
  8243. if (className) {
  8244. me.set(className, cls);
  8245. }
  8246. delete cls._classHooks;
  8247. if (createdFn) {
  8248. createdFn.call(cls, cls);
  8249. }
  8250. if (className) {
  8251. me.triggerCreated(className);
  8252. }
  8253. return;
  8254. }
  8255. if (postprocessor.call(me, className, cls, clsData, me.processCreate) !== false) {
  8256. me.processCreate(className, cls, clsData);
  8257. }
  8258. },
  8259. createOverride: function(className, data, createdFn) {
  8260. var me = this,
  8261. overriddenClassName = data.override,
  8262. requires = data.requires,
  8263. uses = data.uses,
  8264. mixins = data.mixins,
  8265. mixinsIsArray,
  8266. compat = 1,
  8267. dependenciesLoaded,
  8268. classReady = function() {
  8269. var cls, dependencies, i, key, temp;
  8270. if (!dependenciesLoaded) {
  8271. dependencies = requires ? requires.slice(0) : [];
  8272. if (mixins) {
  8273. if (!(mixinsIsArray = mixins instanceof Array)) {
  8274. for (key in mixins) {
  8275. if (Ext.isString(cls = mixins[key])) {
  8276. dependencies.push(cls);
  8277. }
  8278. }
  8279. } else {
  8280. for (i = 0 , temp = mixins.length; i < temp; ++i) {
  8281. if (Ext.isString(cls = mixins[i])) {
  8282. dependencies.push(cls);
  8283. }
  8284. }
  8285. }
  8286. }
  8287. dependenciesLoaded = true;
  8288. if (dependencies.length) {
  8289. Ext.require(dependencies, classReady);
  8290. return;
  8291. }
  8292. }
  8293. if (mixinsIsArray) {
  8294. for (i = 0 , temp = mixins.length; i < temp; ++i) {
  8295. if (Ext.isString(cls = mixins[i])) {
  8296. mixins[i] = Ext.ClassManager.get(cls);
  8297. }
  8298. }
  8299. } else if (mixins) {
  8300. for (key in mixins) {
  8301. if (Ext.isString(cls = mixins[key])) {
  8302. mixins[key] = Ext.ClassManager.get(cls);
  8303. }
  8304. }
  8305. }
  8306. cls = overriddenClassName.$isClass ? overriddenClassName : me.get(overriddenClassName);
  8307. delete data.override;
  8308. delete data.compatibility;
  8309. delete data.requires;
  8310. delete data.uses;
  8311. Ext.override(cls, data);
  8312. Ext.Loader.history.push(className);
  8313. if (uses) {
  8314. Ext['Loader'].addUsedClasses(uses);
  8315. }
  8316. if (createdFn) {
  8317. createdFn.call(cls, cls);
  8318. }
  8319. };
  8320. if (className) {
  8321. Manager.overrideMap[className] = true;
  8322. }
  8323. if ('compatibility' in data) {
  8324. compat = data.compatibility;
  8325. if (!compat) {
  8326. compat = false;
  8327. } else if (typeof compat === 'number') {
  8328. compat = true;
  8329. } else if (typeof compat !== 'boolean') {
  8330. compat = Ext.checkVersion(compat);
  8331. }
  8332. }
  8333. if (compat) {
  8334. if (overriddenClassName.$isClass) {
  8335. classReady();
  8336. } else {
  8337. me.onCreated(classReady, me, overriddenClassName);
  8338. }
  8339. }
  8340. me.triggerCreated(className, 2);
  8341. return me;
  8342. },
  8343. instantiateByAlias: function() {
  8344. var alias = arguments[0],
  8345. args = arraySlice.call(arguments),
  8346. className = this.getNameByAlias(alias);
  8347. if (!className) {
  8348. throw new Error("[Ext.createByAlias] Unrecognized alias: " + alias);
  8349. }
  8350. args[0] = className;
  8351. return Ext.create.apply(Ext, args);
  8352. },
  8353. dynInstantiate: function(name, args) {
  8354. args = arrayFrom(args, true);
  8355. args.unshift(name);
  8356. return Ext.create.apply(Ext, args);
  8357. },
  8358. getInstantiator: function(length) {
  8359. var instantiators = this.instantiators,
  8360. instantiator, i, args;
  8361. instantiator = instantiators[length];
  8362. if (!instantiator) {
  8363. i = length;
  8364. args = [];
  8365. for (i = 0; i < length; i++) {
  8366. args.push('a[' + i + ']');
  8367. }
  8368. instantiator = instantiators[length] = new Function('c', 'a', 'return new c(' + args.join(',') + ')');
  8369. instantiator.name = "Ext.create" + length;
  8370. }
  8371. return instantiator;
  8372. },
  8373. postprocessors: {},
  8374. defaultPostprocessors: [],
  8375. registerPostprocessor: function(name, fn, properties, position, relativeTo) {
  8376. if (!position) {
  8377. position = 'last';
  8378. }
  8379. if (!properties) {
  8380. properties = [
  8381. name
  8382. ];
  8383. }
  8384. this.postprocessors[name] = {
  8385. name: name,
  8386. properties: properties || false,
  8387. fn: fn
  8388. };
  8389. this.setDefaultPostprocessorPosition(name, position, relativeTo);
  8390. return this;
  8391. },
  8392. setDefaultPostprocessors: function(postprocessors) {
  8393. this.defaultPostprocessors = arrayFrom(postprocessors);
  8394. return this;
  8395. },
  8396. setDefaultPostprocessorPosition: function(name, offset, relativeName) {
  8397. var defaultPostprocessors = this.defaultPostprocessors,
  8398. index;
  8399. if (typeof offset === 'string') {
  8400. if (offset === 'first') {
  8401. defaultPostprocessors.unshift(name);
  8402. return this;
  8403. } else if (offset === 'last') {
  8404. defaultPostprocessors.push(name);
  8405. return this;
  8406. }
  8407. offset = (offset === 'after') ? 1 : -1;
  8408. }
  8409. index = Ext.Array.indexOf(defaultPostprocessors, relativeName);
  8410. if (index !== -1) {
  8411. Ext.Array.splice(defaultPostprocessors, Math.max(0, index + offset), 0, name);
  8412. }
  8413. return this;
  8414. }
  8415. });
  8416. Manager.registerPostprocessor('platformConfig', function(name, Class, data) {
  8417. Class.addPlatformConfig(data);
  8418. });
  8419. Manager.registerPostprocessor('alias', function(name, cls, data) {
  8420. Ext.classSystemMonitor && Ext.classSystemMonitor(name, 'Ext.ClassManager#aliasPostProcessor', arguments);
  8421. var aliases = Ext.Array.from(data.alias),
  8422. i, ln;
  8423. for (i = 0 , ln = aliases.length; i < ln; i++) {
  8424. alias = aliases[i];
  8425. this.addAlias(cls, alias);
  8426. }
  8427. }, [
  8428. 'xtype',
  8429. 'alias'
  8430. ]);
  8431. Manager.registerPostprocessor('singleton', function(name, cls, data, fn) {
  8432. Ext.classSystemMonitor && Ext.classSystemMonitor(name, 'Ext.ClassManager#singletonPostProcessor', arguments);
  8433. if (data.singleton) {
  8434. fn.call(this, name, new cls(), data);
  8435. } else {
  8436. return true;
  8437. }
  8438. return false;
  8439. });
  8440. Manager.registerPostprocessor('alternateClassName', function(name, cls, data) {
  8441. Ext.classSystemMonitor && Ext.classSystemMonitor(name, 'Ext.ClassManager#alternateClassNamePostprocessor', arguments);
  8442. var alternates = data.alternateClassName,
  8443. i, ln, alternate;
  8444. if (!(alternates instanceof Array)) {
  8445. alternates = [
  8446. alternates
  8447. ];
  8448. }
  8449. for (i = 0 , ln = alternates.length; i < ln; i++) {
  8450. alternate = alternates[i];
  8451. if (typeof alternate !== 'string') {
  8452. throw new Error("[Ext.define] Invalid alternate of: '" + alternate + "' for class: '" + name + "'; must be a valid string");
  8453. }
  8454. this.set(alternate, cls);
  8455. }
  8456. });
  8457. Manager.registerPostprocessor('debugHooks', function(name, Class, data) {
  8458. Ext.classSystemMonitor && Ext.classSystemMonitor(Class, 'Ext.Class#debugHooks', arguments);
  8459. if (Ext.isDebugEnabled(Class.$className, data.debugHooks.$enabled)) {
  8460. delete data.debugHooks.$enabled;
  8461. Ext.override(Class, data.debugHooks);
  8462. }
  8463. var target = Class.isInstance ? Class.self : Class;
  8464. delete target.prototype.debugHooks;
  8465. });
  8466. Manager.registerPostprocessor('deprecated', function(name, Class, data) {
  8467. Ext.classSystemMonitor && Ext.classSystemMonitor(Class, 'Ext.Class#deprecated', arguments);
  8468. var target = Class.isInstance ? Class.self : Class;
  8469. target.addDeprecations(data.deprecated);
  8470. delete target.prototype.deprecated;
  8471. });
  8472. Ext.apply(Ext, {
  8473. create: function() {
  8474. var name = arguments[0],
  8475. nameType = typeof name,
  8476. args = arraySlice.call(arguments, 1),
  8477. cls;
  8478. if (nameType === 'function') {
  8479. cls = name;
  8480. } else {
  8481. if (nameType !== 'string' && args.length === 0) {
  8482. args = [
  8483. name
  8484. ];
  8485. if (!(name = name.xclass)) {
  8486. name = args[0].xtype;
  8487. if (name) {
  8488. name = 'widget.' + name;
  8489. }
  8490. }
  8491. }
  8492. if (typeof name !== 'string' || name.length < 1) {
  8493. throw new Error("[Ext.create] Invalid class name or alias '" + name + "' specified, must be a non-empty string");
  8494. }
  8495. name = Manager.resolveName(name);
  8496. cls = Manager.get(name);
  8497. }
  8498. if (!cls) {
  8499. Ext.log.warn("[Ext.Loader] Synchronously loading '" + name + "'; consider adding " + "Ext.require('" + name + "') above Ext.onReady");
  8500. Ext.syncRequire(name);
  8501. cls = Manager.get(name);
  8502. }
  8503. if (!cls) {
  8504. throw new Error("[Ext.create] Unrecognized class name / alias: " + name);
  8505. }
  8506. if (typeof cls !== 'function') {
  8507. throw new Error("[Ext.create] Singleton '" + name + "' cannot be instantiated.");
  8508. }
  8509. return Manager.getInstantiator(args.length)(cls, args);
  8510. },
  8511. widget: function(name, config) {
  8512. var xtype = name,
  8513. alias, className, T;
  8514. if (typeof xtype !== 'string') {
  8515. config = name;
  8516. xtype = config.xtype;
  8517. className = config.xclass;
  8518. } else {
  8519. config = config || {};
  8520. }
  8521. if (config.isComponent) {
  8522. return config;
  8523. }
  8524. if (!className) {
  8525. alias = 'widget.' + xtype;
  8526. className = Manager.getNameByAlias(alias);
  8527. }
  8528. if (className) {
  8529. T = Manager.get(className);
  8530. }
  8531. if (!T) {
  8532. return Ext.create(className || alias, config);
  8533. }
  8534. return new T(config);
  8535. },
  8536. createByAlias: alias(Manager, 'instantiateByAlias'),
  8537. define: function(className, data, createdFn) {
  8538. Ext.classSystemMonitor && Ext.classSystemMonitor(className, 'ClassManager#define', arguments);
  8539. if (data.override) {
  8540. Manager.classState[className] = 20;
  8541. return Manager.createOverride.apply(Manager, arguments);
  8542. }
  8543. Manager.classState[className] = 10;
  8544. return Manager.create.apply(Manager, arguments);
  8545. },
  8546. undefine: function(className) {
  8547. Ext.classSystemMonitor && Ext.classSystemMonitor(className, 'Ext.ClassManager#undefine', arguments);
  8548. var classes = Manager.classes;
  8549. if (classes[className]) {
  8550. Manager.classCount--;
  8551. }
  8552. delete classes[className];
  8553. delete Manager.existCache[className];
  8554. delete Manager.classState[className];
  8555. Manager.removeName(className);
  8556. Ext.Factory.clearCaches();
  8557. var entry = Manager.getNamespaceEntry(className),
  8558. scope = entry.parent ? Manager.lookupName(entry.parent, false) : Ext.global,
  8559. entryName;
  8560. if (scope) {
  8561. entryName = entry.name;
  8562. try {
  8563. delete scope[entryName];
  8564. } catch (e) {
  8565. scope[entryName] = undefined;
  8566. }
  8567. }
  8568. return entryName;
  8569. },
  8570. getClassName: alias(Manager, 'getName'),
  8571. getDisplayName: function(object) {
  8572. if (object) {
  8573. if (object.displayName) {
  8574. return object.displayName;
  8575. }
  8576. if (object.$name && object.$class) {
  8577. return Ext.getClassName(object.$class) + '#' + object.$name;
  8578. }
  8579. if (object.$className) {
  8580. return object.$className;
  8581. }
  8582. }
  8583. return 'Anonymous';
  8584. },
  8585. getClass: alias(Manager, 'getClass'),
  8586. namespace: function() {
  8587. var root = global,
  8588. i;
  8589. for (i = arguments.length; i-- > 0; ) {
  8590. root = Manager.lookupName(arguments[i], true);
  8591. }
  8592. return root;
  8593. }
  8594. });
  8595. Ext.addRootNamespaces = Manager.addRootNamespaces;
  8596. Ext.createWidget = Ext.widget;
  8597. Ext.ns = Ext.namespace;
  8598. Class.registerPreprocessor('className', function(cls, data) {
  8599. if ('$className' in data) {
  8600. cls.$className = data.$className;
  8601. cls.displayName = cls.$className;
  8602. }
  8603. Ext.classSystemMonitor && Ext.classSystemMonitor(cls, 'Ext.ClassManager#classNamePreprocessor', arguments);
  8604. },
  8605. true, 'first');
  8606. Class.registerPreprocessor('alias', function(cls, data) {
  8607. Ext.classSystemMonitor && Ext.classSystemMonitor(cls, 'Ext.ClassManager#aliasPreprocessor', arguments);
  8608. var prototype = cls.prototype,
  8609. xtypes = arrayFrom(data.xtype),
  8610. aliases = arrayFrom(data.alias),
  8611. widgetPrefix = 'widget.',
  8612. widgetPrefixLength = widgetPrefix.length,
  8613. xtypesChain = Array.prototype.slice.call(prototype.xtypesChain || []),
  8614. xtypesMap = Ext.merge({}, prototype.xtypesMap || {}),
  8615. i, ln, alias, xtype;
  8616. for (i = 0 , ln = aliases.length; i < ln; i++) {
  8617. alias = aliases[i];
  8618. if (typeof alias !== 'string' || alias.length < 1) {
  8619. throw new Error("[Ext.define] Invalid alias of: '" + alias + "' for class: '" + name + "'; must be a valid string");
  8620. }
  8621. if (alias.substring(0, widgetPrefixLength) === widgetPrefix) {
  8622. xtype = alias.substring(widgetPrefixLength);
  8623. Ext.Array.include(xtypes, xtype);
  8624. }
  8625. }
  8626. cls.xtype = data.xtype = xtypes[0];
  8627. data.xtypes = xtypes;
  8628. for (i = 0 , ln = xtypes.length; i < ln; i++) {
  8629. xtype = xtypes[i];
  8630. if (!xtypesMap[xtype]) {
  8631. xtypesMap[xtype] = true;
  8632. xtypesChain.push(xtype);
  8633. }
  8634. }
  8635. data.xtypesChain = xtypesChain;
  8636. data.xtypesMap = xtypesMap;
  8637. Ext.Function.interceptAfterOnce(cls, 'onClassCreated', function() {
  8638. var cls = this,
  8639. prototype = cls.prototype,
  8640. mixins = prototype.mixins,
  8641. key, mixin;
  8642. Ext.classSystemMonitor && Ext.classSystemMonitor(cls, 'Ext.ClassManager#aliasPreprocessor#afterClassCreated', arguments);
  8643. for (key in mixins) {
  8644. if (mixins.hasOwnProperty(key)) {
  8645. mixin = mixins[key];
  8646. xtypes = mixin.xtypes;
  8647. if (xtypes) {
  8648. for (i = 0 , ln = xtypes.length; i < ln; i++) {
  8649. xtype = xtypes[i];
  8650. if (!xtypesMap[xtype]) {
  8651. xtypesMap[xtype] = true;
  8652. xtypesChain.push(xtype);
  8653. }
  8654. }
  8655. }
  8656. }
  8657. }
  8658. });
  8659. for (i = 0 , ln = xtypes.length; i < ln; i++) {
  8660. xtype = xtypes[i];
  8661. if (typeof xtype !== 'string' || xtype.length < 1) {
  8662. throw new Error("[Ext.define] Invalid xtype of: '" + xtype + "' for class: '" + name + "'; must be a valid non-empty string");
  8663. }
  8664. Ext.Array.include(aliases, widgetPrefix + xtype);
  8665. }
  8666. data.alias = aliases;
  8667. }, [
  8668. 'xtype',
  8669. 'alias'
  8670. ]);
  8671. if (Ext.manifest) {
  8672. var manifest = Ext.manifest,
  8673. classes = manifest.classes,
  8674. paths = manifest.paths,
  8675. aliases = {},
  8676. alternates = {},
  8677. className, obj, name, path, baseUrl;
  8678. if (paths) {
  8679. if (manifest.bootRelative) {
  8680. baseUrl = Ext.Boot.baseUrl;
  8681. for (path in paths) {
  8682. if (paths.hasOwnProperty(path)) {
  8683. paths[path] = baseUrl + paths[path];
  8684. }
  8685. }
  8686. }
  8687. Manager.setPath(paths);
  8688. }
  8689. if (classes) {
  8690. for (className in classes) {
  8691. alternates[className] = [];
  8692. aliases[className] = [];
  8693. obj = classes[className];
  8694. if (obj.alias) {
  8695. aliases[className] = obj.alias;
  8696. }
  8697. if (obj.alternates) {
  8698. alternates[className] = obj.alternates;
  8699. }
  8700. }
  8701. }
  8702. Manager.addAlias(aliases);
  8703. Manager.addAlternate(alternates);
  8704. }
  8705. return Manager;
  8706. }(Ext.Class, Ext.Function.alias, Array.prototype.slice, Ext.Array.from, Ext.global));
  8707. (Ext.env || (Ext.env = {})).Browser = function(userAgent, publish) {
  8708. var me = this,
  8709. browserPrefixes = Ext.Boot.browserPrefixes,
  8710. browserNames = Ext.Boot.browserNames,
  8711. enginePrefixes = me.enginePrefixes,
  8712. engineNames = me.engineNames,
  8713. browserMatch = userAgent.match(new RegExp('((?:' + Ext.Object.getValues(browserPrefixes).join(')|(?:') + '))([\\w\\._]+)')),
  8714. engineMatch = userAgent.match(new RegExp('((?:' + Ext.Object.getValues(enginePrefixes).join(')|(?:') + '))([\\w\\._]+)')),
  8715. browserName = browserNames.other,
  8716. engineName = engineNames.other,
  8717. browserVersion = '',
  8718. engineVersion = '',
  8719. majorVer = '',
  8720. isWebView = false,
  8721. edgeRE = /(Edge\/)([\w.]+)/,
  8722. ripple = '',
  8723. i, prefix, name;
  8724. me.userAgent = userAgent;
  8725. this.is = function(name) {
  8726. return !!this.is[name];
  8727. };
  8728. if (/Edge\//.test(userAgent)) {
  8729. browserMatch = userAgent.match(edgeRE);
  8730. engineMatch = userAgent.match(edgeRE);
  8731. }
  8732. if (browserMatch) {
  8733. browserName = browserNames[Ext.Object.getKey(browserPrefixes, browserMatch[1])];
  8734. if (browserName === 'Safari' && /^Opera/.test(userAgent)) {
  8735. browserName = 'Opera';
  8736. }
  8737. browserVersion = new Ext.Version(browserMatch[2]);
  8738. }
  8739. if (engineMatch) {
  8740. engineName = engineNames[Ext.Object.getKey(enginePrefixes, engineMatch[1])];
  8741. engineVersion = new Ext.Version(engineMatch[2]);
  8742. }
  8743. if (engineName === 'Trident' && browserName !== 'IE') {
  8744. browserName = 'IE';
  8745. var version = userAgent.match(/.*rv:(\d+.\d+)/);
  8746. if (version && version.length) {
  8747. version = version[1];
  8748. browserVersion = new Ext.Version(version);
  8749. }
  8750. }
  8751. if (browserName && browserVersion) {
  8752. Ext.setVersion(browserName, browserVersion);
  8753. }
  8754. if (userAgent.match(/FB/) && browserName === 'Other') {
  8755. browserName = browserNames.safari;
  8756. engineName = engineNames.webkit;
  8757. }
  8758. else if (userAgent.match(/Android.*Chrome/g)) {
  8759. browserName = 'ChromeMobile';
  8760. } else {
  8761. browserMatch = userAgent.match(/OPR\/(\d+.\d+)/);
  8762. if (browserMatch) {
  8763. browserName = 'Opera';
  8764. browserVersion = new Ext.Version(browserMatch[1]);
  8765. }
  8766. }
  8767. Ext.apply(this, {
  8768. engineName: engineName,
  8769. engineVersion: engineVersion,
  8770. name: browserName,
  8771. version: browserVersion
  8772. });
  8773. this.setFlag(browserName, true, publish);
  8774. if (browserVersion) {
  8775. majorVer = browserVersion.getMajor() || '';
  8776. if (me.is.IE) {
  8777. majorVer = document.documentMode || parseInt(majorVer, 10);
  8778. for (i = 7; i <= 11; ++i) {
  8779. prefix = 'isIE' + i;
  8780. Ext[prefix] = majorVer === i;
  8781. Ext[prefix + 'm'] = majorVer <= i;
  8782. Ext[prefix + 'p'] = majorVer >= i;
  8783. }
  8784. }
  8785. if (me.is.Opera && parseInt(majorVer, 10) <= 12) {
  8786. Ext.isOpera12m = true;
  8787. }
  8788. Ext.chromeVersion = Ext.isChrome ? majorVer : 0;
  8789. Ext.firefoxVersion = Ext.isFirefox ? majorVer : 0;
  8790. Ext.ieVersion = Ext.isIE ? majorVer : 0;
  8791. Ext.operaVersion = Ext.isOpera ? majorVer : 0;
  8792. Ext.safariVersion = Ext.isSafari ? majorVer : 0;
  8793. Ext.webKitVersion = Ext.isWebKit ? majorVer : 0;
  8794. this.setFlag(browserName + majorVer, true, publish);
  8795. this.setFlag(browserName + browserVersion.getShortVersion());
  8796. }
  8797. for (i in browserNames) {
  8798. if (browserNames.hasOwnProperty(i)) {
  8799. name = browserNames[i];
  8800. this.setFlag(name, browserName === name);
  8801. }
  8802. }
  8803. this.setFlag(name);
  8804. if (engineVersion) {
  8805. this.setFlag(engineName + (engineVersion.getMajor() || ''));
  8806. this.setFlag(engineName + engineVersion.getShortVersion());
  8807. }
  8808. for (i in engineNames) {
  8809. if (engineNames.hasOwnProperty(i)) {
  8810. name = engineNames[i];
  8811. this.setFlag(name, engineName === name, publish);
  8812. }
  8813. }
  8814. this.setFlag('Standalone', !!navigator.standalone);
  8815. try {
  8816. ripple = window.top.ripple;
  8817. } catch (e) {}
  8818. this.setFlag('Ripple', !!document.getElementById("tinyhippos-injected") && !Ext.isEmpty(ripple));
  8819. this.setFlag('WebWorks', !!window.blackberry);
  8820. if (window.PhoneGap !== undefined || window.Cordova !== undefined || window.cordova !== undefined) {
  8821. isWebView = true;
  8822. this.setFlag('PhoneGap');
  8823. this.setFlag('Cordova');
  8824. }
  8825. if (/(iPhone|iPod|iPad).*AppleWebKit(?!.*Safari)(?!.*FBAN)/i.test(userAgent)) {
  8826. isWebView = true;
  8827. }
  8828. this.setFlag('WebView', isWebView);
  8829. this.isStrict = Ext.isStrict = document.compatMode === "CSS1Compat";
  8830. this.isSecure = Ext.isSecure;
  8831. this.identity = browserName + majorVer + (this.isStrict ? 'Strict' : 'Quirks');
  8832. };
  8833. Ext.env.Browser.prototype = {
  8834. constructor: Ext.env.Browser,
  8835. engineNames: {
  8836. edge: 'Edge',
  8837. webkit: 'WebKit',
  8838. gecko: 'Gecko',
  8839. presto: 'Presto',
  8840. trident: 'Trident',
  8841. other: 'Other'
  8842. },
  8843. enginePrefixes: {
  8844. edge: 'Edge/',
  8845. webkit: 'AppleWebKit/',
  8846. gecko: 'Gecko/',
  8847. presto: 'Presto/',
  8848. trident: 'Trident/'
  8849. },
  8850. styleDashPrefixes: {
  8851. WebKit: '-webkit-',
  8852. Gecko: '-moz-',
  8853. Trident: '-ms-',
  8854. Presto: '-o-',
  8855. Other: ''
  8856. },
  8857. stylePrefixes: {
  8858. WebKit: 'Webkit',
  8859. Gecko: 'Moz',
  8860. Trident: 'ms',
  8861. Presto: 'O',
  8862. Other: ''
  8863. },
  8864. propertyPrefixes: {
  8865. WebKit: 'webkit',
  8866. Gecko: 'moz',
  8867. Trident: 'ms',
  8868. Presto: 'o',
  8869. Other: ''
  8870. },
  8871. name: null,
  8872. version: null,
  8873. engineName: null,
  8874. engineVersion: null,
  8875. setFlag: function(name, value, publish) {
  8876. if (value === undefined) {
  8877. value = true;
  8878. }
  8879. this.is[name] = value;
  8880. this.is[name.toLowerCase()] = value;
  8881. if (publish) {
  8882. Ext['is' + name] = value;
  8883. }
  8884. return this;
  8885. },
  8886. getStyleDashPrefix: function() {
  8887. return this.styleDashPrefixes[this.engineName];
  8888. },
  8889. getStylePrefix: function() {
  8890. return this.stylePrefixes[this.engineName];
  8891. },
  8892. getVendorProperyName: function(name) {
  8893. var prefix = this.propertyPrefixes[this.engineName];
  8894. if (prefix.length > 0) {
  8895. return prefix + Ext.String.capitalize(name);
  8896. }
  8897. return name;
  8898. }
  8899. };
  8900. (function(userAgent) {
  8901. Ext.browser = new Ext.env.Browser(userAgent, true);
  8902. Ext.userAgent = userAgent.toLowerCase();
  8903. Ext.SSL_SECURE_URL = Ext.isSecure && Ext.isIE ? 'javascript:\'\'' : 'about:blank';
  8904. }(
  8905. Ext.global.navigator.userAgent));
  8906. Ext.env.OS = function(userAgent, platform, browserScope) {
  8907. var me = this,
  8908. names = Ext.Boot.osNames,
  8909. prefixes = Ext.Boot.osPrefixes,
  8910. name,
  8911. version = '',
  8912. is = me.is,
  8913. i, prefix, match, item, match1;
  8914. browserScope = browserScope || Ext.browser;
  8915. for (i in prefixes) {
  8916. if (prefixes.hasOwnProperty(i)) {
  8917. prefix = prefixes[i];
  8918. match = userAgent.match(new RegExp('(?:' + prefix + ')([^\\s;]+)'));
  8919. if (match) {
  8920. name = names[i];
  8921. match1 = match[1];
  8922. if (match1 && match1 === "HTC_") {
  8923. version = new Ext.Version("2.3");
  8924. } else if (match1 && match1 === "Silk/") {
  8925. version = new Ext.Version("2.3");
  8926. } else {
  8927. version = new Ext.Version(match[match.length - 1]);
  8928. }
  8929. break;
  8930. }
  8931. }
  8932. }
  8933. if (!name) {
  8934. name = names[(userAgent.toLowerCase().match(/mac|win|linux/) || [
  8935. 'other'
  8936. ])[0]];
  8937. version = new Ext.Version('');
  8938. }
  8939. this.name = name;
  8940. this.version = version;
  8941. if (userAgent.match(/ipad/i)) {
  8942. platform = 'iPad';
  8943. }
  8944. if (platform) {
  8945. this.setFlag(platform.replace(/ simulator$/i, ''));
  8946. }
  8947. this.setFlag(name);
  8948. if (version) {
  8949. this.setFlag(name + (version.getMajor() || ''));
  8950. this.setFlag(name + version.getShortVersion());
  8951. }
  8952. for (i in names) {
  8953. if (names.hasOwnProperty(i)) {
  8954. item = names[i];
  8955. if (!is.hasOwnProperty(name)) {
  8956. this.setFlag(item, (name === item));
  8957. }
  8958. }
  8959. }
  8960. if (this.name === "iOS" && window.screen.height === 568) {
  8961. this.setFlag('iPhone5');
  8962. }
  8963. if (browserScope.is.Safari || browserScope.is.Silk) {
  8964. if (this.is.Android2 || this.is.Android3 || browserScope.version.shortVersion === 501) {
  8965. browserScope.setFlag("AndroidStock");
  8966. }
  8967. if (this.is.Android4) {
  8968. browserScope.setFlag("AndroidStock");
  8969. browserScope.setFlag("AndroidStock4");
  8970. }
  8971. }
  8972. };
  8973. Ext.env.OS.prototype = {
  8974. constructor: Ext.env.OS,
  8975. is: function(name) {
  8976. return !!this[name];
  8977. },
  8978. name: null,
  8979. version: null,
  8980. setFlag: function(name, value) {
  8981. if (value === undefined) {
  8982. value = true;
  8983. }
  8984. if (this.flags) {
  8985. this.flags[name] = value;
  8986. }
  8987. this.is[name] = value;
  8988. this.is[name.toLowerCase()] = value;
  8989. return this;
  8990. }
  8991. };
  8992. (function() {
  8993. var navigation = Ext.global.navigator,
  8994. userAgent = navigation.userAgent,
  8995. OS = Ext.env.OS,
  8996. is = (Ext.is || (Ext.is = {})),
  8997. osEnv, osName, deviceType;
  8998. OS.prototype.flags = is;
  8999. Ext.os = osEnv = new OS(userAgent, navigation.platform);
  9000. osName = osEnv.name;
  9001. Ext['is' + osName] = true;
  9002. Ext.isMac = is.Mac = is.MacOS;
  9003. Ext.isApple = Ext.isMac || Ext.isiOS;
  9004. var search = window.location.search.match(/deviceType=(Tablet|Phone)/),
  9005. nativeDeviceType = window.deviceType;
  9006. if (search && search[1]) {
  9007. deviceType = search[1];
  9008. } else if (nativeDeviceType === 'iPhone') {
  9009. deviceType = 'Phone';
  9010. } else if (nativeDeviceType === 'iPad') {
  9011. deviceType = 'Tablet';
  9012. } else {
  9013. if (!osEnv.is.Android && !osEnv.is.iOS && !osEnv.is.WindowsPhone && /Windows|Linux|MacOS|ChromeOS/.test(osName)) {
  9014. deviceType = 'Desktop';
  9015. Ext.browser.is.WebView = !!Ext.browser.is.Ripple;
  9016. } else if (osEnv.is.iPad || osEnv.is.RIMTablet || osEnv.is.Android3 || Ext.browser.is.Silk || (osEnv.is.Android && userAgent.search(/mobile/i) === -1)) {
  9017. deviceType = 'Tablet';
  9018. } else {
  9019. deviceType = 'Phone';
  9020. }
  9021. }
  9022. osEnv.setFlag(deviceType, true);
  9023. osEnv.deviceType = deviceType;
  9024. delete OS.prototype.flags;
  9025. }());
  9026. Ext.feature = {
  9027. has: function(name) {
  9028. return !!this.has[name];
  9029. },
  9030. testElements: {},
  9031. getTestElement: function(tag, createNew) {
  9032. if (tag === undefined) {
  9033. tag = 'div';
  9034. } else if (typeof tag !== 'string') {
  9035. return tag;
  9036. }
  9037. if (createNew) {
  9038. return document.createElement(tag);
  9039. }
  9040. if (!this.testElements[tag]) {
  9041. this.testElements[tag] = document.createElement(tag);
  9042. }
  9043. return this.testElements[tag];
  9044. },
  9045. isStyleSupported: function(name, tag) {
  9046. var elementStyle = this.getTestElement(tag).style,
  9047. cName = Ext.String.capitalize(name);
  9048. if (typeof elementStyle[name] !== 'undefined' || typeof elementStyle[Ext.browser.getStylePrefix(name) + cName] !== 'undefined') {
  9049. return true;
  9050. }
  9051. return false;
  9052. },
  9053. isStyleSupportedWithoutPrefix: function(name, tag) {
  9054. var elementStyle = this.getTestElement(tag).style;
  9055. if (typeof elementStyle[name] !== 'undefined') {
  9056. return true;
  9057. }
  9058. return false;
  9059. },
  9060. isEventSupported: function(name, tag) {
  9061. if (tag === undefined) {
  9062. tag = window;
  9063. }
  9064. var element = this.getTestElement(tag),
  9065. eventName = 'on' + name.toLowerCase(),
  9066. isSupported = (eventName in element);
  9067. if (!isSupported) {
  9068. if (element.setAttribute && element.removeAttribute) {
  9069. element.setAttribute(eventName, '');
  9070. isSupported = typeof element[eventName] === 'function';
  9071. if (typeof element[eventName] !== 'undefined') {
  9072. element[eventName] = undefined;
  9073. }
  9074. element.removeAttribute(eventName);
  9075. }
  9076. }
  9077. return isSupported;
  9078. },
  9079. getStyle: function(element, styleName) {
  9080. var view = element.ownerDocument.defaultView,
  9081. style = (view ? view.getComputedStyle(element, null) : element.currentStyle);
  9082. return (style || element.style)[styleName];
  9083. },
  9084. getSupportedPropertyName: function(object, name) {
  9085. var vendorName = Ext.browser.getVendorProperyName(name);
  9086. if (vendorName in object) {
  9087. return vendorName;
  9088. } else if (name in object) {
  9089. return name;
  9090. }
  9091. return null;
  9092. },
  9093. detect: function(isReady) {
  9094. var me = this,
  9095. doc = document,
  9096. toRun = me.toRun || me.tests,
  9097. n = toRun.length,
  9098. div = doc.createElement('div'),
  9099. notRun = [],
  9100. supports = Ext.supports,
  9101. has = me.has,
  9102. name, names, test, vector, value;
  9103. 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>' + '</div>' + '<div style="position: absolute; left: 10%; top: 10%;"></div>' + '<div style="float:left; background-color:transparent;"></div>';
  9104. if (isReady) {
  9105. doc.body.appendChild(div);
  9106. }
  9107. vector = me.preDetected[Ext.browser.identity] || [];
  9108. while (n--) {
  9109. test = toRun[n];
  9110. value = vector[n];
  9111. name = test.name;
  9112. names = test.names;
  9113. if (value === undefined) {
  9114. if (!isReady && test.ready) {
  9115. notRun.push(test);
  9116. continue;
  9117. }
  9118. value = test.fn.call(me, doc, div);
  9119. }
  9120. if (name) {
  9121. supports[name] = has[name] = value;
  9122. } else if (names) {
  9123. while (names.length) {
  9124. name = names.pop();
  9125. supports[name] = has[name] = value;
  9126. }
  9127. }
  9128. }
  9129. if (isReady) {
  9130. doc.body.removeChild(div);
  9131. }
  9132. me.toRun = notRun;
  9133. },
  9134. report: function() {
  9135. var values = [],
  9136. len = this.tests.length,
  9137. i;
  9138. for (i = 0; i < len; ++i) {
  9139. values.push(this.has[this.tests[i].name] ? 1 : 0);
  9140. }
  9141. Ext.log(Ext.browser.identity + ': [' + values.join(',') + ']');
  9142. },
  9143. preDetected: {},
  9144. tests: [
  9145. {
  9146. name: 'CloneNodeCopiesExpando',
  9147. fn: function() {
  9148. var el = document.createElement('div');
  9149. el.expandoProp = {};
  9150. return el.cloneNode().expandoProp === el.expandoProp;
  9151. }
  9152. },
  9153. {
  9154. name: 'CSSPointerEvents',
  9155. fn: function(doc) {
  9156. return 'pointerEvents' in doc.documentElement.style;
  9157. }
  9158. },
  9159. {
  9160. name: 'CSS3BoxShadow',
  9161. fn: function(doc) {
  9162. return 'boxShadow' in doc.documentElement.style || 'WebkitBoxShadow' in doc.documentElement.style || 'MozBoxShadow' in doc.documentElement.style;
  9163. }
  9164. },
  9165. {
  9166. name: 'CSS3NegationSelector',
  9167. fn: function(doc) {
  9168. try {
  9169. doc.querySelectorAll("foo:not(bar)");
  9170. } catch (e) {
  9171. return false;
  9172. }
  9173. return true;
  9174. }
  9175. },
  9176. {
  9177. name: 'ClassList',
  9178. fn: function(doc) {
  9179. return !!doc.documentElement.classList;
  9180. }
  9181. },
  9182. {
  9183. name: 'Canvas',
  9184. fn: function() {
  9185. var element = this.getTestElement('canvas');
  9186. return !!(element && element.getContext && element.getContext('2d'));
  9187. }
  9188. },
  9189. {
  9190. name: 'Svg',
  9191. fn: function(doc) {
  9192. return !!(doc.createElementNS && !!doc.createElementNS("http:/" + "/www.w3.org/2000/svg", "svg").createSVGRect);
  9193. }
  9194. },
  9195. {
  9196. name: 'Vml',
  9197. fn: function() {
  9198. var element = this.getTestElement(),
  9199. ret = false;
  9200. element.innerHTML = "<!--[if vml]><br><![endif]-->";
  9201. ret = (element.childNodes.length === 1);
  9202. element.innerHTML = "";
  9203. return ret;
  9204. }
  9205. },
  9206. {
  9207. name: 'Touch',
  9208. fn: function() {
  9209. var maxTouchPoints = navigator.msMaxTouchPoints || navigator.maxTouchPoints;
  9210. if (Ext.browser.is.Chrome && Ext.browser.version.isLessThanOrEqual(39)) {
  9211. return (Ext.supports.TouchEvents && maxTouchPoints !== 1) || maxTouchPoints > 1;
  9212. } else {
  9213. return Ext.supports.TouchEvents || maxTouchPoints > 0;
  9214. }
  9215. }
  9216. },
  9217. {
  9218. name: 'PointerEvents',
  9219. fn: function() {
  9220. return !!(window.PointerEvent && !Ext.supports.TouchEvents);
  9221. }
  9222. },
  9223. {
  9224. name: 'MSPointerEvents',
  9225. fn: function() {
  9226. return Ext.isIE10;
  9227. }
  9228. },
  9229. {
  9230. name: 'TouchEvents',
  9231. fn: function() {
  9232. return this.isEventSupported('touchend');
  9233. }
  9234. },
  9235. {
  9236. name: 'TouchAction',
  9237. ready: true,
  9238. fn: function(doc, div) {
  9239. if (!window.getComputedStyle) {
  9240. return 0;
  9241. }
  9242. var values = [
  9243. 'pan-x',
  9244. 'pan-y',
  9245. 'pinch-zoom',
  9246. 'double-tap-zoom'
  9247. ],
  9248. flags = [
  9249. 1,
  9250. 2,
  9251. 4,
  9252. 8
  9253. ],
  9254. ln = values.length,
  9255. flag = 0,
  9256. i, value;
  9257. for (i = 0; i < ln; i++) {
  9258. value = values[i];
  9259. div.style.touchAction = value;
  9260. if (getComputedStyle(div).touchAction === value) {
  9261. flag |= flags[i];
  9262. }
  9263. }
  9264. return flag;
  9265. }
  9266. },
  9267. {
  9268. name: 'Orientation',
  9269. fn: function() {
  9270. return ('orientation' in window) && this.isEventSupported('orientationchange');
  9271. }
  9272. },
  9273. {
  9274. name: 'OrientationChange',
  9275. fn: function() {
  9276. return this.isEventSupported('orientationchange');
  9277. }
  9278. },
  9279. {
  9280. name: 'DeviceMotion',
  9281. fn: function() {
  9282. return this.isEventSupported('devicemotion');
  9283. }
  9284. },
  9285. {
  9286. names: [
  9287. 'Geolocation',
  9288. 'GeoLocation'
  9289. ],
  9290. fn: function() {
  9291. return 'geolocation' in window.navigator;
  9292. }
  9293. },
  9294. {
  9295. name: 'SqlDatabase',
  9296. fn: function() {
  9297. return 'openDatabase' in window;
  9298. }
  9299. },
  9300. {
  9301. name: 'WebSockets',
  9302. fn: function() {
  9303. return 'WebSocket' in window;
  9304. }
  9305. },
  9306. {
  9307. name: 'Range',
  9308. fn: function() {
  9309. return !!document.createRange;
  9310. }
  9311. },
  9312. {
  9313. name: 'CreateContextualFragment',
  9314. fn: function() {
  9315. var range = !!document.createRange ? document.createRange() : false;
  9316. return range && !!range.createContextualFragment;
  9317. }
  9318. },
  9319. {
  9320. name: 'History',
  9321. fn: function() {
  9322. return ('history' in window && 'pushState' in window.history);
  9323. }
  9324. },
  9325. {
  9326. name: 'Css3dTransforms',
  9327. fn: function() {
  9328. return this.has('CssTransforms') && this.isStyleSupported('perspective');
  9329. }
  9330. },
  9331. {
  9332. name: 'CssTransforms',
  9333. fn: function() {
  9334. return this.isStyleSupported('transform');
  9335. }
  9336. },
  9337. {
  9338. name: 'CssTransformNoPrefix',
  9339. fn: function() {
  9340. return this.isStyleSupportedWithoutPrefix('transform');
  9341. }
  9342. },
  9343. {
  9344. name: 'CssAnimations',
  9345. fn: function() {
  9346. return this.isStyleSupported('animationName');
  9347. }
  9348. },
  9349. {
  9350. names: [
  9351. 'CssTransitions',
  9352. 'Transitions'
  9353. ],
  9354. fn: function() {
  9355. return this.isStyleSupported('transitionProperty');
  9356. }
  9357. },
  9358. {
  9359. names: [
  9360. 'Audio',
  9361. 'AudioTag'
  9362. ],
  9363. fn: function() {
  9364. return !!this.getTestElement('audio').canPlayType;
  9365. }
  9366. },
  9367. {
  9368. name: 'Video',
  9369. fn: function() {
  9370. return !!this.getTestElement('video').canPlayType;
  9371. }
  9372. },
  9373. {
  9374. name: 'LocalStorage',
  9375. fn: function() {
  9376. try {
  9377. if ('localStorage' in window && window['localStorage'] !== null) {
  9378. localStorage.setItem('sencha-localstorage-test', 'test success');
  9379. localStorage.removeItem('sencha-localstorage-test');
  9380. return true;
  9381. }
  9382. } catch (e) {}
  9383. return false;
  9384. }
  9385. },
  9386. {
  9387. name: 'XmlQuerySelector',
  9388. fn: function() {
  9389. var xmlString = '<?xml version="1.0" encoding="UTF-8" standalone="yes" ?><root></root>',
  9390. xmlDoc;
  9391. if (window.ActiveXObject) {
  9392. xmlDoc = new ActiveXObject("Microsoft.xmlDOM");
  9393. xmlDoc.async = false;
  9394. xmlDoc.loadXML(xmlString);
  9395. } else if (window.DOMParser) {
  9396. var parser = new DOMParser();
  9397. xmlDoc = parser.parseFromString(xmlString, 'text/xml');
  9398. }
  9399. return xmlDoc ? !!xmlDoc.lastChild.querySelector : false;
  9400. }
  9401. },
  9402. {
  9403. name: 'XHR2',
  9404. fn: function() {
  9405. return window.ProgressEvent && window.FormData && window.XMLHttpRequest && ('withCredentials' in new XMLHttpRequest());
  9406. }
  9407. },
  9408. {
  9409. name: 'XHRUploadProgress',
  9410. fn: function() {
  9411. if (window.XMLHttpRequest && !Ext.browser.is.AndroidStock) {
  9412. var xhr = new XMLHttpRequest();
  9413. return xhr && ('upload' in xhr) && ('onprogress' in xhr.upload);
  9414. }
  9415. return false;
  9416. }
  9417. },
  9418. {
  9419. name: 'NumericInputPlaceHolder',
  9420. fn: function() {
  9421. return !(Ext.browser.is.AndroidStock4 && Ext.os.version.getMinor() < 2);
  9422. }
  9423. },
  9424. {
  9425. name: 'matchesSelector',
  9426. fn: function() {
  9427. var el = document.documentElement,
  9428. w3 = 'matches',
  9429. wk = 'webkitMatchesSelector',
  9430. ms = 'msMatchesSelector',
  9431. mz = 'mozMatchesSelector';
  9432. return el[w3] ? w3 : el[wk] ? wk : el[ms] ? ms : el[mz] ? mz : null;
  9433. }
  9434. },
  9435. {
  9436. name: 'RightMargin',
  9437. ready: true,
  9438. fn: function(doc, div) {
  9439. var view = doc.defaultView;
  9440. return !(view && view.getComputedStyle(div.firstChild.firstChild, null).marginRight !== '0px');
  9441. }
  9442. },
  9443. {
  9444. name: 'DisplayChangeInputSelectionBug',
  9445. fn: function() {
  9446. var webKitVersion = Ext.webKitVersion;
  9447. return 0 < webKitVersion && webKitVersion < 533;
  9448. }
  9449. },
  9450. {
  9451. name: 'DisplayChangeTextAreaSelectionBug',
  9452. fn: function() {
  9453. var webKitVersion = Ext.webKitVersion;
  9454. return 0 < webKitVersion && webKitVersion < 534.24;
  9455. }
  9456. },
  9457. {
  9458. name: 'TransparentColor',
  9459. ready: true,
  9460. fn: function(doc, div, view) {
  9461. view = doc.defaultView;
  9462. return !(view && view.getComputedStyle(div.lastChild, null).backgroundColor !== 'transparent');
  9463. }
  9464. },
  9465. {
  9466. name: 'ComputedStyle',
  9467. ready: true,
  9468. fn: function(doc, div, view) {
  9469. view = doc.defaultView;
  9470. return !!(view && view.getComputedStyle);
  9471. }
  9472. },
  9473. {
  9474. name: 'Float',
  9475. fn: function(doc) {
  9476. return 'cssFloat' in doc.documentElement.style;
  9477. }
  9478. },
  9479. {
  9480. name: 'CSS3BorderRadius',
  9481. ready: true,
  9482. fn: function(doc) {
  9483. var domPrefixes = [
  9484. 'borderRadius',
  9485. 'BorderRadius',
  9486. 'MozBorderRadius',
  9487. 'WebkitBorderRadius',
  9488. 'OBorderRadius',
  9489. 'KhtmlBorderRadius'
  9490. ],
  9491. pass = false,
  9492. i;
  9493. for (i = 0; i < domPrefixes.length; i++) {
  9494. if (doc.documentElement.style[domPrefixes[i]] !== undefined) {
  9495. pass = true;
  9496. }
  9497. }
  9498. return pass && !Ext.isIE9;
  9499. }
  9500. },
  9501. {
  9502. name: 'CSS3LinearGradient',
  9503. fn: function(doc, div) {
  9504. var property = 'background-image:',
  9505. webkit = '-webkit-gradient(linear, left top, right bottom, from(black), to(white))',
  9506. w3c = 'linear-gradient(left top, black, white)',
  9507. moz = '-moz-' + w3c,
  9508. ms = '-ms-' + w3c,
  9509. opera = '-o-' + w3c,
  9510. options = [
  9511. property + webkit,
  9512. property + w3c,
  9513. property + moz,
  9514. property + ms,
  9515. property + opera
  9516. ];
  9517. div.style.cssText = options.join(';');
  9518. return (("" + div.style.backgroundImage).indexOf('gradient') !== -1) && !Ext.isIE9;
  9519. }
  9520. },
  9521. {
  9522. name: 'MouseEnterLeave',
  9523. fn: function(doc) {
  9524. return ('onmouseenter' in doc.documentElement && 'onmouseleave' in doc.documentElement);
  9525. }
  9526. },
  9527. {
  9528. name: 'MouseWheel',
  9529. fn: function(doc) {
  9530. return ('onmousewheel' in doc.documentElement);
  9531. }
  9532. },
  9533. {
  9534. name: 'Opacity',
  9535. fn: function(doc, div) {
  9536. if (Ext.isIE8) {
  9537. return false;
  9538. }
  9539. div.firstChild.style.cssText = 'opacity:0.73';
  9540. return div.firstChild.style.opacity == '0.73';
  9541. }
  9542. },
  9543. {
  9544. name: 'Placeholder',
  9545. fn: function(doc) {
  9546. return 'placeholder' in doc.createElement('input');
  9547. }
  9548. },
  9549. {
  9550. name: 'Direct2DBug',
  9551. fn: function(doc) {
  9552. return Ext.isString(doc.documentElement.style.msTransformOrigin) && Ext.isIE9m;
  9553. }
  9554. },
  9555. {
  9556. name: 'BoundingClientRect',
  9557. fn: function(doc) {
  9558. return 'getBoundingClientRect' in doc.documentElement;
  9559. }
  9560. },
  9561. {
  9562. name: 'RotatedBoundingClientRect',
  9563. ready: true,
  9564. fn: function(doc) {
  9565. var body = doc.body,
  9566. supports = false,
  9567. el = doc.createElement('div'),
  9568. style = el.style;
  9569. if (el.getBoundingClientRect) {
  9570. style.position = 'absolute';
  9571. style.top = "0";
  9572. style.WebkitTransform = style.MozTransform = style.msTransform = style.OTransform = style.transform = 'rotate(90deg)';
  9573. style.width = '100px';
  9574. style.height = '30px';
  9575. body.appendChild(el);
  9576. supports = el.getBoundingClientRect().height !== 100;
  9577. body.removeChild(el);
  9578. }
  9579. return supports;
  9580. }
  9581. },
  9582. {
  9583. name: 'ChildContentClearedWhenSettingInnerHTML',
  9584. ready: true,
  9585. fn: function() {
  9586. var el = this.getTestElement(),
  9587. child;
  9588. el.innerHTML = '<div>a</div>';
  9589. child = el.firstChild;
  9590. el.innerHTML = '<div>b</div>';
  9591. return child.innerHTML !== 'a';
  9592. }
  9593. },
  9594. {
  9595. name: 'IncludePaddingInWidthCalculation',
  9596. ready: true,
  9597. fn: function(doc, div) {
  9598. return div.childNodes[1].firstChild.offsetWidth === 210;
  9599. }
  9600. },
  9601. {
  9602. name: 'IncludePaddingInHeightCalculation',
  9603. ready: true,
  9604. fn: function(doc, div) {
  9605. return div.childNodes[1].firstChild.offsetHeight === 210;
  9606. }
  9607. },
  9608. {
  9609. name: 'TextAreaMaxLength',
  9610. fn: function(doc) {
  9611. return ('maxlength' in doc.createElement('textarea'));
  9612. }
  9613. },
  9614. {
  9615. name: 'GetPositionPercentage',
  9616. ready: true,
  9617. fn: function(doc, div) {
  9618. return Ext.feature.getStyle(div.childNodes[2], 'left') === '10%';
  9619. }
  9620. },
  9621. {
  9622. name: 'PercentageHeightOverflowBug',
  9623. ready: true,
  9624. fn: function(doc) {
  9625. var hasBug = false,
  9626. style, el;
  9627. if (Ext.getScrollbarSize().height) {
  9628. el = this.getTestElement('div', true);
  9629. style = el.style;
  9630. style.height = '50px';
  9631. style.width = '50px';
  9632. style.overflow = 'auto';
  9633. style.position = 'absolute';
  9634. el.innerHTML = [
  9635. '<div style="display:table;height:100%;">',
  9636. '<div style="width:51px;"></div>',
  9637. '</div>'
  9638. ].join('');
  9639. doc.body.appendChild(el);
  9640. if (el.firstChild.offsetHeight === 50) {
  9641. hasBug = true;
  9642. }
  9643. doc.body.removeChild(el);
  9644. }
  9645. return hasBug;
  9646. }
  9647. },
  9648. {
  9649. name: 'xOriginBug',
  9650. ready: true,
  9651. fn: function(doc, div) {
  9652. 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>';
  9653. var outerBox = document.getElementById('b1').getBoundingClientRect(),
  9654. b2 = document.getElementById('b2').getBoundingClientRect(),
  9655. b3 = document.getElementById('b3').getBoundingClientRect();
  9656. return (b2.left !== outerBox.left && b3.right !== outerBox.right);
  9657. }
  9658. },
  9659. {
  9660. name: 'ScrollWidthInlinePaddingBug',
  9661. ready: true,
  9662. fn: function(doc) {
  9663. var hasBug = false,
  9664. style, el;
  9665. el = doc.createElement('div');
  9666. style = el.style;
  9667. style.height = '50px';
  9668. style.width = '50px';
  9669. style.padding = '10px';
  9670. style.overflow = 'hidden';
  9671. style.position = 'absolute';
  9672. el.innerHTML = '<span style="display:inline-block;zoom:1;height:60px;width:60px;"></span>';
  9673. doc.body.appendChild(el);
  9674. if (el.scrollWidth === 70) {
  9675. hasBug = true;
  9676. }
  9677. doc.body.removeChild(el);
  9678. return hasBug;
  9679. }
  9680. },
  9681. {
  9682. name: 'rtlVertScrollbarOnRight',
  9683. ready: true,
  9684. fn: function(doc, div) {
  9685. div.innerHTML = '<div style="height:100px;width:100px;direction:rtl;overflow:scroll">' + '<div style="width:20px;height:200px;"></div>' + '</div>';
  9686. var outerBox = div.firstChild,
  9687. innerBox = outerBox.firstChild;
  9688. return (innerBox.offsetLeft + innerBox.offsetWidth !== outerBox.offsetLeft + outerBox.offsetWidth);
  9689. }
  9690. },
  9691. {
  9692. name: 'rtlVertScrollbarOverflowBug',
  9693. ready: true,
  9694. fn: function(doc, div) {
  9695. div.innerHTML = '<div style="height:100px;width:100px;direction:rtl;overflow:auto">' + '<div style="width:95px;height:200px;"></div>' + '</div>';
  9696. var outerBox = div.firstChild,
  9697. style = div.style,
  9698. pos = style.position;
  9699. style.position = 'absolute';
  9700. outerBox.offsetHeight;
  9701. style.position = pos;
  9702. return outerBox.clientHeight === outerBox.offsetHeight;
  9703. }
  9704. },
  9705. {
  9706. identity: 'defineProperty',
  9707. fn: function() {
  9708. if (Ext.isIE8m) {
  9709. Ext.Object.defineProperty = Ext.emptyFn;
  9710. return false;
  9711. }
  9712. return true;
  9713. }
  9714. },
  9715. {
  9716. identify: 'nativeXhr',
  9717. fn: function() {
  9718. if (typeof XMLHttpRequest !== 'undefined') {
  9719. return true;
  9720. }
  9721. XMLHttpRequest = function() {
  9722. try {
  9723. return new ActiveXObject('MSXML2.XMLHTTP.3.0');
  9724. }
  9725. catch (ex) {
  9726. return null;
  9727. }
  9728. };
  9729. return false;
  9730. }
  9731. },
  9732. {
  9733. name: 'SpecialKeyDownRepeat',
  9734. fn: function() {
  9735. return Ext.isWebKit ? parseInt(navigator.userAgent.match(/AppleWebKit\/(\d+)/)[1], 10) >= 525 : !(!(Ext.isGecko || Ext.isIE || Ext.isEdge) || (Ext.isOpera && Ext.operaVersion < 12));
  9736. }
  9737. },
  9738. {
  9739. name: 'EmulatedMouseOver',
  9740. fn: function() {
  9741. return Ext.os.is.iOS;
  9742. }
  9743. },
  9744. {
  9745. name: 'Hashchange',
  9746. fn: function() {
  9747. var docMode = document.documentMode;
  9748. return 'onhashchange' in window && (docMode === undefined || docMode > 7);
  9749. }
  9750. },
  9751. {
  9752. name: 'FixedTableWidthBug',
  9753. ready: true,
  9754. fn: function() {
  9755. if (Ext.isIE8) {
  9756. return false;
  9757. }
  9758. var outer = document.createElement('div'),
  9759. inner = document.createElement('div'),
  9760. width;
  9761. outer.setAttribute('style', 'display:table;table-layout:fixed;');
  9762. inner.setAttribute('style', 'display:table-cell;min-width:50px;');
  9763. outer.appendChild(inner);
  9764. document.body.appendChild(outer);
  9765. outer.offsetWidth;
  9766. outer.style.width = '25px';
  9767. width = outer.offsetWidth;
  9768. document.body.removeChild(outer);
  9769. return width === 50;
  9770. }
  9771. },
  9772. {
  9773. name: 'FocusinFocusoutEvents',
  9774. fn: function() {
  9775. return !(Ext.isGecko && Ext.firefoxVersion < 52);
  9776. }
  9777. },
  9778. {
  9779. name: 'AsyncFocusEvents',
  9780. fn: function() {
  9781. return Ext.asyncFocus = !!Ext.isIE;
  9782. }
  9783. },
  9784. {
  9785. name: 'accessibility',
  9786. ready: true,
  9787. fn: function(doc) {
  9788. var body = doc.body,
  9789. div, img, style, supports, bgImg;
  9790. function getColor(colorTxt) {
  9791. var values = [],
  9792. colorValue = 0,
  9793. regex, match;
  9794. if (colorTxt.indexOf('rgb(') !== -1) {
  9795. values = colorTxt.replace('rgb(', '').replace(')', '').split(', ');
  9796. } else if (colorTxt.indexOf('#') !== -1) {
  9797. regex = colorTxt.length === 7 ? /^#(\S\S)(\S\S)(\S\S)$/ : /^#(\S)(\S)(\S)$/;
  9798. match = colorTxt.match(regex);
  9799. if (match) {
  9800. values = [
  9801. '0x' + match[1],
  9802. '0x' + match[2],
  9803. '0x' + match[3]
  9804. ];
  9805. }
  9806. }
  9807. for (var i = 0; i < values.length; i++) {
  9808. colorValue += parseInt(values[i]);
  9809. }
  9810. return colorValue;
  9811. }
  9812. div = doc.createElement('div');
  9813. img = doc.createElement('img');
  9814. style = div.style;
  9815. Ext.apply(style, {
  9816. width: '2px',
  9817. position: 'absolute',
  9818. clip: 'rect(1px,1px,1px,1px)',
  9819. borderWidth: '1px',
  9820. borderStyle: 'solid',
  9821. borderTopTolor: '#f00',
  9822. borderRightColor: '#ff0',
  9823. backgroundColor: '#fff',
  9824. backgroundImage: 'url(' + Ext.BLANK_IMAGE_URL + ')'
  9825. });
  9826. img.alt = '';
  9827. img.src = Ext.BLANK_IMAGE_URL;
  9828. div.appendChild(img);
  9829. body.appendChild(div);
  9830. style = div.currentStyle || div.style;
  9831. bgImg = style.backgroundImage;
  9832. supports = {
  9833. Images: img.offsetWidth === 1 && img.readyState !== 'uninitialized',
  9834. BackgroundImages: !(bgImg !== null && (bgImg === "none" || bgImg === "url(invalid-url:)")),
  9835. BorderColors: style.borderTopColor !== style.borderRightColor,
  9836. LightOnDark: getColor(style.color) - getColor(style.backgroundColor) > 0
  9837. };
  9838. Ext.supports.HighContrastMode = !supports.BackgroundImages;
  9839. body.removeChild(div);
  9840. div = img = null;
  9841. return supports;
  9842. }
  9843. },
  9844. {
  9845. name: 'ViewportUnits',
  9846. ready: true,
  9847. fn: function(doc) {
  9848. if (Ext.isIE8) {
  9849. return false;
  9850. }
  9851. var body = doc.body,
  9852. div = document.createElement('div'),
  9853. style = div.currentStyle || div.style,
  9854. width, divWidth;
  9855. body.appendChild(div);
  9856. Ext.apply(style, {
  9857. width: '50vw'
  9858. });
  9859. width = parseInt(window.innerWidth / 2, 10);
  9860. divWidth = parseInt((window.getComputedStyle ? getComputedStyle(div, null) : div.currentStyle).width, 10);
  9861. body.removeChild(div);
  9862. div = null;
  9863. return width === divWidth;
  9864. }
  9865. },
  9866. {
  9867. name: 'CSSVariables',
  9868. ready: false,
  9869. fn: function() {
  9870. if (!window.getComputedStyle) {
  9871. return false;
  9872. }
  9873. return window.CSS && window.CSS.supports && window.CSS.supports('--test-var', 0);
  9874. }
  9875. },
  9876. {
  9877. name: 'Selectors2',
  9878. ready: false,
  9879. fn: function(doc) {
  9880. try {
  9881. return !!doc.querySelectorAll(':scope');
  9882. } catch (e) {
  9883. return false;
  9884. }
  9885. }
  9886. },
  9887. {
  9888. name: 'CSSScrollSnap',
  9889. ready: false,
  9890. fn: function(doc) {
  9891. var style = doc.documentElement.style;
  9892. return 'scrollSnapType' in style || 'webkitScrollSnapType' in style || 'msScrollSnapType' in style;
  9893. }
  9894. },
  9895. {
  9896. name: 'TranslateYCausesHorizontalScroll',
  9897. ready: true,
  9898. fn: function(doc, div) {
  9899. div.innerHTML = '<div style="position: relative; overflow: auto; height: 200px; width: 200px;">' + '<div>' + '<div style="transform: translateY(260px); width: 50px;">a</div>' + '</div>' + '</div>';
  9900. return div.firstChild.scrollWidth > div.firstChild.clientWidth;
  9901. }
  9902. },
  9903. {
  9904. name: 'FlexBoxBasisBug',
  9905. ready: true,
  9906. fn: function() {
  9907. 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))) {
  9908. return true;
  9909. }
  9910. return false;
  9911. }
  9912. },
  9913. {
  9914. name: 'PercentageSizeFlexBug',
  9915. ready: true,
  9916. fn: function(doc, div) {
  9917. if (Ext.isIE9m) {
  9918. return false;
  9919. }
  9920. var style = div.style;
  9921. style.display = 'flex';
  9922. style.flexDirection = 'column';
  9923. style.height = style.width = '100px';
  9924. div.innerHTML = '<div style="flex: 1 1;"><div style="height:50%"></div></div>';
  9925. return div.firstChild.firstChild.offsetHeight !== 50;
  9926. }
  9927. },
  9928. {
  9929. name: 'CannotScrollExactHeight',
  9930. fn: function() {
  9931. return Ext.isIE10p;
  9932. }
  9933. },
  9934. {
  9935. name: 'WebKitInputTableBoxModelBug',
  9936. ready: true,
  9937. fn: function(doc, div) {
  9938. var table = document.createElement('div'),
  9939. cell = document.createElement('div'),
  9940. input = document.createElement('input'),
  9941. tableStyle = table.style,
  9942. cellStyle = cell.style,
  9943. inputStyle = input.style,
  9944. body = doc.body,
  9945. hasBug;
  9946. input.type = 'text';
  9947. tableStyle.display = 'table';
  9948. tableStyle.height = '100px';
  9949. cellStyle.display = 'table-cell';
  9950. inputStyle.border = '0';
  9951. inputStyle.padding = '10px';
  9952. inputStyle.boxSizing = 'border-box';
  9953. inputStyle.height = '100%';
  9954. cell.appendChild(input);
  9955. table.appendChild(cell);
  9956. body.appendChild(table);
  9957. hasBug = input.offsetHeight === 80;
  9958. body.removeChild(table);
  9959. return hasBug;
  9960. }
  9961. },
  9962. {
  9963. name: 'PassiveEventListener',
  9964. fn: function(doc, div) {
  9965. var supportsPassive = false,
  9966. options;
  9967. try {
  9968. options = Object.defineProperty({}, 'passive', {
  9969. get: function() {
  9970. supportsPassive = true;
  9971. }
  9972. });
  9973. window.addEventListener('e', null, options);
  9974. window.removeEventListener('e', null, options);
  9975. } catch (e) {}
  9976. return supportsPassive;
  9977. }
  9978. },
  9979. {
  9980. name: 'CSSMinContent',
  9981. ready: true,
  9982. fn: function(doc, div) {
  9983. 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>';
  9984. return div.firstChild.offsetHeight === 8;
  9985. }
  9986. },
  9987. {
  9988. name: 'ComputedSizeIncludesPadding',
  9989. ready: true,
  9990. fn: function(doc, div) {
  9991. var ret = false,
  9992. bd = document.body,
  9993. el, w;
  9994. if (window.getComputedStyle) {
  9995. el = document.createElement('div');
  9996. el.style.cssText = 'width:10px;padding:2px;' + '-webkit-box-sizing:border-box;box-sizing:border-box;';
  9997. bd.appendChild(el);
  9998. w = window.getComputedStyle(el, null).width;
  9999. ret = w === '10px';
  10000. bd.removeChild(el);
  10001. }
  10002. return ret;
  10003. }
  10004. },
  10005. 0
  10006. ]
  10007. };
  10008. Ext.feature.tests.pop();
  10009. Ext.supports = {};
  10010. Ext.feature.detect();
  10011. Ext.env.Ready = {
  10012. blocks: (location.search || '').indexOf('ext-pauseReadyFire') > 0 ? 1 : 0,
  10013. bound: 0,
  10014. delay: 1,
  10015. events: [],
  10016. firing: false,
  10017. generation: 0,
  10018. listeners: [],
  10019. nextId: 0,
  10020. sortGeneration: 0,
  10021. state: 0,
  10022. timer: null,
  10023. bind: function() {
  10024. var me = Ext.env.Ready,
  10025. doc = document;
  10026. if (!me.bound) {
  10027. if (doc.readyState === 'complete') {
  10028. me.onReadyEvent({
  10029. type: doc.readyState || 'body'
  10030. });
  10031. } else {
  10032. me.bound = 1;
  10033. if (Ext.browser.is.PhoneGap && !Ext.os.is.Desktop) {
  10034. me.bound = 2;
  10035. doc.addEventListener('deviceready', me.onReadyEvent, false);
  10036. }
  10037. doc.addEventListener('DOMContentLoaded', me.onReadyEvent, false);
  10038. window.addEventListener('load', me.onReadyEvent, false);
  10039. }
  10040. }
  10041. },
  10042. block: function() {
  10043. ++this.blocks;
  10044. Ext.isReady = false;
  10045. },
  10046. fireReady: function() {
  10047. var me = Ext.env.Ready;
  10048. if (!me.state) {
  10049. Ext._readyTime = Ext.ticks();
  10050. Ext.isDomReady = true;
  10051. me.state = 1;
  10052. Ext.feature.detect(true);
  10053. if (!me.delay) {
  10054. me.handleReady();
  10055. } else if (navigator.standalone) {
  10056. me.timer = Ext.defer(function() {
  10057. me.timer = null;
  10058. me.handleReadySoon();
  10059. }, 1);
  10060. } else {
  10061. me.handleReadySoon();
  10062. }
  10063. }
  10064. },
  10065. handleReady: function() {
  10066. var me = this;
  10067. if (me.state === 1) {
  10068. me.state = 2;
  10069. Ext._beforeReadyTime = Ext.ticks();
  10070. me.invokeAll();
  10071. Ext._afterReadyTime = Ext.ticks();
  10072. }
  10073. },
  10074. handleReadySoon: function(delay) {
  10075. var me = this;
  10076. if (!me.timer) {
  10077. me.timer = Ext.defer(function() {
  10078. me.timer = null;
  10079. me.handleReady();
  10080. }, delay || me.delay);
  10081. }
  10082. },
  10083. invoke: function(listener) {
  10084. var delay = listener.delay;
  10085. if (delay) {
  10086. Ext.defer(listener.fn, delay, listener.scope);
  10087. } else {
  10088. if (Ext.elevateFunction) {
  10089. Ext.elevateFunction(listener.fn, listener.scope);
  10090. } else {
  10091. listener.fn.call(listener.scope);
  10092. }
  10093. }
  10094. },
  10095. invokeAll: function() {
  10096. if (Ext.elevateFunction) {
  10097. Ext.elevateFunction(this.doInvokeAll, this);
  10098. } else {
  10099. this.doInvokeAll();
  10100. }
  10101. },
  10102. doInvokeAll: function() {
  10103. var me = this,
  10104. listeners = me.listeners,
  10105. listener;
  10106. if (!me.blocks) {
  10107. Ext.isReady = true;
  10108. }
  10109. me.firing = true;
  10110. while (listeners.length) {
  10111. if (me.sortGeneration !== me.generation) {
  10112. me.sortGeneration = me.generation;
  10113. listeners.sort(me.sortFn);
  10114. }
  10115. listener = listeners.pop();
  10116. if (me.blocks && !listener.dom) {
  10117. listeners.push(listener);
  10118. break;
  10119. }
  10120. me.invoke(listener);
  10121. }
  10122. me.firing = false;
  10123. },
  10124. makeListener: function(fn, scope, options) {
  10125. var ret = {
  10126. fn: fn,
  10127. id: ++this.nextId,
  10128. scope: scope,
  10129. dom: false,
  10130. priority: 0
  10131. };
  10132. if (options) {
  10133. Ext.apply(ret, options);
  10134. }
  10135. ret.phase = ret.dom ? 0 : 1;
  10136. return ret;
  10137. },
  10138. on: function(fn, scope, options) {
  10139. var me = Ext.env.Ready,
  10140. listener = me.makeListener(fn, scope, options);
  10141. if (me.state === 2 && !me.firing && (listener.dom || !me.blocks)) {
  10142. me.invoke(listener);
  10143. } else {
  10144. me.listeners.push(listener);
  10145. ++me.generation;
  10146. if (!me.bound) {
  10147. me.bind();
  10148. }
  10149. }
  10150. },
  10151. onReadyEvent: function(ev) {
  10152. var me = Ext.env.Ready;
  10153. if (Ext.elevateFunction) {
  10154. Ext.elevateFunction(me.doReadyEvent, me, arguments);
  10155. } else {
  10156. me.doReadyEvent(ev);
  10157. }
  10158. },
  10159. doReadyEvent: function(ev) {
  10160. var me = this;
  10161. if (ev && ev.type) {
  10162. me.events.push(ev);
  10163. }
  10164. if (me.bound > 0) {
  10165. me.unbind();
  10166. me.bound = -1;
  10167. }
  10168. if (!me.state) {
  10169. me.fireReady();
  10170. }
  10171. },
  10172. sortFn: function(a, b) {
  10173. return -((a.phase - b.phase) || (b.priority - a.priority) || (a.id - b.id));
  10174. },
  10175. unblock: function() {
  10176. var me = this;
  10177. if (me.blocks) {
  10178. if (!--me.blocks) {
  10179. if (me.state === 2 && !me.firing) {
  10180. me.invokeAll();
  10181. }
  10182. }
  10183. }
  10184. },
  10185. unbind: function() {
  10186. var me = this,
  10187. doc = document;
  10188. if (me.bound > 1) {
  10189. doc.removeEventListener('deviceready', me.onReadyEvent, false);
  10190. }
  10191. doc.removeEventListener('DOMContentLoaded', me.onReadyEvent, false);
  10192. window.removeEventListener('load', me.onReadyEvent, false);
  10193. }
  10194. };
  10195. (function() {
  10196. var Ready = Ext.env.Ready;
  10197. if (Ext.isIE9m) {
  10198. Ext.apply(Ready, {
  10199. scrollTimer: null,
  10200. readyStatesRe: /complete/i,
  10201. pollScroll: function() {
  10202. var scrollable = true;
  10203. try {
  10204. document.documentElement.doScroll('left');
  10205. } catch (e) {
  10206. scrollable = false;
  10207. }
  10208. if (scrollable && document.body) {
  10209. Ready.onReadyEvent({
  10210. type: 'doScroll'
  10211. });
  10212. } else {
  10213. Ready.scrollTimer = Ext.defer(Ready.pollScroll, 20);
  10214. }
  10215. return scrollable;
  10216. },
  10217. bind: function() {
  10218. if (Ready.bound) {
  10219. return;
  10220. }
  10221. var doc = document,
  10222. topContext;
  10223. try {
  10224. topContext = window.frameElement === undefined;
  10225. } catch (e) {}
  10226. if (!topContext || !doc.documentElement.doScroll) {
  10227. Ready.pollScroll = Ext.emptyFn;
  10228. }
  10229. else if (Ready.pollScroll()) {
  10230. return;
  10231. }
  10232. if (doc.readyState === 'complete') {
  10233. Ready.onReadyEvent({
  10234. type: 'already ' + (doc.readyState || 'body')
  10235. });
  10236. } else {
  10237. doc.attachEvent('onreadystatechange', Ready.onReadyStateChange);
  10238. window.attachEvent('onload', Ready.onReadyEvent);
  10239. Ready.bound = 1;
  10240. }
  10241. },
  10242. unbind: function() {
  10243. document.detachEvent('onreadystatechange', Ready.onReadyStateChange);
  10244. window.detachEvent('onload', Ready.onReadyEvent);
  10245. if (Ext.isNumber(Ready.scrollTimer)) {
  10246. Ext.undefer(Ready.scrollTimer);
  10247. Ready.scrollTimer = null;
  10248. }
  10249. },
  10250. onReadyStateChange: function() {
  10251. var state = document.readyState;
  10252. if (Ready.readyStatesRe.test(state)) {
  10253. Ready.onReadyEvent({
  10254. type: state
  10255. });
  10256. }
  10257. }
  10258. });
  10259. }
  10260. Ext.onDocumentReady = function(fn, scope, options) {
  10261. var opt = {
  10262. dom: true
  10263. };
  10264. if (options) {
  10265. Ext.apply(opt, options);
  10266. }
  10267. Ready.on(fn, scope, opt);
  10268. };
  10269. Ext.onReady = function(fn, scope, options) {
  10270. Ready.on(fn, scope, options);
  10271. };
  10272. Ext.onInternalReady = function(fn, scope, options) {
  10273. Ready.on(fn, scope, Ext.apply({
  10274. priority: 1000
  10275. }, options));
  10276. };
  10277. Ready.bind();
  10278. }());
  10279. Ext.Loader = (new function() {
  10280. var Loader = this,
  10281. Manager = Ext.ClassManager,
  10282. Boot = Ext.Boot,
  10283. Class = Ext.Class,
  10284. Ready = Ext.env.Ready,
  10285. alias = Ext.Function.alias,
  10286. dependencyProperties = [
  10287. 'extend',
  10288. 'mixins',
  10289. 'requires'
  10290. ],
  10291. isInHistory = {},
  10292. history = [],
  10293. readyListeners = [],
  10294. usedClasses = [],
  10295. _requiresMap = {},
  10296. _config = {
  10297. enabled: true,
  10298. scriptChainDelay: false,
  10299. disableCaching: true,
  10300. disableCachingParam: '_dc',
  10301. paths: Manager.paths,
  10302. preserveScripts: true,
  10303. scriptCharset: undefined
  10304. },
  10305. delegatedConfigs = {
  10306. disableCaching: true,
  10307. disableCachingParam: true,
  10308. preserveScripts: true,
  10309. scriptChainDelay: 'loadDelay'
  10310. };
  10311. Ext.apply(Loader, {
  10312. isInHistory: isInHistory,
  10313. isLoading: false,
  10314. history: history,
  10315. config: _config,
  10316. readyListeners: readyListeners,
  10317. optionalRequires: usedClasses,
  10318. requiresMap: _requiresMap,
  10319. hasFileLoadError: false,
  10320. scriptsLoading: 0,
  10321. classesLoading: {},
  10322. missingCount: 0,
  10323. missingQueue: {},
  10324. syncModeEnabled: false,
  10325. init: function() {
  10326. var scripts = document.getElementsByTagName('script'),
  10327. src = scripts[scripts.length - 1].src,
  10328. path = src.substring(0, src.lastIndexOf('/') + 1),
  10329. meta = Ext._classPathMetadata,
  10330. microloader = Ext.Microloader,
  10331. manifest = Ext.manifest,
  10332. loadOrder, classes, className, idx, baseUrl, loadlen, l, loadItem;
  10333. if (src.indexOf("packages/core/src/") !== -1) {
  10334. path = path + "../../";
  10335. } else if (src.indexOf("/core/src/class/") !== -1) {
  10336. path = path + "../../../";
  10337. }
  10338. if (!Manager.getPath("Ext")) {
  10339. Manager.setPath('Ext', path + 'src');
  10340. }
  10341. if (meta) {
  10342. Ext._classPathMetadata = null;
  10343. Loader.addClassPathMappings(meta);
  10344. }
  10345. if (manifest) {
  10346. loadOrder = manifest.loadOrder;
  10347. baseUrl = Ext.Boot.baseUrl;
  10348. if (loadOrder && manifest.bootRelative) {
  10349. for (loadlen = loadOrder.length , l = 0; l < loadlen; l++) {
  10350. loadItem = loadOrder[l];
  10351. loadItem.path = baseUrl + loadItem.path;
  10352. loadItem.canonicalPath = true;
  10353. }
  10354. }
  10355. }
  10356. if (microloader) {
  10357. Ready.block();
  10358. microloader.onMicroloaderReady(function() {
  10359. Ready.unblock();
  10360. });
  10361. }
  10362. },
  10363. setConfig: Ext.Function.flexSetter(function(name, value) {
  10364. if (name === 'paths') {
  10365. Loader.setPath(value);
  10366. } else {
  10367. _config[name] = value;
  10368. var delegated = delegatedConfigs[name];
  10369. if (delegated) {
  10370. Boot.setConfig((delegated === true) ? name : delegated, value);
  10371. }
  10372. }
  10373. return Loader;
  10374. }),
  10375. getConfig: function(name) {
  10376. return name ? _config[name] : _config;
  10377. },
  10378. setPath: function() {
  10379. Manager.setPath.apply(Manager, arguments);
  10380. return Loader;
  10381. },
  10382. addClassPathMappings: function(paths) {
  10383. Manager.setPath(paths);
  10384. return Loader;
  10385. },
  10386. addBaseUrlClassPathMappings: function(pathConfig) {
  10387. for (var name in pathConfig) {
  10388. pathConfig[name] = Boot.baseUrl + pathConfig[name];
  10389. }
  10390. Ext.Loader.addClassPathMappings(pathConfig);
  10391. },
  10392. getPath: function(className) {
  10393. return Manager.getPath(className);
  10394. },
  10395. require: function(expressions, fn, scope, excludes) {
  10396. if (excludes) {
  10397. return Loader.exclude(excludes).require(expressions, fn, scope);
  10398. }
  10399. var classNames = Manager.getNamesByExpression(expressions);
  10400. return Loader.load(classNames, fn, scope);
  10401. },
  10402. syncRequire: function() {
  10403. var wasEnabled = Loader.syncModeEnabled;
  10404. Loader.syncModeEnabled = true;
  10405. var ret = Loader.require.apply(Loader, arguments);
  10406. Loader.syncModeEnabled = wasEnabled;
  10407. return ret;
  10408. },
  10409. exclude: function(excludes) {
  10410. var selector = Manager.select({
  10411. require: function(classNames, fn, scope) {
  10412. return Loader.load(classNames, fn, scope);
  10413. },
  10414. syncRequire: function(classNames, fn, scope) {
  10415. var wasEnabled = Loader.syncModeEnabled;
  10416. Loader.syncModeEnabled = true;
  10417. var ret = Loader.load(classNames, fn, scope);
  10418. Loader.syncModeEnabled = wasEnabled;
  10419. return ret;
  10420. }
  10421. });
  10422. selector.exclude(excludes);
  10423. return selector;
  10424. },
  10425. load: function(classNames, callback, scope) {
  10426. if (callback) {
  10427. if (callback.length) {
  10428. callback = Loader.makeLoadCallback(classNames, callback);
  10429. }
  10430. callback = callback.bind(scope || Ext.global);
  10431. }
  10432. var state = Manager.classState,
  10433. missingClassNames = [],
  10434. urls = [],
  10435. urlByClass = {},
  10436. numClasses = classNames.length,
  10437. url, className, i, numMissing;
  10438. for (i = 0; i < numClasses; ++i) {
  10439. className = Manager.resolveName(classNames[i]);
  10440. if (!Manager.isCreated(className)) {
  10441. missingClassNames.push(className);
  10442. if (!state[className]) {
  10443. urlByClass[className] = Loader.getPath(className);
  10444. urls.push(urlByClass[className]);
  10445. }
  10446. }
  10447. }
  10448. numMissing = missingClassNames.length;
  10449. if (numMissing) {
  10450. Loader.missingCount += numMissing;
  10451. Manager.onCreated(function() {
  10452. if (callback) {
  10453. Ext.callback(callback, scope, arguments);
  10454. }
  10455. Loader.checkReady();
  10456. }, Loader, missingClassNames);
  10457. if (!_config.enabled) {
  10458. Ext.raise("Ext.Loader is not enabled, so dependencies cannot be resolved dynamically. " + "Missing required class" + ((missingClassNames.length > 1) ? "es" : "") + ": " + missingClassNames.join(', '));
  10459. }
  10460. if (urls.length) {
  10461. Loader.loadScripts({
  10462. url: urls,
  10463. _classNames: missingClassNames,
  10464. _urlByClass: urlByClass
  10465. });
  10466. } else {
  10467. Loader.checkReady();
  10468. }
  10469. } else {
  10470. if (callback) {
  10471. callback.call(scope);
  10472. }
  10473. Loader.checkReady();
  10474. }
  10475. if (Loader.syncModeEnabled) {
  10476. if (numClasses === 1) {
  10477. return Manager.get(classNames[0]);
  10478. }
  10479. }
  10480. return Loader;
  10481. },
  10482. makeLoadCallback: function(classNames, callback) {
  10483. return function() {
  10484. var classes = [],
  10485. i = classNames.length;
  10486. while (i-- > 0) {
  10487. classes[i] = Manager.get(classNames[i]);
  10488. }
  10489. return callback.apply(this, classes);
  10490. };
  10491. },
  10492. onLoadFailure: function(request) {
  10493. var options = this,
  10494. entries = request.entries || [],
  10495. onError = options.onError,
  10496. error, entry, i;
  10497. Loader.hasFileLoadError = true;
  10498. --Loader.scriptsLoading;
  10499. if (onError) {
  10500. for (i = 0; i < entries.length; i++) {
  10501. entry = entries[i];
  10502. if (entry.error) {
  10503. error = new Error('Failed to load: ' + entry.url);
  10504. break;
  10505. }
  10506. }
  10507. error = error || new Error('Failed to load');
  10508. onError.call(options.userScope, options, error, request);
  10509. } else
  10510. {
  10511. Ext.log.error("[Ext.Loader] Some requested files failed to load.");
  10512. }
  10513. Loader.checkReady();
  10514. },
  10515. onLoadSuccess: function() {
  10516. var options = this,
  10517. onLoad = options.onLoad,
  10518. classNames = options._classNames,
  10519. urlByClass = options._urlByClass,
  10520. state = Manager.classState,
  10521. missingQueue = Loader.missingQueue,
  10522. className, i, len;
  10523. --Loader.scriptsLoading;
  10524. if (onLoad) {
  10525. onLoad.call(options.userScope, options);
  10526. }
  10527. for (i = 0 , len = classNames.length; i < len; i++) {
  10528. className = classNames[i];
  10529. if (!state[className]) {
  10530. missingQueue[className] = urlByClass[className];
  10531. }
  10532. }
  10533. Loader.checkReady();
  10534. },
  10535. reportMissingClasses: function() {
  10536. if (!Loader.syncModeEnabled && !Loader.scriptsLoading && Loader.isLoading && !Loader.hasFileLoadError) {
  10537. var missingQueue = Loader.missingQueue,
  10538. missingClasses = [],
  10539. missingPaths = [];
  10540. for (var missingClassName in missingQueue) {
  10541. missingClasses.push(missingClassName);
  10542. missingPaths.push(missingQueue[missingClassName]);
  10543. }
  10544. if (missingClasses.length) {
  10545. 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("', '"));
  10546. }
  10547. }
  10548. },
  10549. onReady: function(fn, scope, withDomReady, options) {
  10550. if (withDomReady) {
  10551. Ready.on(fn, scope, options);
  10552. } else {
  10553. var listener = Ready.makeListener(fn, scope, options);
  10554. if (Loader.isLoading) {
  10555. readyListeners.push(listener);
  10556. } else {
  10557. Ready.invoke(listener);
  10558. }
  10559. }
  10560. },
  10561. addUsedClasses: function(classes) {
  10562. var cls, i, ln;
  10563. if (classes) {
  10564. classes = (typeof classes === 'string') ? [
  10565. classes
  10566. ] : classes;
  10567. for (i = 0 , ln = classes.length; i < ln; i++) {
  10568. cls = classes[i];
  10569. if (typeof cls === 'string' && !Ext.Array.contains(usedClasses, cls)) {
  10570. usedClasses.push(cls);
  10571. }
  10572. }
  10573. }
  10574. return Loader;
  10575. },
  10576. triggerReady: function() {
  10577. var listener,
  10578. refClasses = usedClasses;
  10579. if (Loader.isLoading && refClasses.length) {
  10580. usedClasses = [];
  10581. Loader.require(refClasses);
  10582. } else {
  10583. Loader.isLoading = false;
  10584. readyListeners.sort(Ready.sortFn);
  10585. while (readyListeners.length && !Loader.isLoading) {
  10586. listener = readyListeners.pop();
  10587. Ready.invoke(listener);
  10588. }
  10589. Ready.unblock();
  10590. }
  10591. },
  10592. historyPush: function(className) {
  10593. if (className && !isInHistory[className] && !Manager.overrideMap[className]) {
  10594. isInHistory[className] = true;
  10595. history.push(className);
  10596. }
  10597. return Loader;
  10598. },
  10599. loadScripts: function(params) {
  10600. var manifest = Ext.manifest,
  10601. loadOrder = manifest && manifest.loadOrder,
  10602. loadOrderMap = manifest && manifest.loadOrderMap,
  10603. options;
  10604. ++Loader.scriptsLoading;
  10605. if (loadOrder && !loadOrderMap) {
  10606. manifest.loadOrderMap = loadOrderMap = Boot.createLoadOrderMap(loadOrder);
  10607. }
  10608. Loader.checkReady();
  10609. options = Ext.apply({
  10610. loadOrder: loadOrder,
  10611. loadOrderMap: loadOrderMap,
  10612. charset: _config.scriptCharset,
  10613. success: Loader.onLoadSuccess,
  10614. failure: Loader.onLoadFailure,
  10615. sync: Loader.syncModeEnabled,
  10616. _classNames: []
  10617. }, params);
  10618. options.userScope = options.scope;
  10619. options.scope = options;
  10620. Boot.load(options);
  10621. },
  10622. loadScriptsSync: function(urls) {
  10623. var syncwas = Loader.syncModeEnabled;
  10624. Loader.syncModeEnabled = true;
  10625. Loader.loadScripts({
  10626. url: urls
  10627. });
  10628. Loader.syncModeEnabled = syncwas;
  10629. },
  10630. loadScriptsSyncBasePrefix: function(urls) {
  10631. var syncwas = Loader.syncModeEnabled;
  10632. Loader.syncModeEnabled = true;
  10633. Loader.loadScripts({
  10634. url: urls,
  10635. prependBaseUrl: true
  10636. });
  10637. Loader.syncModeEnabled = syncwas;
  10638. },
  10639. loadScript: function(options) {
  10640. var isString = typeof options === 'string',
  10641. isArray = options instanceof Array,
  10642. isObject = !isArray && !isString,
  10643. url = isObject ? options.url : options,
  10644. onError = isObject && options.onError,
  10645. onLoad = isObject && options.onLoad,
  10646. scope = isObject && options.scope,
  10647. request = {
  10648. url: url,
  10649. scope: scope,
  10650. onLoad: onLoad,
  10651. onError: onError,
  10652. _classNames: []
  10653. };
  10654. Loader.loadScripts(request);
  10655. },
  10656. checkMissingQueue: function() {
  10657. var missingQueue = Loader.missingQueue,
  10658. newQueue = {},
  10659. name,
  10660. missing = 0;
  10661. for (name in missingQueue) {
  10662. if (!(Manager.classState[name] || Manager.isCreated(name))) {
  10663. newQueue[name] = missingQueue[name];
  10664. missing++;
  10665. }
  10666. }
  10667. Loader.missingCount = missing;
  10668. Loader.missingQueue = newQueue;
  10669. },
  10670. checkReady: function() {
  10671. var wasLoading = Loader.isLoading,
  10672. isLoading;
  10673. Loader.checkMissingQueue();
  10674. isLoading = Loader.missingCount + Loader.scriptsLoading;
  10675. if (isLoading && !wasLoading) {
  10676. Ready.block();
  10677. Loader.isLoading = !!isLoading;
  10678. } else if (!isLoading && wasLoading) {
  10679. Loader.triggerReady();
  10680. }
  10681. if (!Loader.scriptsLoading && Loader.missingCount) {
  10682. Ext.defer(function() {
  10683. if (!Loader.scriptsLoading && Loader.missingCount) {
  10684. Ext.log.error('[Loader] The following classes failed to load:');
  10685. for (var name in Loader.missingQueue) {
  10686. Ext.log.error('[Loader] ' + name + ' from ' + Loader.missingQueue[name]);
  10687. }
  10688. }
  10689. }, 1000);
  10690. }
  10691. }
  10692. });
  10693. Ext.require = alias(Loader, 'require');
  10694. Ext.syncRequire = alias(Loader, 'syncRequire');
  10695. Ext.exclude = alias(Loader, 'exclude');
  10696. Class.registerPreprocessor('loader', function(cls, data, hooks, continueFn) {
  10697. Ext.classSystemMonitor && Ext.classSystemMonitor(cls, 'Ext.Loader#loaderPreprocessor', arguments);
  10698. var me = this,
  10699. dependencies = [],
  10700. dependency,
  10701. className = Manager.getName(cls),
  10702. i, j, ln, subLn, value, propertyName, propertyValue, requiredMap;
  10703. for (i = 0 , ln = dependencyProperties.length; i < ln; i++) {
  10704. propertyName = dependencyProperties[i];
  10705. if (data.hasOwnProperty(propertyName)) {
  10706. propertyValue = data[propertyName];
  10707. if (typeof propertyValue === 'string') {
  10708. dependencies.push(propertyValue);
  10709. } else if (propertyValue instanceof Array) {
  10710. for (j = 0 , subLn = propertyValue.length; j < subLn; j++) {
  10711. value = propertyValue[j];
  10712. if (typeof value === 'string') {
  10713. dependencies.push(value);
  10714. }
  10715. }
  10716. } else if (typeof propertyValue !== 'function') {
  10717. for (j in propertyValue) {
  10718. if (propertyValue.hasOwnProperty(j)) {
  10719. value = propertyValue[j];
  10720. if (typeof value === 'string') {
  10721. dependencies.push(value);
  10722. }
  10723. }
  10724. }
  10725. }
  10726. }
  10727. }
  10728. if (dependencies.length === 0) {
  10729. return;
  10730. }
  10731. if (className) {
  10732. _requiresMap[className] = dependencies;
  10733. }
  10734. var manifestClasses = Ext.manifest && Ext.manifest.classes,
  10735. deadlockPath = [],
  10736. detectDeadlock;
  10737. if (className && (!manifestClasses || !manifestClasses[className])) {
  10738. requiredMap = Loader.requiredByMap || (Loader.requiredByMap = {});
  10739. for (i = 0 , ln = dependencies.length; i < ln; i++) {
  10740. dependency = dependencies[i];
  10741. (requiredMap[dependency] || (requiredMap[dependency] = [])).push(className);
  10742. }
  10743. detectDeadlock = function(cls) {
  10744. deadlockPath.push(cls);
  10745. var requires = _requiresMap[cls],
  10746. dep, i, ln;
  10747. if (requires) {
  10748. if (Ext.Array.contains(requires, className)) {
  10749. Ext.Error.raise("Circular requirement detected! '" + className + "' and '" + deadlockPath[1] + "' mutually require each other. Path: " + deadlockPath.join(' -> ') + " -> " + deadlockPath[0]);
  10750. }
  10751. for (i = 0 , ln = requires.length; i < ln; i++) {
  10752. dep = requires[i];
  10753. if (!isInHistory[dep]) {
  10754. detectDeadlock(requires[i]);
  10755. }
  10756. }
  10757. }
  10758. };
  10759. detectDeadlock(className);
  10760. }
  10761. (className ? Loader.exclude(className) : Loader).require(dependencies, function() {
  10762. for (i = 0 , ln = dependencyProperties.length; i < ln; i++) {
  10763. propertyName = dependencyProperties[i];
  10764. if (data.hasOwnProperty(propertyName)) {
  10765. propertyValue = data[propertyName];
  10766. if (typeof propertyValue === 'string') {
  10767. data[propertyName] = Manager.get(propertyValue);
  10768. } else if (propertyValue instanceof Array) {
  10769. for (j = 0 , subLn = propertyValue.length; j < subLn; j++) {
  10770. value = propertyValue[j];
  10771. if (typeof value === 'string') {
  10772. data[propertyName][j] = Manager.get(value);
  10773. }
  10774. }
  10775. } else if (typeof propertyValue !== 'function') {
  10776. for (var k in propertyValue) {
  10777. if (propertyValue.hasOwnProperty(k)) {
  10778. value = propertyValue[k];
  10779. if (typeof value === 'string') {
  10780. data[propertyName][k] = Manager.get(value);
  10781. }
  10782. }
  10783. }
  10784. }
  10785. }
  10786. }
  10787. continueFn.call(me, cls, data, hooks);
  10788. });
  10789. return false;
  10790. }, true, 'after', 'className');
  10791. Manager.registerPostprocessor('uses', function(name, cls, data) {
  10792. Ext.classSystemMonitor && Ext.classSystemMonitor(cls, 'Ext.Loader#usesPostprocessor', arguments);
  10793. var uses = data.uses,
  10794. classNames;
  10795. if (uses) {
  10796. classNames = Manager.getNamesByExpression(data.uses);
  10797. Loader.addUsedClasses(classNames);
  10798. }
  10799. });
  10800. Manager.onCreated(Loader.historyPush);
  10801. Loader.init();
  10802. }());
  10803. Ext._endTime = Ext.ticks();
  10804. if (Ext._beforereadyhandler) {
  10805. Ext._beforereadyhandler();
  10806. }
  10807. Ext.define('Ext.Mixin', function(Mixin) {
  10808. return {
  10809. statics: {
  10810. addHook: function(hookFn, targetClass, methodName, mixinClassPrototype) {
  10811. var isFunc = Ext.isFunction(hookFn),
  10812. hook = function() {
  10813. var a = arguments,
  10814. fn = isFunc ? hookFn : mixinClassPrototype[hookFn],
  10815. result = this.callParent(a);
  10816. fn.apply(this, a);
  10817. return result;
  10818. },
  10819. existingFn = targetClass.hasOwnProperty(methodName) && targetClass[methodName];
  10820. if (isFunc) {
  10821. hookFn.$previous = Ext.emptyFn;
  10822. }
  10823. hook.$name = methodName;
  10824. hook.$owner = targetClass.self;
  10825. if (existingFn) {
  10826. hook.$previous = existingFn.$previous;
  10827. existingFn.$previous = hook;
  10828. } else {
  10829. targetClass[methodName] = hook;
  10830. }
  10831. }
  10832. },
  10833. onClassExtended: function(cls, data) {
  10834. var mixinConfig = data.mixinConfig,
  10835. hooks = data.xhooks,
  10836. superclass = cls.superclass,
  10837. onClassMixedIn = data.onClassMixedIn,
  10838. parentMixinConfig, befores, afters, extended;
  10839. if (hooks) {
  10840. delete data.xhooks;
  10841. (mixinConfig || (data.mixinConfig = mixinConfig = {})).on = hooks;
  10842. }
  10843. if (mixinConfig) {
  10844. parentMixinConfig = superclass.mixinConfig;
  10845. if (parentMixinConfig) {
  10846. data.mixinConfig = mixinConfig = Ext.merge({}, parentMixinConfig, mixinConfig);
  10847. }
  10848. data.mixinId = mixinConfig.id;
  10849. if (mixinConfig.beforeHooks) {
  10850. Ext.raise('Use of "beforeHooks" is deprecated - use "before" instead');
  10851. }
  10852. if (mixinConfig.hooks) {
  10853. Ext.raise('Use of "hooks" is deprecated - use "after" instead');
  10854. }
  10855. if (mixinConfig.afterHooks) {
  10856. Ext.raise('Use of "afterHooks" is deprecated - use "after" instead');
  10857. }
  10858. befores = mixinConfig.before;
  10859. afters = mixinConfig.after;
  10860. hooks = mixinConfig.on;
  10861. extended = mixinConfig.extended;
  10862. }
  10863. if (befores || afters || hooks || extended) {
  10864. data.onClassMixedIn = function(targetClass) {
  10865. var mixin = this.prototype,
  10866. targetProto = targetClass.prototype,
  10867. key;
  10868. if (befores) {
  10869. Ext.Object.each(befores, function(key, value) {
  10870. targetClass.addMember(key, function() {
  10871. if (mixin[value].apply(this, arguments) !== false) {
  10872. return this.callParent(arguments);
  10873. }
  10874. });
  10875. });
  10876. }
  10877. if (afters) {
  10878. Ext.Object.each(afters, function(key, value) {
  10879. targetClass.addMember(key, function() {
  10880. var ret = this.callParent(arguments);
  10881. mixin[value].apply(this, arguments);
  10882. return ret;
  10883. });
  10884. });
  10885. }
  10886. if (hooks) {
  10887. for (key in hooks) {
  10888. Mixin.addHook(hooks[key], targetProto, key, mixin);
  10889. }
  10890. }
  10891. if (extended) {
  10892. targetClass.onExtended(function() {
  10893. var args = Ext.Array.slice(arguments, 0);
  10894. args.unshift(targetClass);
  10895. return extended.apply(this, args);
  10896. }, this);
  10897. }
  10898. if (onClassMixedIn) {
  10899. onClassMixedIn.apply(this, arguments);
  10900. }
  10901. };
  10902. }
  10903. }
  10904. };
  10905. });
  10906. Ext.util = Ext.util || {};
  10907. Ext.util.DelayedTask = function(fn, scope, args, cancelOnDelay, fireIdleEvent) {
  10908. var me = this,
  10909. delay,
  10910. call = function() {
  10911. me.id = null;
  10912. if (!(scope && scope.destroyed)) {
  10913. args ? fn.apply(scope, args) : fn.call(scope);
  10914. }
  10915. if (fireIdleEvent === false) {
  10916. Ext._suppressIdle = true;
  10917. }
  10918. };
  10919. if (fn) {
  10920. call.$origFn = fn.$origFn || fn;
  10921. call.$skipTimerCheck = call.$origFn.$skipTimerCheck;
  10922. }
  10923. cancelOnDelay = typeof cancelOnDelay === 'boolean' ? cancelOnDelay : true;
  10924. me.id = null;
  10925. me.delay = function(newDelay, newFn, newScope, newArgs) {
  10926. if (cancelOnDelay) {
  10927. me.cancel();
  10928. }
  10929. if (typeof newDelay === 'number') {
  10930. delay = newDelay;
  10931. }
  10932. fn = newFn || fn;
  10933. scope = newScope || scope;
  10934. args = newArgs || args;
  10935. me.delayTime = delay;
  10936. if (fn) {
  10937. call.$origFn = fn.$origFn || fn;
  10938. call.$skipTimerCheck = call.$origFn.$skipTimerCheck;
  10939. }
  10940. if (!me.id) {
  10941. if (delay === -1) {
  10942. me.id = Ext.raf(call);
  10943. } else {
  10944. me.id = Ext.defer(call, delay || 1);
  10945. }
  10946. }
  10947. return me.id;
  10948. };
  10949. me.cancel = function() {
  10950. if (me.id) {
  10951. if (me.delayTime === -1) {
  10952. Ext.unraf(me.id);
  10953. } else {
  10954. Ext.undefer(me.id);
  10955. }
  10956. me.id = null;
  10957. }
  10958. };
  10959. me.flush = function() {
  10960. if (me.id) {
  10961. me.cancel();
  10962. var was = fireIdleEvent;
  10963. fireIdleEvent = true;
  10964. call();
  10965. fireIdleEvent = was;
  10966. }
  10967. };
  10968. me.stop = function(stopFn, stopScope) {
  10969. if (stopFn && stopFn === fn && (!stopScope || stopScope === scope)) {
  10970. me.cancel();
  10971. }
  10972. };
  10973. };
  10974. Ext.define('Ext.util.Event', function() {
  10975. var arraySlice = Array.prototype.slice,
  10976. arrayInsert = Ext.Array.insert,
  10977. toArray = Ext.Array.toArray,
  10978. fireArgs = {};
  10979. return {
  10980. isEvent: true,
  10981. suspended: 0,
  10982. noOptions: {},
  10983. constructor: function(observable, name) {
  10984. this.name = name;
  10985. this.observable = observable;
  10986. this.listeners = [];
  10987. },
  10988. addListener: function(fn, scope, options, caller, manager) {
  10989. var me = this,
  10990. added = false,
  10991. observable = me.observable,
  10992. eventName = me.name,
  10993. listeners, listener, priority, isNegativePriority, highestNegativePriorityIndex, hasNegativePriorityIndex, length, index, i, listenerPriority, managedListeners;
  10994. if (scope && !Ext._namedScopes[scope] && (typeof fn === 'string') && (typeof scope[fn] !== 'function')) {
  10995. Ext.raise("No method named '" + fn + "' found on scope object");
  10996. }
  10997. if (me.findListener(fn, scope) === -1) {
  10998. listener = me.createListener(fn, scope, options, caller, manager);
  10999. if (me.firing) {
  11000. me.listeners = me.listeners.slice(0);
  11001. }
  11002. listeners = me.listeners;
  11003. index = length = listeners.length;
  11004. priority = options && options.priority;
  11005. highestNegativePriorityIndex = me._highestNegativePriorityIndex;
  11006. hasNegativePriorityIndex = highestNegativePriorityIndex !== undefined;
  11007. if (priority) {
  11008. isNegativePriority = (priority < 0);
  11009. if (!isNegativePriority || hasNegativePriorityIndex) {
  11010. for (i = (isNegativePriority ? highestNegativePriorityIndex : 0); i < length; i++) {
  11011. listenerPriority = listeners[i].o ? listeners[i].o.priority || 0 : 0;
  11012. if (listenerPriority < priority) {
  11013. index = i;
  11014. break;
  11015. }
  11016. }
  11017. } else {
  11018. me._highestNegativePriorityIndex = index;
  11019. }
  11020. } else if (hasNegativePriorityIndex) {
  11021. index = highestNegativePriorityIndex;
  11022. }
  11023. if (!isNegativePriority && index <= highestNegativePriorityIndex) {
  11024. me._highestNegativePriorityIndex++;
  11025. }
  11026. if (index === length) {
  11027. listeners[length] = listener;
  11028. } else {
  11029. arrayInsert(listeners, index, [
  11030. listener
  11031. ]);
  11032. }
  11033. if (observable.isElement) {
  11034. observable._getPublisher(eventName, options.translate === false).subscribe(observable, eventName, options.delegated !== false, options.capture);
  11035. }
  11036. if (manager) {
  11037. managedListeners = manager.managedListeners || (manager.managedListeners = []);
  11038. managedListeners.push({
  11039. item: me.observable,
  11040. ename: (options && options.managedName) || me.name,
  11041. fn: fn,
  11042. scope: scope,
  11043. options: options
  11044. });
  11045. }
  11046. added = true;
  11047. }
  11048. return added;
  11049. },
  11050. createListener: function(fn, scope, o, caller, manager) {
  11051. var me = this,
  11052. namedScope = Ext._namedScopes[scope],
  11053. listener = {
  11054. fn: fn,
  11055. scope: scope,
  11056. ev: me,
  11057. caller: caller,
  11058. manager: manager,
  11059. namedScope: namedScope,
  11060. defaultScope: namedScope ? (scope || me.observable) : undefined,
  11061. lateBound: typeof fn === 'string'
  11062. },
  11063. handler = fn,
  11064. wrapped = false,
  11065. type;
  11066. if (o) {
  11067. listener.o = o;
  11068. if (o.single) {
  11069. handler = me.createSingle(handler, listener, o, scope);
  11070. wrapped = true;
  11071. }
  11072. if (o.target) {
  11073. handler = me.createTargeted(handler, listener, o, scope, wrapped);
  11074. wrapped = true;
  11075. }
  11076. if (o.onFrame) {
  11077. handler = me.createAnimFrame(handler, listener, o, scope, wrapped);
  11078. wrapped = true;
  11079. }
  11080. if (o.delay) {
  11081. handler = me.createDelayed(handler, listener, o, scope, wrapped);
  11082. wrapped = true;
  11083. }
  11084. if (o.buffer) {
  11085. handler = me.createBuffered(handler, listener, o, scope, wrapped);
  11086. wrapped = true;
  11087. }
  11088. if (me.observable.isElement) {
  11089. type = o.type;
  11090. if (type) {
  11091. listener.type = type;
  11092. }
  11093. }
  11094. }
  11095. listener.fireFn = handler;
  11096. listener.wrapped = wrapped;
  11097. return listener;
  11098. },
  11099. findListener: function(fn, scope) {
  11100. var listeners = this.listeners,
  11101. i = listeners.length,
  11102. listener;
  11103. while (i--) {
  11104. listener = listeners[i];
  11105. if (listener) {
  11106. if (listener.fn === fn && listener.scope == scope) {
  11107. return i;
  11108. }
  11109. }
  11110. }
  11111. return -1;
  11112. },
  11113. removeListener: function(fn, scope, index) {
  11114. var me = this,
  11115. removed = false,
  11116. observable = me.observable,
  11117. eventName = me.name,
  11118. listener, options, manager, managedListeners, managedListener, i;
  11119. index = index != null ? index : me.findListener(fn, scope);
  11120. if (index !== -1) {
  11121. listener = me.listeners[index];
  11122. if (me.firing) {
  11123. me.listeners = me.listeners.slice(0);
  11124. }
  11125. me.listeners.splice(index, 1);
  11126. if (me._highestNegativePriorityIndex) {
  11127. if (index < me._highestNegativePriorityIndex) {
  11128. me._highestNegativePriorityIndex--;
  11129. } else if (index === me._highestNegativePriorityIndex && index === me.listeners.length) {
  11130. delete me._highestNegativePriorityIndex;
  11131. }
  11132. }
  11133. if (listener) {
  11134. options = listener.o;
  11135. if (listener.task) {
  11136. listener.task.cancel();
  11137. delete listener.task;
  11138. }
  11139. i = listener.tasks && listener.tasks.length;
  11140. if (i) {
  11141. while (i--) {
  11142. listener.tasks[i].cancel();
  11143. }
  11144. delete listener.tasks;
  11145. }
  11146. listener.fireFn.timerId = Ext.undefer(listener.fireFn.timerId);
  11147. manager = listener.manager;
  11148. if (manager) {
  11149. managedListeners = manager.managedListeners;
  11150. if (managedListeners) {
  11151. for (i = managedListeners.length; i--; ) {
  11152. managedListener = managedListeners[i];
  11153. if (managedListener.item === me.observable && managedListener.ename === eventName && managedListener.fn === fn && managedListener.scope === scope) {
  11154. managedListeners.splice(i, 1);
  11155. }
  11156. }
  11157. }
  11158. }
  11159. if (observable.isElement) {
  11160. observable._getPublisher(eventName, options.translate === false).unsubscribe(observable, eventName, options.delegated !== false, options.capture);
  11161. }
  11162. }
  11163. removed = true;
  11164. }
  11165. return removed;
  11166. },
  11167. clearListeners: function() {
  11168. var listeners = this.listeners,
  11169. i = listeners.length,
  11170. listener;
  11171. while (i--) {
  11172. listener = listeners[i];
  11173. this.removeListener(listener.fn, listener.scope);
  11174. }
  11175. },
  11176. suspend: function() {
  11177. ++this.suspended;
  11178. },
  11179. resume: function() {
  11180. if (this.suspended) {
  11181. --this.suspended;
  11182. }
  11183. },
  11184. isSuspended: function() {
  11185. return this.suspended > 0;
  11186. },
  11187. fireDelegated: function(firingObservable, args) {
  11188. this.firingObservable = firingObservable;
  11189. return this.fire.apply(this, args);
  11190. },
  11191. fire: function() {
  11192. var me = this,
  11193. CQ = Ext.ComponentQuery,
  11194. listeners = me.listeners,
  11195. count = listeners.length,
  11196. observable = me.observable,
  11197. isElement = observable.isElement,
  11198. isComponent = observable.isComponent,
  11199. firingObservable = me.firingObservable,
  11200. options, delegate, fireInfo, i, args, listener, len, delegateEl, currentTarget, type, chained, firingArgs, e, fireFn, fireScope;
  11201. if (!me.suspended && count > 0) {
  11202. me.firing = true;
  11203. args = arguments.length ? arraySlice.call(arguments, 0) : [];
  11204. len = args.length;
  11205. if (isElement) {
  11206. e = args[0];
  11207. }
  11208. for (i = 0; i < count; i++) {
  11209. listener = listeners[i];
  11210. if (!listener) {
  11211. continue;
  11212. }
  11213. options = listener.o;
  11214. if (isElement) {
  11215. if (currentTarget) {
  11216. e.setCurrentTarget(currentTarget);
  11217. }
  11218. type = listener.type;
  11219. if (type) {
  11220. chained = e;
  11221. e = args[0] = chained.chain({
  11222. type: type,
  11223. isGesture: false
  11224. });
  11225. }
  11226. Ext.EventObject = e;
  11227. }
  11228. firingArgs = args;
  11229. if (options) {
  11230. delegate = options.delegate;
  11231. if (delegate) {
  11232. if (isElement) {
  11233. delegateEl = e.getTarget(typeof delegate === 'function' ? delegate : '#' + e.currentTarget.id + ' ' + delegate);
  11234. if (delegateEl) {
  11235. args[1] = delegateEl;
  11236. currentTarget = e.currentTarget;
  11237. e.setCurrentTarget(delegateEl);
  11238. } else {
  11239. continue;
  11240. }
  11241. } else if (isComponent && !CQ.is(firingObservable, delegate, observable)) {
  11242. continue;
  11243. }
  11244. }
  11245. if (isElement) {
  11246. if (options.preventDefault) {
  11247. e.preventDefault();
  11248. }
  11249. if (options.stopPropagation) {
  11250. e.stopPropagation();
  11251. }
  11252. if (options.stopEvent) {
  11253. e.stopEvent();
  11254. }
  11255. }
  11256. args[len] = options;
  11257. if (options.args) {
  11258. firingArgs = options.args.concat(args);
  11259. }
  11260. }
  11261. fireInfo = me.getFireInfo(listener);
  11262. fireFn = fireInfo.fn;
  11263. fireScope = fireInfo.scope;
  11264. fireInfo.fn = fireInfo.scope = null;
  11265. if (fireScope && fireScope.destroyed) {
  11266. me.removeListener(fireFn, fireScope, i);
  11267. fireFn = null;
  11268. if (fireScope.$className !== 'Ext.container.Monitor') {
  11269. (Ext.raiseOnDestroyed ? Ext.raise : Ext.log.warn)({
  11270. msg: 'Attempting to fire "' + me.name + '" event on destroyed ' + (fireScope.$className || 'object') + ' instance with id: ' + (fireScope.id || 'unknown'),
  11271. instance: fireScope
  11272. });
  11273. }
  11274. }
  11275. if (fireFn && fireFn.apply(fireScope, firingArgs) === false) {
  11276. Ext.EventObject = null;
  11277. return (me.firing = false);
  11278. }
  11279. if (options) {
  11280. args.length--;
  11281. }
  11282. if (chained) {
  11283. e = args[0] = chained;
  11284. chained = null;
  11285. }
  11286. Ext.EventObject = null;
  11287. }
  11288. }
  11289. me.firing = false;
  11290. return true;
  11291. },
  11292. getFireInfo: function(listener, fromWrapped) {
  11293. var observable = this.observable,
  11294. fireFn = listener.fireFn,
  11295. scope = listener.scope,
  11296. namedScope = listener.namedScope,
  11297. fn;
  11298. if (!fromWrapped && listener.wrapped) {
  11299. fireArgs.fn = fireFn;
  11300. return fireArgs;
  11301. }
  11302. fn = fromWrapped ? listener.fn : fireFn;
  11303. var name = fn;
  11304. if (listener.lateBound) {
  11305. if (!scope || namedScope) {
  11306. scope = (listener.caller || observable).resolveListenerScope(listener.defaultScope);
  11307. }
  11308. if (!scope) {
  11309. Ext.raise('Unable to dynamically resolve scope for "' + listener.ev.name + '" listener on ' + this.observable.id);
  11310. }
  11311. if (!Ext.isFunction(scope[fn])) {
  11312. Ext.raise('No method named "' + fn + '" on ' + (scope.$className || 'scope object.'));
  11313. }
  11314. fn = scope[fn];
  11315. } else if (namedScope && namedScope.isController) {
  11316. scope = (listener.caller || observable).resolveListenerScope(listener.defaultScope);
  11317. if (!scope) {
  11318. Ext.raise('Unable to dynamically resolve scope for "' + listener.ev.name + '" listener on ' + this.observable.id);
  11319. }
  11320. }
  11321. else if (!scope || namedScope) {
  11322. scope = observable;
  11323. }
  11324. fireArgs.fn = fn;
  11325. fireArgs.scope = scope;
  11326. if (!fn) {
  11327. Ext.raise('Unable to dynamically resolve method "' + name + '" on ' + this.observable.$className);
  11328. }
  11329. return fireArgs;
  11330. },
  11331. createAnimFrame: function(handler, listener, o, scope, wrapped) {
  11332. var fireInfo;
  11333. if (!wrapped) {
  11334. fireInfo = listener.ev.getFireInfo(listener, true);
  11335. handler = fireInfo.fn;
  11336. scope = fireInfo.scope;
  11337. fireInfo.fn = fireInfo.scope = null;
  11338. }
  11339. return Ext.Function.createAnimationFrame(handler, scope, o.args);
  11340. },
  11341. createTargeted: function(handler, listener, o, scope, wrapped) {
  11342. return function() {
  11343. if (o.target === arguments[0]) {
  11344. var fireInfo;
  11345. if (!wrapped) {
  11346. fireInfo = listener.ev.getFireInfo(listener, true);
  11347. handler = fireInfo.fn;
  11348. scope = fireInfo.scope;
  11349. fireInfo.fn = fireInfo.scope = null;
  11350. }
  11351. return handler.apply(scope, arguments);
  11352. }
  11353. };
  11354. },
  11355. createBuffered: function(handler, listener, o, scope, wrapped) {
  11356. listener.task = new Ext.util.DelayedTask();
  11357. return function() {
  11358. if (listener.task) {
  11359. var fireInfo;
  11360. if (Ext.Timer.track) {
  11361. o.$delayedTask = listener.task;
  11362. }
  11363. if (!wrapped) {
  11364. fireInfo = listener.ev.getFireInfo(listener, true);
  11365. handler = fireInfo.fn;
  11366. scope = fireInfo.scope;
  11367. fireInfo.fn = fireInfo.scope = null;
  11368. }
  11369. listener.task.delay(o.buffer, handler, scope, toArray(arguments));
  11370. }
  11371. };
  11372. },
  11373. createDelayed: function(handler, listener, o, scope, wrapped) {
  11374. return function() {
  11375. var task = new Ext.util.DelayedTask(),
  11376. fireInfo;
  11377. if (!wrapped) {
  11378. fireInfo = listener.ev.getFireInfo(listener, true);
  11379. handler = fireInfo.fn;
  11380. scope = fireInfo.scope;
  11381. fireInfo.fn = fireInfo.scope = null;
  11382. }
  11383. if (!listener.tasks) {
  11384. listener.tasks = [];
  11385. }
  11386. listener.tasks.push(task);
  11387. if (Ext.Timer.track) {
  11388. o.$delayedTask = task;
  11389. }
  11390. task.delay(o.delay || 10, handler, scope, toArray(arguments));
  11391. };
  11392. },
  11393. createSingle: function(handler, listener, o, scope, wrapped) {
  11394. return function() {
  11395. var event = listener.ev,
  11396. observable = event.observable,
  11397. fn = listener.fn,
  11398. fireInfo;
  11399. if (observable) {
  11400. if (!observable.destroyed) {
  11401. observable.removeListener(event.name, fn, scope);
  11402. }
  11403. } else {
  11404. event.removeListener(fn, scope);
  11405. }
  11406. if (!wrapped) {
  11407. fireInfo = event.getFireInfo(listener, true);
  11408. handler = fireInfo.fn;
  11409. scope = fireInfo.scope;
  11410. fireInfo.fn = fireInfo.scope = null;
  11411. }
  11412. return handler.apply(scope, arguments);
  11413. };
  11414. }
  11415. };
  11416. });
  11417. Ext.define('Ext.mixin.Identifiable', {
  11418. statics: {
  11419. uniqueIds: {}
  11420. },
  11421. isIdentifiable: true,
  11422. mixinId: 'identifiable',
  11423. idCleanRegex: /\.|[^\w\-]/g,
  11424. defaultIdPrefix: 'ext-',
  11425. defaultIdSeparator: '-',
  11426. getOptimizedId: function() {
  11427. return this.id;
  11428. },
  11429. getUniqueId: function() {
  11430. var id = this.id,
  11431. prototype, separator, xtype, uniqueIds, prefix;
  11432. if (!(id || id === 0)) {
  11433. prototype = this.self.prototype;
  11434. separator = this.defaultIdSeparator;
  11435. uniqueIds = Ext.mixin.Identifiable.uniqueIds;
  11436. if (!prototype.hasOwnProperty('identifiablePrefix')) {
  11437. xtype = this.xtype;
  11438. if (xtype) {
  11439. prefix = this.defaultIdPrefix + xtype.replace(this.idCleanRegex, separator) + separator;
  11440. } else if (!(prefix = prototype.$className)) {
  11441. prefix = this.defaultIdPrefix + 'anonymous' + separator;
  11442. } else {
  11443. prefix = prefix.replace(this.idCleanRegex, separator).toLowerCase() + separator;
  11444. }
  11445. prototype.identifiablePrefix = prefix;
  11446. }
  11447. prefix = this.identifiablePrefix;
  11448. if (!uniqueIds.hasOwnProperty(prefix)) {
  11449. uniqueIds[prefix] = 0;
  11450. }
  11451. id = this.id = this.id = prefix + (++uniqueIds[prefix]);
  11452. }
  11453. this.getUniqueId = this.getOptimizedId;
  11454. return id;
  11455. },
  11456. setId: function(id) {
  11457. this.id = this.id = id;
  11458. },
  11459. getId: function() {
  11460. var id = this.id;
  11461. if (!id) {
  11462. id = this.getUniqueId();
  11463. }
  11464. this.getId = this.getOptimizedId;
  11465. return id;
  11466. }
  11467. });
  11468. Ext.define('Ext.mixin.Observable', function(Observable) {
  11469. var emptyFn = Ext.emptyFn,
  11470. emptyArray = [],
  11471. arrayProto = Array.prototype,
  11472. arraySlice = arrayProto.slice,
  11473. ListenerRemover = function(observable) {
  11474. if (observable instanceof ListenerRemover) {
  11475. return observable;
  11476. }
  11477. this.observable = observable;
  11478. if (arguments[1].isObservable) {
  11479. this.managedListeners = true;
  11480. }
  11481. this.args = arraySlice.call(arguments, 1);
  11482. },
  11483. protectedProps = [
  11484. 'events',
  11485. 'hasListeners',
  11486. 'managedListeners',
  11487. 'eventedBeforeEventNames'
  11488. ];
  11489. ListenerRemover.prototype.destroy = function() {
  11490. var me = this,
  11491. args = me.args,
  11492. observable = me.observable,
  11493. elementName = args[0].element || (args[3] && args[3].element);
  11494. if (elementName) {
  11495. if (Ext.Array.indexOf(observable.referenceList, elementName) === -1) {
  11496. Ext.Logger.error("Destroying event listener with an invalid element reference of '" + elementName + "' for this component. Available values are: '" + observable.referenceList.join("', '") + "'", observable);
  11497. }
  11498. observable = observable[elementName];
  11499. }
  11500. if (!observable.destroyed) {
  11501. observable[me.managedListeners ? 'mun' : 'un'].apply(observable, me.args);
  11502. }
  11503. me.destroy = Ext.emptyFn;
  11504. };
  11505. return {
  11506. extend: Ext.Mixin,
  11507. mixinConfig: {
  11508. id: 'observable',
  11509. after: {
  11510. destroy: 'destroyObservable'
  11511. }
  11512. },
  11513. mixins: [
  11514. Ext.mixin.Identifiable
  11515. ],
  11516. statics: {
  11517. releaseCapture: function(o) {
  11518. o.fireEventArgs = this.prototype.fireEventArgs;
  11519. },
  11520. capture: function(o, fn, scope) {
  11521. var newFn = function(eventName, args) {
  11522. return fn.apply(scope, [
  11523. eventName
  11524. ].concat(args));
  11525. };
  11526. this.captureArgs(o, newFn, scope);
  11527. },
  11528. captureArgs: function(o, fn, scope) {
  11529. o.fireEventArgs = Ext.Function.createInterceptor(o.fireEventArgs, fn, scope);
  11530. },
  11531. observe: function(cls, listeners) {
  11532. if (cls) {
  11533. if (!cls.isObservable) {
  11534. Ext.applyIf(cls, new this());
  11535. this.captureArgs(cls.prototype, cls.fireEventArgs, cls);
  11536. }
  11537. if (Ext.isObject(listeners)) {
  11538. cls.on(listeners);
  11539. }
  11540. }
  11541. return cls;
  11542. },
  11543. prepareClass: function(T, mixin, data) {
  11544. var listeners = T.listeners = [],
  11545. target = data || T.prototype,
  11546. targetListeners = target.listeners,
  11547. superListeners = mixin ? mixin.listeners : T.superclass.self.listeners,
  11548. name, scope, namedScope, i, len;
  11549. if (superListeners) {
  11550. listeners.push(superListeners);
  11551. }
  11552. if (targetListeners) {
  11553. scope = targetListeners.scope;
  11554. if (!scope) {
  11555. targetListeners.scope = 'self';
  11556. } else {
  11557. namedScope = Ext._namedScopes[scope];
  11558. if (namedScope && namedScope.isController) {
  11559. targetListeners.scope = 'self.controller';
  11560. }
  11561. }
  11562. listeners.push(targetListeners);
  11563. target.listeners = null;
  11564. }
  11565. if (!T.HasListeners) {
  11566. var HasListeners = function() {},
  11567. SuperHL = T.superclass.HasListeners || (mixin && mixin.HasListeners) || Observable.HasListeners;
  11568. T.prototype.HasListeners = T.HasListeners = HasListeners;
  11569. HasListeners.prototype = T.hasListeners = new SuperHL();
  11570. }
  11571. scope = T.prototype.$noClearOnDestroy || {};
  11572. for (i = 0 , len = protectedProps.length; i < len; i++) {
  11573. scope[protectedProps[i]] = true;
  11574. }
  11575. T.prototype.$noClearOnDestroy = scope;
  11576. }
  11577. },
  11578. isObservable: true,
  11579. $vetoClearingPrototypeOnDestroy: true,
  11580. eventsSuspended: 0,
  11581. constructor: function(config) {
  11582. var me = this,
  11583. self = me.self,
  11584. declaredListeners, listeners, bubbleEvents, len, i;
  11585. if (me.$observableInitialized) {
  11586. return;
  11587. }
  11588. me.$observableInitialized = true;
  11589. me.hasListeners = me.hasListeners = new me.HasListeners();
  11590. me.eventedBeforeEventNames = {};
  11591. me.events = me.events || {};
  11592. declaredListeners = self.listeners;
  11593. if (declaredListeners && !me._addDeclaredListeners(declaredListeners)) {
  11594. self.listeners = null;
  11595. }
  11596. listeners = (config && config.listeners) || me.listeners;
  11597. if (listeners) {
  11598. if (listeners instanceof Array) {
  11599. for (i = 0 , len = listeners.length; i < len; ++i) {
  11600. me.addListener(listeners[i]);
  11601. }
  11602. } else {
  11603. me.addListener(listeners);
  11604. }
  11605. }
  11606. bubbleEvents = (config && config.bubbleEvents) || me.bubbleEvents;
  11607. if (bubbleEvents) {
  11608. me.enableBubble(bubbleEvents);
  11609. }
  11610. if (me.$applyConfigs) {
  11611. if (config) {
  11612. Ext.apply(me, config);
  11613. }
  11614. } else {
  11615. me.initConfig(config);
  11616. }
  11617. if (listeners) {
  11618. me.listeners = null;
  11619. }
  11620. },
  11621. onClassExtended: function(T, data) {
  11622. if (!T.HasListeners) {
  11623. Observable.prepareClass(T, T.prototype.$observableMixedIn ? undefined : data);
  11624. }
  11625. },
  11626. $eventOptions: {
  11627. scope: 1,
  11628. delay: 1,
  11629. buffer: 1,
  11630. onFrame: 1,
  11631. single: 1,
  11632. args: 1,
  11633. destroyable: 1,
  11634. priority: 1,
  11635. order: 1
  11636. },
  11637. $orderToPriority: {
  11638. before: 100,
  11639. current: 0,
  11640. after: -100
  11641. },
  11642. _addDeclaredListeners: function(listeners) {
  11643. var me = this;
  11644. if (listeners instanceof Array) {
  11645. Ext.each(listeners, me._addDeclaredListeners, me);
  11646. } else {
  11647. me._addedDeclaredListeners = true;
  11648. me.addListener(listeners);
  11649. }
  11650. return me._addedDeclaredListeners;
  11651. },
  11652. addManagedListener: function(item, ename, fn, scope, options, noDestroy) {
  11653. var me = this,
  11654. managedListeners = me.managedListeners = me.managedListeners || [],
  11655. config, passedOptions;
  11656. if (typeof ename !== 'string') {
  11657. passedOptions = arguments.length > 4 ? options : ename;
  11658. options = ename;
  11659. for (ename in options) {
  11660. if (options.hasOwnProperty(ename)) {
  11661. config = options[ename];
  11662. if (!item.$eventOptions[ename]) {
  11663. me.addManagedListener(item, ename, config.fn || config, config.scope || options.scope || scope, config.fn ? config : passedOptions, true);
  11664. }
  11665. }
  11666. }
  11667. if (options && options.destroyable) {
  11668. return new ListenerRemover(me, item, options);
  11669. }
  11670. } else {
  11671. if (fn !== emptyFn) {
  11672. item.doAddListener(ename, fn, scope, options, null, me, me);
  11673. if (!noDestroy && options && options.destroyable) {
  11674. return new ListenerRemover(me, item, ename, fn, scope);
  11675. }
  11676. }
  11677. }
  11678. },
  11679. removeManagedListener: function(item, ename, fn, scope) {
  11680. var me = this,
  11681. options, config, managedListeners, length, i;
  11682. if (item.$observableDestroyed) {
  11683. return;
  11684. }
  11685. if (typeof ename !== 'string') {
  11686. options = ename;
  11687. for (ename in options) {
  11688. if (options.hasOwnProperty(ename)) {
  11689. config = options[ename];
  11690. if (!item.$eventOptions[ename]) {
  11691. me.removeManagedListener(item, ename, config.fn || config, config.scope || options.scope || scope);
  11692. }
  11693. }
  11694. }
  11695. } else {
  11696. managedListeners = me.managedListeners ? me.managedListeners.slice() : [];
  11697. ename = Ext.canonicalEventName(ename);
  11698. for (i = 0 , length = managedListeners.length; i < length; i++) {
  11699. me.removeManagedListenerItem(false, managedListeners[i], item, ename, fn, scope);
  11700. }
  11701. }
  11702. },
  11703. fireEvent: function(eventName) {
  11704. return this.fireEventArgs(eventName, arraySlice.call(arguments, 1));
  11705. },
  11706. resolveListenerScope: function(defaultScope) {
  11707. var namedScope = Ext._namedScopes[defaultScope];
  11708. if (namedScope) {
  11709. if (namedScope.isController) {
  11710. Ext.raise('scope: "controller" can only be specified on classes that derive from Ext.Component or Ext.Widget');
  11711. }
  11712. if (namedScope.isSelf || namedScope.isThis) {
  11713. defaultScope = null;
  11714. }
  11715. }
  11716. return defaultScope || this;
  11717. },
  11718. fireEventArgs: function(eventName, args) {
  11719. eventName = Ext.canonicalEventName(eventName);
  11720. var me = this,
  11721. events = me.events,
  11722. event = events && events[eventName],
  11723. ret = true;
  11724. if (me.hasListeners[eventName]) {
  11725. ret = me.doFireEvent(eventName, args || emptyArray, event ? event.bubble : false);
  11726. }
  11727. return ret;
  11728. },
  11729. fireAction: function(eventName, args, fn, scope, options, order) {
  11730. if (typeof fn === 'string' && !scope) {
  11731. fn = this[fn];
  11732. }
  11733. options = options ? Ext.Object.chain(options) : {};
  11734. options.single = true;
  11735. options.priority = ((order === 'after') ? -99.5 : 99.5);
  11736. this.doAddListener(eventName, fn, scope, options);
  11737. this.fireEventArgs(eventName, args);
  11738. },
  11739. $eventedController: {
  11740. _paused: 1,
  11741. pause: function() {
  11742. ++this._paused;
  11743. },
  11744. resume: function() {
  11745. var me = this,
  11746. fn = me.fn,
  11747. scope = me.scope,
  11748. fnArgs = me.fnArgs,
  11749. owner = me.owner,
  11750. args, ret;
  11751. if (!--me._paused) {
  11752. if (fn) {
  11753. args = Ext.Array.slice(fnArgs || me.args);
  11754. if (fnArgs === false) {
  11755. args.shift();
  11756. }
  11757. me.fn = null;
  11758. args.push(me);
  11759. if (Ext.isFunction(fn)) {
  11760. ret = fn.apply(scope, args);
  11761. } else if (scope && Ext.isString(fn) && Ext.isFunction(scope[fn])) {
  11762. ret = scope[fn].apply(scope, args);
  11763. }
  11764. if (ret === false) {
  11765. return false;
  11766. }
  11767. }
  11768. if (!me._paused) {
  11769. return me.owner.fireEventArgs(me.eventName, me.args);
  11770. }
  11771. }
  11772. }
  11773. },
  11774. fireEventedAction: function(eventName, args, fn, scope, fnArgs) {
  11775. var me = this,
  11776. eventedBeforeEventNames = me.eventedBeforeEventNames,
  11777. beforeEventName = eventedBeforeEventNames[eventName] || (eventedBeforeEventNames[eventName] = 'before' + eventName),
  11778. controller = Ext.apply({
  11779. owner: me,
  11780. eventName: eventName,
  11781. fn: fn,
  11782. scope: scope,
  11783. fnArgs: fnArgs,
  11784. args: args
  11785. }, me.$eventedController),
  11786. value;
  11787. args.push(controller);
  11788. value = me.fireEventArgs(beforeEventName, args);
  11789. args.pop();
  11790. if (value === false) {
  11791. return false;
  11792. }
  11793. return controller.resume();
  11794. },
  11795. doFireEvent: function(eventName, args, bubbles) {
  11796. var target = this,
  11797. queue, event,
  11798. ret = true;
  11799. do {
  11800. if (target.eventsSuspended) {
  11801. if ((queue = target.eventQueue)) {
  11802. queue.push([
  11803. eventName,
  11804. args
  11805. ]);
  11806. }
  11807. return ret;
  11808. } else {
  11809. event = target.events && target.events[eventName];
  11810. if (event && event !== true) {
  11811. if ((ret = event.fire.apply(event, args)) === false) {
  11812. break;
  11813. }
  11814. }
  11815. }
  11816. } while (
  11817. bubbles && (target = target.getBubbleParent()));
  11818. return ret;
  11819. },
  11820. getBubbleParent: function() {
  11821. var me = this,
  11822. parent = me.getBubbleTarget && me.getBubbleTarget();
  11823. if (parent && parent.isObservable) {
  11824. return parent;
  11825. }
  11826. return null;
  11827. },
  11828. addListener: function(eventName, fn, scope, options, order, caller) {
  11829. var me = this,
  11830. namedScopes = Ext._namedScopes,
  11831. config, namedScope, isClassListener, innerScope, eventOptions;
  11832. if (typeof eventName !== 'string') {
  11833. options = eventName;
  11834. scope = options.scope;
  11835. namedScope = scope && namedScopes[scope];
  11836. isClassListener = namedScope && namedScope.isSelf;
  11837. eventOptions = ((me.isComponent || me.isWidget) && options.element) ? me.$elementEventOptions : me.$eventOptions;
  11838. for (eventName in options) {
  11839. config = options[eventName];
  11840. if (!eventOptions[eventName]) {
  11841. innerScope = config.scope;
  11842. if (innerScope && isClassListener) {
  11843. namedScope = namedScopes[innerScope];
  11844. if (namedScope && namedScope.isController) {
  11845. innerScope = 'self.controller';
  11846. }
  11847. }
  11848. me.doAddListener(eventName, config.fn || config, innerScope || scope, config.fn ? config : options, order, caller);
  11849. }
  11850. }
  11851. if (options && options.destroyable) {
  11852. return new ListenerRemover(me, options);
  11853. }
  11854. } else {
  11855. me.doAddListener(eventName, fn, scope, options, order, caller);
  11856. if (options && options.destroyable) {
  11857. return new ListenerRemover(me, eventName, fn, scope, options);
  11858. }
  11859. }
  11860. return me;
  11861. },
  11862. removeListener: function(eventName, fn, scope, eventOptions) {
  11863. var me = this,
  11864. config, options;
  11865. if (typeof eventName !== 'string') {
  11866. options = eventName;
  11867. eventOptions = eventOptions || me.$eventOptions;
  11868. for (eventName in options) {
  11869. if (options.hasOwnProperty(eventName)) {
  11870. config = options[eventName];
  11871. if (!me.$eventOptions[eventName]) {
  11872. me.doRemoveListener(eventName, config.fn || config, config.scope || options.scope);
  11873. }
  11874. }
  11875. }
  11876. } else {
  11877. me.doRemoveListener(eventName, fn, scope);
  11878. }
  11879. return me;
  11880. },
  11881. onBefore: function(eventName, fn, scope, options) {
  11882. return this.addListener(eventName, fn, scope, options, 'before');
  11883. },
  11884. onAfter: function(eventName, fn, scope, options) {
  11885. return this.addListener(eventName, fn, scope, options, 'after');
  11886. },
  11887. unBefore: function(eventName, fn, scope, options) {
  11888. return this.removeListener(eventName, fn, scope, options, 'before');
  11889. },
  11890. unAfter: function(eventName, fn, scope, options) {
  11891. return this.removeListener(eventName, fn, scope, options, 'after');
  11892. },
  11893. addBeforeListener: function() {
  11894. return this.onBefore.apply(this, arguments);
  11895. },
  11896. addAfterListener: function() {
  11897. return this.onAfter.apply(this, arguments);
  11898. },
  11899. removeBeforeListener: function() {
  11900. return this.unBefore.apply(this, arguments);
  11901. },
  11902. removeAfterListener: function() {
  11903. return this.unAfter.apply(this, arguments);
  11904. },
  11905. clearListeners: function() {
  11906. var me = this,
  11907. events = me.events,
  11908. hasListeners = me.hasListeners,
  11909. event, key;
  11910. if (events) {
  11911. for (key in events) {
  11912. if (events.hasOwnProperty(key)) {
  11913. event = events[key];
  11914. if (event.isEvent) {
  11915. delete hasListeners[key];
  11916. event.clearListeners();
  11917. }
  11918. }
  11919. }
  11920. me.events = null;
  11921. }
  11922. me.clearManagedListeners();
  11923. },
  11924. purgeListeners: function() {
  11925. if (Ext.global.console) {
  11926. Ext.global.console.warn('Observable: purgeListeners has been deprecated. Please use clearListeners.');
  11927. }
  11928. return this.clearListeners.apply(this, arguments);
  11929. },
  11930. clearManagedListeners: function() {
  11931. var me = this,
  11932. managedListeners = me.managedListeners,
  11933. i, len;
  11934. if (managedListeners) {
  11935. me.managedListeners = null;
  11936. for (i = 0 , len = managedListeners.length; i < len; i++) {
  11937. me.removeManagedListenerItem(true, managedListeners[i]);
  11938. }
  11939. managedListeners.length = 0;
  11940. }
  11941. me.managedListeners = managedListeners;
  11942. },
  11943. removeManagedListenerItem: function(isClear, managedListener, item, ename, fn, scope) {
  11944. if (isClear || (managedListener.item === item && managedListener.ename === ename && (!fn || managedListener.fn === fn) && (!scope || managedListener.scope === scope))) {
  11945. if (!managedListener.item.destroyed) {
  11946. managedListener.item.doRemoveListener(managedListener.ename, managedListener.fn, managedListener.scope, managedListener.options);
  11947. }
  11948. if (!isClear) {
  11949. Ext.Array.remove(this.managedListeners, managedListener);
  11950. }
  11951. }
  11952. },
  11953. purgeManagedListeners: function() {
  11954. if (Ext.global.console) {
  11955. Ext.global.console.warn('Observable: purgeManagedListeners has been deprecated. Please use clearManagedListeners.');
  11956. }
  11957. return this.clearManagedListeners.apply(this, arguments);
  11958. },
  11959. hasListener: function(eventName) {
  11960. eventName = Ext.canonicalEventName(eventName);
  11961. return !!this.hasListeners[eventName];
  11962. },
  11963. isSuspended: function(event) {
  11964. var suspended = this.eventsSuspended > 0,
  11965. events = this.events;
  11966. if (!suspended && event && events) {
  11967. event = events[event];
  11968. if (event && event.isEvent) {
  11969. return event.isSuspended();
  11970. }
  11971. }
  11972. return suspended;
  11973. },
  11974. suspendEvents: function(queueSuspended) {
  11975. ++this.eventsSuspended;
  11976. if (queueSuspended && !this.eventQueue) {
  11977. this.eventQueue = [];
  11978. }
  11979. },
  11980. suspendEvent: function() {
  11981. var me = this,
  11982. events = me.events,
  11983. len = arguments.length,
  11984. i, event, ename;
  11985. for (i = 0; i < len; i++) {
  11986. ename = arguments[i];
  11987. ename = Ext.canonicalEventName(ename);
  11988. event = events[ename];
  11989. if (!event || !event.isEvent) {
  11990. event = me._initEvent(ename);
  11991. }
  11992. event.suspend();
  11993. }
  11994. },
  11995. resumeEvent: function() {
  11996. var events = this.events || 0,
  11997. len = events && arguments.length,
  11998. i, event, ename;
  11999. for (i = 0; i < len; i++) {
  12000. ename = Ext.canonicalEventName(arguments[i]);
  12001. event = events[ename];
  12002. if (event && event.resume) {
  12003. event.resume();
  12004. }
  12005. }
  12006. },
  12007. resumeEvents: function(discardQueue) {
  12008. var me = this,
  12009. queued = me.eventQueue,
  12010. qLen, q;
  12011. if (me.eventsSuspended && !--me.eventsSuspended) {
  12012. delete me.eventQueue;
  12013. if (!discardQueue && queued) {
  12014. qLen = queued.length;
  12015. for (q = 0; q < qLen; q++) {
  12016. me.fireEventArgs.apply(me, queued[q]);
  12017. }
  12018. }
  12019. }
  12020. },
  12021. relayEvents: function(origin, events, prefix) {
  12022. var me = this,
  12023. len = events.length,
  12024. i = 0,
  12025. oldName, newName,
  12026. relayers = {};
  12027. if (Ext.isObject(events)) {
  12028. for (i in events) {
  12029. newName = events[i];
  12030. relayers[i] = me.createRelayer(newName);
  12031. }
  12032. } else {
  12033. for (; i < len; i++) {
  12034. oldName = events[i];
  12035. relayers[oldName] = me.createRelayer(prefix ? prefix + oldName : oldName);
  12036. }
  12037. }
  12038. me.mon(origin, relayers, null, null, undefined);
  12039. return new ListenerRemover(me, origin, relayers);
  12040. },
  12041. createRelayer: function(newName, beginEnd) {
  12042. var me = this;
  12043. return function() {
  12044. return me.fireEventArgs.call(me, newName, beginEnd ? arraySlice.apply(arguments, beginEnd) : arguments);
  12045. };
  12046. },
  12047. enableBubble: function(eventNames) {
  12048. if (eventNames) {
  12049. var me = this,
  12050. names = (typeof eventNames == 'string') ? arguments : eventNames,
  12051. events = me.events,
  12052. length = events && names.length,
  12053. ename, event, i;
  12054. for (i = 0; i < length; ++i) {
  12055. ename = names[i];
  12056. ename = Ext.canonicalEventName(ename);
  12057. event = events[ename];
  12058. if (!event || !event.isEvent) {
  12059. event = me._initEvent(ename);
  12060. }
  12061. me.hasListeners._incr_(ename);
  12062. event.bubble = true;
  12063. }
  12064. }
  12065. },
  12066. destroy: function() {
  12067. this.clearListeners();
  12068. this.callParent();
  12069. this.destroyObservable(true);
  12070. },
  12071. destroyObservable: function(skipClearListeners) {
  12072. var me = this,
  12073. clearPropertiesOnDestroy = me.clearPropertiesOnDestroy;
  12074. if (me.$observableDestroyed) {
  12075. return;
  12076. }
  12077. if (!skipClearListeners) {
  12078. me.clearListeners();
  12079. }
  12080. if (me.destroyed) {
  12081. if (clearPropertiesOnDestroy) {
  12082. if (clearPropertiesOnDestroy === true && !me.$nulled) {
  12083. me.$reap();
  12084. }
  12085. if (!me.clearPrototypeOnDestroy) {
  12086. me.fireEvent = me.fireEventArgs = me.fireAction = me.fireEventedAction = Ext.emptyFn;
  12087. }
  12088. me.events = me.managedListeners = me.eventedBeforeEventNames = null;
  12089. me.$observableDestroyed = true;
  12090. }
  12091. if (me.clearPrototypeOnDestroy && Object.setPrototypeOf && !me.$alreadyNulled) {
  12092. Object.setPrototypeOf(me, null);
  12093. me.$alreadyNulled = true;
  12094. }
  12095. }
  12096. },
  12097. privates: {
  12098. doAddListener: function(ename, fn, scope, options, order, caller, manager) {
  12099. var me = this,
  12100. ret = false,
  12101. event, priority;
  12102. order = order || (options && options.order);
  12103. if (order) {
  12104. priority = (options && options.priority);
  12105. if (!priority) {
  12106. options = options ? Ext.Object.chain(options) : {};
  12107. options.priority = me.$orderToPriority[order];
  12108. }
  12109. }
  12110. ename = Ext.canonicalEventName(ename);
  12111. if (!fn) {
  12112. Ext.raise("Cannot add '" + ename + "' listener to " + me.$className + " instance. No function specified.");
  12113. }
  12114. event = (me.events || (me.events = {}))[ename];
  12115. if (!event || !event.isEvent) {
  12116. event = me._initEvent(ename);
  12117. }
  12118. if (fn !== emptyFn) {
  12119. if (!manager && (scope && scope.isObservable && (scope !== me))) {
  12120. manager = scope;
  12121. }
  12122. if (event.addListener(fn, scope, options, caller, manager)) {
  12123. me.hasListeners._incr_(ename);
  12124. ret = true;
  12125. }
  12126. }
  12127. return ret;
  12128. },
  12129. doRemoveListener: function(ename, fn, scope) {
  12130. var me = this,
  12131. ret = false,
  12132. events = me.events,
  12133. event;
  12134. ename = Ext.canonicalEventName(ename);
  12135. event = events && events[ename];
  12136. if (!fn) {
  12137. Ext.raise("Cannot remove '" + ename + "' listener to " + me.$className + " instance. No function specified.");
  12138. }
  12139. if (event && event.isEvent) {
  12140. if (event.removeListener(fn, scope)) {
  12141. me.hasListeners._decr_(ename);
  12142. ret = true;
  12143. }
  12144. }
  12145. return ret;
  12146. },
  12147. _initEvent: function(eventName) {
  12148. return (this.events[eventName] = new Ext.util.Event(this, eventName));
  12149. }
  12150. },
  12151. deprecated: {
  12152. '5.0': {
  12153. methods: {
  12154. addEvents: null
  12155. }
  12156. }
  12157. }
  12158. };
  12159. }, function() {
  12160. var Observable = this,
  12161. proto = Observable.prototype,
  12162. HasListeners = function() {},
  12163. prepareMixin = function(T) {
  12164. if (!T.HasListeners) {
  12165. var proto = T.prototype;
  12166. proto.$observableMixedIn = 1;
  12167. Observable.prepareClass(T, this);
  12168. T.onExtended(function(U, data) {
  12169. Ext.classSystemMonitor && Ext.classSystemMonitor('extend mixin', arguments);
  12170. Observable.prepareClass(U, null, data);
  12171. });
  12172. if (proto.onClassMixedIn) {
  12173. Ext.override(T, {
  12174. onClassMixedIn: function(U) {
  12175. prepareMixin.call(this, U);
  12176. this.callParent(arguments);
  12177. }
  12178. });
  12179. } else {
  12180. proto.onClassMixedIn = function(U) {
  12181. prepareMixin.call(this, U);
  12182. };
  12183. }
  12184. }
  12185. superOnClassMixedIn.call(this, T);
  12186. },
  12187. superOnClassMixedIn = proto.onClassMixedIn;
  12188. HasListeners.prototype = {
  12189. _decr_: function(ev, count) {
  12190. if (count == null) {
  12191. count = 1;
  12192. }
  12193. if (!(this[ev] -= count)) {
  12194. delete this[ev];
  12195. }
  12196. },
  12197. _incr_: function(ev) {
  12198. if (this.hasOwnProperty(ev)) {
  12199. ++this[ev];
  12200. } else {
  12201. this[ev] = 1;
  12202. }
  12203. }
  12204. };
  12205. proto.HasListeners = Observable.HasListeners = HasListeners;
  12206. Observable.createAlias({
  12207. on: 'addListener',
  12208. un: 'removeListener',
  12209. mon: 'addManagedListener',
  12210. mun: 'removeManagedListener',
  12211. setListeners: 'addListener'
  12212. });
  12213. Observable.observeClass = Observable.observe;
  12214. function getMethodEvent(method) {
  12215. var event = (this.methodEvents = this.methodEvents || {})[method],
  12216. returnValue, v, cancel,
  12217. me = this,
  12218. makeCall;
  12219. if (!event) {
  12220. me.methodEvents[method] = event = {};
  12221. event.originalFn = me[method];
  12222. event.methodName = method;
  12223. event.before = [];
  12224. event.after = [];
  12225. makeCall = function(fn, scope, args) {
  12226. scope = scope || me;
  12227. if (typeof fn === 'string') {
  12228. fn = scope[fn];
  12229. }
  12230. if ((v = fn.apply(scope, args)) !== undefined) {
  12231. if (typeof v == 'object') {
  12232. if (v.returnValue !== undefined) {
  12233. returnValue = v.returnValue;
  12234. } else {
  12235. returnValue = v;
  12236. }
  12237. cancel = !!v.cancel;
  12238. } else if (v === false) {
  12239. cancel = true;
  12240. } else {
  12241. returnValue = v;
  12242. }
  12243. }
  12244. };
  12245. me[method] = function() {
  12246. var args = Array.prototype.slice.call(arguments, 0),
  12247. argsLen = args.length,
  12248. b, i, len;
  12249. returnValue = v = undefined;
  12250. cancel = false;
  12251. for (i = 0 , len = event.before.length; i < len; i++) {
  12252. b = event.before[i];
  12253. if (b.extraArgs) {
  12254. args.push.apply(args, b.extraArgs);
  12255. }
  12256. makeCall(b.fn, b.scope, args);
  12257. args.length = argsLen;
  12258. if (cancel || b.preventDefault) {
  12259. return returnValue;
  12260. }
  12261. }
  12262. if ((v = event.originalFn.apply(me, args)) !== undefined) {
  12263. returnValue = v;
  12264. }
  12265. for (i = 0 , len = event.after.length; i < len; i++) {
  12266. b = event.after[i];
  12267. if (b.extraArgs) {
  12268. args.push.apply(args, b.extraArgs);
  12269. }
  12270. makeCall(b.fn, b.scope, args);
  12271. args.length = argsLen;
  12272. if (cancel || b.preventDefault) {
  12273. return returnValue;
  12274. }
  12275. }
  12276. return returnValue;
  12277. };
  12278. }
  12279. return event;
  12280. }
  12281. Ext.apply(proto, {
  12282. onClassMixedIn: prepareMixin,
  12283. beforeMethod: function(method, fn, scope, preventDefault, extraArgs) {
  12284. getMethodEvent.call(this, method).before.push({
  12285. fn: fn,
  12286. scope: scope,
  12287. extraArgs: extraArgs,
  12288. preventDefault: preventDefault
  12289. });
  12290. },
  12291. afterMethod: function(method, fn, scope, preventDefault, extraArgs) {
  12292. getMethodEvent.call(this, method).after.push({
  12293. fn: fn,
  12294. scope: scope,
  12295. extraArgs: extraArgs,
  12296. preventDefault: preventDefault
  12297. });
  12298. },
  12299. removeMethodListener: function(method, fn, scope) {
  12300. var e = getMethodEvent.call(this, method),
  12301. i, len;
  12302. for (i = 0 , len = e.before.length; i < len; i++) {
  12303. if (e.before[i].fn == fn && e.before[i].scope == scope) {
  12304. Ext.Array.erase(e.before, i, 1);
  12305. return;
  12306. }
  12307. }
  12308. for (i = 0 , len = e.after.length; i < len; i++) {
  12309. if (e.after[i].fn == fn && e.after[i].scope == scope) {
  12310. Ext.Array.erase(e.after, i, 1);
  12311. return;
  12312. }
  12313. }
  12314. },
  12315. toggleEventLogging: function(toggle) {
  12316. Ext.util.Observable[toggle ? 'capture' : 'releaseCapture'](this, function(en) {
  12317. if (Ext.isDefined(Ext.global.console)) {
  12318. Ext.global.console.log(en, arguments);
  12319. }
  12320. });
  12321. }
  12322. });
  12323. });
  12324. Ext.define('Ext.util.HashMap', {
  12325. mixins: [
  12326. Ext.mixin.Observable
  12327. ],
  12328. generation: 0,
  12329. config: {
  12330. keyFn: null
  12331. },
  12332. constructor: function(config) {
  12333. var me = this,
  12334. fn;
  12335. me.mixins.observable.constructor.call(me, config);
  12336. me.clear(true);
  12337. fn = me.getKeyFn();
  12338. if (fn) {
  12339. me.getKey = fn;
  12340. }
  12341. },
  12342. getCount: function() {
  12343. return this.length;
  12344. },
  12345. getData: function(key, value) {
  12346. if (value === undefined) {
  12347. value = key;
  12348. key = this.getKey(value);
  12349. }
  12350. return [
  12351. key,
  12352. value
  12353. ];
  12354. },
  12355. getKey: function(o) {
  12356. return o.id;
  12357. },
  12358. add: function(key, value) {
  12359. var me = this;
  12360. if (arguments.length === 1) {
  12361. value = key;
  12362. key = me.getKey(value);
  12363. }
  12364. if (me.containsKey(key)) {
  12365. return me.replace(key, value);
  12366. }
  12367. me.map[key] = value;
  12368. ++me.length;
  12369. me.generation++;
  12370. if (me.hasListeners.add) {
  12371. me.fireEvent('add', me, key, value);
  12372. }
  12373. return value;
  12374. },
  12375. replace: function(key, value) {
  12376. var me = this,
  12377. map = me.map,
  12378. old;
  12379. if (arguments.length === 1) {
  12380. value = key;
  12381. key = me.getKey(value);
  12382. }
  12383. if (!me.containsKey(key)) {
  12384. me.add(key, value);
  12385. }
  12386. old = map[key];
  12387. map[key] = value;
  12388. me.generation++;
  12389. if (me.hasListeners.replace) {
  12390. me.fireEvent('replace', me, key, value, old);
  12391. }
  12392. return value;
  12393. },
  12394. remove: function(o) {
  12395. var key = this.findKey(o);
  12396. if (key !== undefined) {
  12397. return this.removeAtKey(key);
  12398. }
  12399. return false;
  12400. },
  12401. removeAtKey: function(key) {
  12402. var me = this,
  12403. value;
  12404. if (me.containsKey(key)) {
  12405. value = me.map[key];
  12406. delete me.map[key];
  12407. --me.length;
  12408. me.generation++;
  12409. if (me.hasListeners.remove) {
  12410. me.fireEvent('remove', me, key, value);
  12411. }
  12412. return true;
  12413. }
  12414. return false;
  12415. },
  12416. get: function(key) {
  12417. var map = this.map;
  12418. return map.hasOwnProperty(key) ? map[key] : undefined;
  12419. },
  12420. clear: function(initial) {
  12421. var me = this;
  12422. if (initial || me.generation) {
  12423. me.map = {};
  12424. me.length = 0;
  12425. me.generation = initial ? 0 : me.generation + 1;
  12426. }
  12427. if (initial !== true && me.hasListeners.clear) {
  12428. me.fireEvent('clear', me);
  12429. }
  12430. return me;
  12431. },
  12432. containsKey: function(key) {
  12433. var map = this.map;
  12434. return map.hasOwnProperty(key) && map[key] !== undefined;
  12435. },
  12436. contains: function(value) {
  12437. return this.containsKey(this.findKey(value));
  12438. },
  12439. getKeys: function() {
  12440. return this.getArray(true);
  12441. },
  12442. getValues: function() {
  12443. return this.getArray(false);
  12444. },
  12445. getArray: function(isKey) {
  12446. var arr = [],
  12447. key,
  12448. map = this.map;
  12449. for (key in map) {
  12450. if (map.hasOwnProperty(key)) {
  12451. arr.push(isKey ? key : map[key]);
  12452. }
  12453. }
  12454. return arr;
  12455. },
  12456. each: function(fn, scope) {
  12457. var items = Ext.apply({}, this.map),
  12458. key,
  12459. length = this.length;
  12460. scope = scope || this;
  12461. for (key in items) {
  12462. if (items.hasOwnProperty(key)) {
  12463. if (fn.call(scope, key, items[key], length) === false) {
  12464. break;
  12465. }
  12466. }
  12467. }
  12468. return this;
  12469. },
  12470. clone: function() {
  12471. var hash = new this.self(this.initialConfig),
  12472. map = this.map,
  12473. key;
  12474. hash.suspendEvents();
  12475. for (key in map) {
  12476. if (map.hasOwnProperty(key)) {
  12477. hash.add(key, map[key]);
  12478. }
  12479. }
  12480. hash.resumeEvents();
  12481. return hash;
  12482. },
  12483. findKey: function(value) {
  12484. var key,
  12485. map = this.map;
  12486. for (key in map) {
  12487. if (map.hasOwnProperty(key) && map[key] === value) {
  12488. return key;
  12489. }
  12490. }
  12491. return undefined;
  12492. }
  12493. }, function(HashMap) {
  12494. var prototype = HashMap.prototype;
  12495. prototype.removeByKey = prototype.removeAtKey;
  12496. });
  12497. Ext.define('Ext.AbstractManager', {
  12498. typeName: 'type',
  12499. constructor: function(config) {
  12500. Ext.apply(this, config || {});
  12501. this.all = new Ext.util.HashMap();
  12502. this.types = {};
  12503. },
  12504. get: function(id) {
  12505. return this.all.get(id);
  12506. },
  12507. register: function(item) {
  12508. var key = this.all.getKey(item);
  12509. if (key === undefined) {
  12510. Ext.raise('Key is undefined. Please ensure the item has a key before registering the item.');
  12511. }
  12512. if (this.all.containsKey(key)) {
  12513. Ext.raise('Registering duplicate id "' + key + '" with ' + this.$className);
  12514. }
  12515. this.all.add(item);
  12516. },
  12517. unregister: function(item) {
  12518. this.all.remove(item);
  12519. },
  12520. registerType: function(type, cls) {
  12521. this.types[type] = cls;
  12522. cls[this.typeName] = type;
  12523. },
  12524. isRegistered: function(type) {
  12525. return this.types[type] !== undefined;
  12526. },
  12527. create: function(config, defaultType) {
  12528. var type = config[this.typeName] || config.type || defaultType,
  12529. Constructor = this.types[type];
  12530. if (Constructor === undefined) {
  12531. Ext.raise("The '" + type + "' type has not been registered with this manager");
  12532. }
  12533. return new Constructor(config);
  12534. },
  12535. onAvailable: function(id, fn, scope) {
  12536. var all = this.all,
  12537. item, callback;
  12538. if (all.containsKey(id)) {
  12539. item = all.get(id);
  12540. fn.call(scope || item, item);
  12541. } else {
  12542. callback = function(map, key, item) {
  12543. if (key == id) {
  12544. fn.call(scope || item, item);
  12545. all.un('add', callback);
  12546. }
  12547. };
  12548. all.on('add', callback);
  12549. }
  12550. },
  12551. each: function(fn, scope) {
  12552. this.all.each(fn, scope || this);
  12553. },
  12554. getCount: function() {
  12555. return this.all.getCount();
  12556. }
  12557. });
  12558. Ext.define('Ext.promise.Consequence', function(Consequence) {
  12559. return {
  12560. promise: null,
  12561. deferred: null,
  12562. onFulfilled: null,
  12563. onRejected: null,
  12564. onProgress: null,
  12565. constructor: function(onFulfilled, onRejected, onProgress) {
  12566. var me = this;
  12567. me.onFulfilled = onFulfilled;
  12568. me.onRejected = onRejected;
  12569. me.onProgress = onProgress;
  12570. me.deferred = new Ext.promise.Deferred();
  12571. me.promise = me.deferred.promise;
  12572. },
  12573. trigger: function(action, value) {
  12574. var me = this,
  12575. deferred = me.deferred;
  12576. switch (action) {
  12577. case 'fulfill':
  12578. me.propagate(value, me.onFulfilled, deferred, deferred.resolve);
  12579. break;
  12580. case 'reject':
  12581. me.propagate(value, me.onRejected, deferred, deferred.reject);
  12582. break;
  12583. }
  12584. },
  12585. update: function(progress) {
  12586. if (Ext.isFunction(this.onProgress)) {
  12587. progress = this.onProgress(progress);
  12588. }
  12589. this.deferred.update(progress);
  12590. },
  12591. propagate: function(value, callback, deferred, deferredMethod) {
  12592. if (Ext.isFunction(callback)) {
  12593. this.schedule(function() {
  12594. try {
  12595. deferred.resolve(callback(value));
  12596. } catch (e) {
  12597. deferred.reject(e);
  12598. }
  12599. });
  12600. } else {
  12601. deferredMethod.call(this.deferred, value);
  12602. }
  12603. },
  12604. schedule: function(callback) {
  12605. var n = Consequence.queueSize++;
  12606. Consequence.queue[n] = callback;
  12607. if (!n) {
  12608. Ext.asap(Consequence.dispatch);
  12609. }
  12610. },
  12611. statics: {
  12612. queue: new Array(10000),
  12613. queueSize: 0,
  12614. dispatch: function() {
  12615. var queue = Consequence.queue,
  12616. fn, i;
  12617. for (i = 0; i < Consequence.queueSize; ++i) {
  12618. fn = queue[i];
  12619. queue[i] = null;
  12620. fn();
  12621. }
  12622. Consequence.queueSize = 0;
  12623. }
  12624. }
  12625. };
  12626. },
  12627. function(Consequence) {
  12628. Consequence.dispatch.$skipTimerCheck = true;
  12629. });
  12630. Ext.define('Ext.promise.Deferred', {
  12631. promise: null,
  12632. consequences: [],
  12633. completed: false,
  12634. completionAction: null,
  12635. completionValue: null,
  12636. constructor: function() {
  12637. var me = this;
  12638. me.promise = new Ext.promise.Promise(me);
  12639. me.consequences = [];
  12640. me.completed = false;
  12641. me.completionAction = null;
  12642. me.completionValue = null;
  12643. },
  12644. then: function(onFulfilled, onRejected, onProgress) {
  12645. var me = this,
  12646. consequence = new Ext.promise.Consequence(onFulfilled, onRejected, onProgress);
  12647. if (me.completed) {
  12648. consequence.trigger(me.completionAction, me.completionValue);
  12649. } else {
  12650. me.consequences.push(consequence);
  12651. }
  12652. return consequence.promise;
  12653. },
  12654. resolve: function(value) {
  12655. var me = this,
  12656. isHandled, thenFn;
  12657. if (me.completed) {
  12658. return;
  12659. }
  12660. try {
  12661. if (value === me.promise) {
  12662. throw new TypeError('A Promise cannot be resolved with itself.');
  12663. }
  12664. if (value != null && (typeof value === 'object' || Ext.isFunction(value)) && Ext.isFunction(thenFn = value.then)) {
  12665. isHandled = false;
  12666. try {
  12667. thenFn.call(value, function(value) {
  12668. if (!isHandled) {
  12669. isHandled = true;
  12670. me.resolve(value);
  12671. }
  12672. }, function(error) {
  12673. if (!isHandled) {
  12674. isHandled = true;
  12675. me.reject(error);
  12676. }
  12677. });
  12678. } catch (e1) {
  12679. if (!isHandled) {
  12680. me.reject(e1);
  12681. }
  12682. }
  12683. } else {
  12684. me.complete('fulfill', value);
  12685. }
  12686. } catch (e2) {
  12687. me.reject(e2);
  12688. }
  12689. },
  12690. reject: function(reason) {
  12691. if (this.completed) {
  12692. return;
  12693. }
  12694. this.complete('reject', reason);
  12695. },
  12696. update: function(progress) {
  12697. var consequences = this.consequences,
  12698. consequence, i, len;
  12699. if (this.completed) {
  12700. return;
  12701. }
  12702. for (i = 0 , len = consequences.length; i < len; i++) {
  12703. consequence = consequences[i];
  12704. consequence.update(progress);
  12705. }
  12706. },
  12707. complete: function(action, value) {
  12708. var me = this,
  12709. consequences = me.consequences,
  12710. consequence, i, len;
  12711. me.completionAction = action;
  12712. me.completionValue = value;
  12713. me.completed = true;
  12714. for (i = 0 , len = consequences.length; i < len; i++) {
  12715. consequence = consequences[i];
  12716. consequence.trigger(me.completionAction, me.completionValue);
  12717. }
  12718. me.consequences = null;
  12719. }
  12720. });
  12721. Ext.define('Ext.promise.Promise', function(ExtPromise) {
  12722. var Deferred;
  12723. return {
  12724. statics: {
  12725. CancellationError: Ext.global.CancellationError || Error,
  12726. _ready: function() {
  12727. Deferred = Ext.promise.Deferred;
  12728. },
  12729. all: function(promisesOrValues) {
  12730. if (!(Ext.isArray(promisesOrValues) || ExtPromise.is(promisesOrValues))) {
  12731. Ext.raise('Invalid parameter: expected an Array or Promise of an Array.');
  12732. }
  12733. return ExtPromise.when(promisesOrValues).then(function(promisesOrValues) {
  12734. var deferred = new Deferred(),
  12735. remainingToResolve = promisesOrValues.length,
  12736. results = new Array(remainingToResolve),
  12737. index, promiseOrValue, resolve, i, len;
  12738. if (!remainingToResolve) {
  12739. deferred.resolve(results);
  12740. } else {
  12741. resolve = function(item, index) {
  12742. return ExtPromise.when(item).then(function(value) {
  12743. results[index] = value;
  12744. if (!--remainingToResolve) {
  12745. deferred.resolve(results);
  12746. }
  12747. return value;
  12748. }, function(reason) {
  12749. return deferred.reject(reason);
  12750. });
  12751. };
  12752. for (index = i = 0 , len = promisesOrValues.length; i < len; index = ++i) {
  12753. promiseOrValue = promisesOrValues[index];
  12754. if (index in promisesOrValues) {
  12755. resolve(promiseOrValue, index);
  12756. } else {
  12757. remainingToResolve--;
  12758. }
  12759. }
  12760. }
  12761. return deferred.promise;
  12762. });
  12763. },
  12764. is: function(value) {
  12765. return value != null && (typeof value === 'object' || Ext.isFunction(value)) && Ext.isFunction(value.then);
  12766. },
  12767. race: function(promises) {
  12768. if (!Ext.isArray(promises)) {
  12769. Ext.raise('Invalid parameter: expected an Array.');
  12770. }
  12771. var deferred = new Deferred(),
  12772. len = promises.length,
  12773. i;
  12774. for (i = 0; i < len; ++i) {
  12775. deferred.resolve(promises[i]);
  12776. }
  12777. return deferred.promise;
  12778. },
  12779. rethrowError: function(error) {
  12780. Ext.asap(function() {
  12781. throw error;
  12782. });
  12783. },
  12784. when: function(value) {
  12785. var deferred = new Deferred();
  12786. deferred.resolve(value);
  12787. return deferred.promise;
  12788. }
  12789. },
  12790. owner: null,
  12791. constructor: function(owner) {
  12792. this.owner = owner;
  12793. },
  12794. then: function(onFulfilled, onRejected, onProgress, scope) {
  12795. var ref;
  12796. if (arguments.length === 1 && Ext.isObject(arguments[0])) {
  12797. ref = arguments[0];
  12798. onFulfilled = ref.success;
  12799. onRejected = ref.failure;
  12800. onProgress = ref.progress;
  12801. scope = ref.scope;
  12802. }
  12803. if (scope) {
  12804. if (onFulfilled) {
  12805. onFulfilled = onFulfilled.bind(scope);
  12806. }
  12807. if (onRejected) {
  12808. onRejected = onRejected.bind(scope);
  12809. }
  12810. if (onProgress) {
  12811. onProgress = onProgress.bind(scope);
  12812. }
  12813. }
  12814. return this.owner.then(onFulfilled, onRejected, onProgress);
  12815. },
  12816. 'catch': function(onRejected, scope) {
  12817. var ref;
  12818. if (arguments.length === 1 && Ext.isObject(arguments[0])) {
  12819. ref = arguments[0];
  12820. onRejected = ref.fn;
  12821. scope = ref.scope;
  12822. }
  12823. if (scope != null) {
  12824. onRejected = onRejected.bind(scope);
  12825. }
  12826. return this.owner.then(null, onRejected);
  12827. },
  12828. otherwise: function(onRejected, scope) {
  12829. return this['catch'].apply(this, arguments);
  12830. },
  12831. always: function(onCompleted, scope) {
  12832. var ref;
  12833. if (arguments.length === 1 && Ext.isObject(arguments[0])) {
  12834. ref = arguments[0];
  12835. onCompleted = ref.fn;
  12836. scope = ref.scope;
  12837. }
  12838. if (scope != null) {
  12839. onCompleted = onCompleted.bind(scope);
  12840. }
  12841. return this.owner.then(function(value) {
  12842. try {
  12843. onCompleted();
  12844. } catch (e) {
  12845. ExtPromise.rethrowError(e);
  12846. }
  12847. return value;
  12848. }, function(reason) {
  12849. try {
  12850. onCompleted();
  12851. } catch (e) {
  12852. ExtPromise.rethrowError(e);
  12853. }
  12854. throw reason;
  12855. });
  12856. },
  12857. done: function() {
  12858. this.owner.then(null, ExtPromise.rethrowError);
  12859. },
  12860. cancel: function(reason) {
  12861. if (reason == null) {
  12862. reason = null;
  12863. }
  12864. this.owner.reject(new this.self.CancellationError(reason));
  12865. },
  12866. log: function(identifier) {
  12867. if (identifier == null) {
  12868. identifier = '';
  12869. }
  12870. return this.owner.then(function(value) {
  12871. Ext.log("" + (identifier || 'Promise') + " resolved with value: " + value);
  12872. return value;
  12873. }, function(reason) {
  12874. Ext.log("" + (identifier || 'Promise') + " rejected with reason: " + reason);
  12875. throw reason;
  12876. });
  12877. }
  12878. };
  12879. }, function(ExtPromise) {
  12880. ExtPromise._ready();
  12881. });
  12882. Ext.define('Ext.Promise', function() {
  12883. var Polyfiller;
  12884. return {
  12885. statics: {
  12886. _ready: function() {
  12887. Polyfiller = Ext.promise.Promise;
  12888. },
  12889. all: function() {
  12890. return Polyfiller.all.apply(Polyfiller, arguments);
  12891. },
  12892. race: function() {
  12893. return Polyfiller.race.apply(Polyfiller, arguments);
  12894. },
  12895. reject: function(reason) {
  12896. var deferred = new Ext.promise.Deferred();
  12897. deferred.reject(reason);
  12898. return deferred.promise;
  12899. },
  12900. resolve: function(value) {
  12901. var deferred = new Ext.promise.Deferred();
  12902. deferred.resolve(value);
  12903. return deferred.promise;
  12904. }
  12905. },
  12906. constructor: function(action) {
  12907. var deferred = new Ext.promise.Deferred();
  12908. action(deferred.resolve.bind(deferred), deferred.reject.bind(deferred));
  12909. return deferred.promise;
  12910. }
  12911. };
  12912. }, function(ExtPromise) {
  12913. var P = Ext.global.Promise;
  12914. if (P && P.resolve && !Ext.useExtPromises) {
  12915. Ext.Promise = P;
  12916. } else {
  12917. ExtPromise._ready();
  12918. }
  12919. });
  12920. Ext.define('Ext.Deferred', function(Deferred) {
  12921. var ExtPromise, rejected, resolved, when;
  12922. return {
  12923. extend: Ext.promise.Deferred,
  12924. statics: {
  12925. _ready: function() {
  12926. ExtPromise = Ext.promise.Promise;
  12927. when = Ext.Promise.resolve;
  12928. },
  12929. all: function() {
  12930. return ExtPromise.all.apply(ExtPromise, arguments);
  12931. },
  12932. any: function(promisesOrValues) {
  12933. if (!(Ext.isArray(promisesOrValues) || ExtPromise.is(promisesOrValues))) {
  12934. Ext.raise('Invalid parameter: expected an Array or Promise of an Array.');
  12935. }
  12936. return Deferred.some(promisesOrValues, 1).then(function(array) {
  12937. return array[0];
  12938. }, function(error) {
  12939. if (error instanceof Error && error.message === 'Too few Promises were resolved.') {
  12940. Ext.raise('No Promises were resolved.');
  12941. } else {
  12942. throw error;
  12943. }
  12944. });
  12945. },
  12946. delay: function(promiseOrValue, milliseconds) {
  12947. var deferred;
  12948. if (arguments.length === 1) {
  12949. milliseconds = promiseOrValue;
  12950. promiseOrValue = undefined;
  12951. }
  12952. milliseconds = Math.max(milliseconds, 1);
  12953. deferred = new Deferred();
  12954. deferred.timeoutId = Ext.defer(function() {
  12955. delete deferred.timeoutId;
  12956. deferred.resolve(promiseOrValue);
  12957. }, milliseconds);
  12958. return deferred.promise;
  12959. },
  12960. getCachedRejected: function() {
  12961. if (!rejected) {
  12962. rejected = Ext.Promise.reject();
  12963. }
  12964. return rejected;
  12965. },
  12966. getCachedResolved: function() {
  12967. if (!resolved) {
  12968. resolved = Ext.Promise.resolve();
  12969. }
  12970. return resolved;
  12971. },
  12972. map: function(promisesOrValues, mapFn) {
  12973. if (!(Ext.isArray(promisesOrValues) || ExtPromise.is(promisesOrValues))) {
  12974. Ext.raise('Invalid parameter: expected an Array or Promise of an Array.');
  12975. }
  12976. if (!Ext.isFunction(mapFn)) {
  12977. Ext.raise('Invalid parameter: expected a function.');
  12978. }
  12979. return Deferred.resolved(promisesOrValues).then(function(promisesOrValues) {
  12980. var deferred, index, promiseOrValue, remainingToResolve, resolve, results, i, len;
  12981. remainingToResolve = promisesOrValues.length;
  12982. results = new Array(promisesOrValues.length);
  12983. deferred = new Deferred();
  12984. if (!remainingToResolve) {
  12985. deferred.resolve(results);
  12986. } else {
  12987. resolve = function(item, index) {
  12988. return Deferred.resolved(item).then(function(value) {
  12989. return mapFn(value, index, results);
  12990. }).then(function(value) {
  12991. results[index] = value;
  12992. if (!--remainingToResolve) {
  12993. deferred.resolve(results);
  12994. }
  12995. return value;
  12996. }, function(reason) {
  12997. return deferred.reject(reason);
  12998. });
  12999. };
  13000. for (index = i = 0 , len = promisesOrValues.length; i < len; index = ++i) {
  13001. promiseOrValue = promisesOrValues[index];
  13002. if (index in promisesOrValues) {
  13003. resolve(promiseOrValue, index);
  13004. } else {
  13005. remainingToResolve--;
  13006. }
  13007. }
  13008. }
  13009. return deferred.promise;
  13010. });
  13011. },
  13012. memoize: function(fn, scope, hashFn) {
  13013. var memoizedFn = Ext.Function.memoize(fn, scope, hashFn);
  13014. return function() {
  13015. return Deferred.all(Ext.Array.slice(arguments)).then(function(values) {
  13016. return memoizedFn.apply(scope, values);
  13017. });
  13018. };
  13019. },
  13020. parallel: function(fns, scope) {
  13021. if (scope == null) {
  13022. scope = null;
  13023. }
  13024. var args = Ext.Array.slice(arguments, 2);
  13025. return Deferred.map(fns, function(fn) {
  13026. if (!Ext.isFunction(fn)) {
  13027. throw new Error('Invalid parameter: expected a function.');
  13028. }
  13029. return fn.apply(scope, args);
  13030. });
  13031. },
  13032. pipeline: function(fns, initialValue, scope) {
  13033. if (scope == null) {
  13034. scope = null;
  13035. }
  13036. return Deferred.reduce(fns, function(value, fn) {
  13037. if (!Ext.isFunction(fn)) {
  13038. throw new Error('Invalid parameter: expected a function.');
  13039. }
  13040. return fn.call(scope, value);
  13041. }, initialValue);
  13042. },
  13043. race: function() {
  13044. return ExtPromise.race.apply(ExtPromise, arguments);
  13045. },
  13046. reduce: function(values, reduceFn, initialValue) {
  13047. if (!(Ext.isArray(values) || ExtPromise.is(values))) {
  13048. Ext.raise('Invalid parameter: expected an Array or Promise of an Array.');
  13049. }
  13050. if (!Ext.isFunction(reduceFn)) {
  13051. Ext.raise('Invalid parameter: expected a function.');
  13052. }
  13053. var initialValueSpecified = arguments.length === 3;
  13054. return Deferred.resolved(values).then(function(promisesOrValues) {
  13055. var reduceArguments = [
  13056. promisesOrValues,
  13057. function(previousValueOrPromise, currentValueOrPromise, currentIndex) {
  13058. return Deferred.resolved(previousValueOrPromise).then(function(previousValue) {
  13059. return Deferred.resolved(currentValueOrPromise).then(function(currentValue) {
  13060. return reduceFn(previousValue, currentValue, currentIndex, promisesOrValues);
  13061. });
  13062. });
  13063. }
  13064. ];
  13065. if (initialValueSpecified) {
  13066. reduceArguments.push(initialValue);
  13067. }
  13068. return Ext.Array.reduce.apply(Ext.Array, reduceArguments);
  13069. });
  13070. },
  13071. rejected: function(reason) {
  13072. var deferred = new Ext.Deferred();
  13073. deferred.reject(reason);
  13074. return deferred.promise;
  13075. },
  13076. resolved: function(promiseOrValue) {
  13077. var deferred = new Ext.Deferred();
  13078. deferred.resolve(promiseOrValue);
  13079. return deferred.promise;
  13080. },
  13081. sequence: function(fns, scope) {
  13082. if (scope == null) {
  13083. scope = null;
  13084. }
  13085. var args = Ext.Array.slice(arguments, 2);
  13086. return Deferred.reduce(fns, function(results, fn) {
  13087. if (!Ext.isFunction(fn)) {
  13088. throw new Error('Invalid parameter: expected a function.');
  13089. }
  13090. return Deferred.resolved(fn.apply(scope, args)).then(function(result) {
  13091. results.push(result);
  13092. return results;
  13093. });
  13094. }, []);
  13095. },
  13096. some: function(promisesOrValues, howMany) {
  13097. if (!(Ext.isArray(promisesOrValues) || ExtPromise.is(promisesOrValues))) {
  13098. Ext.raise('Invalid parameter: expected an Array or Promise of an Array.');
  13099. }
  13100. if (!Ext.isNumeric(howMany) || howMany <= 0) {
  13101. Ext.raise('Invalid parameter: expected a positive integer.');
  13102. }
  13103. return Deferred.resolved(promisesOrValues).then(function(promisesOrValues) {
  13104. var deferred, index, onReject, onResolve, promiseOrValue, remainingToReject, remainingToResolve, values, i, len;
  13105. values = [];
  13106. remainingToResolve = howMany;
  13107. remainingToReject = (promisesOrValues.length - remainingToResolve) + 1;
  13108. deferred = new Deferred();
  13109. if (promisesOrValues.length < howMany) {
  13110. deferred.reject(new Error('Too few Promises were resolved.'));
  13111. } else {
  13112. onResolve = function(value) {
  13113. if (remainingToResolve > 0) {
  13114. values.push(value);
  13115. }
  13116. remainingToResolve--;
  13117. if (remainingToResolve === 0) {
  13118. deferred.resolve(values);
  13119. }
  13120. return value;
  13121. };
  13122. onReject = function(reason) {
  13123. remainingToReject--;
  13124. if (remainingToReject === 0) {
  13125. deferred.reject(new Error('Too few Promises were resolved.'));
  13126. }
  13127. return reason;
  13128. };
  13129. for (index = i = 0 , len = promisesOrValues.length; i < len; index = ++i) {
  13130. promiseOrValue = promisesOrValues[index];
  13131. if (index in promisesOrValues) {
  13132. Deferred.resolved(promiseOrValue).then(onResolve, onReject);
  13133. }
  13134. }
  13135. }
  13136. return deferred.promise;
  13137. });
  13138. },
  13139. timeout: function(promiseOrValue, milliseconds) {
  13140. var deferred = new Deferred(),
  13141. timeoutId;
  13142. timeoutId = Ext.defer(function() {
  13143. if (timeoutId) {
  13144. deferred.reject(new Error('Promise timed out.'));
  13145. }
  13146. }, milliseconds);
  13147. Deferred.resolved(promiseOrValue).then(function(value) {
  13148. Ext.undefer(timeoutId);
  13149. timeoutId = null;
  13150. deferred.resolve(value);
  13151. }, function(reason) {
  13152. Ext.undefer(timeoutId);
  13153. timeoutId = null;
  13154. deferred.reject(reason);
  13155. });
  13156. return deferred.promise;
  13157. }
  13158. }
  13159. };
  13160. }, function(Deferred) {
  13161. Deferred._ready();
  13162. });
  13163. Ext.Factory = function(type) {
  13164. var me = this;
  13165. me.aliasPrefix = type + '.';
  13166. me.cache = {};
  13167. me.name = type.replace(me.fixNameRe, me.fixNameFn);
  13168. me.type = type;
  13169. me.creator = 'create' + Ext.String.capitalize(me.name);
  13170. };
  13171. Ext.Factory.prototype = {
  13172. defaultProperty: 'type',
  13173. instanceProp: 'isInstance',
  13174. typeProperty: 'type',
  13175. create: function(config, defaultType) {
  13176. var me = this,
  13177. Manager = Ext.ClassManager,
  13178. cache = me.cache,
  13179. typeProperty = me.typeProperty,
  13180. alias, className, klass, suffix;
  13181. if (config) {
  13182. if (config[me.instanceProp]) {
  13183. return config;
  13184. }
  13185. if (typeof config === 'string') {
  13186. suffix = config;
  13187. config = {};
  13188. config[me.defaultProperty] = suffix;
  13189. }
  13190. className = config.xclass;
  13191. suffix = config[typeProperty];
  13192. }
  13193. if (defaultType && defaultType.constructor === Object) {
  13194. config = Ext.apply({}, config, defaultType);
  13195. defaultType = defaultType[typeProperty];
  13196. }
  13197. if (className) {
  13198. if (!(klass = Manager.get(className))) {
  13199. return Manager.instantiate(className, config);
  13200. }
  13201. } else {
  13202. if (!(suffix = suffix || defaultType || me.defaultType)) {
  13203. klass = me.defaultClass;
  13204. }
  13205. if (!suffix && !klass) {
  13206. Ext.raise('No type specified for ' + me.type + '.create');
  13207. }
  13208. if (!klass && !(klass = cache[suffix])) {
  13209. alias = me.aliasPrefix + suffix;
  13210. className = Manager.getNameByAlias(alias);
  13211. if (!(klass = className && Manager.get(className))) {
  13212. return Manager.instantiateByAlias(alias, config);
  13213. }
  13214. cache[suffix] = klass;
  13215. }
  13216. }
  13217. return klass.isInstance ? klass : new klass(config);
  13218. },
  13219. fixNameRe: /\.[a-z]/ig,
  13220. fixNameFn: function(match) {
  13221. return match.substring(1).toUpperCase();
  13222. },
  13223. clearCache: function() {
  13224. this.cache = {};
  13225. this.instanceCache = {};
  13226. },
  13227. hook: function(fn) {
  13228. var me = this,
  13229. original = me.create;
  13230. me.create = function(config, defaultType) {
  13231. var ret = fn.call(me, original, config, defaultType);
  13232. if (ret === undefined) {
  13233. ret = original.call(me, config, defaultType);
  13234. }
  13235. return ret;
  13236. };
  13237. },
  13238. update: function(instance, config, creator, creatorMethod, defaultsConfig) {
  13239. var me = this,
  13240. aliases, defaults, reuse, type;
  13241. if (!config || config.isInstance) {
  13242. if (config && !config[me.instanceProp]) {
  13243. Ext.raise('Config instance failed ' + me.instanceProp + ' requirement');
  13244. }
  13245. if (instance && instance !== config) {
  13246. instance.destroy();
  13247. }
  13248. return config;
  13249. }
  13250. if (typeof config === 'string') {
  13251. type = config;
  13252. config = {};
  13253. config[me.defaultProperty] = type;
  13254. }
  13255. if (instance) {
  13256. if (config === true) {
  13257. return instance;
  13258. }
  13259. if (!(type = config.xclass)) {
  13260. if (!(type = config.xtype)) {
  13261. type = config[me.typeProperty];
  13262. if (type) {
  13263. type = me.aliasPrefix + type;
  13264. aliases = instance.self.prototype;
  13265. if (aliases.hasOwnProperty('alias')) {
  13266. aliases = aliases.alias;
  13267. if (aliases) {
  13268. reuse = aliases === type || aliases.indexOf(type) > -1;
  13269. }
  13270. }
  13271. }
  13272. } else {
  13273. reuse = instance.isXType(type,
  13274. true);
  13275. }
  13276. } else {
  13277. reuse = instance.$className === type;
  13278. }
  13279. if (reuse) {
  13280. instance.setConfig(config);
  13281. return instance;
  13282. }
  13283. instance.destroy();
  13284. }
  13285. if (config === true) {
  13286. config = {};
  13287. }
  13288. if (creator) {
  13289. if (defaultsConfig) {
  13290. defaults = Ext.Config.map[defaultsConfig];
  13291. defaults = creator[defaults.names.get]();
  13292. if (defaults) {
  13293. config = Ext.merge(Ext.clone(defaults), config);
  13294. }
  13295. }
  13296. creatorMethod = creatorMethod || me.creator;
  13297. if (creator[creatorMethod]) {
  13298. config = creator[creatorMethod](config);
  13299. if (!config) {
  13300. Ext.raise('Missing return value from ' + creatorMethod + ' on class ' + creator.$className);
  13301. }
  13302. }
  13303. }
  13304. return me.create(config);
  13305. }
  13306. };
  13307. Ext.Factory.define = function(type, config) {
  13308. var Factory = Ext.Factory,
  13309. cacheable = config && config.cacheable,
  13310. defaultClass, factory, fn;
  13311. if (type.constructor === Object) {
  13312. Ext.Object.each(type, Factory.define, Factory);
  13313. } else {
  13314. factory = new Ext.Factory(type);
  13315. if (config) {
  13316. if (config.constructor === Object) {
  13317. Ext.apply(factory, config);
  13318. if (typeof (defaultClass = factory.xclass) === 'string') {
  13319. factory.defaultClass = Ext.ClassManager.get(defaultClass);
  13320. }
  13321. } else {
  13322. factory.defaultType = config;
  13323. }
  13324. }
  13325. Factory[factory.name] = fn = function(config, defaultType) {
  13326. return factory.create(config, defaultType);
  13327. };
  13328. if (cacheable) {
  13329. factory.instanceCache = {};
  13330. factory.hook(function(original, config, defaultType) {
  13331. var cache = this.instanceCache,
  13332. v;
  13333. if (typeof config === 'string' && !(v = cache[config])) {
  13334. v = original.call(this, config, defaultType);
  13335. if (v.cacheable !== false) {
  13336. cache[config] = v;
  13337. Ext.Object.freeze(v);
  13338. }
  13339. }
  13340. return v;
  13341. });
  13342. }
  13343. fn.instance = factory;
  13344. fn.update = function(instance, config, creator, creatorMethod, defaultsConfig) {
  13345. return factory.update(instance, config, creator, creatorMethod, defaultsConfig);
  13346. };
  13347. }
  13348. return fn;
  13349. };
  13350. Ext.Factory.clearCaches = function() {
  13351. var Factory = Ext.Factory,
  13352. key, item;
  13353. for (key in Factory) {
  13354. item = Factory[key];
  13355. item = item.instance;
  13356. if (item) {
  13357. item.clearCache();
  13358. }
  13359. }
  13360. };
  13361. Ext.Factory.on = function(name, fn) {
  13362. Ext.Factory[name].instance.hook(fn);
  13363. };
  13364. Ext.define('Ext.mixin.Factoryable', {
  13365. mixinId: 'factoryable',
  13366. onClassMixedIn: function(targetClass) {
  13367. var proto = targetClass.prototype,
  13368. factoryConfig = proto.factoryConfig,
  13369. alias = proto.alias,
  13370. config = {},
  13371. dot, createFn;
  13372. alias = alias && alias.length && alias[0];
  13373. if (alias && (dot = alias.lastIndexOf('.')) > 0) {
  13374. config.type = alias.substring(0, dot);
  13375. config.defaultType = alias.substring(dot + 1);
  13376. }
  13377. if (factoryConfig) {
  13378. delete proto.factoryConfig;
  13379. Ext.apply(config, factoryConfig);
  13380. }
  13381. createFn = Ext.Factory.define(config.type, config);
  13382. if (targetClass.create === Ext.Base.create) {
  13383. targetClass.create = createFn;
  13384. }
  13385. }
  13386. });
  13387. Ext.define('Ext.data.request.Base', {
  13388. mixins: [
  13389. Ext.mixin.Factoryable
  13390. ],
  13391. factoryConfig: {
  13392. type: 'request',
  13393. defaultType: 'ajax'
  13394. },
  13395. result: null,
  13396. success: null,
  13397. timer: null,
  13398. constructor: function(config) {
  13399. var me = this;
  13400. Ext.apply(me, config.options || {}, config.ownerConfig);
  13401. me.id = ++Ext.data.Connection.requestId;
  13402. me.owner = config.owner;
  13403. me.options = config.options;
  13404. me.requestOptions = config.requestOptions;
  13405. },
  13406. start: function() {
  13407. var me = this,
  13408. timeout = me.getTimeout();
  13409. if (timeout && me.async) {
  13410. me.timer = Ext.defer(me.onTimeout, timeout, me);
  13411. }
  13412. },
  13413. abort: function() {
  13414. var me = this;
  13415. me.clearTimer();
  13416. if (!me.timedout) {
  13417. me.aborted = true;
  13418. }
  13419. me.abort = Ext.emptyFn;
  13420. },
  13421. createDeferred: function() {
  13422. var me = this,
  13423. result = me.result,
  13424. d = new Ext.Deferred();
  13425. if (me.completed) {
  13426. if (me.success) {
  13427. d.resolve(result);
  13428. } else {
  13429. d.reject(result);
  13430. }
  13431. }
  13432. me.deferred = d;
  13433. return d;
  13434. },
  13435. getDeferred: function() {
  13436. return this.deferred || this.createDeferred();
  13437. },
  13438. getPromise: function() {
  13439. return this.getDeferred().promise;
  13440. },
  13441. then: function() {
  13442. var promise = this.getPromise();
  13443. return promise.then.apply(promise, arguments);
  13444. },
  13445. onComplete: function() {
  13446. var me = this,
  13447. deferred = me.deferred,
  13448. result = me.result;
  13449. me.clearTimer();
  13450. if (deferred) {
  13451. if (me.success) {
  13452. deferred.resolve(result);
  13453. } else {
  13454. deferred.reject(result);
  13455. }
  13456. }
  13457. me.completed = true;
  13458. },
  13459. onTimeout: function() {
  13460. var me = this;
  13461. me.timedout = true;
  13462. me.timer = null;
  13463. me.abort(true);
  13464. },
  13465. getTimeout: function() {
  13466. return this.timeout;
  13467. },
  13468. clearTimer: function() {
  13469. this.timer = Ext.undefer(this.timer);
  13470. },
  13471. destroy: function() {
  13472. var me = this;
  13473. me.abort();
  13474. me.owner = me.options = me.requestOptions = me.result = null;
  13475. me.callParent();
  13476. },
  13477. privates: {
  13478. createException: function() {
  13479. var me = this,
  13480. result;
  13481. result = {
  13482. request: me,
  13483. requestId: me.id,
  13484. status: me.aborted ? -1 : 0,
  13485. statusText: me.aborted ? 'transaction aborted' : 'communication failure',
  13486. getResponseHeader: me._getHeader,
  13487. getAllResponseHeaders: me._getHeaders
  13488. };
  13489. if (me.aborted) {
  13490. result.aborted = true;
  13491. }
  13492. if (me.timedout) {
  13493. result.timedout = true;
  13494. }
  13495. return result;
  13496. },
  13497. _getHeader: function(name) {
  13498. var headers = this.headers;
  13499. return headers && headers[name.toLowerCase()];
  13500. },
  13501. _getHeaders: function() {
  13502. return this.headers;
  13503. }
  13504. }
  13505. });
  13506. Ext.define('Ext.data.flash.BinaryXhr', {
  13507. statics: {
  13508. flashPluginActivated: function() {
  13509. Ext.data.flash.BinaryXhr.flashPluginActive = true;
  13510. Ext.data.flash.BinaryXhr.flashPlugin = document.getElementById("ext-flash-polyfill");
  13511. Ext.GlobalEvents.fireEvent("flashready");
  13512. },
  13513. flashPluginActive: false,
  13514. flashPluginInjected: false,
  13515. connectionIndex: 1,
  13516. liveConnections: {},
  13517. flashPlugin: null,
  13518. onFlashStateChange: function(javascriptId, state, data) {
  13519. var connection;
  13520. connection = this.liveConnections[Number(javascriptId)];
  13521. if (connection) {
  13522. connection.onFlashStateChange(state, data);
  13523. } else
  13524. {
  13525. Ext.warn.log("onFlashStateChange for unknown connection ID: " + javascriptId);
  13526. }
  13527. },
  13528. registerConnection: function(conn) {
  13529. var i = this.connectionIndex;
  13530. this.conectionIndex = this.connectionIndex + 1;
  13531. this.liveConnections[i] = conn;
  13532. return i;
  13533. },
  13534. injectFlashPlugin: function() {
  13535. var me = this,
  13536. flashLoaderPath, flashObjectPath;
  13537. me.flashPolyfillEl = Ext.getBody().appendChild({
  13538. id: 'ext-flash-polyfill',
  13539. cn: [
  13540. {
  13541. tag: 'p',
  13542. html: 'To view this page ensure that Adobe Flash Player version 11.1.0 or greater is installed.'
  13543. },
  13544. {
  13545. tag: 'a',
  13546. href: 'http://www.adobe.com/go/getflashplayer',
  13547. cn: [
  13548. {
  13549. tag: 'img',
  13550. src: window.location.protocol + '//www.adobe.com/images/shared/download_buttons/get_flash_player.gif',
  13551. alt: 'Get Adobe Flash player'
  13552. }
  13553. ]
  13554. }
  13555. ]
  13556. });
  13557. flashLoaderPath = [
  13558. Ext.Loader.getPath('Ext.data.Connection'),
  13559. '../../../plugins/flash/swfobject.js'
  13560. ].join('/');
  13561. flashObjectPath = "/plugins/flash/FlashPlugin.swf";
  13562. flashObjectPath = [
  13563. Ext.Loader.getPath('Ext.data.Connection'),
  13564. '../../plugins/flash/FlashPlugin.swf'
  13565. ].join('/');
  13566. if (Ext.flashPluginPath) {
  13567. flashObjectPath = Ext.flashPluginPath;
  13568. }
  13569. Ext.Loader.loadScript({
  13570. url: flashLoaderPath,
  13571. onLoad: function() {
  13572. var swfVersionStr = "11.4.0";
  13573. var xiSwfUrlStr = "playerProductInstall.swf";
  13574. var flashvars = {};
  13575. var params = {};
  13576. params.quality = "high";
  13577. params.bgcolor = "#ffffff";
  13578. params.allowscriptaccess = "sameDomain";
  13579. params.allowfullscreen = "true";
  13580. var attributes = {};
  13581. attributes.id = "ext-flash-polyfill";
  13582. attributes.name = "polyfill";
  13583. attributes.align = "middle";
  13584. swfobject.embedSWF(flashObjectPath, "ext-flash-polyfill", "0", "0",
  13585. swfVersionStr, xiSwfUrlStr, flashvars, params, attributes);
  13586. },
  13587. onError: function() {
  13588. Ext.raise("Could not load flash-loader file swfobject.js from " + flashLoader);
  13589. },
  13590. scope: me
  13591. });
  13592. Ext.data.flash.BinaryXhr.flashPluginInjected = true;
  13593. }
  13594. },
  13595. readyState: 0,
  13596. status: 0,
  13597. statusText: "",
  13598. responseBytes: null,
  13599. javascriptId: null,
  13600. constructor: function(config) {
  13601. if (!Ext.data.flash.BinaryXhr.flashPluginInjected) {
  13602. Ext.data.flash.BinaryXhr.injectFlashPlugin();
  13603. }
  13604. var me = this;
  13605. Ext.apply(me, config);
  13606. me.requestHeaders = {};
  13607. },
  13608. abort: function() {
  13609. var me = this;
  13610. if (me.readyState == 4) {
  13611. Ext.warn.log("Aborting a connection that's completed its transfer: " + this.url);
  13612. return;
  13613. }
  13614. me.aborted = true;
  13615. if (!Ext.data.flash.BinaryXhr.flashPluginActive) {
  13616. Ext.GlobalEvents.removeListener("flashready", me.onFlashReady, me);
  13617. return;
  13618. }
  13619. Ext.data.flash.BinaryXhr.flashPlugin.abortRequest(me.javascriptId);
  13620. delete Ext.data.flash.BinaryXhr.liveConnections[me.javascriptId];
  13621. },
  13622. getAllResponseHeaders: function() {
  13623. var headers = [];
  13624. Ext.Object.each(this.responseHeaders, function(name, value) {
  13625. headers.push(name + ': ' + value);
  13626. });
  13627. return headers.join('\r\n');
  13628. },
  13629. getResponseHeader: function(header) {
  13630. var headers = this.responseHeaders;
  13631. return (headers && headers[header]) || null;
  13632. },
  13633. open: function(method, url, async, user, password) {
  13634. var me = this;
  13635. me.method = method;
  13636. me.url = url;
  13637. me.async = async !== false;
  13638. me.user = user;
  13639. me.password = password;
  13640. if (!me.async) {
  13641. Ext.raise("Binary posts are only supported in async mode: " + url);
  13642. }
  13643. if (me.method != "POST") {
  13644. Ext.log.warn("Binary data can only be sent as a POST request: " + url);
  13645. }
  13646. },
  13647. overrideMimeType: function(mimeType) {
  13648. this.mimeType = mimeType;
  13649. },
  13650. send: function(body) {
  13651. var me = this;
  13652. me.body = body;
  13653. if (!Ext.data.flash.BinaryXhr.flashPluginActive) {
  13654. Ext.GlobalEvents.addListener("flashready", me.onFlashReady, me);
  13655. } else {
  13656. this.onFlashReady();
  13657. }
  13658. },
  13659. onFlashReady: function() {
  13660. var me = this,
  13661. req, status;
  13662. me.javascriptId = Ext.data.flash.BinaryXhr.registerConnection(me);
  13663. req = {
  13664. method: me.method,
  13665. url: me.url,
  13666. user: me.user,
  13667. password: me.password,
  13668. mimeType: me.mimeType,
  13669. requestHeaders: me.requestHeaders,
  13670. body: me.body,
  13671. javascriptId: me.javascriptId
  13672. };
  13673. status = Ext.data.flash.BinaryXhr.flashPlugin.postBinary(req);
  13674. },
  13675. setReadyState: function(state) {
  13676. var me = this;
  13677. if (me.readyState != state) {
  13678. me.readyState = state;
  13679. me.onreadystatechange();
  13680. }
  13681. },
  13682. setRequestHeader: function(header, value) {
  13683. this.requestHeaders[header] = value;
  13684. },
  13685. onreadystatechange: Ext.emptyFn,
  13686. parseData: function(data) {
  13687. var me = this;
  13688. this.status = data.status || 0;
  13689. me.responseHeaders = {};
  13690. if (me.mimeType) {
  13691. me.responseHeaders["content-type"] = me.mimeType;
  13692. }
  13693. if (data.reason == "complete") {
  13694. this.responseBytes = data.data;
  13695. me.responseHeaders["content-length"] = data.data.length;
  13696. } else if (data.reason == "error" || data.reason == "securityError") {
  13697. this.statusText = data.text;
  13698. me.responseHeaders["content-length"] = 0;
  13699. } else
  13700. {
  13701. Ext.raise("Unkown reason code in data: " + data.reason);
  13702. }
  13703. },
  13704. onFlashStateChange: function(state, data) {
  13705. var me = this;
  13706. if (state == 4) {
  13707. me.parseData(data);
  13708. delete Ext.data.flash.BinaryXhr.liveConnections[me.javascriptId];
  13709. }
  13710. me.setReadyState(state);
  13711. }
  13712. });
  13713. Ext.define('Ext.data.request.Ajax', {
  13714. extend: Ext.data.request.Base,
  13715. alias: 'request.ajax',
  13716. statics: {
  13717. parseStatus: function(status, response) {
  13718. var type, len;
  13719. if (response) {
  13720. type = response.responseType;
  13721. if (type === 'arraybuffer') {
  13722. len = response.byteLength;
  13723. } else if (type === 'blob') {
  13724. len = response.response.size;
  13725. } else if (type === 'json' || type === 'document') {
  13726. len = 0;
  13727. } else if ((type === 'text' || type === '' || !type) && response.responseText) {
  13728. len = response.responseText.length;
  13729. }
  13730. }
  13731. status = status == 1223 ? 204 : status;
  13732. var success = (status >= 200 && status < 300) || status == 304 || (status == 0 && Ext.isNumber(len)),
  13733. isException = false;
  13734. if (!success) {
  13735. switch (status) {
  13736. case 12002:
  13737. case 12029:
  13738. case 12030:
  13739. case 12031:
  13740. case 12152:
  13741. case 13030:
  13742. isException = true;
  13743. break;
  13744. }
  13745. }
  13746. return {
  13747. success: success,
  13748. isException: isException
  13749. };
  13750. }
  13751. },
  13752. start: function(data) {
  13753. var me = this,
  13754. options = me.options,
  13755. requestOptions = me.requestOptions,
  13756. isXdr = me.isXdr,
  13757. xhr, headers;
  13758. xhr = me.xhr = me.openRequest(options, requestOptions, me.async, me.username, me.password);
  13759. if (!isXdr) {
  13760. headers = me.setupHeaders(xhr, options, requestOptions.data, requestOptions.params);
  13761. }
  13762. if (me.async) {
  13763. if (!isXdr) {
  13764. xhr.onreadystatechange = me.bindStateChange();
  13765. }
  13766. }
  13767. if (isXdr) {
  13768. me.processXdrRequest(me, xhr);
  13769. }
  13770. me.callParent([
  13771. data
  13772. ]);
  13773. xhr.send(data);
  13774. if (!me.async) {
  13775. return me.onComplete();
  13776. }
  13777. return me;
  13778. },
  13779. abort: function(force) {
  13780. var me = this,
  13781. xhr = me.xhr;
  13782. if (force || me.isLoading()) {
  13783. try {
  13784. xhr.onreadystatechange = null;
  13785. } catch (e) {
  13786. xhr.onreadystatechange = Ext.emptyFn;
  13787. }
  13788. xhr.abort();
  13789. me.callParent([
  13790. force
  13791. ]);
  13792. me.onComplete();
  13793. me.cleanup();
  13794. }
  13795. },
  13796. cleanup: function() {
  13797. this.xhr = null;
  13798. delete this.xhr;
  13799. },
  13800. isLoading: function() {
  13801. var me = this,
  13802. xhr = me.xhr,
  13803. state = xhr && xhr.readyState,
  13804. C = Ext.data.flash && Ext.data.flash.BinaryXhr;
  13805. if (!xhr || me.aborted || me.timedout) {
  13806. return false;
  13807. }
  13808. if (C && xhr instanceof C) {
  13809. return state !== 4;
  13810. }
  13811. return state !== 0 && state !== 4;
  13812. },
  13813. openRequest: function(options, requestOptions, async, username, password) {
  13814. var me = this,
  13815. xhr = me.newRequest(options);
  13816. if (username) {
  13817. xhr.open(requestOptions.method, requestOptions.url, async, username, password);
  13818. } else {
  13819. if (me.isXdr) {
  13820. xhr.open(requestOptions.method, requestOptions.url);
  13821. } else {
  13822. xhr.open(requestOptions.method, requestOptions.url, async);
  13823. }
  13824. }
  13825. if (options.binary || me.binary) {
  13826. if (window.Uint8Array) {
  13827. xhr.responseType = 'arraybuffer';
  13828. } else if (xhr.overrideMimeType) {
  13829. xhr.overrideMimeType('text/plain; charset=x-user-defined');
  13830. }
  13831. else if (!Ext.isIE) {
  13832. Ext.log.warn("Your browser does not support loading binary data using Ajax.");
  13833. }
  13834. }
  13835. if (options.responseType) {
  13836. xhr.responseType = options.responseType;
  13837. }
  13838. if (options.withCredentials || me.withCredentials) {
  13839. xhr.withCredentials = true;
  13840. }
  13841. return xhr;
  13842. },
  13843. newRequest: function(options) {
  13844. var me = this,
  13845. xhr;
  13846. if (options.binaryData) {
  13847. if (window.Uint8Array) {
  13848. xhr = me.getXhrInstance();
  13849. } else {
  13850. xhr = new Ext.data.flash.BinaryXhr();
  13851. }
  13852. } else if (me.cors && Ext.isIE9m) {
  13853. xhr = me.getXdrInstance();
  13854. me.isXdr = true;
  13855. } else {
  13856. xhr = me.getXhrInstance();
  13857. me.isXdr = false;
  13858. }
  13859. return xhr;
  13860. },
  13861. setupHeaders: function(xhr, options, data, params) {
  13862. var me = this,
  13863. headers = Ext.apply({}, options.headers || {}, me.defaultHeaders),
  13864. contentType = me.defaultPostHeader,
  13865. jsonData = options.jsonData,
  13866. xmlData = options.xmlData,
  13867. type = 'Content-Type',
  13868. useHeader = me.useDefaultXhrHeader,
  13869. key, header;
  13870. if (!headers.hasOwnProperty(type) && (data || params)) {
  13871. if (data) {
  13872. if (options.rawData) {
  13873. contentType = 'text/plain';
  13874. } else {
  13875. if (xmlData && Ext.isDefined(xmlData)) {
  13876. contentType = 'text/xml';
  13877. } else if (jsonData && Ext.isDefined(jsonData)) {
  13878. contentType = 'application/json';
  13879. }
  13880. }
  13881. }
  13882. headers[type] = contentType;
  13883. }
  13884. if (useHeader && !headers['X-Requested-With']) {
  13885. headers['X-Requested-With'] = me.defaultXhrHeader;
  13886. }
  13887. if (headers[type] === undefined || headers[type] === null) {
  13888. delete headers[type];
  13889. }
  13890. try {
  13891. for (key in headers) {
  13892. if (headers.hasOwnProperty(key)) {
  13893. header = headers[key];
  13894. xhr.setRequestHeader(key, header);
  13895. }
  13896. }
  13897. } catch (e) {
  13898. me.owner.fireEvent('exception', key, header);
  13899. }
  13900. return headers;
  13901. },
  13902. getXdrInstance: function() {
  13903. var xdr;
  13904. if (Ext.ieVersion >= 8) {
  13905. xdr = new XDomainRequest();
  13906. } else {
  13907. Ext.raise({
  13908. msg: 'Your browser does not support CORS'
  13909. });
  13910. }
  13911. return xdr;
  13912. },
  13913. getXhrInstance: function() {
  13914. return new XMLHttpRequest();
  13915. },
  13916. processXdrRequest: function(request, xhr) {
  13917. var me = this;
  13918. delete request.headers;
  13919. request.contentType = request.options.contentType || me.defaultXdrContentType;
  13920. xhr.onload = me.bindStateChange(true);
  13921. xhr.onerror = xhr.ontimeout = me.bindStateChange(false);
  13922. },
  13923. processXdrResponse: function(response, xhr) {
  13924. response.getAllResponseHeaders = function() {
  13925. return [];
  13926. };
  13927. response.getResponseHeader = function() {
  13928. return '';
  13929. };
  13930. response.contentType = xhr.contentType || this.defaultXdrContentType;
  13931. },
  13932. bindStateChange: function(xdrResult) {
  13933. var me = this;
  13934. return function() {
  13935. Ext.elevate(function() {
  13936. me.onStateChange(xdrResult);
  13937. });
  13938. };
  13939. },
  13940. onStateChange: function(xdrResult) {
  13941. var me = this,
  13942. xhr = me.xhr;
  13943. if ((xhr && xhr.readyState == 4) || me.isXdr) {
  13944. me.clearTimer();
  13945. me.onComplete(xdrResult);
  13946. me.cleanup();
  13947. }
  13948. },
  13949. onComplete: function(xdrResult) {
  13950. var me = this,
  13951. owner = me.owner,
  13952. options = me.options,
  13953. xhr = me.xhr,
  13954. failure = {
  13955. success: false,
  13956. isException: false
  13957. },
  13958. result, success, response;
  13959. if (!xhr || me.destroyed) {
  13960. return me.result = failure;
  13961. }
  13962. try {
  13963. result = Ext.data.request.Ajax.parseStatus(xhr.status, xhr);
  13964. if (result.success) {
  13965. result.success = xhr.readyState === 4;
  13966. }
  13967. } catch (e) {
  13968. result = failure;
  13969. }
  13970. success = me.success = me.isXdr ? xdrResult : result.success;
  13971. if (success) {
  13972. response = me.createResponse(xhr);
  13973. if (owner.hasListeners.requestcomplete) {
  13974. owner.fireEvent('requestcomplete', owner, response, options);
  13975. }
  13976. if (options.success) {
  13977. Ext.callback(options.success, options.scope, [
  13978. response,
  13979. options
  13980. ]);
  13981. }
  13982. } else {
  13983. if (result.isException || me.aborted || me.timedout) {
  13984. response = me.createException(xhr);
  13985. } else {
  13986. response = me.createResponse(xhr);
  13987. }
  13988. if (owner.hasListeners.requestexception) {
  13989. owner.fireEvent('requestexception', owner, response, options);
  13990. }
  13991. if (options.failure) {
  13992. Ext.callback(options.failure, options.scope, [
  13993. response,
  13994. options
  13995. ]);
  13996. }
  13997. }
  13998. me.result = response;
  13999. if (options.callback) {
  14000. Ext.callback(options.callback, options.scope, [
  14001. options,
  14002. success,
  14003. response
  14004. ]);
  14005. }
  14006. owner.onRequestComplete(me);
  14007. me.callParent([
  14008. xdrResult
  14009. ]);
  14010. return response;
  14011. },
  14012. createResponse: function(xhr) {
  14013. var me = this,
  14014. isXdr = me.isXdr,
  14015. headers = {},
  14016. lines = isXdr ? [] : xhr.getAllResponseHeaders().replace(/\r\n/g, '\n').split('\n'),
  14017. count = lines.length,
  14018. line, index, key, response, byteArray;
  14019. while (count--) {
  14020. line = lines[count];
  14021. index = line.indexOf(':');
  14022. if (index >= 0) {
  14023. key = line.substr(0, index).toLowerCase();
  14024. if (line.charAt(index + 1) == ' ') {
  14025. ++index;
  14026. }
  14027. headers[key] = line.substr(index + 1);
  14028. }
  14029. }
  14030. response = {
  14031. request: me,
  14032. requestId: me.id,
  14033. status: xhr.status,
  14034. statusText: xhr.statusText,
  14035. getResponseHeader: function(header) {
  14036. return headers[header.toLowerCase()];
  14037. },
  14038. getAllResponseHeaders: function() {
  14039. return headers;
  14040. }
  14041. };
  14042. if (isXdr) {
  14043. me.processXdrResponse(response, xhr);
  14044. }
  14045. if (me.binary) {
  14046. response.responseBytes = me.getByteArray(xhr);
  14047. } else {
  14048. if (xhr.responseType) {
  14049. response.responseType = xhr.responseType;
  14050. }
  14051. if (xhr.responseType === 'blob') {
  14052. response.responseBlob = xhr.response;
  14053. } else if (xhr.responseType === 'json') {
  14054. response.responseJson = xhr.response;
  14055. } else if (xhr.responseType === 'document') {
  14056. response.responseXML = xhr.response;
  14057. } else {
  14058. response.responseText = xhr.responseText;
  14059. response.responseXML = xhr.responseXML;
  14060. }
  14061. }
  14062. return response;
  14063. },
  14064. destroy: function() {
  14065. this.xhr = null;
  14066. this.callParent();
  14067. },
  14068. privates: {
  14069. getByteArray: function(xhr) {
  14070. var response = xhr.response,
  14071. responseBody = xhr.responseBody,
  14072. Cls = Ext.data.flash && Ext.data.flash.BinaryXhr,
  14073. byteArray, responseText, len, i;
  14074. if (xhr instanceof Cls) {
  14075. byteArray = xhr.responseBytes;
  14076. } else if (window.Uint8Array) {
  14077. byteArray = response ? new Uint8Array(response) : [];
  14078. } else if (Ext.isIE9p) {
  14079. try {
  14080. byteArray = new VBArray(responseBody).toArray();
  14081. }
  14082. catch (e) {
  14083. byteArray = [];
  14084. }
  14085. } else if (Ext.isIE) {
  14086. if (!this.self.vbScriptInjected) {
  14087. this.injectVBScript();
  14088. }
  14089. getIEByteArray(xhr.responseBody, byteArray = []);
  14090. } else
  14091. {
  14092. byteArray = [];
  14093. responseText = xhr.responseText;
  14094. len = responseText.length;
  14095. for (i = 0; i < len; i++) {
  14096. byteArray.push(responseText.charCodeAt(i) & 255);
  14097. }
  14098. }
  14099. return byteArray;
  14100. },
  14101. injectVBScript: function() {
  14102. var scriptTag = document.createElement('script');
  14103. scriptTag.type = 'text/vbscript';
  14104. scriptTag.text = [
  14105. 'Function getIEByteArray(byteArray, out)',
  14106. 'Dim len, i',
  14107. 'len = LenB(byteArray)',
  14108. 'For i = 1 to len',
  14109. 'out.push(AscB(MidB(byteArray, i, 1)))',
  14110. 'Next',
  14111. 'End Function'
  14112. ].join('\n');
  14113. Ext.getHead().dom.appendChild(scriptTag);
  14114. this.self.vbScriptInjected = true;
  14115. }
  14116. }
  14117. });
  14118. Ext.define('Ext.data.request.Form', {
  14119. extend: Ext.data.request.Base,
  14120. alias: 'request.form',
  14121. start: function(data) {
  14122. var me = this,
  14123. options = me.options,
  14124. requestOptions = me.requestOptions;
  14125. me.callParent([
  14126. data
  14127. ]);
  14128. me.form = me.upload(options.form, requestOptions.url, requestOptions.data, options);
  14129. return me;
  14130. },
  14131. abort: function(force) {
  14132. var me = this,
  14133. frame;
  14134. if (me.isLoading()) {
  14135. try {
  14136. frame = me.frame.dom;
  14137. if (frame.stop) {
  14138. frame.stop();
  14139. } else {
  14140. frame.document.execCommand('Stop');
  14141. }
  14142. } catch (e) {}
  14143. }
  14144. me.callParent([
  14145. force
  14146. ]);
  14147. me.onComplete();
  14148. me.cleanup();
  14149. },
  14150. cleanup: function() {
  14151. var me = this,
  14152. frame = me.frame;
  14153. if (frame) {
  14154. frame.un('load', me.onComplete, me);
  14155. Ext.removeNode(frame);
  14156. }
  14157. me.frame = me.form = null;
  14158. },
  14159. isLoading: function() {
  14160. return !!this.frame;
  14161. },
  14162. upload: function(form, url, params, options) {
  14163. form = Ext.getDom(form);
  14164. options = options || {};
  14165. var frameDom = document.createElement('iframe'),
  14166. frame = Ext.get(frameDom),
  14167. id = frame.id,
  14168. hiddens = [],
  14169. encoding = 'multipart/form-data',
  14170. buf = {
  14171. target: form.target,
  14172. method: form.method,
  14173. encoding: form.encoding,
  14174. enctype: form.enctype,
  14175. action: form.action
  14176. },
  14177. addField = function(name, value) {
  14178. hiddenItem = document.createElement('input');
  14179. Ext.fly(hiddenItem).set({
  14180. type: 'hidden',
  14181. value: value,
  14182. name: name
  14183. });
  14184. form.appendChild(hiddenItem);
  14185. hiddens.push(hiddenItem);
  14186. },
  14187. hiddenItem, obj, value, name, vLen, v, hLen, h;
  14188. frame.set({
  14189. name: id,
  14190. cls: Ext.baseCSSPrefix + 'hidden-display',
  14191. src: Ext.SSL_SECURE_URL,
  14192. tabIndex: -1
  14193. });
  14194. document.body.appendChild(frameDom);
  14195. document.body.appendChild(form);
  14196. if (document.frames) {
  14197. document.frames[id].name = id;
  14198. }
  14199. Ext.fly(form).set({
  14200. target: id,
  14201. method: 'POST',
  14202. enctype: encoding,
  14203. encoding: encoding,
  14204. action: url || buf.action
  14205. });
  14206. if (params) {
  14207. obj = Ext.Object.fromQueryString(params) || {};
  14208. for (name in obj) {
  14209. if (obj.hasOwnProperty(name)) {
  14210. value = obj[name];
  14211. if (Ext.isArray(value)) {
  14212. vLen = value.length;
  14213. for (v = 0; v < vLen; v++) {
  14214. addField(name, value[v]);
  14215. }
  14216. } else {
  14217. addField(name, value);
  14218. }
  14219. }
  14220. }
  14221. }
  14222. this.frame = frame;
  14223. frame.on({
  14224. load: this.onComplete,
  14225. scope: this,
  14226. single: !Ext.isOpera
  14227. });
  14228. form.submit();
  14229. document.body.removeChild(form);
  14230. Ext.fly(form).set(buf);
  14231. for (hLen = hiddens.length , h = 0; h < hLen; h++) {
  14232. Ext.removeNode(hiddens[h]);
  14233. }
  14234. return form;
  14235. },
  14236. getDoc: function() {
  14237. var frame = this.frame.dom;
  14238. return (frame && (frame.contentWindow.document || frame.contentDocument)) || (window.frames[frame.id] || {}).document;
  14239. },
  14240. getTimeout: function() {
  14241. return this.options.timeout;
  14242. },
  14243. onComplete: function() {
  14244. var me = this,
  14245. frame = me.frame,
  14246. owner = me.owner,
  14247. options = me.options,
  14248. callback, doc, success, contentNode, response;
  14249. if (!frame) {
  14250. return;
  14251. }
  14252. if (me.aborted || me.timedout) {
  14253. me.result = response = me.createException();
  14254. response.responseXML = null;
  14255. response.responseText = Ext.encode({
  14256. success: false,
  14257. message: Ext.String.trim(response.statusText)
  14258. });
  14259. response.request = me;
  14260. callback = options.failure;
  14261. success = false;
  14262. } else {
  14263. try {
  14264. doc = me.getDoc();
  14265. me.result = response = {
  14266. responseText: '',
  14267. responseXML: null,
  14268. request: me
  14269. };
  14270. if (doc) {
  14271. if (Ext.isOpera && doc.location == Ext.SSL_SECURE_URL) {
  14272. return;
  14273. }
  14274. if (doc.body) {
  14275. if ((contentNode = doc.body.firstChild) && /pre/i.test(contentNode.tagName)) {
  14276. response.responseText = contentNode.textContent || contentNode.innerText;
  14277. }
  14278. else if ((contentNode = doc.getElementsByTagName('textarea')[0])) {
  14279. response.responseText = contentNode.value;
  14280. } else
  14281. {
  14282. response.responseText = doc.body.textContent || doc.body.innerText;
  14283. }
  14284. }
  14285. response.responseXML = doc.XMLDocument || doc;
  14286. callback = options.success;
  14287. success = true;
  14288. response.status = 200;
  14289. } else {
  14290. Ext.raise("Could not acquire a suitable connection for the file upload service.");
  14291. }
  14292. } catch (e) {
  14293. me.result = response = me.createException();
  14294. response.status = 400;
  14295. response.statusText = (e.message || e.description) + '';
  14296. response.responseText = Ext.encode({
  14297. success: false,
  14298. message: Ext.String.trim(response.statusText)
  14299. });
  14300. response.responseXML = null;
  14301. callback = options.failure;
  14302. success = false;
  14303. }
  14304. }
  14305. me.frame = null;
  14306. me.success = success;
  14307. owner.fireEvent(success ? 'requestcomplete' : 'requestexception', owner, response, options);
  14308. Ext.callback(callback, options.scope, [
  14309. response,
  14310. options
  14311. ]);
  14312. Ext.callback(options.callback, options.scope, [
  14313. options,
  14314. success,
  14315. response
  14316. ]);
  14317. owner.onRequestComplete(me);
  14318. Ext.asap(frame.destroy, frame);
  14319. me.callParent();
  14320. },
  14321. destroy: function() {
  14322. this.cleanup();
  14323. this.callParent();
  14324. }
  14325. });
  14326. Ext.define('Ext.data.Connection', {
  14327. mixins: {
  14328. observable: Ext.mixin.Observable
  14329. },
  14330. statics: {
  14331. requestId: 0
  14332. },
  14333. enctypeRe: /multipart\/form-data/i,
  14334. config: {
  14335. url: null,
  14336. async: true,
  14337. username: '',
  14338. password: '',
  14339. disableCaching: true,
  14340. withCredentials: false,
  14341. binary: false,
  14342. cors: false,
  14343. isXdr: false,
  14344. defaultXdrContentType: 'text/plain',
  14345. disableCachingParam: '_dc',
  14346. timeout: 30000,
  14347. extraParams: null,
  14348. autoAbort: false,
  14349. method: null,
  14350. defaultHeaders: null,
  14351. defaultPostHeader: 'application/x-www-form-urlencoded; charset=UTF-8',
  14352. useDefaultXhrHeader: true,
  14353. defaultXhrHeader: 'XMLHttpRequest'
  14354. },
  14355. constructor: function(config) {
  14356. this.mixins.observable.constructor.call(this, config);
  14357. this.requests = {};
  14358. },
  14359. request: function(options) {
  14360. options = options || {};
  14361. var me = this,
  14362. requestOptions, request;
  14363. if (me.fireEvent('beforerequest', me, options) !== false) {
  14364. requestOptions = me.setOptions(options, options.scope || Ext.global);
  14365. request = me.createRequest(options, requestOptions);
  14366. return request.start(requestOptions.data);
  14367. }
  14368. request = {
  14369. status: -1,
  14370. statusText: 'Request cancelled in beforerequest event handler'
  14371. };
  14372. Ext.callback(options.callback, options.scope, [
  14373. options,
  14374. false,
  14375. request
  14376. ]);
  14377. return Ext.Deferred.rejected([
  14378. options,
  14379. false,
  14380. request
  14381. ]);
  14382. },
  14383. createRequest: function(options, requestOptions) {
  14384. var me = this,
  14385. type = options.type || requestOptions.type,
  14386. request;
  14387. if (!type) {
  14388. type = me.isFormUpload(options) ? 'form' : 'ajax';
  14389. }
  14390. if (options.autoAbort || me.getAutoAbort()) {
  14391. me.abort();
  14392. }
  14393. request = Ext.Factory.request({
  14394. type: type,
  14395. owner: me,
  14396. options: options,
  14397. requestOptions: requestOptions,
  14398. ownerConfig: me.getConfig()
  14399. });
  14400. me.requests[request.id] = request;
  14401. me.latestId = request.id;
  14402. return request;
  14403. },
  14404. isFormUpload: function(options) {
  14405. var form = this.getForm(options);
  14406. if (form) {
  14407. return options.isUpload || this.enctypeRe.test(form.getAttribute('enctype'));
  14408. }
  14409. return false;
  14410. },
  14411. getForm: function(options) {
  14412. return Ext.getDom(options.form);
  14413. },
  14414. setOptions: function(options, scope) {
  14415. var me = this,
  14416. params = options.params || {},
  14417. extraParams = me.getExtraParams(),
  14418. urlParams = options.urlParams,
  14419. url = options.url || me.getUrl(),
  14420. cors = options.cors,
  14421. jsonData = options.jsonData,
  14422. method, disableCache, data;
  14423. if (cors !== undefined) {
  14424. me.setCors(cors);
  14425. }
  14426. if (Ext.isFunction(params)) {
  14427. params = params.call(scope, options);
  14428. }
  14429. if (Ext.isFunction(url)) {
  14430. url = url.call(scope, options);
  14431. }
  14432. url = this.setupUrl(options, url);
  14433. if (!url) {
  14434. Ext.raise({
  14435. options: options,
  14436. msg: 'No URL specified'
  14437. });
  14438. }
  14439. data = options.rawData || options.binaryData || options.xmlData || jsonData || null;
  14440. if (jsonData && !Ext.isPrimitive(jsonData)) {
  14441. data = Ext.encode(data);
  14442. }
  14443. if (options.binaryData) {
  14444. if (!Ext.isArray(options.binaryData)) {
  14445. Ext.log.warn("Binary submission data must be an array of byte values! Instead got " + typeof (options.binaryData));
  14446. }
  14447. if (me.nativeBinaryPostSupport()) {
  14448. data = (new Uint8Array(options.binaryData));
  14449. if ((Ext.isChrome && Ext.chromeVersion < 22) || Ext.isSafari || Ext.isGecko) {
  14450. data = data.buffer;
  14451. }
  14452. }
  14453. }
  14454. if (Ext.isObject(params)) {
  14455. params = Ext.Object.toQueryString(params);
  14456. }
  14457. if (Ext.isObject(extraParams)) {
  14458. extraParams = Ext.Object.toQueryString(extraParams);
  14459. }
  14460. params = params + ((extraParams) ? ((params) ? '&' : '') + extraParams : '');
  14461. urlParams = Ext.isObject(urlParams) ? Ext.Object.toQueryString(urlParams) : urlParams;
  14462. params = this.setupParams(options, params);
  14463. method = (options.method || me.getMethod() || ((params || data) ? 'POST' : 'GET')).toUpperCase();
  14464. this.setupMethod(options, method);
  14465. disableCache = options.disableCaching !== false ? (options.disableCaching || me.getDisableCaching()) : false;
  14466. if (method === 'GET' && disableCache) {
  14467. url = Ext.urlAppend(url, (options.disableCachingParam || me.getDisableCachingParam()) + '=' + (new Date().getTime()));
  14468. }
  14469. if ((method == 'GET' || data) && params) {
  14470. url = Ext.urlAppend(url, params);
  14471. params = null;
  14472. }
  14473. if (urlParams) {
  14474. url = Ext.urlAppend(url, urlParams);
  14475. }
  14476. return {
  14477. url: url,
  14478. method: method,
  14479. data: data || params || null
  14480. };
  14481. },
  14482. setupUrl: function(options, url) {
  14483. var form = this.getForm(options);
  14484. if (form) {
  14485. url = url || form.action;
  14486. }
  14487. return url;
  14488. },
  14489. setupParams: function(options, params) {
  14490. var form = this.getForm(options),
  14491. serializedForm;
  14492. if (form && !this.isFormUpload(options)) {
  14493. serializedForm = Ext.Element.serializeForm(form);
  14494. params = params ? (params + '&' + serializedForm) : serializedForm;
  14495. }
  14496. return params;
  14497. },
  14498. setupMethod: function(options, method) {
  14499. if (this.isFormUpload(options)) {
  14500. return 'POST';
  14501. }
  14502. return method;
  14503. },
  14504. isLoading: function(request) {
  14505. if (!request) {
  14506. request = this.getLatest();
  14507. }
  14508. return request ? request.isLoading() : false;
  14509. },
  14510. abort: function(request) {
  14511. if (!request) {
  14512. request = this.getLatest();
  14513. }
  14514. if (request && request.isLoading()) {
  14515. request.abort();
  14516. }
  14517. },
  14518. abortAll: function() {
  14519. var requests = this.requests,
  14520. id;
  14521. for (id in requests) {
  14522. this.abort(requests[id]);
  14523. }
  14524. },
  14525. getLatest: function() {
  14526. var id = this.latestId,
  14527. request;
  14528. if (id) {
  14529. request = this.requests[id];
  14530. }
  14531. return request || null;
  14532. },
  14533. clearTimeout: function(request) {
  14534. if (!request) {
  14535. request = this.getLatest();
  14536. }
  14537. if (request) {
  14538. request.clearTimer();
  14539. }
  14540. },
  14541. onRequestComplete: function(request) {
  14542. delete this.requests[request.id];
  14543. },
  14544. nativeBinaryPostSupport: function() {
  14545. return Ext.isChrome || (Ext.isSafari && Ext.isDefined(window.Uint8Array)) || (Ext.isGecko && Ext.isDefined(window.Uint8Array));
  14546. }
  14547. });
  14548. Ext.define('Ext.Ajax', {
  14549. extend: Ext.data.Connection,
  14550. singleton: true,
  14551. autoAbort: false
  14552. });
  14553. Ext.define('Ext.AnimationQueue', {
  14554. singleton: true,
  14555. constructor: function() {
  14556. var me = this;
  14557. me.queue = [];
  14558. me.taskQueue = [];
  14559. me.runningQueue = [];
  14560. me.idleQueue = [];
  14561. me.isRunning = false;
  14562. me.isIdle = true;
  14563. me.run = me.run.bind(me);
  14564. if (Ext.os.is.iOS) {
  14565. me.watch.$skipTimerCheck = true;
  14566. me.watchdogTimer = Ext.interval(me.watch, 500, me);
  14567. }
  14568. },
  14569. start: function(fn, scope, args) {
  14570. var me = this;
  14571. me.queue.push(arguments);
  14572. if (!me.isRunning) {
  14573. if (me.hasOwnProperty('idleTimer')) {
  14574. Ext.undefer(me.idleTimer);
  14575. delete me.idleTimer;
  14576. }
  14577. if (me.hasOwnProperty('idleQueueTimer')) {
  14578. Ext.undefer(me.idleQueueTimer);
  14579. delete me.idleQueueTimer;
  14580. }
  14581. me.isIdle = false;
  14582. me.isRunning = true;
  14583. me.startCountTime = Ext.now();
  14584. me.count = 0;
  14585. me.doStart();
  14586. }
  14587. },
  14588. clear: function() {
  14589. var me = this;
  14590. Ext.undefer(me.idleTimer);
  14591. Ext.undefer(me.idleQueueTimer);
  14592. Ext.unraf(me.animationFrameId);
  14593. me.idleTimer = me.idleQueueTimer = me.animationFrameId = null;
  14594. me.queue.length = me.taskQueue.length = me.runningQueue.length = me.idleQueue.length = 0;
  14595. me.isRunning = false;
  14596. me.isIdle = true;
  14597. me.startCountTime = Ext.now();
  14598. me.count = 0;
  14599. },
  14600. watch: function() {
  14601. if (this.isRunning && Ext.now() - this.lastRunTime >= 500) {
  14602. this.run();
  14603. }
  14604. },
  14605. run: function() {
  14606. var me = this,
  14607. item, element;
  14608. me.animationFrameId = null;
  14609. if (!me.isRunning) {
  14610. return;
  14611. }
  14612. var queue = me.runningQueue,
  14613. now = Ext.now(),
  14614. i, ln;
  14615. me.lastRunTime = now;
  14616. me.frameStartTime = now;
  14617. i = me.queue.length;
  14618. while (i--) {
  14619. item = me.queue[i];
  14620. element = item[1] && item[1].getElement && item[1].getElement();
  14621. if (element && element.destroyed) {
  14622. me.queue.splice(i, 1);
  14623. }
  14624. }
  14625. queue.push.apply(queue, me.queue);
  14626. for (i = 0 , ln = queue.length; i < ln; i++) {
  14627. me.invoke(queue[i]);
  14628. }
  14629. queue.length = 0;
  14630. var elapse = me.frameStartTime - me.startCountTime,
  14631. count = ++me.count;
  14632. if (elapse >= 200) {
  14633. me.onFpsChanged(count * 1000 / elapse, count, elapse);
  14634. me.startCountTime = me.frameStartTime;
  14635. me.count = 0;
  14636. }
  14637. if (!me.queue.length) {
  14638. me.stop();
  14639. }
  14640. if (me.isRunning) {
  14641. me.doIterate();
  14642. }
  14643. },
  14644. onFpsChanged: Ext.emptyFn,
  14645. onStop: Ext.emptyFn,
  14646. doStart: function() {
  14647. if (!this.animationFrameId) {
  14648. this.animationFrameId = Ext.raf(this.run);
  14649. }
  14650. this.lastRunTime = Ext.now();
  14651. },
  14652. doIterate: function() {
  14653. if (!this.animationFrameId) {
  14654. this.animationFrameId = Ext.raf(this.run);
  14655. }
  14656. },
  14657. doStop: function() {
  14658. if (this.animationFrameId) {
  14659. Ext.unraf(this.animationFrameId);
  14660. }
  14661. this.animationFrameId = null;
  14662. },
  14663. stop: function(fn, scope, args) {
  14664. var me = this;
  14665. if (!me.isRunning) {
  14666. return;
  14667. }
  14668. var queue = me.queue,
  14669. ln = queue.length,
  14670. i, item;
  14671. for (i = 0; i < ln; i++) {
  14672. item = queue[i];
  14673. if (item[0] === fn && item[1] === scope && item[2] === args) {
  14674. queue.splice(i, 1);
  14675. i--;
  14676. ln--;
  14677. }
  14678. }
  14679. if (ln === 0) {
  14680. me.doStop();
  14681. me.onStop();
  14682. me.isRunning = false;
  14683. if (me.idleQueue.length && !me.idleTimer) {
  14684. me.idleTimer = Ext.defer(me.whenIdle, 100, me);
  14685. }
  14686. }
  14687. },
  14688. onIdle: function(fn, scope, args) {
  14689. var me = this,
  14690. listeners = me.idleQueue,
  14691. i, ln, listener;
  14692. for (i = 0 , ln = listeners.length; i < ln; i++) {
  14693. listener = listeners[i];
  14694. if (fn === listener[0] && scope === listener[1] && args === listener[2]) {
  14695. return;
  14696. }
  14697. }
  14698. listeners.push(arguments);
  14699. if (me.isIdle) {
  14700. me.processIdleQueue();
  14701. } else if (!me.idleTimer) {
  14702. me.idleTimer = Ext.defer(me.whenIdle, 100, me);
  14703. }
  14704. },
  14705. unIdle: function(fn, scope, args) {
  14706. var me = this,
  14707. listeners = me.idleQueue,
  14708. i, ln, listener;
  14709. for (i = 0 , ln = listeners.length; i < ln; i++) {
  14710. listener = listeners[i];
  14711. if (fn === listener[0] && scope === listener[1] && args === listener[2]) {
  14712. listeners.splice(i, 1);
  14713. return true;
  14714. }
  14715. }
  14716. if (!listeners.length && me.idleTimer) {
  14717. Ext.undefer(me.idleTimer);
  14718. delete me.idleTimer;
  14719. }
  14720. if (!listeners.length && me.idleQueueTimer) {
  14721. Ext.undefer(me.idleQueueTimer);
  14722. delete me.idleQueueTimer;
  14723. }
  14724. return false;
  14725. },
  14726. queueTask: function(fn, scope, args) {
  14727. this.taskQueue.push(arguments);
  14728. this.processTaskQueue();
  14729. },
  14730. dequeueTask: function(fn, scope, args) {
  14731. var listeners = this.taskQueue,
  14732. i, ln, listener;
  14733. for (i = 0 , ln = listeners.length; i < ln; i++) {
  14734. listener = listeners[i];
  14735. if (fn === listener[0] && scope === listener[1] && args === listener[2]) {
  14736. listeners.splice(i, 1);
  14737. i--;
  14738. ln--;
  14739. }
  14740. }
  14741. },
  14742. invoke: function(listener) {
  14743. var fn = listener[0],
  14744. scope = listener[1],
  14745. args = listener[2];
  14746. fn = (typeof fn == 'string' ? scope[fn] : fn);
  14747. if (Ext.isArray(args)) {
  14748. fn.apply(scope, args);
  14749. } else {
  14750. fn.call(scope, args);
  14751. }
  14752. },
  14753. whenIdle: function() {
  14754. delete this.idleTimer;
  14755. this.isIdle = true;
  14756. this.processIdleQueue();
  14757. },
  14758. processIdleQueue: function() {
  14759. if (!this.hasOwnProperty('idleQueueTimer')) {
  14760. this.idleQueueTimer = Ext.defer(this.processIdleQueueItem, 1, this);
  14761. }
  14762. },
  14763. processIdleQueueItem: function() {
  14764. delete this.idleQueueTimer;
  14765. if (!this.isIdle) {
  14766. return;
  14767. }
  14768. var listeners = this.idleQueue,
  14769. listener;
  14770. if (listeners.length > 0) {
  14771. listener = listeners.shift();
  14772. this.invoke(listener);
  14773. this.processIdleQueue();
  14774. }
  14775. },
  14776. processTaskQueue: function() {
  14777. if (!this.hasOwnProperty('taskQueueTimer')) {
  14778. this.taskQueueTimer = Ext.defer(this.processTaskQueueItem, 15, this);
  14779. }
  14780. },
  14781. processTaskQueueItem: function() {
  14782. delete this.taskQueueTimer;
  14783. var listeners = this.taskQueue,
  14784. listener;
  14785. if (listeners.length > 0) {
  14786. listener = listeners.shift();
  14787. this.invoke(listener);
  14788. this.processTaskQueue();
  14789. }
  14790. },
  14791. showFps: function() {
  14792. var styleTpl = {
  14793. color: 'white',
  14794. 'background-color': 'black',
  14795. 'text-align': 'center',
  14796. 'font-family': 'sans-serif',
  14797. 'font-size': '8px',
  14798. 'font-weight': 'normal',
  14799. 'font-style': 'normal',
  14800. 'line-height': '20px',
  14801. '-webkit-font-smoothing': 'antialiased',
  14802. 'zIndex': 100000,
  14803. position: 'absolute'
  14804. };
  14805. Ext.getBody().append([
  14806. {
  14807. style: Ext.applyIf({
  14808. bottom: '50px',
  14809. left: 0,
  14810. width: '50px',
  14811. height: '20px'
  14812. }, styleTpl),
  14813. html: 'Average'
  14814. },
  14815. {
  14816. style: Ext.applyIf({
  14817. 'background-color': 'red',
  14818. 'font-size': '18px',
  14819. 'line-height': '50px',
  14820. bottom: 0,
  14821. left: 0,
  14822. width: '50px',
  14823. height: '50px'
  14824. }, styleTpl),
  14825. id: '__averageFps',
  14826. html: '0'
  14827. },
  14828. {
  14829. style: Ext.applyIf({
  14830. bottom: '50px',
  14831. left: '50px',
  14832. width: '50px',
  14833. height: '20px'
  14834. }, styleTpl),
  14835. html: 'Min (Last 1k)'
  14836. },
  14837. {
  14838. style: Ext.applyIf({
  14839. 'background-color': 'orange',
  14840. 'font-size': '18px',
  14841. 'line-height': '50px',
  14842. bottom: 0,
  14843. left: '50px',
  14844. width: '50px',
  14845. height: '50px'
  14846. }, styleTpl),
  14847. id: '__minFps',
  14848. html: '0'
  14849. },
  14850. {
  14851. style: Ext.applyIf({
  14852. bottom: '50px',
  14853. left: '100px',
  14854. width: '50px',
  14855. height: '20px'
  14856. }, styleTpl),
  14857. html: 'Max (Last 1k)'
  14858. },
  14859. {
  14860. style: Ext.applyIf({
  14861. 'background-color': 'maroon',
  14862. 'font-size': '18px',
  14863. 'line-height': '50px',
  14864. bottom: 0,
  14865. left: '100px',
  14866. width: '50px',
  14867. height: '50px'
  14868. }, styleTpl),
  14869. id: '__maxFps',
  14870. html: '0'
  14871. },
  14872. {
  14873. style: Ext.applyIf({
  14874. bottom: '50px',
  14875. left: '150px',
  14876. width: '50px',
  14877. height: '20px'
  14878. }, styleTpl),
  14879. html: 'Current'
  14880. },
  14881. {
  14882. style: Ext.applyIf({
  14883. 'background-color': 'green',
  14884. 'font-size': '18px',
  14885. 'line-height': '50px',
  14886. bottom: 0,
  14887. left: '150px',
  14888. width: '50px',
  14889. height: '50px'
  14890. }, styleTpl),
  14891. id: '__currentFps',
  14892. html: '0'
  14893. }
  14894. ]);
  14895. Ext.AnimationQueue.resetFps();
  14896. },
  14897. resetFps: function() {
  14898. var currentFps = Ext.get('__currentFps'),
  14899. averageFps = Ext.get('__averageFps'),
  14900. minFps = Ext.get('__minFps'),
  14901. maxFps = Ext.get('__maxFps'),
  14902. min = 1000,
  14903. max = 0,
  14904. count = 0,
  14905. sum = 0;
  14906. if (!currentFps) {
  14907. return;
  14908. }
  14909. Ext.AnimationQueue.onFpsChanged = function(fps) {
  14910. count++;
  14911. if (!(count % 10)) {
  14912. min = 1000;
  14913. max = 0;
  14914. }
  14915. sum += fps;
  14916. min = Math.min(min, fps);
  14917. max = Math.max(max, fps);
  14918. currentFps.setHtml(Math.round(fps));
  14919. averageFps.setHtml(Math.round(sum / count));
  14920. minFps.setHtml(Math.round(min));
  14921. maxFps.setHtml(Math.round(max));
  14922. };
  14923. }
  14924. }, function() {
  14925. var paramsString = window.location.search.substr(1),
  14926. paramsArray = paramsString.split("&");
  14927. if (Ext.Array.contains(paramsArray, "showfps")) {
  14928. Ext.onReady(this.showFps.bind(this));
  14929. }
  14930. });
  14931. Ext.define('Ext.mixin.Bufferable', function(Bufferable) {
  14932. return {
  14933. extend: Ext.Mixin,
  14934. mixinConfig: {
  14935. id: 'bufferable',
  14936. before: {
  14937. destroy: 'cancelAllCalls'
  14938. },
  14939. extended: function(baseClass, derivedClass, classBody) {
  14940. var bufferableMethods = classBody.bufferableMethods;
  14941. if (bufferableMethods) {
  14942. delete classBody.bufferableMethods;
  14943. Bufferable.processClass(derivedClass, bufferableMethods);
  14944. }
  14945. }
  14946. },
  14947. afterClassMixedIn: function(targetClass) {
  14948. Bufferable.processClass(targetClass);
  14949. },
  14950. privates: {
  14951. cancelAllCalls: function() {
  14952. var bufferables = this.bufferables,
  14953. name;
  14954. if (bufferables) {
  14955. for (name in bufferables) {
  14956. bufferables[name].cancel();
  14957. delete bufferables[name];
  14958. }
  14959. }
  14960. },
  14961. cancelBufferedCall: function(name, invoke) {
  14962. var bufferables = this.bufferables,
  14963. timer = bufferables && bufferables[name];
  14964. if (timer) {
  14965. timer[invoke ? 'invoke' : 'cancel']();
  14966. }
  14967. return !!timer;
  14968. },
  14969. flushBufferedCall: function(name) {
  14970. return this.cancelBufferedCall(name, true);
  14971. },
  14972. initBufferables: function() {
  14973. var me = this,
  14974. methods = me.hasOwnProperty('bufferableMethods') && me.bufferableMethods,
  14975. classMethods;
  14976. if (methods) {
  14977. Bufferable._canonicalize(methods);
  14978. classMethods = me.self.prototype.bufferableMethods;
  14979. me.bufferableMethods = Ext.merge(Ext.clone(classMethods), methods);
  14980. }
  14981. return (me.bufferables = {});
  14982. },
  14983. isCallPending: function(name) {
  14984. var bufferables = this.bufferables,
  14985. timer = bufferables && bufferables[name];
  14986. return !!timer;
  14987. },
  14988. statics: {
  14989. SINGLE: {
  14990. single: true
  14991. },
  14992. _canonicalize: function(methods) {
  14993. var t, def, s, name;
  14994. for (name in methods) {
  14995. s = Ext.String.capitalize(name);
  14996. def = methods[name];
  14997. t = typeof def;
  14998. if (t === 'number' || t === 'string') {
  14999. methods[name] = def = {
  15000. delay: def
  15001. };
  15002. }
  15003. if (typeof (t = def.delay) === 'string') {
  15004. def[t] = true;
  15005. delete def.delay;
  15006. }
  15007. def.capitalized = s;
  15008. def.name = name;
  15009. if (!def.fn) {
  15010. def.fn = 'do' + s;
  15011. }
  15012. if (!def.flag) {
  15013. def.flag = 'is' + s + 'Pending';
  15014. }
  15015. }
  15016. },
  15017. _canceller: function() {
  15018. var timer = this,
  15019. id = timer.id;
  15020. if (id) {
  15021. if (timer.delay) {
  15022. Ext.undefer(id);
  15023. } else if (timer.asap) {
  15024. Ext.unasap(id);
  15025. } else if (timer.idle) {
  15026. Ext.un('idle', id, null, Bufferable.SINGLE);
  15027. } else if (timer.raf) {
  15028. Ext.unraf(id);
  15029. }
  15030. timer.id = null;
  15031. }
  15032. timer.args = null;
  15033. timer.target[timer.flag] = false;
  15034. },
  15035. _invoker: function() {
  15036. var timer = this,
  15037. args = timer.args || Ext.emptyArray,
  15038. target = timer.target;
  15039. ++timer.invokes;
  15040. timer.cancel();
  15041. target[timer.fn].apply(target, args);
  15042. },
  15043. delayCall: function(target, def, args) {
  15044. var bufferables = target.bufferables || target.initBufferables(),
  15045. name = def.name,
  15046. timer = bufferables[name] || (bufferables[name] = Ext.apply({
  15047. calls: 0,
  15048. invokes: 0,
  15049. args: null,
  15050. cancel: Bufferable._canceller,
  15051. id: null,
  15052. target: target,
  15053. invoke: Bufferable._invoker
  15054. }, def)),
  15055. delay = def.delay,
  15056. exec = function() {
  15057. if (timer.id) {
  15058. timer.id = null;
  15059. timer.invoke();
  15060. }
  15061. };
  15062. if (timer.id) {
  15063. timer.cancel();
  15064. }
  15065. timer.args = args;
  15066. ++timer.calls;
  15067. target[timer.flag] = true;
  15068. if (delay) {
  15069. timer.id = Ext.defer(exec, delay);
  15070. } else if (def.asap) {
  15071. timer.id = Ext.asap(exec);
  15072. } else if (def.idle) {
  15073. timer.id = exec;
  15074. Ext.on('idle', exec, null, Bufferable.SINGLE);
  15075. } else if (def.raf) {
  15076. timer.id = Ext.raf(exec);
  15077. } else {
  15078. timer.invoke();
  15079. }
  15080. },
  15081. processClass: function(cls, bufferableMethods) {
  15082. var proto = cls.prototype,
  15083. inherited = proto.bufferableMethods,
  15084. def, name;
  15085. if (bufferableMethods) {
  15086. Bufferable._canonicalize(bufferableMethods);
  15087. if (inherited) {
  15088. inherited = Ext.merge(Ext.clone(inherited), bufferableMethods);
  15089. }
  15090. proto.bufferableMethods = inherited || bufferableMethods;
  15091. } else {
  15092. bufferableMethods = inherited;
  15093. Bufferable._canonicalize(bufferableMethods);
  15094. proto.bufferables = null;
  15095. }
  15096. if (bufferableMethods) {
  15097. for (name in bufferableMethods) {
  15098. if (!proto[name]) {
  15099. def = bufferableMethods[name];
  15100. Bufferable.processMethod(proto, def, Array.prototype.slice);
  15101. }
  15102. }
  15103. }
  15104. },
  15105. processMethod: function(proto, def, slice) {
  15106. var name = def.name,
  15107. cap = def.capitalized;
  15108. proto[name] = function() {
  15109. return Bufferable.delayCall(this, def, slice.call(arguments));
  15110. };
  15111. proto['cancel' + cap] = function() {
  15112. return this.cancelBufferedCall(name);
  15113. };
  15114. proto['flush' + cap] = function() {
  15115. return this.flushBufferedCall(name);
  15116. };
  15117. }
  15118. }
  15119. }
  15120. };
  15121. });
  15122. Ext.define('Ext.ComponentManager', {
  15123. alternateClassName: 'Ext.ComponentMgr',
  15124. singleton: true,
  15125. mixins: [
  15126. Ext.mixin.Bufferable
  15127. ],
  15128. count: 0,
  15129. referencesDirty: true,
  15130. referenceRepairs: 0,
  15131. typeName: 'xtype',
  15132. bufferableMethods: {
  15133. handleDocumentMouseDown: 'asap'
  15134. },
  15135. constructor: function(config) {
  15136. var me = this;
  15137. Ext.apply(me, config);
  15138. me.all = {};
  15139. me.byInstanceId = {};
  15140. me.holders = {};
  15141. me.names = {};
  15142. me.references = {};
  15143. me.onAvailableCallbacks = {};
  15144. },
  15145. create: function(config, defaultType) {
  15146. if (typeof config === 'string') {
  15147. return Ext.widget(config);
  15148. }
  15149. if (config.isComponent) {
  15150. return config;
  15151. }
  15152. if ('xclass' in config) {
  15153. return Ext.create(config.xclass, config);
  15154. }
  15155. return Ext.widget(config.xtype || defaultType, config);
  15156. },
  15157. get: function(id) {
  15158. return this.all[id];
  15159. },
  15160. register: function(component) {
  15161. var me = this,
  15162. id = component.getId(),
  15163. onAvailableCallbacks = me.onAvailableCallbacks;
  15164. if (id === undefined) {
  15165. Ext.raise('Component id is undefined. Please ensure the component has an id.');
  15166. }
  15167. if (id in me.all) {
  15168. Ext.raise('Duplicate component id "' + id + '"');
  15169. }
  15170. if (component.$iid in me.byInstanceId) {
  15171. Ext.raise('Duplicate component instance id "' + component.$iid + '"');
  15172. }
  15173. me.all[id] = component;
  15174. me.byInstanceId[component.$iid] = component;
  15175. if (component.reference) {
  15176. me.references[id] = component;
  15177. }
  15178. if (component.name && component.nameable) {
  15179. me.names[id] = component;
  15180. }
  15181. if (component.nameHolder || component.referenceHolder) {
  15182. me.holders[id] = component;
  15183. }
  15184. ++me.count;
  15185. if (!me.hasFocusListener) {
  15186. me.installFocusListener();
  15187. }
  15188. onAvailableCallbacks = onAvailableCallbacks && onAvailableCallbacks[id];
  15189. if (onAvailableCallbacks && onAvailableCallbacks.length) {
  15190. me.notifyAvailable(component);
  15191. }
  15192. },
  15193. unregister: function(component) {
  15194. var me = this,
  15195. all = me.all,
  15196. byInstanceId = me.byInstanceId,
  15197. holders = me.holders,
  15198. references = me.references,
  15199. names = me.names,
  15200. id = component.getId();
  15201. if (id in holders) {
  15202. holders[id] = null;
  15203. delete holders[id];
  15204. }
  15205. if (id in names) {
  15206. names[id] = null;
  15207. delete names[id];
  15208. }
  15209. if (id in references) {
  15210. references[id] = null;
  15211. delete references[id];
  15212. }
  15213. all[id] = null;
  15214. delete all[id];
  15215. id = component.$iid;
  15216. byInstanceId[id] = null;
  15217. delete byInstanceId[id];
  15218. --me.count;
  15219. },
  15220. markReferencesDirty: function() {
  15221. var me = this,
  15222. holders = me.holders,
  15223. key;
  15224. if (!me.referencesDirty) {
  15225. for (key in holders) {
  15226. holders[key].refs = holders[key].nameRefs = null;
  15227. }
  15228. me.referencesDirty = true;
  15229. }
  15230. },
  15231. fixReferences: function() {
  15232. var me = this,
  15233. references = me.references,
  15234. names = me.names,
  15235. key;
  15236. if (me.referencesDirty) {
  15237. ++me.referenceRepairs;
  15238. for (key in references) {
  15239. references[key]._fixReference();
  15240. }
  15241. for (key in names) {
  15242. names[key]._fixName();
  15243. }
  15244. me.referencesDirty = false;
  15245. }
  15246. },
  15247. onAvailable: function(id, fn, scope) {
  15248. var me = this,
  15249. callbacks = me.onAvailableCallbacks,
  15250. all = me.all,
  15251. item;
  15252. if (id in all) {
  15253. item = all[id];
  15254. fn.call(scope || item, item);
  15255. } else if (id) {
  15256. if (!Ext.isArray(callbacks[id])) {
  15257. callbacks[id] = [];
  15258. }
  15259. callbacks[id].push(function(item) {
  15260. fn.call(scope || item, item);
  15261. });
  15262. }
  15263. },
  15264. notifyAvailable: function(item) {
  15265. var callbacks = this.onAvailableCallbacks[item && item.getId()] || [];
  15266. while (callbacks.length) {
  15267. (callbacks.shift())(item);
  15268. }
  15269. },
  15270. each: function(fn, scope) {
  15271. Ext.Object.each(this.all, fn, scope);
  15272. },
  15273. getCount: function() {
  15274. return this.count;
  15275. },
  15276. getAll: function() {
  15277. return Ext.Object.getValues(this.all);
  15278. },
  15279. getActiveComponent: function() {
  15280. return Ext.Component.from(Ext.dom.Element.getActiveElement());
  15281. },
  15282. onGlobalFocus: function(e) {
  15283. var me = this,
  15284. event = e.event,
  15285. toComponent = event.toComponent = e.toComponent = Ext.Component.from(e.toElement),
  15286. fromComponent = event.fromComponent = e.fromComponent = Ext.Component.from(e.fromElement),
  15287. commonAncestor = me.getCommonAncestor(fromComponent, toComponent),
  15288. targetComponent;
  15289. if (toComponent !== fromComponent) {
  15290. if (fromComponent && !fromComponent.destroyed && !fromComponent.isDestructing()) {
  15291. if (fromComponent.handleBlurEvent) {
  15292. fromComponent.handleBlurEvent(e);
  15293. }
  15294. for (targetComponent = fromComponent; targetComponent && targetComponent !== commonAncestor; targetComponent = targetComponent.getRefOwner()) {
  15295. if (!(targetComponent.destroyed || targetComponent.destroying)) {
  15296. e.type = 'focusleave';
  15297. targetComponent.onFocusLeave(event);
  15298. }
  15299. }
  15300. }
  15301. if (toComponent && !toComponent.destroyed && !toComponent.isDestructing()) {
  15302. if (toComponent.handleFocusEvent) {
  15303. toComponent.handleFocusEvent(e);
  15304. }
  15305. for (targetComponent = toComponent; targetComponent && targetComponent !== commonAncestor; targetComponent = targetComponent.getRefOwner()) {
  15306. e.type = 'focusenter';
  15307. targetComponent.onFocusEnter(event);
  15308. }
  15309. }
  15310. }
  15311. for (targetComponent = commonAncestor; targetComponent; targetComponent = targetComponent.getRefOwner()) {
  15312. if (!(targetComponent.destroying || targetComponent.destroyed)) {
  15313. targetComponent.onFocusMove(e);
  15314. }
  15315. }
  15316. },
  15317. getCommonAncestor: function(compA, compB) {
  15318. if (compA === compB) {
  15319. return compA;
  15320. }
  15321. while (compA && !(compA.isAncestor(compB) || compA === compB)) {
  15322. compA = compA.getRefOwner();
  15323. }
  15324. return compA;
  15325. },
  15326. privates: {
  15327. doHandleDocumentMouseDown: function(e) {
  15328. var floatedSelector = Ext.Widget.prototype.floatedSelector,
  15329. targetFloated;
  15330. if (floatedSelector) {
  15331. targetFloated = Ext.Component.from(e.getTarget(floatedSelector, Ext.getBody()));
  15332. if (targetFloated) {
  15333. targetFloated.toFront(true);
  15334. }
  15335. }
  15336. },
  15337. installFocusListener: function() {
  15338. var me = this;
  15339. Ext.on('focus', me.onGlobalFocus, me);
  15340. me.hasFocusListener = true;
  15341. },
  15342. clearAll: function() {
  15343. this.all = {};
  15344. this.names = {};
  15345. this.references = {};
  15346. this.onAvailableCallbacks = {};
  15347. },
  15348. from: function(el, limit, selector) {
  15349. if (el && el.isEvent) {
  15350. el = el.target;
  15351. }
  15352. var target = Ext.getDom(el),
  15353. cache = this.all,
  15354. depth = 0,
  15355. topmost, cmpId, cmp;
  15356. if (typeof limit !== 'number') {
  15357. topmost = Ext.getDom(limit);
  15358. limit = Number.MAX_VALUE;
  15359. }
  15360. while (target && target.nodeType === 1 && depth < limit && target !== topmost) {
  15361. cmpId = target.getAttribute('data-componentid') || target.id;
  15362. if (cmpId) {
  15363. cmp = cache[cmpId];
  15364. if (cmp && (!selector || Ext.ComponentQuery.is(cmp, selector))) {
  15365. return cmp;
  15366. }
  15367. depth++;
  15368. }
  15369. target = target.parentNode;
  15370. }
  15371. return null;
  15372. }
  15373. }
  15374. }, function() {
  15375. var ComponentManager = Ext.ComponentManager;
  15376. ComponentManager.fromElement = ComponentManager.from;
  15377. Ext.getCmp = function(id) {
  15378. return ComponentManager.get(id);
  15379. };
  15380. Ext.iidToCmp = function(iid) {
  15381. return ComponentManager.byInstanceId[iid] || null;
  15382. };
  15383. Ext.doEv = function(node, e) {
  15384. var cmp, method, event;
  15385. cmp = Ext.Component.from(e.target);
  15386. if (cmp && !cmp.destroying && !cmp.destroyed && cmp.getEventHandlers) {
  15387. method = cmp.getEventHandlers()[e.type];
  15388. if (method && cmp[method]) {
  15389. event = new Ext.event.Event(e);
  15390. return cmp[method](event);
  15391. }
  15392. }
  15393. return true;
  15394. };
  15395. });
  15396. Ext.ns('Ext.util').Operators = {
  15397. "=": function(a, v) {
  15398. return a == v;
  15399. },
  15400. "!=": function(a, v) {
  15401. return a != v;
  15402. },
  15403. "^=": function(a, v) {
  15404. return a && a.substr(0, v.length) == v;
  15405. },
  15406. "$=": function(a, v) {
  15407. return a && a.substr(a.length - v.length) == v;
  15408. },
  15409. "*=": function(a, v) {
  15410. return a && a.indexOf(v) !== -1;
  15411. },
  15412. "%=": function(a, v) {
  15413. return (a % v) === 0;
  15414. },
  15415. "|=": function(a, v) {
  15416. return a && (a == v || a.substr(0, v.length + 1) == v + '-');
  15417. },
  15418. "~=": function(a, v) {
  15419. return a && (' ' + a + ' ').indexOf(' ' + v + ' ') != -1;
  15420. }
  15421. };
  15422. Ext.define('Ext.util.LruCache', {
  15423. extend: Ext.util.HashMap,
  15424. config: {
  15425. maxSize: null
  15426. },
  15427. add: function(key, newValue) {
  15428. var me = this,
  15429. entry, last;
  15430. me.removeAtKey(key);
  15431. last = me.last;
  15432. entry = {
  15433. prev: last,
  15434. next: null,
  15435. key: key,
  15436. value: newValue
  15437. };
  15438. if (last) {
  15439. last.next = entry;
  15440. } else {
  15441. me.first = entry;
  15442. }
  15443. me.last = entry;
  15444. me.callParent([
  15445. key,
  15446. entry
  15447. ]);
  15448. me.prune();
  15449. return newValue;
  15450. },
  15451. insertBefore: function(key, newValue, sibling) {
  15452. var me = this,
  15453. existingKey, entry;
  15454. if (sibling = this.map[this.findKey(sibling)]) {
  15455. existingKey = me.findKey(newValue);
  15456. if (existingKey) {
  15457. me.unlinkEntry(entry = me.map[existingKey]);
  15458. } else
  15459. {
  15460. entry = {
  15461. prev: sibling.prev,
  15462. next: sibling,
  15463. key: key,
  15464. value: newValue
  15465. };
  15466. }
  15467. if (sibling.prev) {
  15468. entry.prev.next = entry;
  15469. } else {
  15470. me.first = entry;
  15471. }
  15472. entry.next = sibling;
  15473. sibling.prev = entry;
  15474. me.prune();
  15475. return newValue;
  15476. } else
  15477. {
  15478. return me.add(key, newValue);
  15479. }
  15480. },
  15481. get: function(key) {
  15482. var entry = this.map[key];
  15483. if (entry) {
  15484. if (entry.next) {
  15485. this.moveToEnd(entry);
  15486. }
  15487. return entry.value;
  15488. }
  15489. },
  15490. removeAtKey: function(key) {
  15491. this.unlinkEntry(this.map[key]);
  15492. return this.callParent(arguments);
  15493. },
  15494. clear: function(initial) {
  15495. this.first = this.last = null;
  15496. return this.callParent([
  15497. initial
  15498. ]);
  15499. },
  15500. unlinkEntry: function(entry) {
  15501. if (entry) {
  15502. if (entry.next) {
  15503. entry.next.prev = entry.prev;
  15504. } else {
  15505. this.last = entry.prev;
  15506. }
  15507. if (entry.prev) {
  15508. entry.prev.next = entry.next;
  15509. } else {
  15510. this.first = entry.next;
  15511. }
  15512. entry.prev = entry.next = null;
  15513. }
  15514. },
  15515. moveToEnd: function(entry) {
  15516. this.unlinkEntry(entry);
  15517. if (entry.prev = this.last) {
  15518. this.last.next = entry;
  15519. } else
  15520. {
  15521. this.first = entry;
  15522. }
  15523. this.last = entry;
  15524. },
  15525. getArray: function(isKey) {
  15526. var arr = [],
  15527. entry = this.first;
  15528. while (entry) {
  15529. arr.push(isKey ? entry.key : entry.value);
  15530. entry = entry.next;
  15531. }
  15532. return arr;
  15533. },
  15534. each: function(fn, scope, reverse) {
  15535. var me = this,
  15536. entry = reverse ? me.last : me.first,
  15537. length = me.length;
  15538. scope = scope || me;
  15539. while (entry) {
  15540. if (fn.call(scope, entry.key, entry.value, length) === false) {
  15541. break;
  15542. }
  15543. entry = reverse ? entry.prev : entry.next;
  15544. }
  15545. return me;
  15546. },
  15547. findKey: function(value) {
  15548. var key,
  15549. map = this.map;
  15550. for (key in map) {
  15551. if (map.hasOwnProperty(key) && map[key].value === value) {
  15552. return key;
  15553. }
  15554. }
  15555. return undefined;
  15556. },
  15557. clone: function() {
  15558. var newCache = new this.self(this.initialConfig),
  15559. map = this.map,
  15560. key;
  15561. newCache.suspendEvents();
  15562. for (key in map) {
  15563. if (map.hasOwnProperty(key)) {
  15564. newCache.add(key, map[key].value);
  15565. }
  15566. }
  15567. newCache.resumeEvents();
  15568. return newCache;
  15569. },
  15570. prune: function() {
  15571. var me = this,
  15572. max = me.getMaxSize(),
  15573. purgeCount = max ? (me.length - max) : 0;
  15574. if (purgeCount > 0) {
  15575. for (; me.first && purgeCount; purgeCount--) {
  15576. me.removeAtKey(me.first.key);
  15577. }
  15578. }
  15579. }
  15580. });
  15581. Ext.define('Ext.ComponentQuery', {
  15582. singleton: true
  15583. }, function() {
  15584. var cq = this,
  15585. queryOperators = Ext.util.Operators,
  15586. nthRe = /(\d*)n\+?(\d*)/,
  15587. nthRe2 = /\D/,
  15588. stripLeadingSpaceRe = /^(\s)+/,
  15589. unescapeRe = /\\(.)/g,
  15590. regexCache = new Ext.util.LruCache({
  15591. maxSize: 100
  15592. }),
  15593. filterFnPattern = [
  15594. 'var r = [],',
  15595. 'i = 0,',
  15596. 'it = items,',
  15597. 'l = it.length,',
  15598. 'c;',
  15599. 'for (; i < l; i++) {',
  15600. 'c = it[i];',
  15601. 'if (c.{0}) {',
  15602. 'r.push(c);',
  15603. '}',
  15604. '}',
  15605. 'return r;'
  15606. ].join(''),
  15607. filterItems = function(items, operation) {
  15608. return operation.method.apply(this, [
  15609. items
  15610. ].concat(operation.args));
  15611. },
  15612. getItems = function(items, mode) {
  15613. var result = [],
  15614. i = 0,
  15615. length = items.length,
  15616. candidate,
  15617. deep = mode !== '>';
  15618. for (; i < length; i++) {
  15619. candidate = items[i];
  15620. if (candidate.getRefItems) {
  15621. result = result.concat(candidate.getRefItems(deep));
  15622. }
  15623. }
  15624. return result;
  15625. },
  15626. getAncestors = function(items) {
  15627. var result = [],
  15628. i = 0,
  15629. length = items.length,
  15630. candidate;
  15631. for (; i < length; i++) {
  15632. candidate = items[i];
  15633. while (!!(candidate = candidate.getRefOwner())) {
  15634. result.push(candidate);
  15635. }
  15636. }
  15637. return result;
  15638. },
  15639. filterByXType = function(items, xtype, shallow) {
  15640. if (xtype === '*') {
  15641. return items.slice();
  15642. } else {
  15643. var result = [],
  15644. i = 0,
  15645. length = items.length,
  15646. candidate;
  15647. for (; i < length; i++) {
  15648. candidate = items[i];
  15649. if (!candidate.destroyed && candidate.isXType(xtype, shallow)) {
  15650. result.push(candidate);
  15651. }
  15652. }
  15653. return result;
  15654. }
  15655. },
  15656. filterByAttribute = function(items, property, operator, compareTo) {
  15657. var result = [],
  15658. i = 0,
  15659. length = items.length,
  15660. mustBeOwnProperty, presenceOnly, candidate, propValue, j, propLen, config;
  15661. if (property.charAt(0) === '@') {
  15662. mustBeOwnProperty = true;
  15663. property = property.substr(1);
  15664. }
  15665. if (property.charAt(0) === '?') {
  15666. mustBeOwnProperty = true;
  15667. presenceOnly = true;
  15668. property = property.substr(1);
  15669. }
  15670. for (; i < length; i++) {
  15671. candidate = items[i];
  15672. config = candidate.self && candidate.self.getConfigurator && candidate.self.$config.configs[property];
  15673. if (config) {
  15674. propValue = candidate[config.names.get]();
  15675. } else if (mustBeOwnProperty && !candidate.hasOwnProperty(property)) {
  15676. continue;
  15677. } else {
  15678. propValue = candidate[property];
  15679. }
  15680. if (presenceOnly) {
  15681. result.push(candidate);
  15682. }
  15683. else if (operator === '~=') {
  15684. if (propValue) {
  15685. if (!Ext.isArray(propValue)) {
  15686. propValue = propValue.split(' ');
  15687. }
  15688. for (j = 0 , propLen = propValue.length; j < propLen; j++) {
  15689. if (queryOperators[operator](Ext.coerce(propValue[j], compareTo), compareTo)) {
  15690. result.push(candidate);
  15691. break;
  15692. }
  15693. }
  15694. }
  15695. } else if (operator === '/=') {
  15696. if (propValue != null && compareTo.test(propValue)) {
  15697. result.push(candidate);
  15698. }
  15699. } else if (!compareTo ? !!propValue : queryOperators[operator](Ext.coerce(propValue, compareTo), compareTo)) {
  15700. result.push(candidate);
  15701. }
  15702. }
  15703. return result;
  15704. },
  15705. filterById = function(items, id, idOnly) {
  15706. var result = [],
  15707. i = 0,
  15708. length = items.length,
  15709. candidate, check;
  15710. for (; i < length; i++) {
  15711. candidate = items[i];
  15712. check = idOnly ? candidate.id : candidate.getItemId();
  15713. if (check === id) {
  15714. result.push(candidate);
  15715. }
  15716. }
  15717. return result;
  15718. },
  15719. filterByPseudo = function(items, name, value) {
  15720. return cq.pseudos[name](items, value);
  15721. },
  15722. modeRe = /^(\s?([>\^])\s?|\s|$)/,
  15723. tokenRe = /^(#)?((?:\\\.|[\w\-])+|\*)(?:\((true|false)\))?/,
  15724. matchers = [
  15725. {
  15726. re: /^\.((?:\\\.|[\w\-])+)(?:\((true|false)\))?/,
  15727. method: filterByXType,
  15728. argTransform: function(args) {
  15729. var selector = args[0];
  15730. Ext.log.warn('"' + selector + '" ComponentQuery selector style is deprecated,' + ' use "' + selector.replace(/^\./, '') + '" without the leading dot instead');
  15731. if (args[1] !== undefined) {
  15732. args[1] = args[1].replace(unescapeRe, '$1');
  15733. }
  15734. return args.slice(1);
  15735. }
  15736. },
  15737. {
  15738. re: /^(?:\[((?:[@?$])?[\w\-]*)\s*(?:([\^$*~%!\/]?=)\s*(['"])?((?:\\\]|.)*?)\3)?(?!\\)\])/,
  15739. method: filterByAttribute,
  15740. argTransform: function(args) {
  15741. var selector = args[0],
  15742. property = args[1],
  15743. operator = args[2],
  15744. compareTo = args[4],
  15745. compareRe;
  15746. if (compareTo !== undefined) {
  15747. compareTo = compareTo.replace(unescapeRe, '$1');
  15748. var format = Ext.String.format,
  15749. 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})",
  15750. match;
  15751. if (match = /^(['"]).*?[^'"]$/.exec(compareTo)) {
  15752. Ext.log.warn(format(msg, selector, match[1], 'beginning'));
  15753. } else if (match = /^[^'"].*?(['"])$/.exec(compareTo)) {
  15754. Ext.log.warn(format(msg, selector, match[1], 'end'));
  15755. }
  15756. }
  15757. if (operator === '/=') {
  15758. compareRe = regexCache.get(compareTo);
  15759. if (compareRe) {
  15760. compareTo = compareRe;
  15761. } else {
  15762. compareTo = regexCache.add(compareTo, new RegExp(compareTo));
  15763. }
  15764. }
  15765. return [
  15766. property,
  15767. operator,
  15768. compareTo
  15769. ];
  15770. }
  15771. },
  15772. {
  15773. re: /^#((?:\\\.|[\w\-])+)/,
  15774. method: filterById
  15775. },
  15776. {
  15777. re: /^\:([\w\-]+)(?:\(((?:\{[^\}]+\})|(?:(?!\{)[^\s>\/]*?(?!\})))\))?/,
  15778. method: filterByPseudo,
  15779. argTransform: function(args) {
  15780. if (args[2] !== undefined) {
  15781. args[2] = args[2].replace(unescapeRe, '$1');
  15782. }
  15783. return args.slice(1);
  15784. }
  15785. },
  15786. {
  15787. re: /^(?:\{([^\}]+)\})/,
  15788. method: filterFnPattern
  15789. }
  15790. ];
  15791. cq.Query = Ext.extend(Object, {
  15792. constructor: function(cfg) {
  15793. cfg = cfg || {};
  15794. Ext.apply(this, cfg);
  15795. },
  15796. execute: function(root) {
  15797. var operations = this.operations,
  15798. result = [],
  15799. op, i, len;
  15800. for (i = 0 , len = operations.length; i < len; i++) {
  15801. op = operations[i];
  15802. result = result.concat(this._execute(root, op));
  15803. }
  15804. return result;
  15805. },
  15806. _execute: function(root, operations) {
  15807. var i = 0,
  15808. length = operations.length,
  15809. operation, workingItems;
  15810. if (!root) {
  15811. workingItems = Ext.ComponentManager.getAll();
  15812. }
  15813. else if (Ext.isIterable(root)) {
  15814. workingItems = root;
  15815. }
  15816. else if (root.isMixedCollection) {
  15817. workingItems = root.items;
  15818. }
  15819. for (; i < length; i++) {
  15820. operation = operations[i];
  15821. if (operation.mode === '^') {
  15822. workingItems = getAncestors(workingItems || [
  15823. root
  15824. ]);
  15825. } else if (operation.mode) {
  15826. workingItems = getItems(workingItems || [
  15827. root
  15828. ], operation.mode);
  15829. } else {
  15830. workingItems = filterItems(workingItems || getItems([
  15831. root
  15832. ]), operation);
  15833. }
  15834. if (i === length - 1) {
  15835. return workingItems;
  15836. }
  15837. }
  15838. return [];
  15839. },
  15840. is: function(component, root) {
  15841. var operations = this.operations,
  15842. result = false,
  15843. len = operations.length,
  15844. op, i;
  15845. if (len === 0) {
  15846. return true;
  15847. }
  15848. for (i = 0; i < len; i++) {
  15849. op = operations[i];
  15850. result = this._is(component, root, op);
  15851. if (result) {
  15852. return result;
  15853. }
  15854. }
  15855. return false;
  15856. },
  15857. _is: function(component, root, operations) {
  15858. var len = operations.length,
  15859. active = [
  15860. component
  15861. ],
  15862. operation, i, j, mode, items, item;
  15863. for (i = len - 1; i >= 0; --i) {
  15864. operation = operations[i];
  15865. mode = operation.mode;
  15866. if (mode) {
  15867. if (mode === '^') {
  15868. active = getItems(active, ' ');
  15869. } else if (mode === '>') {
  15870. items = [];
  15871. for (j = 0 , len = active.length; j < len; ++j) {
  15872. item = active[j].getRefOwner();
  15873. if (item) {
  15874. items.push(item);
  15875. }
  15876. }
  15877. active = items;
  15878. } else {
  15879. active = getAncestors(active);
  15880. }
  15881. } else {
  15882. active = filterItems(active, operation);
  15883. }
  15884. if (active.length === 0) {
  15885. return false;
  15886. }
  15887. }
  15888. if (root) {
  15889. if (!mode) {
  15890. active = getAncestors(active);
  15891. }
  15892. if (active.length > 0) {
  15893. active = filterItems(active, {
  15894. method: filterById,
  15895. args: [
  15896. root.id,
  15897. true
  15898. ]
  15899. });
  15900. }
  15901. if (active.length === 0) {
  15902. return false;
  15903. }
  15904. }
  15905. return true;
  15906. },
  15907. getMatches: function(components, operations) {
  15908. var len = operations.length,
  15909. i;
  15910. for (i = 0; i < len; ++i) {
  15911. components = filterItems(components, operations[i]);
  15912. if (components.length === 0) {
  15913. break;
  15914. }
  15915. }
  15916. return components;
  15917. },
  15918. isMultiMatch: function() {
  15919. return this.operations.length > 1;
  15920. }
  15921. });
  15922. Ext.apply(cq, {
  15923. cache: new Ext.util.LruCache({
  15924. maxSize: 100
  15925. }),
  15926. pseudos: {
  15927. not: function(components, selector) {
  15928. var i = 0,
  15929. length = components.length,
  15930. results = [],
  15931. index = -1,
  15932. component;
  15933. for (; i < length; ++i) {
  15934. component = components[i];
  15935. if (!cq.is(component, selector)) {
  15936. results[++index] = component;
  15937. }
  15938. }
  15939. return results;
  15940. },
  15941. first: function(components) {
  15942. var ret = [];
  15943. if (components.length > 0) {
  15944. ret.push(components[0]);
  15945. }
  15946. return ret;
  15947. },
  15948. last: function(components) {
  15949. var len = components.length,
  15950. ret = [];
  15951. if (len > 0) {
  15952. ret.push(components[len - 1]);
  15953. }
  15954. return ret;
  15955. },
  15956. focusable: function(cmps) {
  15957. var len = cmps.length,
  15958. results = [],
  15959. i = 0,
  15960. c;
  15961. for (; i < len; i++) {
  15962. c = cmps[i];
  15963. if (c.isFocusable && c.isFocusable()) {
  15964. results.push(c);
  15965. }
  15966. }
  15967. return results;
  15968. },
  15969. canfocus: function(cmps, value) {
  15970. var len = cmps.length,
  15971. results = [],
  15972. i = 0,
  15973. c;
  15974. for (; i < len; i++) {
  15975. c = cmps[i];
  15976. if (c.canFocus && c.canFocus(false, value)) {
  15977. results.push(c);
  15978. }
  15979. }
  15980. return results;
  15981. },
  15982. "nth-child": function(c, a) {
  15983. var result = [],
  15984. m = nthRe.exec(a === "even" && "2n" || a === "odd" && "2n+1" || !nthRe2.test(a) && "n+" + a || a),
  15985. f = (m[1] || 1) - 0,
  15986. len = m[2] - 0,
  15987. i, n, nodeIndex;
  15988. for (i = 0; n = c[i]; i++) {
  15989. nodeIndex = i + 1;
  15990. if (f === 1) {
  15991. if (len === 0 || nodeIndex === len) {
  15992. result.push(n);
  15993. }
  15994. } else if ((nodeIndex + len) % f === 0) {
  15995. result.push(n);
  15996. }
  15997. }
  15998. return result;
  15999. },
  16000. scrollable: function(cmps) {
  16001. var len = cmps.length,
  16002. results = [],
  16003. i = 0,
  16004. c;
  16005. for (; i < len; i++) {
  16006. c = cmps[i];
  16007. if (c.scrollable || c._scrollable) {
  16008. results.push(c);
  16009. }
  16010. }
  16011. return results;
  16012. },
  16013. visible: function(cmps, deep) {
  16014. deep = deep === 'true';
  16015. var len = cmps.length,
  16016. results = [],
  16017. i = 0,
  16018. c;
  16019. for (; i < len; i++) {
  16020. c = cmps[i];
  16021. if (c.isVisible(deep)) {
  16022. results.push(c);
  16023. }
  16024. }
  16025. return results;
  16026. }
  16027. },
  16028. query: function(selector, root) {
  16029. if (!selector) {
  16030. return Ext.ComponentManager.getAll();
  16031. }
  16032. var results = [],
  16033. noDupResults = [],
  16034. dupMatcher = {},
  16035. query = cq.cache.get(selector),
  16036. resultsLn, cmp, i;
  16037. if (!query) {
  16038. query = cq.cache.add(selector, cq.parse(selector));
  16039. }
  16040. results = query.execute(root);
  16041. if (query.isMultiMatch()) {
  16042. resultsLn = results.length;
  16043. for (i = 0; i < resultsLn; i++) {
  16044. cmp = results[i];
  16045. if (!dupMatcher[cmp.id]) {
  16046. noDupResults.push(cmp);
  16047. dupMatcher[cmp.id] = true;
  16048. }
  16049. }
  16050. results = noDupResults;
  16051. }
  16052. return results;
  16053. },
  16054. visitPreOrder: function(selector, root, fn, scope, extraArgs) {
  16055. cq._visit(true, selector, root, fn, scope, extraArgs);
  16056. },
  16057. visitPostOrder: function(selector, root, fn, scope, extraArgs) {
  16058. cq._visit(false, selector, root, fn, scope, extraArgs);
  16059. },
  16060. _visit: function(preOrder, selector, root, fn, scope, extraArgs) {
  16061. var query = cq.cache.get(selector),
  16062. callArgs = [
  16063. root
  16064. ],
  16065. children,
  16066. len = 0,
  16067. i, rootMatch;
  16068. if (!query) {
  16069. query = cq.cache.add(selector, cq.parse(selector));
  16070. }
  16071. rootMatch = query.is(root);
  16072. if (root.getRefItems) {
  16073. children = root.getRefItems();
  16074. len = children.length;
  16075. }
  16076. if (extraArgs) {
  16077. Ext.Array.push(callArgs, extraArgs);
  16078. }
  16079. if (preOrder) {
  16080. if (rootMatch) {
  16081. if (fn.apply(scope || root, callArgs) === false) {
  16082. return false;
  16083. }
  16084. }
  16085. }
  16086. for (i = 0; i < len; i++) {
  16087. if (cq._visit.call(cq, preOrder, selector, children[i], fn, scope, extraArgs) === false) {
  16088. return false;
  16089. }
  16090. }
  16091. if (!preOrder) {
  16092. if (rootMatch) {
  16093. if (fn.apply(scope || root, callArgs) === false) {
  16094. return false;
  16095. }
  16096. }
  16097. }
  16098. },
  16099. is: function(component, selector, root) {
  16100. if (!selector) {
  16101. return true;
  16102. }
  16103. if (typeof selector === 'function') {
  16104. return selector(component);
  16105. } else {
  16106. var query = cq.cache.get(selector);
  16107. if (!query) {
  16108. query = cq.cache.add(selector, cq.parse(selector));
  16109. }
  16110. return query.is(component, root);
  16111. }
  16112. },
  16113. parse: function(selector) {
  16114. var operations = [],
  16115. selectors, sel, i, len;
  16116. selectors = Ext.splitAndUnescape(selector, ',');
  16117. for (i = 0 , len = selectors.length; i < len; i++) {
  16118. sel = Ext.String.trim(selectors[i]);
  16119. if (sel === '') {
  16120. Ext.raise('Invalid ComponentQuery selector: ""');
  16121. }
  16122. operations.push(cq._parse(sel));
  16123. }
  16124. return new cq.Query({
  16125. operations: operations
  16126. });
  16127. },
  16128. _parse: function(selector) {
  16129. var operations = [],
  16130. trim = Ext.String.trim,
  16131. length = matchers.length,
  16132. lastSelector, tokenMatch, token, matchedChar, modeMatch, selectorMatch, transform, i, matcher, method, args;
  16133. while (selector && lastSelector !== selector) {
  16134. lastSelector = selector;
  16135. tokenMatch = selector.match(tokenRe);
  16136. if (tokenMatch) {
  16137. matchedChar = tokenMatch[1];
  16138. token = trim(tokenMatch[2]).replace(unescapeRe, '$1');
  16139. if (matchedChar === '#') {
  16140. operations.push({
  16141. method: filterById,
  16142. args: [
  16143. token
  16144. ]
  16145. });
  16146. } else
  16147. {
  16148. operations.push({
  16149. method: filterByXType,
  16150. args: [
  16151. token,
  16152. Boolean(tokenMatch[3])
  16153. ]
  16154. });
  16155. }
  16156. selector = selector.replace(tokenMatch[0], '').replace(stripLeadingSpaceRe, '$1');
  16157. }
  16158. while (!(modeMatch = selector.match(modeRe))) {
  16159. for (i = 0; selector && i < length; i++) {
  16160. matcher = matchers[i];
  16161. selectorMatch = selector.match(matcher.re);
  16162. method = matcher.method;
  16163. transform = matcher.argTransform;
  16164. if (selectorMatch) {
  16165. if (transform) {
  16166. args = transform(selectorMatch);
  16167. } else {
  16168. args = selectorMatch.slice(1);
  16169. }
  16170. operations.push({
  16171. method: Ext.isString(matcher.method) ?
  16172. Ext.functionFactory('items', Ext.String.format.apply(Ext.String, [
  16173. method
  16174. ].concat(selectorMatch.slice(1)))) : matcher.method,
  16175. args: args
  16176. });
  16177. selector = selector.replace(selectorMatch[0], '').replace(stripLeadingSpaceRe, '$1');
  16178. break;
  16179. }
  16180. if (i === (length - 1)) {
  16181. Ext.raise('Invalid ComponentQuery selector: "' + arguments[0] + '"');
  16182. }
  16183. }
  16184. }
  16185. if (modeMatch[1]) {
  16186. operations.push({
  16187. mode: modeMatch[2] || modeMatch[1]
  16188. });
  16189. selector = selector.replace(modeMatch[0], '').replace(stripLeadingSpaceRe, '');
  16190. }
  16191. }
  16192. return operations;
  16193. }
  16194. });
  16195. Ext.all = function() {
  16196. return cq.query.apply(cq, arguments);
  16197. };
  16198. Ext.first = function() {
  16199. var matches = cq.query.apply(cq, arguments);
  16200. return (matches && matches[0]) || null;
  16201. };
  16202. });
  16203. Ext.define('Ext.Evented', {
  16204. alternateClassName: 'Ext.EventedBase',
  16205. mixins: [
  16206. Ext.mixin.Observable
  16207. ],
  16208. initialized: false,
  16209. constructor: function(config) {
  16210. this.callParent();
  16211. this.mixins.observable.constructor.call(this, config);
  16212. this.initialized = true;
  16213. },
  16214. onClassExtended: function(cls, data) {
  16215. if (!data.hasOwnProperty('eventedConfig')) {
  16216. return;
  16217. }
  16218. var config = data.config,
  16219. eventedConfig = data.eventedConfig,
  16220. name, cfg;
  16221. if (config) {
  16222. Ext.applyIf(config, eventedConfig);
  16223. } else {
  16224. cls.addConfig(eventedConfig);
  16225. }
  16226. for (name in eventedConfig) {
  16227. if (eventedConfig.hasOwnProperty(name)) {
  16228. cfg = Ext.Config.get(name);
  16229. data[cfg.names.set] = cfg.eventedSetter || cfg.getEventedSetter();
  16230. }
  16231. }
  16232. }
  16233. });
  16234. Ext.define('Ext.util.Positionable', {
  16235. mixinId: 'positionable',
  16236. _positionTopLeft: [
  16237. 'position',
  16238. 'top',
  16239. 'left'
  16240. ],
  16241. clippedCls: Ext.baseCSSPrefix + 'clipped',
  16242. afterSetPosition: Ext.emptyFn,
  16243. getAnchorToXY: function() {
  16244. Ext.raise("getAnchorToXY is not implemented in " + this.$className);
  16245. },
  16246. getBorderPadding: function() {
  16247. Ext.raise("getBorderPadding is not implemented in " + this.$className);
  16248. },
  16249. getLocalX: function() {
  16250. Ext.raise("getLocalX is not implemented in " + this.$className);
  16251. },
  16252. getLocalXY: function() {
  16253. Ext.raise("getLocalXY is not implemented in " + this.$className);
  16254. },
  16255. getLocalY: function() {
  16256. Ext.raise("getLocalY is not implemented in " + this.$className);
  16257. },
  16258. getX: function() {
  16259. Ext.raise("getX is not implemented in " + this.$className);
  16260. },
  16261. getXY: function() {
  16262. Ext.raise("getXY is not implemented in " + this.$className);
  16263. },
  16264. getY: function() {
  16265. Ext.raise("getY is not implemented in " + this.$className);
  16266. },
  16267. setLocalX: function() {
  16268. Ext.raise("setLocalX is not implemented in " + this.$className);
  16269. },
  16270. setLocalXY: function() {
  16271. Ext.raise("setLocalXY is not implemented in " + this.$className);
  16272. },
  16273. setLocalY: function() {
  16274. Ext.raise("setLocalY is not implemented in " + this.$className);
  16275. },
  16276. setX: function() {
  16277. Ext.raise("setX is not implemented in " + this.$className);
  16278. },
  16279. setXY: function() {
  16280. Ext.raise("setXY is not implemented in " + this.$className);
  16281. },
  16282. setY: function() {
  16283. Ext.raise("setY is not implemented in " + this.$className);
  16284. },
  16285. adjustForConstraints: function(xy, parent) {
  16286. var vector = this.getConstrainVector(parent, xy);
  16287. if (vector) {
  16288. xy[0] += vector[0];
  16289. xy[1] += vector[1];
  16290. }
  16291. return xy;
  16292. },
  16293. alignTo: function(element, position, offsets, animate) {
  16294. var me = this,
  16295. el = me.el;
  16296. return me.setXY(me.getAlignToXY(element, position, offsets), el.anim && !!animate ? el.anim(animate) : false);
  16297. },
  16298. calculateAnchorXY: function(anchor, extraX, extraY, size) {
  16299. var region = this.getRegion();
  16300. region.setPosition(0, 0);
  16301. region.translateBy(extraX || 0, extraY || 0);
  16302. if (size) {
  16303. region.setWidth(size.width);
  16304. region.setHeight(size.height);
  16305. }
  16306. return region.getAnchorPoint(anchor);
  16307. },
  16308. convertPositionSpec: function(posSpec) {
  16309. return Ext.util.Region.getAlignInfo(posSpec);
  16310. },
  16311. getAlignToXY: function(alignToEl, position, offsets) {
  16312. var newRegion = this.getAlignToRegion(alignToEl, position, offsets);
  16313. return [
  16314. newRegion.x,
  16315. newRegion.y
  16316. ];
  16317. },
  16318. getAlignToRegion: function(alignToEl, posSpec, offset, minHeight) {
  16319. var me = this,
  16320. inside, newRegion, bodyScroll;
  16321. alignToEl = Ext.fly(alignToEl.el || alignToEl);
  16322. if (!alignToEl || !alignToEl.dom) {
  16323. Ext.raise({
  16324. sourceClass: 'Ext.util.Positionable',
  16325. sourceMethod: 'getAlignToXY',
  16326. msg: 'Attempted to align an element that doesn\'t exist'
  16327. });
  16328. }
  16329. posSpec = me.convertPositionSpec(posSpec);
  16330. if (posSpec.constrain) {
  16331. if (posSpec.constrain === '!') {
  16332. inside = alignToEl;
  16333. } else {
  16334. inside = me.constrainTo || me.container || me.el.parent();
  16335. }
  16336. inside = Ext.fly(inside.el || inside).getConstrainRegion();
  16337. }
  16338. if (alignToEl === Ext.getBody()) {
  16339. bodyScroll = alignToEl.getScroll();
  16340. offset = [
  16341. bodyScroll.left,
  16342. bodyScroll.top
  16343. ];
  16344. }
  16345. newRegion = me.getRegion().alignTo({
  16346. target: alignToEl.getRegion(),
  16347. inside: inside,
  16348. minHeight: minHeight,
  16349. offset: offset,
  16350. align: posSpec,
  16351. axisLock: true
  16352. });
  16353. return newRegion;
  16354. },
  16355. getAnchorXY: function(anchor, local, size) {
  16356. var me = this,
  16357. region = me.getRegion(),
  16358. el = me.el,
  16359. isViewport = el.dom.nodeName === 'BODY' || el.dom.nodeType === 9,
  16360. scroll = el.getScroll();
  16361. if (local) {
  16362. region.setPosition(0, 0);
  16363. } else if (isViewport) {
  16364. region.setPosition(scroll.left, scroll.top);
  16365. }
  16366. if (size) {
  16367. region.setWidth(size.width);
  16368. region.setHeight(size.height);
  16369. }
  16370. return region.getAnchorPoint(anchor);
  16371. },
  16372. getBox: function(contentBox, local) {
  16373. var me = this,
  16374. xy = local ? me.getLocalXY() : me.getXY(),
  16375. x = xy[0],
  16376. y = xy[1],
  16377. w, h, borderPadding, beforeX, beforeY;
  16378. if (me.el.dom.nodeName === 'BODY' || me.el.dom.nodeType === 9) {
  16379. w = Ext.Element.getViewportWidth();
  16380. h = Ext.Element.getViewportHeight();
  16381. } else {
  16382. w = me.getWidth();
  16383. h = me.getHeight();
  16384. }
  16385. if (contentBox) {
  16386. borderPadding = me.getBorderPadding();
  16387. beforeX = borderPadding.beforeX;
  16388. beforeY = borderPadding.beforeY;
  16389. x += beforeX;
  16390. y += beforeY;
  16391. w -= (beforeX + borderPadding.afterX);
  16392. h -= (beforeY + borderPadding.afterY);
  16393. }
  16394. return {
  16395. x: x,
  16396. left: x,
  16397. 0: x,
  16398. y: y,
  16399. top: y,
  16400. 1: y,
  16401. width: w,
  16402. height: h,
  16403. right: x + w,
  16404. bottom: y + h
  16405. };
  16406. },
  16407. calculateConstrainedPosition: function(constrainTo, proposedPosition, local, proposedSize) {
  16408. var me = this,
  16409. vector,
  16410. fp = me.floatParent,
  16411. parentNode = fp ? fp.getTargetEl() : null,
  16412. parentOffset, borderPadding, proposedConstrainPosition,
  16413. xy = false;
  16414. if (local && fp) {
  16415. parentOffset = parentNode.getXY();
  16416. borderPadding = parentNode.getBorderPadding();
  16417. parentOffset[0] += borderPadding.beforeX;
  16418. parentOffset[1] += borderPadding.beforeY;
  16419. if (proposedPosition) {
  16420. proposedConstrainPosition = [
  16421. proposedPosition[0] + parentOffset[0],
  16422. proposedPosition[1] + parentOffset[1]
  16423. ];
  16424. }
  16425. } else {
  16426. proposedConstrainPosition = proposedPosition;
  16427. }
  16428. constrainTo = constrainTo || me.constrainTo || parentNode || me.container || me.el.parent();
  16429. if (local && proposedConstrainPosition) {
  16430. proposedConstrainPosition = me.reverseTranslateXY(proposedConstrainPosition);
  16431. }
  16432. vector = ((me.constrainHeader && me.header.rendered) ? me.header : me).getConstrainVector(constrainTo, proposedConstrainPosition, proposedSize);
  16433. if (vector) {
  16434. xy = proposedPosition || me.getPosition(local);
  16435. xy[0] += vector[0];
  16436. xy[1] += vector[1];
  16437. }
  16438. return xy;
  16439. },
  16440. getConstrainRegion: function() {
  16441. var me = this,
  16442. el = me.el,
  16443. isBody = el.dom.nodeName === 'BODY',
  16444. dom = el.dom,
  16445. borders = el.getBorders(),
  16446. pos = el.getXY(),
  16447. left = pos[0] + borders.beforeX,
  16448. top = pos[1] + borders.beforeY,
  16449. scroll, width, height;
  16450. if (isBody) {
  16451. scroll = el.getScroll();
  16452. left = scroll.left;
  16453. top = scroll.top;
  16454. width = Ext.Element.getViewportWidth();
  16455. height = Ext.Element.getViewportHeight();
  16456. } else {
  16457. width = dom.clientWidth;
  16458. height = dom.clientHeight;
  16459. }
  16460. return new Ext.util.Region(top, left + width, top + height, left);
  16461. },
  16462. getConstrainVector: function(constrainTo, proposedPosition, proposedSize) {
  16463. var me = this,
  16464. thisRegion = me.getRegion(),
  16465. vector = [
  16466. 0,
  16467. 0
  16468. ],
  16469. shadowSize = (me.shadow && me.constrainShadow && !me.shadowDisabled) ? me.el.shadow.getShadowSize() : undefined,
  16470. overflowed = false,
  16471. constraintInsets = me.constraintInsets;
  16472. if (!(constrainTo instanceof Ext.util.Region)) {
  16473. constrainTo = Ext.get(constrainTo.el || constrainTo);
  16474. constrainTo = constrainTo.getConstrainRegion();
  16475. }
  16476. if (constraintInsets) {
  16477. constraintInsets = Ext.isObject(constraintInsets) ? constraintInsets : Ext.Element.parseBox(constraintInsets);
  16478. constrainTo.adjust(constraintInsets.top, constraintInsets.right, constraintInsets.bottom, constraintInsets.left);
  16479. }
  16480. if (proposedPosition) {
  16481. thisRegion.translateBy(proposedPosition[0] - thisRegion.x, proposedPosition[1] - thisRegion.y);
  16482. }
  16483. if (proposedSize) {
  16484. thisRegion.right = thisRegion.left + proposedSize[0];
  16485. thisRegion.bottom = thisRegion.top + proposedSize[1];
  16486. }
  16487. if (shadowSize) {
  16488. constrainTo.adjust(shadowSize[0], -shadowSize[1], -shadowSize[2], shadowSize[3]);
  16489. }
  16490. if (thisRegion.right > constrainTo.right) {
  16491. overflowed = true;
  16492. vector[0] = (constrainTo.right - thisRegion.right);
  16493. }
  16494. if (thisRegion.left + vector[0] < constrainTo.left) {
  16495. overflowed = true;
  16496. vector[0] = (constrainTo.left - thisRegion.left);
  16497. }
  16498. if (thisRegion.bottom > constrainTo.bottom) {
  16499. overflowed = true;
  16500. vector[1] = (constrainTo.bottom - thisRegion.bottom);
  16501. }
  16502. if (thisRegion.top + vector[1] < constrainTo.top) {
  16503. overflowed = true;
  16504. vector[1] = (constrainTo.top - thisRegion.top);
  16505. }
  16506. return overflowed ? vector : false;
  16507. },
  16508. getOffsetsTo: function(offsetsTo) {
  16509. var o = this.getXY(),
  16510. e = offsetsTo.isRegion ? [
  16511. offsetsTo.x,
  16512. offsetsTo.y
  16513. ] : Ext.fly(offsetsTo.el || offsetsTo).getXY();
  16514. return [
  16515. o[0] - e[0],
  16516. o[1] - e[1]
  16517. ];
  16518. },
  16519. getRegion: function(contentBox, local) {
  16520. var box = this.getBox(contentBox, local);
  16521. return new Ext.util.Region(box.top, box.right, box.bottom, box.left);
  16522. },
  16523. getClientRegion: function() {
  16524. var me = this,
  16525. el = me.el,
  16526. dom = el.dom,
  16527. viewContentBox = me.getBox(true),
  16528. scrollbarHeight = dom.offsetHeight > dom.clientHeight,
  16529. scrollbarWidth = dom.offsetWidth > dom.clientWidth,
  16530. padding, scrollSize, isRTL;
  16531. if (scrollbarHeight || scrollbarWidth) {
  16532. scrollSize = Ext.getScrollbarSize();
  16533. if (scrollbarWidth) {
  16534. scrollbarWidth = scrollSize.width;
  16535. isRTL = el.getStyle('direction') === 'rtl' && !Ext.supports.rtlVertScrollbarOnRight;
  16536. if (isRTL) {
  16537. padding = el.getPadding('l');
  16538. viewContentBox.left -= padding + Math.max(padding, scrollbarWidth);
  16539. } else {
  16540. padding = el.getPadding('r');
  16541. viewContentBox.right += padding - Math.max(padding, scrollbarWidth);
  16542. }
  16543. }
  16544. if (scrollbarHeight) {
  16545. scrollbarHeight = scrollSize.height;
  16546. padding = el.getPadding('b');
  16547. viewContentBox.bottom += padding - Math.max(padding, scrollbarHeight);
  16548. }
  16549. }
  16550. return new Ext.util.Region(viewContentBox.top, viewContentBox.right, viewContentBox.bottom, viewContentBox.left);
  16551. },
  16552. getViewRegion: function() {
  16553. var me = this,
  16554. el = me.el,
  16555. isBody = el.dom.nodeName === 'BODY',
  16556. borderPadding, scroll, pos, top, left, width, height;
  16557. if (isBody) {
  16558. scroll = el.getScroll();
  16559. left = scroll.left;
  16560. top = scroll.top;
  16561. width = Ext.Element.getViewportWidth();
  16562. height = Ext.Element.getViewportHeight();
  16563. } else {
  16564. borderPadding = me.getBorderPadding();
  16565. pos = me.getXY();
  16566. left = pos[0] + borderPadding.beforeX;
  16567. top = pos[1] + borderPadding.beforeY;
  16568. width = me.getWidth(true);
  16569. height = me.getHeight(true);
  16570. }
  16571. return new Ext.util.Region(top, left + width, top + height, left);
  16572. },
  16573. move: function(direction, distance, animate) {
  16574. var me = this,
  16575. xy = me.getXY(),
  16576. x = xy[0],
  16577. y = xy[1],
  16578. left = [
  16579. x - distance,
  16580. y
  16581. ],
  16582. right = [
  16583. x + distance,
  16584. y
  16585. ],
  16586. top = [
  16587. x,
  16588. y - distance
  16589. ],
  16590. bottom = [
  16591. x,
  16592. y + distance
  16593. ],
  16594. hash = {
  16595. l: left,
  16596. left: left,
  16597. r: right,
  16598. right: right,
  16599. t: top,
  16600. top: top,
  16601. up: top,
  16602. b: bottom,
  16603. bottom: bottom,
  16604. down: bottom
  16605. };
  16606. direction = direction.toLowerCase();
  16607. me.setXY([
  16608. hash[direction][0],
  16609. hash[direction][1]
  16610. ], animate);
  16611. },
  16612. setBox: function(box) {
  16613. var me = this,
  16614. x, y;
  16615. if (box.isRegion) {
  16616. box = {
  16617. x: box.left,
  16618. y: box.top,
  16619. width: box.right - box.left,
  16620. height: box.bottom - box.top
  16621. };
  16622. }
  16623. me.constrainBox(box);
  16624. x = box.x;
  16625. y = box.y;
  16626. me.setXY([
  16627. x,
  16628. y
  16629. ]);
  16630. me.setSize(box.width, box.height);
  16631. me.afterSetPosition(x, y);
  16632. return me;
  16633. },
  16634. constrainBox: function(box) {
  16635. var me = this,
  16636. constrainedPos, x, y;
  16637. if (me.constrain || me.constrainHeader) {
  16638. x = ('x' in box) ? box.x : box.left;
  16639. y = ('y' in box) ? box.y : box.top;
  16640. constrainedPos = me.calculateConstrainedPosition(null, [
  16641. x,
  16642. y
  16643. ], false, [
  16644. box.width,
  16645. box.height
  16646. ]);
  16647. if (constrainedPos) {
  16648. box.x = constrainedPos[0];
  16649. box.y = constrainedPos[1];
  16650. }
  16651. }
  16652. },
  16653. translatePoints: function(x, y) {
  16654. var pos = this.translateXY(x, y);
  16655. return {
  16656. left: pos.x,
  16657. top: pos.y
  16658. };
  16659. },
  16660. translateXY: function(x, y) {
  16661. var me = this,
  16662. el = me.el,
  16663. styles = el.getStyle(me._positionTopLeft),
  16664. relative = styles.position === 'relative',
  16665. left = parseFloat(styles.left),
  16666. top = parseFloat(styles.top),
  16667. xy = me.getXY();
  16668. if (Ext.isArray(x)) {
  16669. y = x[1];
  16670. x = x[0];
  16671. }
  16672. if (isNaN(left)) {
  16673. left = relative ? 0 : el.dom.offsetLeft;
  16674. }
  16675. if (isNaN(top)) {
  16676. top = relative ? 0 : el.dom.offsetTop;
  16677. }
  16678. left = (typeof x === 'number') ? x - xy[0] + left : undefined;
  16679. top = (typeof y === 'number') ? y - xy[1] + top : undefined;
  16680. return {
  16681. x: left,
  16682. y: top
  16683. };
  16684. },
  16685. reverseTranslateXY: function(xy) {
  16686. var coords = xy,
  16687. el = this.el,
  16688. dom = el.dom,
  16689. offsetParent = dom.offsetParent,
  16690. relative, offsetParentXY, x, y;
  16691. if (offsetParent) {
  16692. relative = el.isStyle('position', 'relative') , offsetParentXY = Ext.fly(offsetParent).getXY() , x = xy[0] + offsetParentXY[0] + offsetParent.clientLeft;
  16693. y = xy[1] + offsetParentXY[1] + offsetParent.clientTop;
  16694. if (relative) {
  16695. x += el.getPadding('l');
  16696. y += el.getPadding('t');
  16697. }
  16698. coords = [
  16699. x,
  16700. y
  16701. ];
  16702. }
  16703. return coords;
  16704. },
  16705. privates: {
  16706. clipTo: function(clippingEl, sides) {
  16707. var clippingRegion,
  16708. el = this.el,
  16709. floaterRegion = el.getRegion(),
  16710. overflow, i,
  16711. clipValues = [],
  16712. clippedCls = this.clippedCls,
  16713. clipStyle, clipped, shadow;
  16714. if (clippingEl.isRegion) {
  16715. clippingRegion = clippingEl;
  16716. } else {
  16717. clippingRegion = (clippingEl.isComponent ? clippingEl.el : Ext.fly(clippingEl)).getConstrainRegion();
  16718. }
  16719. if (!sides) {
  16720. sides = 15;
  16721. }
  16722. if (sides & 1 && (overflow = clippingRegion.top - floaterRegion.top) > 0) {
  16723. clipValues[0] = overflow;
  16724. clipped = true;
  16725. } else {
  16726. clipValues[0] = -10000;
  16727. }
  16728. if (sides & 2 && (overflow = floaterRegion.right - clippingRegion.right) > 0) {
  16729. clipValues[1] = Math.max(0, el.getWidth() - overflow);
  16730. clipped = true;
  16731. } else {
  16732. clipValues[1] = 10000;
  16733. }
  16734. if (sides & 4 && (overflow = floaterRegion.bottom - clippingRegion.bottom) > 0) {
  16735. clipValues[2] = Math.max(0, el.getHeight() - overflow);
  16736. clipped = true;
  16737. } else {
  16738. clipValues[2] = 10000;
  16739. }
  16740. if (sides & 8 && (overflow = clippingRegion.left - floaterRegion.left) > 0) {
  16741. clipValues[3] = overflow;
  16742. clipped = true;
  16743. } else {
  16744. clipValues[3] = -10000;
  16745. }
  16746. clipStyle = 'rect(';
  16747. for (i = 0; i < 4; ++i) {
  16748. clipStyle += Ext.Element.addUnits(clipValues[i], 'px');
  16749. clipStyle += (i === 3) ? ')' : ',';
  16750. }
  16751. el.dom.style.clip = clipStyle;
  16752. el.addCls(clippedCls);
  16753. if ((shadow = el.shadow) && (el = shadow.el) && el.dom) {
  16754. clipValues[2] -= shadow.offsets.y;
  16755. clipValues[3] -= shadow.offsets.x;
  16756. clipStyle = 'rect(';
  16757. for (i = 0; i < 4; ++i) {
  16758. clipStyle += Ext.Element.addUnits(clipValues[i], 'px');
  16759. clipStyle += (i === 3) ? ')' : ',';
  16760. }
  16761. el.dom.style.clip = clipStyle;
  16762. if (clipped && !Ext.supports.CSS3BoxShadow) {
  16763. el.dom.style.display = 'none';
  16764. } else {
  16765. el.dom.style.display = '';
  16766. el.addCls(clippedCls);
  16767. }
  16768. }
  16769. },
  16770. clearClip: function() {
  16771. var el = this.el,
  16772. clippedCls = this.clippedCls;
  16773. el.dom.style.clip = Ext.isIE8 ? 'auto' : '';
  16774. el.removeCls(clippedCls);
  16775. if (el.shadow && el.shadow.el && el.shadow.el.dom) {
  16776. el.shadow.el.dom.style.clip = Ext.isIE8 ? 'auto' : '';
  16777. if (!Ext.supports.CSS3BoxShadow) {
  16778. el.dom.style.display = '';
  16779. el.removeCls(clippedCls);
  16780. }
  16781. }
  16782. }
  16783. }
  16784. });
  16785. Ext.define('Ext.dom.UnderlayPool', {
  16786. constructor: function(elementConfig) {
  16787. this.elementConfig = elementConfig;
  16788. this.cache = [];
  16789. },
  16790. checkOut: function() {
  16791. var el = this.cache.shift();
  16792. if (!el) {
  16793. el = Ext.Element.create(this.elementConfig);
  16794. el.setVisibilityMode(2);
  16795. el.dom.setAttribute('data-sticky', true);
  16796. }
  16797. return el;
  16798. },
  16799. checkIn: function(el) {
  16800. this.cache.push(el);
  16801. Ext.getDetachedBody().dom.appendChild(el.dom);
  16802. },
  16803. reset: function() {
  16804. var cache = this.cache,
  16805. i = cache.length;
  16806. while (i--) {
  16807. cache[i].destroy();
  16808. }
  16809. this.cache = [];
  16810. }
  16811. });
  16812. Ext.define('Ext.dom.Underlay', {
  16813. constructor: function(config) {
  16814. Ext.apply(this, config);
  16815. },
  16816. beforeShow: Ext.emptyFn,
  16817. getInsertionTarget: function() {
  16818. return this.target;
  16819. },
  16820. getPool: function() {
  16821. return this.pool || (this.self.prototype.pool = new Ext.dom.UnderlayPool(this.elementConfig));
  16822. },
  16823. hide: function() {
  16824. var me = this,
  16825. el = me.el;
  16826. if (el) {
  16827. if (el.dom) {
  16828. el.hide();
  16829. me.getPool().checkIn(el);
  16830. }
  16831. me.el = null;
  16832. }
  16833. me.hidden = true;
  16834. },
  16835. realign: function(x, y, width, height) {
  16836. var me = this,
  16837. el = me.el,
  16838. target = me.target,
  16839. offsets = me.offsets,
  16840. max = Math.max;
  16841. if (el) {
  16842. if (x == null) {
  16843. x = target.getX();
  16844. }
  16845. if (y == null) {
  16846. y = target.getY();
  16847. }
  16848. if (width == null) {
  16849. width = target.getWidth();
  16850. }
  16851. if (height == null) {
  16852. height = target.getHeight();
  16853. }
  16854. if (offsets) {
  16855. x = x + offsets.x;
  16856. y = y + offsets.y;
  16857. width = max(width + offsets.w, 0);
  16858. height = max(height + offsets.h, 0);
  16859. }
  16860. el.setXY([
  16861. x,
  16862. y
  16863. ]);
  16864. el.setSize(width, height);
  16865. }
  16866. },
  16867. setZIndex: function(zIndex) {
  16868. this.zIndex = zIndex;
  16869. if (this.el) {
  16870. this.el.setStyle("z-index", zIndex);
  16871. }
  16872. },
  16873. show: function() {
  16874. var me = this,
  16875. target = me.target,
  16876. zIndex = me.zIndex,
  16877. el = me.el,
  16878. insertionTarget = me.getInsertionTarget().dom,
  16879. dom;
  16880. if (!el) {
  16881. el = me.el = me.getPool().checkOut();
  16882. }
  16883. me.beforeShow();
  16884. if (zIndex == null) {
  16885. zIndex = (parseInt(target.getStyle("z-index"), 10));
  16886. }
  16887. if (zIndex) {
  16888. el.setStyle("z-index", zIndex);
  16889. }
  16890. el.setStyle('position', me.fixed ? 'fixed' : '');
  16891. dom = el.dom;
  16892. if (dom.nextSibling !== insertionTarget) {
  16893. target.dom.parentNode.insertBefore(dom, insertionTarget);
  16894. }
  16895. el.show();
  16896. me.realign();
  16897. me.hidden = false;
  16898. }
  16899. });
  16900. Ext.define('Ext.dom.Shadow', {
  16901. extend: Ext.dom.Underlay,
  16902. alternateClassName: 'Ext.Shadow',
  16903. mode: 'drop',
  16904. offset: 4,
  16905. cls: Ext.baseCSSPrefix + (!Ext.supports.CSS3BoxShadow ? 'ie' : 'css') + '-shadow',
  16906. constructor: function(config) {
  16907. var me = this,
  16908. outerOffsets, offsets, offset, rad;
  16909. me.callParent([
  16910. config
  16911. ]);
  16912. me.elementConfig = {
  16913. cls: me.cls,
  16914. role: 'presentation'
  16915. };
  16916. offset = me.offset;
  16917. rad = Math.floor(offset / 2);
  16918. me.opacity = 50;
  16919. switch (me.mode.toLowerCase()) {
  16920. case "drop":
  16921. outerOffsets = {
  16922. x: 0,
  16923. y: 0,
  16924. w: offset,
  16925. h: offset
  16926. };
  16927. if (Ext.supports.CSS3BoxShadow) {
  16928. offsets = {
  16929. x: offset,
  16930. y: offset,
  16931. h: -offset,
  16932. w: -offset
  16933. };
  16934. } else {
  16935. offsets = {
  16936. x: -rad,
  16937. y: -rad,
  16938. h: -rad,
  16939. w: -rad
  16940. };
  16941. };
  16942. break;
  16943. case "sides":
  16944. outerOffsets = {
  16945. x: -offset,
  16946. y: 0,
  16947. w: offset * 2,
  16948. h: offset
  16949. };
  16950. if (Ext.supports.CSS3BoxShadow) {
  16951. offsets = {
  16952. x: 0,
  16953. y: offset,
  16954. h: -offset,
  16955. w: 0
  16956. };
  16957. } else {
  16958. offsets = {
  16959. x: 1 + rad - 2 * offset,
  16960. y: -(1 + rad),
  16961. h: -1,
  16962. w: rad - 1
  16963. };
  16964. };
  16965. break;
  16966. case "frame":
  16967. outerOffsets = {
  16968. x: -offset,
  16969. y: -offset,
  16970. w: offset * 2,
  16971. h: offset * 2
  16972. };
  16973. if (Ext.supports.CSS3BoxShadow) {
  16974. offsets = {
  16975. x: 0,
  16976. y: 0,
  16977. h: 0,
  16978. w: 0
  16979. };
  16980. } else {
  16981. offsets = {
  16982. x: 1 + rad - 2 * offset,
  16983. y: 1 + rad - 2 * offset,
  16984. h: offset - rad - 1,
  16985. w: offset - rad - 1
  16986. };
  16987. };
  16988. break;
  16989. case "bottom":
  16990. outerOffsets = {
  16991. x: -offset,
  16992. y: 0,
  16993. w: offset * 2,
  16994. h: offset
  16995. };
  16996. if (Ext.supports.CSS3BoxShadow) {
  16997. offsets = {
  16998. x: 0,
  16999. y: offset,
  17000. h: -offset,
  17001. w: 0
  17002. };
  17003. } else {
  17004. offsets = {
  17005. x: 0,
  17006. y: offset,
  17007. h: 0,
  17008. w: 0
  17009. };
  17010. };
  17011. break;
  17012. }
  17013. me.offsets = offsets;
  17014. me.outerOffsets = outerOffsets;
  17015. },
  17016. getShadowSize: function() {
  17017. var me = this,
  17018. offset = me.el ? me.offset : 0,
  17019. result = [
  17020. offset,
  17021. offset,
  17022. offset,
  17023. offset
  17024. ],
  17025. mode = me.mode.toLowerCase();
  17026. if (me.el && mode !== 'frame') {
  17027. result[0] = 0;
  17028. if (mode == 'drop') {
  17029. result[3] = 0;
  17030. }
  17031. }
  17032. return result;
  17033. },
  17034. boxShadowProperty: (function() {
  17035. var property = 'boxShadow',
  17036. style = document.documentElement.style;
  17037. if (!('boxShadow' in style)) {
  17038. if ('WebkitBoxShadow' in style) {
  17039. property = 'WebkitBoxShadow';
  17040. } else if ('MozBoxShadow' in style) {
  17041. property = 'MozBoxShadow';
  17042. }
  17043. }
  17044. return property;
  17045. }()),
  17046. beforeShow: function() {
  17047. var me = this,
  17048. style = me.el.dom.style,
  17049. shim = me.shim;
  17050. if (Ext.supports.CSS3BoxShadow) {
  17051. style[me.boxShadowProperty] = '0 0 ' + (me.offset + 2) + 'px #888';
  17052. } else {
  17053. style.filter = "progid:DXImageTransform.Microsoft.alpha(opacity=" + me.opacity + ") progid:DXImageTransform.Microsoft.Blur(pixelradius=" + (me.offset) + ")";
  17054. }
  17055. if (shim) {
  17056. shim.realign();
  17057. }
  17058. },
  17059. setOpacity: function(opacity) {
  17060. var el = this.el;
  17061. if (el) {
  17062. if (Ext.isIE && !Ext.supports.CSS3BoxShadow) {
  17063. opacity = Math.floor(opacity * 100 / 2) / 100;
  17064. }
  17065. this.opacity = opacity;
  17066. el.setOpacity(opacity);
  17067. }
  17068. }
  17069. });
  17070. Ext.define('Ext.dom.Shim', {
  17071. extend: Ext.dom.Underlay,
  17072. cls: Ext.baseCSSPrefix + 'shim',
  17073. constructor: function(config) {
  17074. this.callParent([
  17075. config
  17076. ]);
  17077. this.elementConfig = {
  17078. tag: 'iframe',
  17079. cls: this.cls,
  17080. role: 'presentation',
  17081. frameBorder: '0',
  17082. src: Ext.SSL_SECURE_URL,
  17083. tabindex: '-1'
  17084. };
  17085. },
  17086. getInsertionTarget: function() {
  17087. var shadow = this.shadow;
  17088. return (shadow && shadow.el) || this.target;
  17089. }
  17090. });
  17091. Ext.define('Ext.dom.ElementEvent', {
  17092. extend: Ext.util.Event,
  17093. addListener: function(fn, scope, options, caller, manager) {
  17094. var me = this,
  17095. added = false,
  17096. name = me.name,
  17097. isDirectEvent = Ext.event.publisher.Dom.instance.directEvents[name],
  17098. captures, directs, directCaptures;
  17099. options = options || {};
  17100. if (options.delegated === false || isDirectEvent) {
  17101. if (isDirectEvent && options.delegate) {
  17102. options.capture = true;
  17103. }
  17104. if (options.capture) {
  17105. directCaptures = me.directCaptures || (me.directCaptures = new Ext.util.Event(me.observable, name));
  17106. added = directCaptures.addListener(fn, scope, options, caller, manager);
  17107. } else {
  17108. directs = me.directs || (me.directs = new Ext.util.Event(me.observable, name));
  17109. added = directs.addListener(fn, scope, options, caller, manager);
  17110. }
  17111. } else if (options.capture) {
  17112. captures = me.captures || (me.captures = new Ext.util.Event(me.observable, name));
  17113. added = captures.addListener(fn, scope, options, caller, manager);
  17114. } else {
  17115. added = me.callParent([
  17116. fn,
  17117. scope,
  17118. options,
  17119. caller,
  17120. manager
  17121. ]);
  17122. }
  17123. return added;
  17124. },
  17125. removeListener: function(fn, scope) {
  17126. var me = this,
  17127. captures = me.captures,
  17128. directs = me.directs,
  17129. directCaptures = me.directCaptures,
  17130. removed = false,
  17131. index = me.findListener(fn, scope);
  17132. if (index !== -1) {
  17133. removed = me.callParent([
  17134. fn,
  17135. scope,
  17136. index
  17137. ]);
  17138. } else {
  17139. if (directs) {
  17140. index = directs.findListener(fn, scope);
  17141. }
  17142. if (index !== -1) {
  17143. removed = directs.removeListener(fn, scope, index);
  17144. } else {
  17145. if (captures) {
  17146. index = captures.findListener(fn, scope);
  17147. }
  17148. if (index !== -1) {
  17149. removed = captures.removeListener(fn, scope, index);
  17150. } else if (directCaptures) {
  17151. index = directCaptures.findListener(fn, scope);
  17152. if (index !== -1) {
  17153. removed = directCaptures.removeListener(fn, scope, index);
  17154. }
  17155. }
  17156. }
  17157. }
  17158. return removed;
  17159. },
  17160. clearListeners: function() {
  17161. var me = this,
  17162. directCaptures = me.directCaptures,
  17163. directs = me.directs,
  17164. captures = me.captures;
  17165. if (directCaptures) {
  17166. directCaptures.clearListeners();
  17167. }
  17168. if (directs) {
  17169. directs.clearListeners();
  17170. }
  17171. if (captures) {
  17172. captures.clearListeners();
  17173. }
  17174. me.callParent();
  17175. },
  17176. suspend: function() {
  17177. var me = this,
  17178. directCaptures = me.directCaptures,
  17179. directs = me.directs,
  17180. captures = me.captures;
  17181. if (directCaptures) {
  17182. directCaptures.suspend();
  17183. }
  17184. if (directs) {
  17185. directs.suspend();
  17186. }
  17187. if (captures) {
  17188. captures.suspend();
  17189. }
  17190. me.callParent();
  17191. },
  17192. resume: function() {
  17193. var me = this,
  17194. directCaptures = me.directCaptures,
  17195. directs = me.directs,
  17196. captures = me.captures;
  17197. if (directCaptures) {
  17198. directCaptures.resume();
  17199. }
  17200. if (directs) {
  17201. directs.resume();
  17202. }
  17203. if (captures) {
  17204. captures.resume();
  17205. }
  17206. me.callParent();
  17207. }
  17208. });
  17209. Ext.define('Ext.event.publisher.Publisher', {
  17210. isEventPublisher: true,
  17211. $vetoClearingPrototypeOnDestroy: true,
  17212. handledEvents: [],
  17213. statics: {
  17214. publishers: {},
  17215. publishersByEvent: {}
  17216. },
  17217. constructor: function() {
  17218. var me = this,
  17219. type = me.type;
  17220. me.handles = {};
  17221. if (!type) {
  17222. Ext.raise("Event publisher '" + me.$className + "' defined without a 'type' property.");
  17223. }
  17224. if (me.self.instance) {
  17225. Ext.raise("Cannot create multiple instances of '" + me.$className + "'. " + "Use '" + me.$className + ".instance' to retrieve the singleton instance.");
  17226. }
  17227. me.registerEvents();
  17228. Ext.event.publisher.Publisher.publishers[type] = me;
  17229. },
  17230. registerEvents: function(events) {
  17231. var me = this,
  17232. publishersByEvent = Ext.event.publisher.Publisher.publishersByEvent,
  17233. handledEvents = events || me.handledEvents,
  17234. ln = handledEvents.length,
  17235. eventName, i;
  17236. for (i = 0; i < ln; i++) {
  17237. eventName = handledEvents[i];
  17238. me.handles[eventName] = 1;
  17239. publishersByEvent[eventName] = me;
  17240. }
  17241. },
  17242. subscribe: function() {
  17243. Ext.raise("Ext.event.publisher.Publisher subclass '" + this.$className + '" has no subscribe method.');
  17244. },
  17245. unsubscribe: function() {
  17246. Ext.raise("Ext.event.publisher.Publisher subclass '" + this.$className + '" has no unsubscribe method.');
  17247. },
  17248. fire: function(element, eventName, args) {
  17249. var event;
  17250. if (element.hasListeners[eventName]) {
  17251. event = element.events[eventName];
  17252. if (event) {
  17253. event.fire.apply(event, args);
  17254. }
  17255. }
  17256. }
  17257. });
  17258. Ext.define('Ext.util.Offset', {
  17259. statics: {
  17260. fromObject: function(obj) {
  17261. if (obj instanceof this) {
  17262. return obj;
  17263. }
  17264. if (typeof obj === 'number') {
  17265. return new this(obj, obj);
  17266. }
  17267. if (obj.length) {
  17268. return new this(obj[0], obj[1]);
  17269. }
  17270. return new this(obj.x, obj.y);
  17271. }
  17272. },
  17273. constructor: function(x, y) {
  17274. this.x = (x != null && !isNaN(x)) ? x : 0;
  17275. this.y = (y != null && !isNaN(y)) ? y : 0;
  17276. return this;
  17277. },
  17278. copy: function() {
  17279. return new Ext.util.Offset(this.x, this.y);
  17280. },
  17281. copyFrom: function(p) {
  17282. this.x = p.x;
  17283. this.y = p.y;
  17284. },
  17285. toString: function() {
  17286. return "Offset[" + this.x + "," + this.y + "]";
  17287. },
  17288. equals: function(offset) {
  17289. if (!(offset instanceof this.statics())) {
  17290. Ext.raise('Offset must be an instance of Ext.util.Offset');
  17291. }
  17292. return (this.x === offset.x && this.y === offset.y);
  17293. },
  17294. add: function(offset) {
  17295. if (!(offset instanceof this.statics())) {
  17296. Ext.raise('Offset must be an instance of Ext.util.Offset');
  17297. }
  17298. this.x += offset.x;
  17299. this.y += offset.y;
  17300. },
  17301. round: function(to) {
  17302. if (!isNaN(to)) {
  17303. var factor = Math.pow(10, to);
  17304. this.x = Math.round(this.x * factor) / factor;
  17305. this.y = Math.round(this.y * factor) / factor;
  17306. } else {
  17307. this.x = Math.round(this.x);
  17308. this.y = Math.round(this.y);
  17309. }
  17310. },
  17311. isZero: function() {
  17312. return this.x === 0 && this.y === 0;
  17313. }
  17314. });
  17315. Ext.define('Ext.util.Region', function() {
  17316. var ExtUtil = Ext.util,
  17317. constrainRe = /([^\?!]*)(!|\?)?$/,
  17318. 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,
  17319. LTROffsetFactors = {
  17320. l: 0,
  17321. r: 100,
  17322. t: 0,
  17323. b: 100,
  17324. c: 50
  17325. },
  17326. RTLOffsetFactors = {
  17327. l: 100,
  17328. r: 0,
  17329. t: 0,
  17330. b: 100,
  17331. c: 50
  17332. },
  17333. relativePositions = {
  17334. b: 0,
  17335. l: 1,
  17336. t: 2,
  17337. r: 3
  17338. },
  17339. alignMap = {
  17340. "tl-tr": "l0-r0",
  17341. "tl-r": "l0-r50",
  17342. "bl-r": "l100-r50",
  17343. "bl-br": "l100-r100",
  17344. "tr-tl": "r0-l0",
  17345. "tr-l": "r0-l50",
  17346. "br-l": "r100-l50",
  17347. "br-bl": "r100-l100"
  17348. },
  17349. rtlAlignMap = {
  17350. "tl-tr": "r0-l0",
  17351. "tl-r": "r0-l50",
  17352. "bl-r": "r100-l50",
  17353. "bl-br": "r100-l100",
  17354. "tr-tl": "l0-r0",
  17355. "tr-l": "l0-r50",
  17356. "br-l": "l100-r50",
  17357. "br-bl": "l100-r100"
  17358. },
  17359. adjustParams = [],
  17360. zeroOffset = new ExtUtil.Offset(0, 0),
  17361. parseRegion = function(box) {
  17362. var Region = ExtUtil.Region,
  17363. type = typeof box,
  17364. top, right, bottom, left;
  17365. if (box == null) {
  17366. return Region.EMPTY;
  17367. }
  17368. if (box.isRegion) {
  17369. return box;
  17370. }
  17371. if (box.isElement || box.nodeType === 1) {
  17372. return this.getRegion(box);
  17373. }
  17374. if (type === 'string') {
  17375. box = box.split(' ');
  17376. switch (box.length) {
  17377. case 1:
  17378. box[1] = box[2] = box[3] = box[0];
  17379. break;
  17380. case 2:
  17381. box[2] = box[0];
  17382. box[3] = box[1];
  17383. break;
  17384. case 3:
  17385. box[3] = box[1];
  17386. }
  17387. top = parseInt(box[0], 10) || 0;
  17388. right = parseInt(box[1], 10) || 0;
  17389. bottom = parseInt(box[2], 10) || 0;
  17390. left = parseInt(box[3], 10) || 0;
  17391. } else if (type === 'number') {
  17392. top = right = bottom = left = box;
  17393. } else if (typeof box.x === 'number') {
  17394. top = box.y;
  17395. left = box.x;
  17396. if (typeof box.right === 'number') {
  17397. right = box.right;
  17398. bottom = box.bottom;
  17399. } else {
  17400. right = left + box.width;
  17401. bottom = top + box.height;
  17402. }
  17403. } else
  17404. {
  17405. Ext.raise('Not convertible to a Region: ' + box);
  17406. }
  17407. return new Region(top, right, bottom, left);
  17408. },
  17409. magnitude = [
  17410. -1,
  17411. 1,
  17412. 1,
  17413. -1
  17414. ],
  17415. addAnchorOffset = function(target, anchorSize, relativePosition) {
  17416. if (relativePosition != null && anchorSize) {
  17417. adjustParams[0] = adjustParams[1] = adjustParams[2] = adjustParams[3] = 0;
  17418. adjustParams[relativePosition] = anchorSize.y * magnitude[relativePosition];
  17419. target = ExtUtil.Region.from(target);
  17420. target.adjust.apply(target, adjustParams);
  17421. }
  17422. return target;
  17423. },
  17424. calculateAnchorPosition = function(target, result, relativePosition, anchorSize, inside) {
  17425. var anchorWidth = Math.ceil(anchorSize.x),
  17426. minOverlap = Math.ceil(anchorWidth / 2) + 3,
  17427. min, max, anchorPos, isBefore, overlapLine, x, y;
  17428. if (inside && !inside.intersect(target)) {
  17429. return;
  17430. }
  17431. if (relativePosition != null) {
  17432. if (relativePosition & 1) {
  17433. if (result.getHeight() < anchorWidth + 4) {
  17434. return;
  17435. }
  17436. min = target.top + minOverlap - result.height;
  17437. max = target.bottom - minOverlap - 1;
  17438. result.setPosition(result.x, Math.min(Math.max(result.y, min), max));
  17439. min = result.top + 2;
  17440. max = result.bottom - (anchorWidth + 2);
  17441. isBefore = relativePosition === 3;
  17442. x = isBefore ? result.right : result.left;
  17443. overlapLine = new ExtUtil.Region(Math.max(result.top, target.top), x, Math.min(result.bottom, target.bottom), x);
  17444. anchorPos = new ExtUtil.Region(0, 0, 0, 0).setWidth(anchorSize.y).setHeight(anchorWidth).alignTo({
  17445. target: overlapLine,
  17446. align: isBefore ? 'l-r' : 'r-l',
  17447. overlap: true
  17448. });
  17449. anchorPos.setPosition(anchorPos.x, Math.min(Math.max(anchorPos.y, min), max));
  17450. anchorPos.position = isBefore ? 'right' : 'left';
  17451. } else
  17452. {
  17453. if (result.getWidth() < anchorWidth + 4) {
  17454. return;
  17455. }
  17456. min = target.left + minOverlap - result.width;
  17457. max = target.right - minOverlap - 1;
  17458. result.setPosition(Math.min(Math.max(result.x, min), max), result.y);
  17459. min = result.left + 2;
  17460. max = result.right - (anchorWidth + 2);
  17461. isBefore = relativePosition === 0;
  17462. y = isBefore ? result.bottom : result.top;
  17463. overlapLine = new ExtUtil.Region(y, Math.min(result.right, target.right), y, Math.max(result.left, target.left));
  17464. anchorPos = new ExtUtil.Region(0, 0, 0, 0).setWidth(anchorWidth).setHeight(anchorSize.y).alignTo({
  17465. target: overlapLine,
  17466. align: isBefore ? 't-b' : 'b-t',
  17467. overlap: true
  17468. });
  17469. anchorPos.setPosition(Math.min(Math.max(anchorPos.x, min), max), anchorPos.y);
  17470. anchorPos.position = isBefore ? 'bottom' : 'top';
  17471. }
  17472. if (inside && !inside.contains(anchorPos)) {
  17473. return;
  17474. }
  17475. result.anchor = anchorPos;
  17476. result.anchor.align = relativePosition;
  17477. }
  17478. },
  17479. checkMinHeight = function(minHeight, result, target, inside) {
  17480. var newHeight;
  17481. if (minHeight && inside) {
  17482. if (result.top >= target.bottom && result.bottom > inside.bottom) {
  17483. result.setHeight(Math.max(result.getHeight() + inside.bottom - result.bottom, minHeight));
  17484. result.constrainHeight = true;
  17485. }
  17486. else if (result.bottom <= target.top && result.top < inside.top) {
  17487. newHeight = Math.max(result.getHeight() + result.top - inside.top, minHeight);
  17488. result.adjust(result.getHeight() - newHeight);
  17489. result.constrainHeight = true;
  17490. }
  17491. else if (result.getHeight() > inside.getHeight()) {
  17492. result.setHeight(Math.max(minHeight, inside.getHeight()));
  17493. result.setPosition(result.x, 0);
  17494. result.constrainHeight = true;
  17495. }
  17496. }
  17497. },
  17498. checkMinWidth = function(minWidth, result, target, inside) {
  17499. var newWidth;
  17500. if (minWidth && inside) {
  17501. if (result.left >= target.right && result.right > inside.right) {
  17502. result.setWidth(Math.max(result.getWidth() + inside.right - result.right, minWidth));
  17503. result.constrainWidth = true;
  17504. }
  17505. else if (result.right <= target.left && result.left < inside.left) {
  17506. newWidth = Math.max(result.getWidth() + result.left - inside.left, minWidth);
  17507. result.adjust(0, 0, 0, result.getWidth() - newWidth);
  17508. result.constrainWidth = true;
  17509. }
  17510. else if (result.getWidth() > inside.getWidth()) {
  17511. result.setWidth(Math.max(minWidth, inside.getWidth()));
  17512. result.setPosition(0, result.y);
  17513. result.constrainWidth = true;
  17514. }
  17515. }
  17516. };
  17517. return {
  17518. isRegion: true,
  17519. statics: {
  17520. getRegion: function(el) {
  17521. return Ext.fly(el).getRegion();
  17522. },
  17523. from: function(o) {
  17524. return new this(o.top, o.right, o.bottom, o.left);
  17525. },
  17526. getAlignInfo: function(align, rtl) {
  17527. if (typeof align === 'object') {
  17528. return align;
  17529. }
  17530. align = align ? ((align.indexOf('-') < 0) ? 'tl-' + align : align) : 'tl-bl';
  17531. constrain = constrainRe.exec(align);
  17532. align = constrain[1];
  17533. align = (rtl ? rtlAlignMap : alignMap)[align] || align;
  17534. var offsetFactors = rtl ? RTLOffsetFactors : LTROffsetFactors,
  17535. constrain,
  17536. parts = alignRe.exec(align),
  17537. result;
  17538. if (!parts) {
  17539. Ext.raise({
  17540. sourceClass: 'Ext.util.Region',
  17541. sourceMethod: 'getAlignInfo',
  17542. position: align,
  17543. msg: 'Attempted to align an element with an invalid position: "' + align + '"'
  17544. });
  17545. }
  17546. result = {
  17547. myEdge: parts[1],
  17548. myOffset: parts[2],
  17549. otherEdge: parts[4],
  17550. otherOffset: parts[5],
  17551. constrain: constrain[2]
  17552. };
  17553. if (parts[3]) {
  17554. result.myEdge = parts[3][0];
  17555. result.myOffset = offsetFactors[parts[3][1]];
  17556. if (result.myOffset == null) {
  17557. result.myOffset = 50;
  17558. }
  17559. }
  17560. if (parts[6]) {
  17561. result.otherEdge = parts[6][0];
  17562. result.otherOffset = offsetFactors[parts[6][1]];
  17563. if (result.otherOffset == null) {
  17564. result.otherOffset = 50;
  17565. }
  17566. }
  17567. result.position = relativePositions[result.myEdge];
  17568. return result;
  17569. }
  17570. },
  17571. constructor: function(top, right, bottom, left) {
  17572. var me = this;
  17573. me.y = me.top = me[1] = top;
  17574. me.right = right;
  17575. me.bottom = bottom;
  17576. me.x = me.left = me[0] = left;
  17577. me.height = me.bottom - me.top;
  17578. me.width = me.right - me.left;
  17579. },
  17580. setPosition: function(x, y) {
  17581. if (arguments.length === 1) {
  17582. y = x[1];
  17583. x = x[0];
  17584. }
  17585. return this.translateBy(x - this.x, y - this.y);
  17586. },
  17587. contains: function(region) {
  17588. var me = this;
  17589. return (region.x >= me.x && (region.right || region.x) <= me.right && region.y >= me.y && (region.bottom || region.y) <= me.bottom);
  17590. },
  17591. intersect: function(region) {
  17592. var me = this,
  17593. t = Math.max(me.y, region.y),
  17594. r = Math.min(me.right, region.right),
  17595. b = Math.min(me.bottom, region.bottom),
  17596. l = Math.max(me.x, region.x);
  17597. if (b > t && r > l) {
  17598. return new this.self(t, r, b, l);
  17599. } else {
  17600. return false;
  17601. }
  17602. },
  17603. union: function(region) {
  17604. var me = this,
  17605. t = Math.min(me.y, region.y),
  17606. r = Math.max(me.right, region.right),
  17607. b = Math.max(me.bottom, region.bottom),
  17608. l = Math.min(me.x, region.x);
  17609. return new this.self(t, r, b, l);
  17610. },
  17611. constrainTo: function(targetRegion) {
  17612. var me = this,
  17613. constrain = Ext.Number.constrain;
  17614. me.top = me.y = constrain(me.top, targetRegion.y, targetRegion.bottom);
  17615. me.bottom = constrain(me.bottom, targetRegion.y, targetRegion.bottom);
  17616. me.left = me.x = constrain(me.left, targetRegion.x, targetRegion.right);
  17617. me.right = constrain(me.right, targetRegion.x, targetRegion.right);
  17618. me.height = me.bottom - me.top;
  17619. me.width = me.right - me.left;
  17620. return me;
  17621. },
  17622. adjust: function(top, right, bottom, left) {
  17623. var me = this;
  17624. me.top = me.y += top || 0;
  17625. me.left = me.x += left || 0;
  17626. me.right += right || 0;
  17627. me.bottom += bottom || 0;
  17628. me.height = me.bottom - me.top;
  17629. me.width = me.right - me.left;
  17630. return me;
  17631. },
  17632. getOutOfBoundOffset: function(axis, p) {
  17633. if (!Ext.isObject(axis)) {
  17634. if (axis === 'x') {
  17635. return this.getOutOfBoundOffsetX(p);
  17636. } else {
  17637. return this.getOutOfBoundOffsetY(p);
  17638. }
  17639. } else {
  17640. p = axis;
  17641. var d = new ExtUtil.Offset();
  17642. d.x = this.getOutOfBoundOffsetX(p.x);
  17643. d.y = this.getOutOfBoundOffsetY(p.y);
  17644. return d;
  17645. }
  17646. },
  17647. getOutOfBoundOffsetX: function(p) {
  17648. if (p <= this.x) {
  17649. return this.x - p;
  17650. } else if (p >= this.right) {
  17651. return this.right - p;
  17652. }
  17653. return 0;
  17654. },
  17655. getOutOfBoundOffsetY: function(p) {
  17656. if (p <= this.y) {
  17657. return this.y - p;
  17658. } else if (p >= this.bottom) {
  17659. return this.bottom - p;
  17660. }
  17661. return 0;
  17662. },
  17663. isOutOfBound: function(axis, p) {
  17664. if (!Ext.isObject(axis)) {
  17665. if (axis === 'x') {
  17666. return this.isOutOfBoundX(p);
  17667. } else {
  17668. return this.isOutOfBoundY(p);
  17669. }
  17670. } else {
  17671. p = axis;
  17672. return (this.isOutOfBoundX(p.x) || this.isOutOfBoundY(p.y));
  17673. }
  17674. },
  17675. isOutOfBoundX: function(p) {
  17676. return (p < this.x || p > this.right);
  17677. },
  17678. isOutOfBoundY: function(p) {
  17679. return (p < this.y || p > this.bottom);
  17680. },
  17681. restrict: function(axis, p, factor) {
  17682. if (Ext.isObject(axis)) {
  17683. var newP;
  17684. factor = p;
  17685. p = axis;
  17686. if (p.copy) {
  17687. newP = p.copy();
  17688. } else {
  17689. newP = {
  17690. x: p.x,
  17691. y: p.y
  17692. };
  17693. }
  17694. newP.x = this.restrictX(p.x, factor);
  17695. newP.y = this.restrictY(p.y, factor);
  17696. return newP;
  17697. } else {
  17698. if (axis === 'x') {
  17699. return this.restrictX(p, factor);
  17700. } else {
  17701. return this.restrictY(p, factor);
  17702. }
  17703. }
  17704. },
  17705. restrictX: function(p, factor) {
  17706. if (!factor) {
  17707. factor = 1;
  17708. }
  17709. if (p <= this.x) {
  17710. p -= (p - this.x) * factor;
  17711. } else if (p >= this.right) {
  17712. p -= (p - this.right) * factor;
  17713. }
  17714. return p;
  17715. },
  17716. restrictY: function(p, factor) {
  17717. if (!factor) {
  17718. factor = 1;
  17719. }
  17720. if (p <= this.y) {
  17721. p -= (p - this.y) * factor;
  17722. } else if (p >= this.bottom) {
  17723. p -= (p - this.bottom) * factor;
  17724. }
  17725. return p;
  17726. },
  17727. alignTo: function(options) {
  17728. var me = this,
  17729. Region = me.self,
  17730. Offset = ExtUtil.Offset,
  17731. Element = Ext.Element,
  17732. target = parseRegion(options.target),
  17733. targetPlusAnchorOffset,
  17734. rtl = options.rtl,
  17735. overlap = options.overlap,
  17736. align = options.align,
  17737. anchorSize = options.anchorSize,
  17738. offset = options.offset,
  17739. inside = options.inside,
  17740. position = options.position,
  17741. allowXTranslate = options.allowXTranslate,
  17742. allowYTranslate = options.allowYTranslate,
  17743. wasConstrained, result, initialPosition, constrainedPosition;
  17744. if (offset) {
  17745. offset = Offset.fromObject(offset);
  17746. if (!(offset instanceof Offset)) {
  17747. Ext.raise('offset option must be an Ext.util.Offset');
  17748. }
  17749. }
  17750. if (anchorSize) {
  17751. anchorSize = Offset.fromObject(anchorSize);
  17752. if (!(anchorSize instanceof Offset)) {
  17753. Ext.raise('anchorSize option must be an Ext.util.Offset');
  17754. }
  17755. }
  17756. if (inside && !inside.isRegion) {
  17757. if (Ext.getDom(inside) === document.body) {
  17758. inside = new Region(0, Element.getDocumentWidth(), Element.getDocumentHeight(), 0);
  17759. } else {
  17760. inside = Ext.fly(inside).getRegion();
  17761. }
  17762. }
  17763. if (position) {
  17764. if (position.length === 2) {
  17765. position = new ExtUtil.Point(position[0], position[1]);
  17766. }
  17767. result = new Region().copyFrom(me).setPosition(position.x, position.y);
  17768. } else {
  17769. align = me.getAlignInfo(align, rtl);
  17770. if (inside) {
  17771. if (target.x >= inside.right) {
  17772. target.setPosition(inside.right - 1, target.y);
  17773. if (align.position !== 3) {
  17774. align = me.getAlignInfo('r-l', rtl);
  17775. }
  17776. } else if (target.right < inside.x) {
  17777. target.setPosition(inside.x - target.getWidth() + 1, target.y);
  17778. if (align.position !== 1) {
  17779. align = me.getAlignInfo('l-r', rtl);
  17780. }
  17781. }
  17782. if (target.y >= inside.bottom) {
  17783. target.setPosition(target.x, inside.bottom - 1);
  17784. if (align.position !== 0) {
  17785. align = me.getAlignInfo('b-t', rtl);
  17786. }
  17787. } else if (target.bottom < inside.y) {
  17788. target.setPosition(target.x, inside.y - target.getHeight() + 1);
  17789. if (align.position !== 2) {
  17790. align = me.getAlignInfo('t-b', rtl);
  17791. }
  17792. }
  17793. }
  17794. targetPlusAnchorOffset = anchorSize ? addAnchorOffset(target, anchorSize, align.position) : target;
  17795. result = Region.from(me).translateBy(me.getAlignToVector(targetPlusAnchorOffset, align));
  17796. overlap = !!result.intersect(targetPlusAnchorOffset);
  17797. if (offset && (overlap || !anchorSize)) {
  17798. result.translateBy(offset);
  17799. }
  17800. if (anchorSize) {
  17801. calculateAnchorPosition(target, result, align.position, anchorSize, inside);
  17802. }
  17803. }
  17804. if (inside) {
  17805. initialPosition = result.copy();
  17806. if (result.left < inside.left) {
  17807. result.translateBy(inside.left - result.left, 0);
  17808. wasConstrained = true;
  17809. }
  17810. if (result.right > inside.right && result.left > inside.left) {
  17811. result.translateBy(inside.right - result.right, 0);
  17812. wasConstrained = true;
  17813. }
  17814. if (result.top < inside.top) {
  17815. result.translateBy(0, inside.top - result.top);
  17816. wasConstrained = true;
  17817. }
  17818. if (result.bottom > inside.bottom && result.top > inside.top) {
  17819. result.translateBy(0, inside.bottom - result.bottom);
  17820. wasConstrained = true;
  17821. }
  17822. if (wasConstrained && !overlap) {
  17823. result.anchor = null;
  17824. if (options.axisLock) {
  17825. if (align.position & 1) {
  17826. allowYTranslate = false;
  17827. } else {
  17828. allowXTranslate = false;
  17829. }
  17830. }
  17831. if (position) {
  17832. if (result.contains(position)) {
  17833. position.exclude(result, {
  17834. inside: inside,
  17835. centerOnSideChange: false
  17836. });
  17837. }
  17838. } else
  17839. {
  17840. constrainedPosition = result.copy();
  17841. if (result.intersect(targetPlusAnchorOffset)) {
  17842. align.position = target.exclude(result, {
  17843. initialPosition: initialPosition,
  17844. defaultPosition: align.position,
  17845. inside: inside,
  17846. minHeight: options.minHeight,
  17847. minWidth: options.minWidth,
  17848. allowX: allowXTranslate,
  17849. allowY: allowYTranslate,
  17850. offset: offset,
  17851. anchorHeight: anchorSize ? anchorSize.y : 0,
  17852. centerOnSideChange: !!anchorSize
  17853. });
  17854. } else if (options.minWidth && result.getWidth() > inside.getWidth()) {
  17855. result.setPosition(0, result.y);
  17856. result.setWidth(Math.max(inside.getWidth(), options.minWidth));
  17857. result.constrainWidth = true;
  17858. } else if (options.minHeight && result.getHeight() > inside.getHeight()) {
  17859. result.setPosition(result.x, 0);
  17860. result.setHeight(Math.max(inside.getHeight(), options.minHeight));
  17861. result.constrainHeight = true;
  17862. }
  17863. result.align = align;
  17864. if (inside.contains(result)) {
  17865. if (anchorSize) {
  17866. calculateAnchorPosition(target, result, align.position, anchorSize, inside);
  17867. }
  17868. } else
  17869. {
  17870. result = constrainedPosition;
  17871. }
  17872. }
  17873. }
  17874. }
  17875. return result;
  17876. },
  17877. exclude: function(other, options) {
  17878. options = options || {};
  17879. var me = this,
  17880. initialPosition = options.initialPosition || other,
  17881. inside = options.inside,
  17882. defaultPosition = options.defaultPosition,
  17883. centerOnSideChange = options.centerOnSideChange,
  17884. minHeight = options.minHeight,
  17885. minWidth = options.minWidth,
  17886. allowX = options.allowX !== false,
  17887. allowY = options.allowY !== false,
  17888. anchorHeight = options.anchorHeight,
  17889. offset = options.offset,
  17890. translations = [],
  17891. testRegion, t, i, sizeConstrainedSolution, leastBadSolution, intersection, result;
  17892. if (!offset) {
  17893. offset = zeroOffset;
  17894. }
  17895. if (allowY) {
  17896. translations.push([
  17897. 0,
  17898. me.top - other.bottom - anchorHeight + offset.y,
  17899. 'b-t',
  17900. 0,
  17901. Math.abs(me.top - initialPosition.bottom - anchorHeight + offset.y)
  17902. ]);
  17903. translations.push([
  17904. 0,
  17905. me.bottom - other.top + anchorHeight + offset.y,
  17906. 't-b',
  17907. 2,
  17908. Math.abs(me.bottom - initialPosition.top + anchorHeight + offset.y)
  17909. ]);
  17910. } else {
  17911. centerOnSideChange = false;
  17912. }
  17913. if (allowX) {
  17914. translations.push([
  17915. me.left - other.right - anchorHeight + offset.x,
  17916. 0,
  17917. 'r-l',
  17918. 3,
  17919. Math.abs(me.left - initialPosition.right - anchorHeight + offset.x)
  17920. ]);
  17921. translations.push([
  17922. me.right - other.left + anchorHeight + offset.x,
  17923. 0,
  17924. 'l-r',
  17925. 1,
  17926. Math.abs(me.right - initialPosition.left + anchorHeight + offset.x)
  17927. ]);
  17928. } else {
  17929. centerOnSideChange = false;
  17930. }
  17931. Ext.Array.sort(translations, function(l, r) {
  17932. var result = l[4] - r[4];
  17933. if (!result) {
  17934. if (l[3] === defaultPosition) {
  17935. return -1;
  17936. }
  17937. if (r[3] === defaultPosition) {
  17938. return 1;
  17939. }
  17940. }
  17941. return result;
  17942. });
  17943. if (inside) {
  17944. for (i = 0; i < translations.length; i++) {
  17945. t = translations[i];
  17946. testRegion = ExtUtil.Region.from(other);
  17947. testRegion.translateBy.apply(testRegion, t);
  17948. if (inside.contains(testRegion)) {
  17949. other.copyFrom(testRegion);
  17950. result = {
  17951. align: t[2],
  17952. position: t[3],
  17953. distance: t[4]
  17954. };
  17955. break;
  17956. }
  17957. if (minHeight) {
  17958. checkMinHeight(minHeight, testRegion, me, inside);
  17959. if (inside.contains(testRegion)) {
  17960. if (!sizeConstrainedSolution || testRegion.getArea() > sizeConstrainedSolution.region.getArea()) {
  17961. sizeConstrainedSolution = {
  17962. region: testRegion,
  17963. align: t[2],
  17964. position: t[3],
  17965. distance: t[4]
  17966. };
  17967. }
  17968. }
  17969. }
  17970. if (minWidth) {
  17971. checkMinWidth(minWidth, testRegion, me, inside);
  17972. if (inside.contains(testRegion)) {
  17973. if (!sizeConstrainedSolution || testRegion.getArea() > sizeConstrainedSolution.region.getArea()) {
  17974. sizeConstrainedSolution = {
  17975. region: testRegion,
  17976. align: t[2],
  17977. position: t[3],
  17978. distance: t[4]
  17979. };
  17980. }
  17981. }
  17982. }
  17983. intersection = inside.intersect(testRegion);
  17984. if (intersection) {
  17985. intersection = intersection.getArea();
  17986. if (!leastBadSolution || (intersection && leastBadSolution.area < intersection)) {
  17987. leastBadSolution = {
  17988. region: testRegion,
  17989. align: t[2],
  17990. position: t[3],
  17991. distance: t[4],
  17992. area: intersection
  17993. };
  17994. }
  17995. }
  17996. }
  17997. if (!result) {
  17998. if (sizeConstrainedSolution) {
  17999. other.copyFrom(sizeConstrainedSolution.region);
  18000. result = sizeConstrainedSolution;
  18001. other.constrainWidth = sizeConstrainedSolution.region.constrainWidth;
  18002. other.constrainHeight = sizeConstrainedSolution.region.constrainHeight;
  18003. }
  18004. else if (leastBadSolution) {
  18005. other.copyFrom(leastBadSolution.region);
  18006. result = leastBadSolution;
  18007. }
  18008. }
  18009. if (result) {
  18010. if ((result.position & 1) !== (defaultPosition & 1)) {
  18011. if (result.distance && centerOnSideChange) {
  18012. t = other.alignTo({
  18013. align: result.align,
  18014. target: me,
  18015. anchorSize: anchorHeight,
  18016. offset: offset,
  18017. axisLock: true,
  18018. inside: inside,
  18019. minHeight: options.minHeight,
  18020. minWidth: options.minWidth
  18021. });
  18022. if (inside.contains(t)) {
  18023. other.setPosition(t.x, t.y);
  18024. }
  18025. }
  18026. }
  18027. return result.position;
  18028. }
  18029. } else
  18030. {
  18031. other.translateBy.apply(other, translations[0]);
  18032. return translations[0][3];
  18033. }
  18034. return defaultPosition;
  18035. },
  18036. getAlignToXY: function(target, align, rtl) {
  18037. var alignVector = this.getAlignToVector(target, align, rtl);
  18038. return [
  18039. this.x + alignVector[0],
  18040. this.y + alignVector[1]
  18041. ];
  18042. },
  18043. getAnchorPoint: function(align, rtl) {
  18044. align = (typeof align === 'string') ? this.getAlignInfo(align + '-tl', rtl) : align;
  18045. return this['getAnchorPoint_' + align.myEdge](align.myOffset);
  18046. },
  18047. getAlignToVector: function(target, align, rtl) {
  18048. align = (typeof align === 'string') ? this.getAlignInfo(align, rtl) : align;
  18049. var myAnchorPoint = this['getAnchorPoint_' + align.myEdge](align.myOffset),
  18050. targetAnchorPoint = target['getAnchorPoint_' + align.otherEdge](align.otherOffset);
  18051. return [
  18052. targetAnchorPoint[0] - myAnchorPoint[0],
  18053. targetAnchorPoint[1] - myAnchorPoint[1]
  18054. ];
  18055. },
  18056. getAnchorPoint_t: function(offset) {
  18057. return [
  18058. this.x + Math.round(this.getWidth() * (offset / 100)),
  18059. this.y
  18060. ];
  18061. },
  18062. getAnchorPoint_b: function(offset) {
  18063. return [
  18064. this.x + Math.round(this.getWidth() * (offset / 100)),
  18065. this.bottom
  18066. ];
  18067. },
  18068. getAnchorPoint_l: function(offset) {
  18069. return [
  18070. this.x,
  18071. this.y + Math.round(this.getHeight() * (offset / 100))
  18072. ];
  18073. },
  18074. getAnchorPoint_r: function(offset) {
  18075. return [
  18076. this.right,
  18077. this.y + Math.round(this.getHeight() * (offset / 100))
  18078. ];
  18079. },
  18080. getAnchorPoint_c: function() {
  18081. return [
  18082. this.x + Math.round(this.getWidth() / 2),
  18083. this.y + Math.round(this.getHeight() / 2)
  18084. ];
  18085. },
  18086. getCenter: function() {
  18087. return [
  18088. this.x + this.width / 2,
  18089. this.y + this.height / 2
  18090. ];
  18091. },
  18092. getHeight: function() {
  18093. return this.bottom - this.y;
  18094. },
  18095. getWidth: function() {
  18096. return this.right - this.x;
  18097. },
  18098. getArea: function() {
  18099. return this.getHeight() * this.getWidth();
  18100. },
  18101. setHeight: function(h) {
  18102. this.height = h;
  18103. this.bottom = this.top + h;
  18104. return this;
  18105. },
  18106. setWidth: function(w) {
  18107. this.width = w;
  18108. this.right = this.left + w;
  18109. return this;
  18110. },
  18111. getSize: function() {
  18112. return {
  18113. width: this.right - this.x,
  18114. height: this.bottom - this.y
  18115. };
  18116. },
  18117. setSize: function(w, h) {
  18118. if (h === undefined) {
  18119. h = w;
  18120. }
  18121. this.setWidth(w);
  18122. return this.setHeight(h);
  18123. },
  18124. copy: function() {
  18125. return new this.self(this.y, this.right, this.bottom, this.x);
  18126. },
  18127. copyFrom: function(p) {
  18128. var me = this;
  18129. me.top = me.y = me[1] = p.y;
  18130. me.right = p.right;
  18131. me.bottom = p.bottom;
  18132. me.left = me.x = me[0] = p.x;
  18133. return me;
  18134. },
  18135. toString: function() {
  18136. return "Region[" + this.top + "," + this.right + "," + this.bottom + "," + this.left + "]";
  18137. },
  18138. translateBy: function(x, y) {
  18139. if (x.length) {
  18140. y = x[1];
  18141. x = x[0];
  18142. } else if (arguments.length === 1) {
  18143. y = x.y;
  18144. x = x.x;
  18145. }
  18146. var me = this;
  18147. me.top = me.y += y;
  18148. me.right += x;
  18149. me.bottom += y;
  18150. me.left = me.x += x;
  18151. return me;
  18152. },
  18153. round: function() {
  18154. var me = this;
  18155. me.top = me.y = Math.round(me.y);
  18156. me.right = Math.round(me.right);
  18157. me.bottom = Math.round(me.bottom);
  18158. me.left = me.x = Math.round(me.x);
  18159. return me;
  18160. },
  18161. equals: function(region) {
  18162. return (this.top === region.top && this.right === region.right && this.bottom === region.bottom && this.left === region.left);
  18163. },
  18164. getOffsetsTo: function(offsetsTo) {
  18165. return {
  18166. x: this.x - offsetsTo.x,
  18167. y: this.y - offsetsTo.y
  18168. };
  18169. },
  18170. highlight: function() {
  18171. var highlightEl = Ext.getBody().createChild({
  18172. style: 'background-color:#52a0db;opacity:0.4;position:absolute;z-index:9999999'
  18173. });
  18174. highlightEl.setBox(this);
  18175. Ext.defer(function() {
  18176. highlightEl.destroy();
  18177. }, 5000);
  18178. return highlightEl;
  18179. }
  18180. };
  18181. },
  18182. function(Region) {
  18183. Region.prototype.getAlignInfo = Region.getAlignInfo;
  18184. Region.EMPTY = new Region(0, 0, 0, 0);
  18185. if (Object.freeze) {
  18186. Object.freeze(Region.EMPTY);
  18187. }
  18188. });
  18189. Ext.define('Ext.util.Point', {
  18190. extend: Ext.util.Region,
  18191. isPoint: true,
  18192. radianToDegreeConstant: 180 / Math.PI,
  18193. origin: {
  18194. x: 0,
  18195. y: 0
  18196. },
  18197. statics: {
  18198. fromEvent: function(e) {
  18199. var changedTouches = e.changedTouches,
  18200. touch = (changedTouches && changedTouches.length > 0) ? changedTouches[0] : e;
  18201. return this.fromTouch(touch);
  18202. },
  18203. fromTouch: function(touch) {
  18204. return new this(touch.pageX, touch.pageY);
  18205. },
  18206. from: function(object) {
  18207. if (!object) {
  18208. return new this(0, 0);
  18209. }
  18210. if (!(object instanceof this)) {
  18211. return new this(object.x, object.y);
  18212. }
  18213. return object;
  18214. }
  18215. },
  18216. constructor: function(x, y) {
  18217. if (x == null) {
  18218. x = 0;
  18219. }
  18220. if (y == null) {
  18221. y = 0;
  18222. }
  18223. this.callParent([
  18224. y,
  18225. x,
  18226. y,
  18227. x
  18228. ]);
  18229. },
  18230. clone: function() {
  18231. return new this.self(this.x, this.y);
  18232. },
  18233. copy: function() {
  18234. return this.clone.apply(this, arguments);
  18235. },
  18236. copyFrom: function(point) {
  18237. this.x = point.x;
  18238. this.y = point.y;
  18239. return this;
  18240. },
  18241. toString: function() {
  18242. return "Point[" + this.x + "," + this.y + "]";
  18243. },
  18244. equals: function(point) {
  18245. return (this.x === point.x && this.y === point.y);
  18246. },
  18247. isCloseTo: function(point, threshold) {
  18248. if (typeof threshold == 'number') {
  18249. return this.getDistanceTo(point) <= threshold;
  18250. }
  18251. var x = point.x,
  18252. y = point.y,
  18253. thresholdX = threshold.x,
  18254. thresholdY = threshold.y;
  18255. return (this.x <= x + thresholdX && this.x >= x - thresholdX && this.y <= y + thresholdY && this.y >= y - thresholdY);
  18256. },
  18257. isWithin: function() {
  18258. return this.isCloseTo.apply(this, arguments);
  18259. },
  18260. isContainedBy: function(region) {
  18261. if (!(region instanceof Ext.util.Region)) {
  18262. region = Ext.get(region.el || region).getRegion();
  18263. }
  18264. return region.contains(this);
  18265. },
  18266. roundedEquals: function(point) {
  18267. if (!point || typeof point !== 'object') {
  18268. point = this.origin;
  18269. }
  18270. return (Math.round(this.x) === Math.round(point.x) && Math.round(this.y) === Math.round(point.y));
  18271. },
  18272. getDistanceTo: function(point) {
  18273. if (!point || typeof point !== 'object') {
  18274. point = this.origin;
  18275. }
  18276. var deltaX = this.x - point.x,
  18277. deltaY = this.y - point.y;
  18278. return Math.sqrt(deltaX * deltaX + deltaY * deltaY);
  18279. },
  18280. getAngleTo: function(point) {
  18281. if (!point || typeof point !== 'object') {
  18282. point = this.origin;
  18283. }
  18284. var deltaX = this.x - point.x,
  18285. deltaY = this.y - point.y;
  18286. return Math.atan2(deltaY, deltaX) * this.radianToDegreeConstant;
  18287. }
  18288. }, function() {
  18289. this.prototype.translate = this.prototype.translateBy;
  18290. });
  18291. Ext.define('Ext.event.Event', {
  18292. alternateClassName: 'Ext.EventObjectImpl',
  18293. stopped: false,
  18294. claimed: false,
  18295. defaultPrevented: false,
  18296. isEvent: true,
  18297. geckoRelatedTargetEvents: {
  18298. blur: 1,
  18299. dragenter: 1,
  18300. dragleave: 1,
  18301. focus: 1
  18302. },
  18303. statics: {
  18304. resolveTextNode: function(node) {
  18305. return (node && node.nodeType === 3) ? node.parentNode : node;
  18306. },
  18307. gestureEvents: {},
  18308. pointerEvents: {
  18309. pointerdown: 1,
  18310. pointermove: 1,
  18311. pointerup: 1,
  18312. pointercancel: 1,
  18313. pointerover: 1,
  18314. pointerout: 1,
  18315. pointerenter: 1,
  18316. pointerleave: 1,
  18317. MSPointerDown: 1,
  18318. MSPointerMove: 1,
  18319. MSPointerUp: 1,
  18320. MSPointerOver: 1,
  18321. MSPointerOut: 1,
  18322. MSPointerCancel: 1,
  18323. MSPointerEnter: 1,
  18324. MSPointerLeave: 1
  18325. },
  18326. mouseEvents: {
  18327. mousedown: 1,
  18328. mousemove: 1,
  18329. mouseup: 1,
  18330. mouseover: 1,
  18331. mouseout: 1,
  18332. mouseenter: 1,
  18333. mouseleave: 1
  18334. },
  18335. clickEvents: {
  18336. click: 1,
  18337. dblclick: 1
  18338. },
  18339. touchEvents: {
  18340. touchstart: 1,
  18341. touchmove: 1,
  18342. touchend: 1,
  18343. touchcancel: 1
  18344. },
  18345. focusEvents: {
  18346. focus: 1,
  18347. focusin: 1,
  18348. focusenter: 1
  18349. },
  18350. blurEvents: {
  18351. blur: 1,
  18352. focusout: 1,
  18353. focusleave: 1
  18354. },
  18355. pointerTypeMap: {
  18356. 2: 'touch',
  18357. 3: 'pen',
  18358. 4: 'mouse',
  18359. touch: 'touch',
  18360. pen: 'pen',
  18361. mouse: 'mouse'
  18362. },
  18363. keyEventRe: /^key/,
  18364. keyFlags: {
  18365. CTRL: 'ctrlKey',
  18366. CONTROL: 'ctrlKey',
  18367. ALT: 'altKey',
  18368. SHIFT: 'shiftKey',
  18369. CMD: 'metaKey',
  18370. COMMAND: 'metaKey',
  18371. CMDORCTRL: Ext.isMac ? 'metaKey' : 'ctrlKey',
  18372. COMMANDORCONTROL: Ext.isMac ? 'metaKey' : 'ctrlKey',
  18373. META: 'metaKey'
  18374. },
  18375. modifierGlyphs: {
  18376. ctrlKey: '⌃',
  18377. altKey: '⌥',
  18378. metaKey: Ext.isMac ? '⌘' : '⊞',
  18379. shiftKey: '⇧'
  18380. },
  18381. specialKeyGlyphs: {
  18382. BACKSPACE: '⌫',
  18383. TAB: '⇥',
  18384. ENTER: '⏎',
  18385. RETURN: '⏎',
  18386. SPACE: '␣',
  18387. PAGE_UP: '⇞',
  18388. PAGE_DOWN: '⇟',
  18389. END: '⇲',
  18390. HOME: '⌂',
  18391. LEFT: '←',
  18392. UP: '↑',
  18393. RIGHT: '→',
  18394. DOWN: '↓',
  18395. PRINT_SCREEN: '⎙',
  18396. INSERT: '⎀',
  18397. DELETE: '⌦',
  18398. CONTEXT_MENU: '☰'
  18399. },
  18400. _hyphenRe: /^[a-z]+\-/i,
  18401. getKeyId: function(keyName) {
  18402. if (typeof keyName === 'number') {
  18403. keyName = this.keyCodes[keyName];
  18404. } else {
  18405. keyName = keyName.toUpperCase();
  18406. }
  18407. var me = this,
  18408. delim = me._hyphenRe.test(keyName) ? '-' : '+',
  18409. parts = (keyName === delim) ? [
  18410. delim
  18411. ] : keyName.split(delim),
  18412. numModifiers = parts.length - 1,
  18413. rawKey = parts[numModifiers],
  18414. result = [],
  18415. eventFlag, i;
  18416. if (!Ext.event.Event[rawKey]) {
  18417. Ext.raise('Invalid key name: "' + rawKey + '"');
  18418. }
  18419. for (i = 0; i < numModifiers; i++) {
  18420. eventFlag = me.keyFlags[parts[i]];
  18421. if (!eventFlag) {
  18422. Ext.raise('Invalid key modifier: "' + parts[i] + '"');
  18423. }
  18424. result[eventFlag] = true;
  18425. }
  18426. if (result.ctrlKey) {
  18427. result.push(me.modifierGlyphs.ctrlKey);
  18428. }
  18429. if (result.altKey) {
  18430. result.push(me.modifierGlyphs.altKey);
  18431. }
  18432. if (result.shiftKey) {
  18433. result.push(me.modifierGlyphs.shiftKey);
  18434. }
  18435. if (result.metaKey) {
  18436. result.push(me.modifierGlyphs.metaKey);
  18437. }
  18438. result.push(this.specialKeyGlyphs[rawKey] || rawKey);
  18439. return result.join('');
  18440. },
  18441. globalTabKeyDown: function(e) {
  18442. if (e.keyCode === 9) {
  18443. Ext.event.Event.forwardTab = !e.shiftKey;
  18444. }
  18445. },
  18446. globalTabKeyUp: function(e) {
  18447. if (e.keyCode === 9) {
  18448. delete Ext.event.Event.forwardTab;
  18449. }
  18450. }
  18451. },
  18452. constructor: function(event) {
  18453. var me = this,
  18454. self = me.self,
  18455. resolveTextNode = me.self.resolveTextNode,
  18456. changedTouches = event.changedTouches,
  18457. coordinateOwner = changedTouches ? changedTouches[0] : event,
  18458. type = event.type,
  18459. pointerType, relatedTarget;
  18460. me.timeStamp = me.time = Ext.now();
  18461. me.pageX = coordinateOwner.pageX;
  18462. me.pageY = coordinateOwner.pageY;
  18463. me.clientX = coordinateOwner.clientX;
  18464. me.clientY = coordinateOwner.clientY;
  18465. me.target = me.delegatedTarget = resolveTextNode(event.target);
  18466. me.currentTarget = resolveTextNode(event.currentTarget);
  18467. relatedTarget = event.relatedTarget;
  18468. if (relatedTarget) {
  18469. if (Ext.isGecko && me.geckoRelatedTargetEvents[type]) {
  18470. try {
  18471. me.relatedTarget = resolveTextNode(relatedTarget);
  18472. } catch (e) {
  18473. me.relatedTarget = null;
  18474. }
  18475. } else {
  18476. me.relatedTarget = resolveTextNode(relatedTarget);
  18477. }
  18478. }
  18479. me.browserEvent = me.event = event;
  18480. me.type = type;
  18481. me.button = event.button || 0;
  18482. me.shiftKey = event.shiftKey;
  18483. me.ctrlKey = event.ctrlKey || event.metaKey || false;
  18484. me.altKey = event.altKey;
  18485. me.charCode = event.charCode;
  18486. me.keyCode = event.keyCode;
  18487. me.buttons = event.buttons;
  18488. if (me.button === 0 && me.buttons === 0) {
  18489. me.buttons = 1;
  18490. }
  18491. if (self.focusEvents[type] || self.blurEvents[type]) {
  18492. if (self.forwardTab !== undefined) {
  18493. me.forwardTab = self.forwardTab;
  18494. }
  18495. if (self.focusEvents[type]) {
  18496. me.fromElement = event.relatedTarget;
  18497. me.toElement = event.target;
  18498. } else {
  18499. me.fromElement = event.target;
  18500. me.toElement = event.relatedTarget;
  18501. }
  18502. } else if (type !== 'keydown') {
  18503. delete self.forwardTab;
  18504. }
  18505. if (self.mouseEvents[type]) {
  18506. pointerType = 'mouse';
  18507. } else if (self.clickEvents[type]) {
  18508. pointerType = self.pointerTypeMap[event.pointerType] || (((Ext.now() - Ext.event.publisher.Dom.lastTouchEndTime) < 1000) ? 'touch' : 'mouse');
  18509. } else if (self.pointerEvents[type]) {
  18510. pointerType = self.pointerTypeMap[event.pointerType] || 'mouse';
  18511. } else if (self.touchEvents[type]) {
  18512. pointerType = 'touch';
  18513. }
  18514. if (pointerType) {
  18515. me.pointerType = pointerType;
  18516. }
  18517. me.isMultitouch = event.isPrimary === false || (event.touches && event.touches.length > 1);
  18518. },
  18519. chain: function(props) {
  18520. var e = Ext.Object.chain(this);
  18521. e.parentEvent = this;
  18522. return Ext.apply(e, props);
  18523. },
  18524. correctWheelDelta: function(delta) {
  18525. var scale = this.WHEEL_SCALE,
  18526. ret = Math.round(delta / scale);
  18527. if (!ret && delta) {
  18528. ret = (delta < 0) ? -1 : 1;
  18529. }
  18530. return ret;
  18531. },
  18532. getChar: function() {
  18533. var r = this.which();
  18534. return String.fromCharCode(r);
  18535. },
  18536. getCharCode: function() {
  18537. return this.charCode || this.keyCode;
  18538. },
  18539. getKey: function() {
  18540. return this.keyCode || this.charCode;
  18541. },
  18542. getKeyName: function() {
  18543. return this.type === 'keypress' ? String.fromCharCode(this.getCharCode()) : this.keyCodes[this.keyCode];
  18544. },
  18545. key: function() {
  18546. return this.browserEvent.key;
  18547. },
  18548. which: function() {
  18549. var me = this,
  18550. e = me.browserEvent,
  18551. r = e.which;
  18552. if (r == null) {
  18553. if (me.self.keyEventRe.test(e.type)) {
  18554. r = e.charCode || e.keyCode;
  18555. } else if ((r = e.button) !== undefined) {
  18556. r = (r & 1) ? 1 : ((r & 4) ? 2 : ((r & 2) ? 3 : 0));
  18557. }
  18558. }
  18559. return r;
  18560. },
  18561. getClipboardData: function(type) {
  18562. var clipboardData = this.browserEvent.clipboardData,
  18563. clipIE = Ext.global.clipboardData,
  18564. result = null,
  18565. typeIE;
  18566. type = type || 'text/plain';
  18567. if (clipboardData && clipboardData.getData) {
  18568. result = clipboardData.getData(type);
  18569. } else if (clipIE && clipIE.getData) {
  18570. typeIE = this.ieMimeType[type];
  18571. if (typeIE) {
  18572. result = clipIE.getData(typeIE);
  18573. }
  18574. }
  18575. return result;
  18576. },
  18577. getPoint: function() {
  18578. var me = this,
  18579. point = me.point,
  18580. xy;
  18581. if (!point) {
  18582. xy = me.getXY();
  18583. point = me.point = new Ext.util.Point(xy[0], xy[1]);
  18584. }
  18585. return point;
  18586. },
  18587. getRelatedTarget: function(selector, maxDepth, returnEl) {
  18588. var relatedTarget = this.relatedTarget,
  18589. target = null;
  18590. if (relatedTarget && relatedTarget.nodeType) {
  18591. if (selector) {
  18592. target = Ext.fly(relatedTarget).findParent(selector, maxDepth, returnEl);
  18593. } else {
  18594. target = returnEl ? Ext.get(relatedTarget) : relatedTarget;
  18595. }
  18596. }
  18597. return target;
  18598. },
  18599. getTarget: function(selector, maxDepth, returnEl) {
  18600. return selector ? Ext.fly(this.target).findParent(selector, maxDepth, returnEl) : (returnEl ? Ext.get(this.target) : this.target);
  18601. },
  18602. getTime: function() {
  18603. return this.time;
  18604. },
  18605. getWheelDelta: function() {
  18606. var deltas = this.getWheelDeltas();
  18607. return deltas.y;
  18608. },
  18609. getWheelDeltas: function() {
  18610. var me = this,
  18611. event = me.browserEvent,
  18612. dx = 0,
  18613. dy = 0;
  18614. if (Ext.isDefined(event.wheelDeltaX)) {
  18615. dx = event.wheelDeltaX;
  18616. dy = event.wheelDeltaY;
  18617. } else if (event.wheelDelta) {
  18618. dy = event.wheelDelta;
  18619. } else if ('deltaX' in event) {
  18620. dx = event.deltaX;
  18621. dy = -event.deltaY;
  18622. }
  18623. else if (event.detail) {
  18624. dy = -event.detail;
  18625. if (dy > 100) {
  18626. dy = 3;
  18627. } else if (dy < -100) {
  18628. dy = -3;
  18629. }
  18630. if (Ext.isDefined(event.axis) && event.axis === event.HORIZONTAL_AXIS) {
  18631. dx = dy;
  18632. dy = 0;
  18633. }
  18634. }
  18635. return {
  18636. x: me.correctWheelDelta(dx),
  18637. y: me.correctWheelDelta(dy)
  18638. };
  18639. },
  18640. getX: function() {
  18641. return this.getXY()[0];
  18642. },
  18643. getXY: function() {
  18644. var me = this,
  18645. xy = me.xy;
  18646. if (!xy) {
  18647. xy = me.xy = [
  18648. me.pageX,
  18649. me.pageY
  18650. ];
  18651. var x = xy[0],
  18652. browserEvent, doc, docEl, body;
  18653. if (!x && x !== 0) {
  18654. browserEvent = me.browserEvent;
  18655. doc = document;
  18656. docEl = doc.documentElement;
  18657. body = doc.body;
  18658. xy[0] = browserEvent.clientX + (docEl && docEl.scrollLeft || body && body.scrollLeft || 0) - (docEl && docEl.clientLeft || body && body.clientLeft || 0);
  18659. xy[1] = browserEvent.clientY + (docEl && docEl.scrollTop || body && body.scrollTop || 0) - (docEl && docEl.clientTop || body && body.clientTop || 0);
  18660. }
  18661. }
  18662. return xy;
  18663. },
  18664. getY: function() {
  18665. return this.getXY()[1];
  18666. },
  18667. hasModifier: function() {
  18668. var me = this;
  18669. return !!(me.ctrlKey || me.altKey || me.shiftKey || me.metaKey);
  18670. },
  18671. isNavKeyPress: function(scrollableOnly) {
  18672. var me = this,
  18673. k = me.keyCode,
  18674. isKeyPress = me.type === 'keypress';
  18675. return ((!isKeyPress || Ext.isGecko) && k >= 33 && k <= 40) || (
  18676. !scrollableOnly && (k === me.RETURN || k === me.TAB || k === me.ESC));
  18677. },
  18678. isSpecialKey: function() {
  18679. var me = this,
  18680. k = me.keyCode,
  18681. isGecko = Ext.isGecko,
  18682. isKeyPress = me.type === 'keypress';
  18683. return (isGecko && isKeyPress && me.charCode === 0) || (this.isNavKeyPress()) || (k === me.BACKSPACE) || (k === me.ENTER) || (k >= 16 && k <= 20) || (
  18684. (!isKeyPress || isGecko) && k >= 44 && k <= 46);
  18685. },
  18686. makeUnpreventable: function() {
  18687. this.browserEvent.preventDefault = Ext.emptyFn;
  18688. },
  18689. preventDefault: function() {
  18690. var me = this,
  18691. parentEvent = me.parentEvent;
  18692. me.defaultPrevented = true;
  18693. if (parentEvent) {
  18694. parentEvent.defaultPrevented = true;
  18695. }
  18696. me.browserEvent.preventDefault();
  18697. return me;
  18698. },
  18699. setCurrentTarget: function(target) {
  18700. this.currentTarget = this.delegatedTarget = target;
  18701. },
  18702. stopEvent: function() {
  18703. return this.preventDefault().stopPropagation();
  18704. },
  18705. mousedownEvents: {
  18706. mousedown: 1,
  18707. pointerdown: 1,
  18708. touchstart: 1
  18709. },
  18710. mouseupEvents: {
  18711. mouseup: 1,
  18712. pointerup: 1,
  18713. touchend: 1
  18714. },
  18715. stopPropagation: function() {
  18716. var me = this,
  18717. browserEvent = me.browserEvent,
  18718. parentEvent = me.parentEvent;
  18719. if (me.mousedownEvents[me.type]) {
  18720. Ext.GlobalEvents.fireMouseDown(me);
  18721. }
  18722. if (me.mouseupEvents[me.type]) {
  18723. Ext.GlobalEvents.fireMouseUp(me);
  18724. }
  18725. me.stopped = true;
  18726. if (parentEvent && !me.isGesture) {
  18727. parentEvent.stopped = true;
  18728. }
  18729. if (!browserEvent.stopPropagation) {
  18730. browserEvent.cancelBubble = true;
  18731. return me;
  18732. }
  18733. browserEvent.stopPropagation();
  18734. return me;
  18735. },
  18736. claimGesture: function() {
  18737. var me = this,
  18738. parentEvent = me.parentEvent;
  18739. me.claimed = true;
  18740. if (parentEvent && !me.isGesture) {
  18741. parentEvent.claimGesture();
  18742. } else {
  18743. me.preventDefault();
  18744. }
  18745. return me;
  18746. },
  18747. within: function(el, related, allowEl) {
  18748. var t;
  18749. if (el) {
  18750. t = related ? this.getRelatedTarget() : this.getTarget();
  18751. }
  18752. if (!t || (allowEl === false && t === Ext.getDom(el))) {
  18753. return false;
  18754. }
  18755. return Ext.fly(el).contains(t);
  18756. },
  18757. privates: {
  18758. ieMimeType: {
  18759. "text/plain": 'Text'
  18760. }
  18761. },
  18762. deprecated: {
  18763. '4.0': {
  18764. methods: {
  18765. getPageX: 'getX',
  18766. getPageY: 'getY'
  18767. }
  18768. }
  18769. }
  18770. }, function(Event) {
  18771. var constants = {
  18772. BACKSPACE: 8,
  18773. TAB: 9,
  18774. NUM_CENTER: 12,
  18775. ENTER: 13,
  18776. RETURN: 13,
  18777. SHIFT: 16,
  18778. CTRL: 17,
  18779. ALT: 18,
  18780. PAUSE: 19,
  18781. CAPS_LOCK: 20,
  18782. ESC: 27,
  18783. SPACE: 32,
  18784. PAGE_UP: 33,
  18785. PAGE_DOWN: 34,
  18786. END: 35,
  18787. HOME: 36,
  18788. LEFT: 37,
  18789. UP: 38,
  18790. RIGHT: 39,
  18791. DOWN: 40,
  18792. PRINT_SCREEN: 44,
  18793. INSERT: 45,
  18794. DELETE: 46,
  18795. ZERO: 48,
  18796. ONE: 49,
  18797. TWO: 50,
  18798. THREE: 51,
  18799. FOUR: 52,
  18800. FIVE: 53,
  18801. SIX: 54,
  18802. SEVEN: 55,
  18803. EIGHT: 56,
  18804. NINE: 57,
  18805. A: 65,
  18806. B: 66,
  18807. C: 67,
  18808. D: 68,
  18809. E: 69,
  18810. F: 70,
  18811. G: 71,
  18812. H: 72,
  18813. I: 73,
  18814. J: 74,
  18815. K: 75,
  18816. L: 76,
  18817. M: 77,
  18818. N: 78,
  18819. O: 79,
  18820. P: 80,
  18821. Q: 81,
  18822. R: 82,
  18823. S: 83,
  18824. T: 84,
  18825. U: 85,
  18826. V: 86,
  18827. W: 87,
  18828. X: 88,
  18829. Y: 89,
  18830. Z: 90,
  18831. META: 91,
  18832. CONTEXT_MENU: 93,
  18833. NUM_ZERO: 96,
  18834. NUM_ONE: 97,
  18835. NUM_TWO: 98,
  18836. NUM_THREE: 99,
  18837. NUM_FOUR: 100,
  18838. NUM_FIVE: 101,
  18839. NUM_SIX: 102,
  18840. NUM_SEVEN: 103,
  18841. NUM_EIGHT: 104,
  18842. NUM_NINE: 105,
  18843. NUM_MULTIPLY: 106,
  18844. NUM_PLUS: 107,
  18845. NUM_MINUS: 109,
  18846. NUM_PERIOD: 110,
  18847. NUM_DIVISION: 111,
  18848. F1: 112,
  18849. F2: 113,
  18850. F3: 114,
  18851. F4: 115,
  18852. F5: 116,
  18853. F6: 117,
  18854. F7: 118,
  18855. F8: 119,
  18856. F9: 120,
  18857. F10: 121,
  18858. F11: 122,
  18859. F12: 123,
  18860. WHEEL_SCALE: 120
  18861. },
  18862. keyCodes = {},
  18863. gestureEvents = Event.gestureEvents,
  18864. prototype = Event.prototype,
  18865. i, keyName, keyCode, keys, s, scale;
  18866. if (Ext.isGecko) {
  18867. constants.WHEEL_SCALE = 3;
  18868. } else if (Ext.isMac) {
  18869. if (Ext.isSafari && Ext.webKitVersion >= 532) {
  18870. scale = 120;
  18871. } else {
  18872. scale = 12;
  18873. }
  18874. constants.WHEEL_SCALE = 3 * scale;
  18875. }
  18876. Ext.apply(gestureEvents, Event.mouseEvents);
  18877. Ext.apply(gestureEvents, Event.pointerEvents);
  18878. Ext.apply(gestureEvents, Event.touchEvents);
  18879. Ext.apply(Event, constants);
  18880. Ext.apply(prototype, constants);
  18881. delete constants.WHEEL_SCALE;
  18882. delete constants.RETURN;
  18883. for (keyName in constants) {
  18884. keyCode = constants[keyName];
  18885. keyCodes[keyCode] = keyName;
  18886. }
  18887. Event.keyCodes = prototype.keyCodes = keyCodes;
  18888. if (!Ext.isIE9m) {
  18889. document.addEventListener('keydown', Event.globalTabKeyDown, true);
  18890. document.addEventListener('keyup', Event.globalTabKeyUp, true);
  18891. }
  18892. prototype.getTrueXY = prototype.getXY;
  18893. if (typeof KeyboardEvent !== 'undefined' && !('key' in KeyboardEvent.prototype)) {
  18894. prototype._keys = keys = {
  18895. 3: 'Cancel',
  18896. 6: 'Help',
  18897. 8: 'Backspace',
  18898. 9: 'Tab',
  18899. 12: 'Clear',
  18900. 13: 'Enter',
  18901. 16: 'Shift',
  18902. 17: 'Control',
  18903. 18: 'Alt',
  18904. 19: 'Pause',
  18905. 20: 'CapsLock',
  18906. 27: 'Escape',
  18907. 28: 'Convert',
  18908. 29: 'NonConvert',
  18909. 30: 'Accept',
  18910. 31: 'ModeChange',
  18911. 32: ' ',
  18912. 33: 'PageUp',
  18913. 34: 'PageDown',
  18914. 35: 'End',
  18915. 36: 'Home',
  18916. 37: 'ArrowLeft',
  18917. 38: 'ArrowUp',
  18918. 39: 'ArrowRight',
  18919. 40: 'ArrowDown',
  18920. 41: 'Select',
  18921. 42: 'Print',
  18922. 43: 'Execute',
  18923. 44: 'PrintScreen',
  18924. 45: 'Insert',
  18925. 46: 'Delete',
  18926. 48: [
  18927. '0',
  18928. ')'
  18929. ],
  18930. 49: [
  18931. '1',
  18932. '!'
  18933. ],
  18934. 50: [
  18935. '2',
  18936. '@'
  18937. ],
  18938. 51: [
  18939. '3',
  18940. '#'
  18941. ],
  18942. 52: [
  18943. '4',
  18944. '$'
  18945. ],
  18946. 53: [
  18947. '5',
  18948. '%'
  18949. ],
  18950. 54: [
  18951. '6',
  18952. '^'
  18953. ],
  18954. 55: [
  18955. '7',
  18956. '&'
  18957. ],
  18958. 56: [
  18959. '8',
  18960. '*'
  18961. ],
  18962. 57: [
  18963. '9',
  18964. '('
  18965. ],
  18966. 91: 'OS',
  18967. 93: 'ContextMenu',
  18968. 144: 'NumLock',
  18969. 145: 'ScrollLock',
  18970. 181: 'VolumeMute',
  18971. 182: 'VolumeDown',
  18972. 183: 'VolumeUp',
  18973. 186: [
  18974. ';',
  18975. ':'
  18976. ],
  18977. 187: [
  18978. '=',
  18979. '+'
  18980. ],
  18981. 188: [
  18982. ',',
  18983. '<'
  18984. ],
  18985. 189: [
  18986. '-',
  18987. '_'
  18988. ],
  18989. 190: [
  18990. '.',
  18991. '>'
  18992. ],
  18993. 191: [
  18994. '/',
  18995. '?'
  18996. ],
  18997. 192: [
  18998. '`',
  18999. '~'
  19000. ],
  19001. 219: [
  19002. '[',
  19003. '{'
  19004. ],
  19005. 220: [
  19006. '\\',
  19007. '|'
  19008. ],
  19009. 221: [
  19010. ']',
  19011. '}'
  19012. ],
  19013. 222: [
  19014. "'",
  19015. '"'
  19016. ],
  19017. 224: 'Meta',
  19018. 225: 'AltGraph',
  19019. 246: 'Attn',
  19020. 247: 'CrSel',
  19021. 248: 'ExSel',
  19022. 249: 'EraseEof',
  19023. 250: 'Play',
  19024. 251: 'ZoomOut'
  19025. };
  19026. for (i = 1; i < 25; ++i) {
  19027. keys[i + 111] = 'F' + i;
  19028. }
  19029. for (i = 0; i < 26; ++i) {
  19030. keys[i] = [
  19031. String.fromCharCode(i + 97),
  19032. String.fromCharCode(i + 65)
  19033. ];
  19034. }
  19035. prototype.key = function() {
  19036. var k = keys[this.browserEvent.which || this.keyCode];
  19037. if (k && typeof k !== 'string') {
  19038. k = k[+this.shiftKey];
  19039. }
  19040. return k;
  19041. };
  19042. }
  19043. });
  19044. Ext.define('Ext.event.publisher.Dom', {
  19045. extend: Ext.event.publisher.Publisher,
  19046. type: 'dom',
  19047. handledDomEvents: [],
  19048. reEnterCount: 0,
  19049. captureEvents: {
  19050. animationstart: 1,
  19051. animationend: 1,
  19052. resize: 1,
  19053. focus: 1,
  19054. blur: 1
  19055. },
  19056. directEvents: {
  19057. mouseenter: 1,
  19058. mouseleave: 1,
  19059. pointerenter: 1,
  19060. pointerleave: 1,
  19061. MSPointerEnter: 1,
  19062. MSPointerLeave: 1,
  19063. load: 1,
  19064. unload: 1,
  19065. beforeunload: 1,
  19066. error: 1,
  19067. DOMContentLoaded: 1,
  19068. DOMFrameContentLoaded: 1,
  19069. hashchange: 1,
  19070. scroll: 1,
  19071. online: 1,
  19072. offline: 1
  19073. },
  19074. blockedPointerEvents: {
  19075. pointerover: 1,
  19076. pointerout: 1,
  19077. pointerenter: 1,
  19078. pointerleave: 1,
  19079. MSPointerOver: 1,
  19080. MSPointerOut: 1,
  19081. MSPointerEnter: 1,
  19082. MSPointerLeave: 1
  19083. },
  19084. blockedCompatibilityMouseEvents: {
  19085. mouseenter: 1,
  19086. mouseleave: 1
  19087. },
  19088. constructor: function() {
  19089. var me = this,
  19090. supportsPassive = Ext.supports.PassiveEventListener;
  19091. me.listenerOptions = supportsPassive ? {
  19092. passive: false
  19093. } : false;
  19094. me.captureOptions = supportsPassive ? {
  19095. passive: false,
  19096. capture: true
  19097. } : true;
  19098. me.bubbleSubscribers = {};
  19099. me.captureSubscribers = {};
  19100. me.directSubscribers = {};
  19101. me.directCaptureSubscribers = {};
  19102. me.delegatedListeners = {};
  19103. me.initHandlers();
  19104. Ext.onInternalReady(me.onReady, me);
  19105. me.callParent();
  19106. me.registerDomEvents();
  19107. },
  19108. registerDomEvents: function() {
  19109. var me = this,
  19110. publishersByEvent = Ext.event.publisher.Publisher.publishersByEvent,
  19111. domEvents = me.handledDomEvents,
  19112. ln = domEvents.length,
  19113. i, eventName;
  19114. for (i = 0; i < ln; i++) {
  19115. eventName = domEvents[i];
  19116. me.handles[eventName] = 1;
  19117. publishersByEvent[eventName] = me;
  19118. }
  19119. },
  19120. onReady: function() {
  19121. var me = this,
  19122. domEvents = me.handledDomEvents,
  19123. ln, i;
  19124. if (domEvents) {
  19125. for (i = 0 , ln = domEvents.length; i < ln; i++) {
  19126. me.addDelegatedListener(domEvents[i]);
  19127. }
  19128. }
  19129. Ext.getWin().on('unload', me.destroy, me, {
  19130. priority: -10000
  19131. });
  19132. },
  19133. initHandlers: function() {
  19134. var me = this;
  19135. me.onDelegatedEvent = Ext.bind(me.onDelegatedEvent, me);
  19136. me.onDirectEvent = Ext.bind(me.onDirectEvent, me);
  19137. me.onDirectCaptureEvent = Ext.bind(me.onDirectCaptureEvent, me);
  19138. },
  19139. addDelegatedListener: function(eventName) {
  19140. var me = this;
  19141. me.delegatedListeners[eventName] = 1;
  19142. me.target.addEventListener(eventName, me.onDelegatedEvent, me.captureEvents[eventName] ? me.captureOptions : me.listenerOptions);
  19143. },
  19144. removeDelegatedListener: function(eventName) {
  19145. var me = this;
  19146. delete me.delegatedListeners[eventName];
  19147. me.target.removeEventListener(eventName, me.onDelegatedEvent, me.captureEvents[eventName] ? me.captureOptions : me.listenerOptions);
  19148. },
  19149. addDirectListener: function(eventName, element, capture) {
  19150. var me = this;
  19151. element.dom.addEventListener(eventName, capture ? me.onDirectCaptureEvent : me.onDirectEvent, capture ? me.captureOptions : me.listenerOptions);
  19152. },
  19153. removeDirectListener: function(eventName, element, capture) {
  19154. var me = this;
  19155. element.dom.removeEventListener(eventName, capture ? me.onDirectCaptureEvent : me.onDirectEvent, capture ? me.captureOptions : me.listenerOptions);
  19156. },
  19157. subscribe: function(element, eventName, delegated, capture) {
  19158. var me = this,
  19159. subscribers, id;
  19160. if (delegated && !me.directEvents[eventName]) {
  19161. subscribers = capture ? me.captureSubscribers : me.bubbleSubscribers;
  19162. if (!me.handles[eventName] && !me.delegatedListeners[eventName]) {
  19163. me.addDelegatedListener(eventName);
  19164. }
  19165. if (subscribers[eventName]) {
  19166. ++subscribers[eventName];
  19167. } else {
  19168. subscribers[eventName] = 1;
  19169. }
  19170. } else {
  19171. subscribers = capture ? me.directCaptureSubscribers : me.directSubscribers;
  19172. id = element.id;
  19173. subscribers = subscribers[eventName] || (subscribers[eventName] = {});
  19174. if (subscribers[id]) {
  19175. ++subscribers[id];
  19176. } else {
  19177. subscribers[id] = 1;
  19178. me.addDirectListener(eventName, element, capture);
  19179. }
  19180. }
  19181. },
  19182. unsubscribe: function(element, eventName, delegated, capture) {
  19183. var me = this,
  19184. captureSubscribers, bubbleSubscribers, subscribers, id;
  19185. if (delegated && !me.directEvents[eventName]) {
  19186. captureSubscribers = me.captureSubscribers;
  19187. bubbleSubscribers = me.bubbleSubscribers;
  19188. subscribers = capture ? captureSubscribers : bubbleSubscribers;
  19189. if (subscribers[eventName]) {
  19190. --subscribers[eventName];
  19191. }
  19192. if (!me.handles[eventName] && !bubbleSubscribers[eventName] && !captureSubscribers[eventName]) {
  19193. this.removeDelegatedListener(eventName);
  19194. }
  19195. } else {
  19196. subscribers = capture ? me.directCaptureSubscribers : me.directSubscribers;
  19197. id = element.id;
  19198. subscribers = subscribers[eventName];
  19199. if (subscribers[id]) {
  19200. --subscribers[id];
  19201. }
  19202. if (!subscribers[id]) {
  19203. delete subscribers[id];
  19204. me.removeDirectListener(eventName, element, capture);
  19205. }
  19206. }
  19207. },
  19208. getPropagatingTargets: function(target) {
  19209. var currentNode = target,
  19210. targets = [],
  19211. parentNode;
  19212. while (currentNode) {
  19213. targets.push(currentNode);
  19214. parentNode = currentNode.parentNode;
  19215. if (!parentNode) {
  19216. parentNode = currentNode.defaultView;
  19217. }
  19218. currentNode = parentNode;
  19219. }
  19220. return targets;
  19221. },
  19222. publish: function(e, targets, claimed) {
  19223. var me = this,
  19224. hasCaptureSubscribers = false,
  19225. hasBubbleSubscribers = false,
  19226. events, type, target, el, i, ln, j, eLn;
  19227. claimed = claimed || false;
  19228. if (!targets) {
  19229. if (e instanceof Array) {
  19230. Ext.raise("Propagation targets must be supplied when publishing an array of events.");
  19231. }
  19232. target = e.target;
  19233. if (me.captureEvents[e.type]) {
  19234. el = Ext.cache[target.id];
  19235. targets = el ? [
  19236. el
  19237. ] : [];
  19238. } else {
  19239. targets = me.getPropagatingTargets(target);
  19240. }
  19241. }
  19242. events = Ext.Array.from(e);
  19243. ln = targets.length;
  19244. eLn = events.length;
  19245. for (i = 0; i < eLn; i++) {
  19246. type = events[i].type;
  19247. if (!hasCaptureSubscribers && me.captureSubscribers[type]) {
  19248. hasCaptureSubscribers = true;
  19249. }
  19250. if (!hasBubbleSubscribers && me.bubbleSubscribers[type]) {
  19251. hasBubbleSubscribers = true;
  19252. }
  19253. }
  19254. if (hasCaptureSubscribers) {
  19255. for (i = ln; i--; ) {
  19256. el = Ext.cache[targets[i].id];
  19257. if (el) {
  19258. for (j = 0; j < eLn; j++) {
  19259. e = events[j];
  19260. me.fire(el, e.type, e, false, true);
  19261. if (!claimed && e.claimed) {
  19262. claimed = true;
  19263. j = me.filterClaimed(events, e);
  19264. eLn = events.length;
  19265. }
  19266. if (e.stopped) {
  19267. events.splice(j, 1);
  19268. j--;
  19269. eLn--;
  19270. }
  19271. }
  19272. }
  19273. }
  19274. }
  19275. if (hasBubbleSubscribers && !e.stopped) {
  19276. for (i = 0; i < ln; i++) {
  19277. el = Ext.cache[targets[i].id];
  19278. if (el) {
  19279. for (j = 0; j < eLn; j++) {
  19280. e = events[j];
  19281. me.fire(el, e.type, e, false, false);
  19282. if (!claimed && e.claimed && me.filterClaimed) {
  19283. claimed = true;
  19284. j = me.filterClaimed(events, e);
  19285. eLn = events.length;
  19286. }
  19287. if (e.stopped) {
  19288. events.splice(j, 1);
  19289. j--;
  19290. eLn--;
  19291. }
  19292. }
  19293. }
  19294. }
  19295. }
  19296. },
  19297. publishDelegatedDomEvent: function(e) {
  19298. this.publish(e);
  19299. },
  19300. fire: function(element, eventName, e, direct, capture) {
  19301. var event;
  19302. if (element.hasListeners[eventName]) {
  19303. event = element.events[eventName];
  19304. if (event) {
  19305. if (capture && direct) {
  19306. event = event.directCaptures;
  19307. } else if (capture) {
  19308. event = event.captures;
  19309. } else if (direct) {
  19310. event = event.directs;
  19311. }
  19312. if (event) {
  19313. e.setCurrentTarget(element.dom);
  19314. event.fire(e, e.target);
  19315. }
  19316. }
  19317. }
  19318. },
  19319. onDelegatedEvent: function(e) {
  19320. if (Ext.elevateFunction) {
  19321. Ext.elevateFunction(this.doDelegatedEvent, this, [
  19322. e
  19323. ]);
  19324. } else {
  19325. this.doDelegatedEvent(e);
  19326. }
  19327. },
  19328. doDelegatedEvent: function(e) {
  19329. var me = this,
  19330. timeStamp;
  19331. e = new Ext.event.Event(e);
  19332. timeStamp = e.time;
  19333. if (!me.isEventBlocked(e)) {
  19334. me.beforeEvent(e);
  19335. Ext.frameStartTime = timeStamp;
  19336. me.reEnterCountAdjusted = false;
  19337. me.reEnterCount++;
  19338. me.publishDelegatedDomEvent(e);
  19339. if (!me.reEnterCountAdjusted) {
  19340. me.reEnterCount--;
  19341. }
  19342. me.afterEvent(e);
  19343. }
  19344. },
  19345. onDirectEvent: function(e) {
  19346. if (Ext.elevateFunction) {
  19347. Ext.elevateFunction(this.doDirectEvent, this, [
  19348. e,
  19349. false
  19350. ]);
  19351. } else {
  19352. this.doDirectEvent(e, false);
  19353. }
  19354. },
  19355. onDirectCaptureEvent: function(e) {
  19356. if (Ext.elevateFunction) {
  19357. Ext.elevateFunction(this.doDirectEvent, this, [
  19358. e,
  19359. true
  19360. ]);
  19361. } else {
  19362. this.doDirectEvent(e, true);
  19363. }
  19364. },
  19365. doDirectEvent: function(e, capture) {
  19366. var me = this,
  19367. currentTarget = e.currentTarget,
  19368. timeStamp, el;
  19369. e = new Ext.event.Event(e);
  19370. timeStamp = e.time;
  19371. if (me.isEventBlocked(e)) {
  19372. return;
  19373. }
  19374. me.beforeEvent(e);
  19375. Ext.frameStartTime = timeStamp;
  19376. el = Ext.cache[currentTarget.id];
  19377. if (el) {
  19378. me.reEnterCountAdjusted = false;
  19379. me.reEnterCount++;
  19380. me.fire(el, e.type, e, true, capture);
  19381. if (!me.reEnterCountAdjusted) {
  19382. me.reEnterCount--;
  19383. }
  19384. }
  19385. me.afterEvent(e);
  19386. },
  19387. beforeEvent: function(e) {
  19388. var browserEvent = e.browserEvent,
  19389. self = Ext.event.publisher.Dom,
  19390. touches, touch;
  19391. if (browserEvent.type === 'touchstart') {
  19392. touches = browserEvent.touches;
  19393. if (touches.length === 1) {
  19394. touch = touches[0];
  19395. self.lastTouchStartX = touch.pageX;
  19396. self.lastTouchStartY = touch.pageY;
  19397. }
  19398. }
  19399. },
  19400. afterEvent: function(e) {
  19401. var browserEvent = e.browserEvent,
  19402. type = browserEvent.type,
  19403. self = Ext.event.publisher.Dom,
  19404. GlobalEvents = Ext.GlobalEvents;
  19405. if (e.self.pointerEvents[type] && e.pointerType !== 'mouse') {
  19406. self.lastScreenPointerEventTime = Ext.now();
  19407. }
  19408. if (type === 'touchend') {
  19409. self.lastTouchEndTime = Ext.now();
  19410. }
  19411. if (!this.reEnterCount && !GlobalEvents.idleEventMask[type]) {
  19412. Ext.fireIdle();
  19413. }
  19414. },
  19415. isEventBlocked: function(e) {
  19416. var me = this,
  19417. type = e.type,
  19418. self = Ext.event.publisher.Dom,
  19419. now = Ext.now();
  19420. if (Ext.isGecko && e.type === 'click' && e.button === 2) {
  19421. return true;
  19422. }
  19423. return (me.blockedPointerEvents[type] && e.pointerType !== 'mouse') ||
  19424. (me.blockedCompatibilityMouseEvents[type] && (now - self.lastScreenPointerEventTime < 1000)) || (Ext.supports.TouchEvents && e.self.mouseEvents[e.type] &&
  19425. Math.abs(e.pageX - self.lastTouchStartX) < 15 && Math.abs(e.pageY - self.lastTouchStartY) < 15 &&
  19426. (Ext.now() - self.lastTouchEndTime) < 1000);
  19427. },
  19428. destroy: function() {
  19429. var GC = Ext.dom['GarbageCollector'],
  19430. eventName;
  19431. for (eventName in this.delegatedListeners) {
  19432. this.removeDelegatedListener(eventName);
  19433. }
  19434. Ext.Reaper.flush();
  19435. if (GC) {
  19436. GC.collect();
  19437. }
  19438. this.callParent();
  19439. },
  19440. reset: function() {
  19441. var self = Ext.event.publisher.Dom;
  19442. this.reEnterCount = 0;
  19443. self.lastScreenPointerEventTime = self.lastTouchEndTime = self.lastTouchStartX = self.lastTouchStartY = undefined;
  19444. }
  19445. }, function(Dom) {
  19446. var doc = document,
  19447. defaultView = doc.defaultView,
  19448. prototype = Dom.prototype;
  19449. if ((Ext.os.is.iOS && Ext.os.version.getMajor() < 5) || Ext.browser.is.AndroidStock || !(defaultView && defaultView.addEventListener)) {
  19450. prototype.target = doc;
  19451. } else {
  19452. prototype.target = defaultView;
  19453. }
  19454. Dom.instance = new Dom();
  19455. });
  19456. Ext.define('Ext.event.publisher.Gesture', {
  19457. extend: Ext.event.publisher.Dom,
  19458. type: 'gesture',
  19459. isCancelEvent: {
  19460. touchcancel: 1,
  19461. pointercancel: 1,
  19462. MSPointerCancel: 1
  19463. },
  19464. isEndEvent: {
  19465. mouseup: 1,
  19466. touchend: 1,
  19467. pointerup: 1,
  19468. MSPointerUp: 1
  19469. },
  19470. handledEvents: [],
  19471. handledDomEvents: [],
  19472. constructor: function(config) {
  19473. var me = this,
  19474. handledDomEvents = me.handledDomEvents,
  19475. supports = Ext.supports,
  19476. supportsTouchEvents = supports.TouchEvents,
  19477. onTouchStart = me.onTouchStart,
  19478. onTouchMove = me.onTouchMove,
  19479. onTouchEnd = me.onTouchEnd;
  19480. me.handlers = {
  19481. touchstart: onTouchStart,
  19482. touchmove: onTouchMove,
  19483. touchend: onTouchEnd,
  19484. touchcancel: onTouchEnd,
  19485. pointerdown: onTouchStart,
  19486. pointermove: onTouchMove,
  19487. pointerup: onTouchEnd,
  19488. pointercancel: onTouchEnd,
  19489. MSPointerDown: onTouchStart,
  19490. MSPointerMove: onTouchMove,
  19491. MSPointerUp: onTouchEnd,
  19492. MSPointerCancel: onTouchEnd,
  19493. mousedown: onTouchStart,
  19494. mousemove: onTouchMove,
  19495. mouseup: onTouchEnd
  19496. };
  19497. me.activeTouchesMap = {};
  19498. me.activeTouches = [];
  19499. me.changedTouches = [];
  19500. me.recognizers = [];
  19501. me.eventToRecognizer = {};
  19502. me.cancelEvents = [];
  19503. if (supportsTouchEvents) {
  19504. me.onTargetTouchMove = me.onTargetTouchMove.bind(me);
  19505. me.onTargetTouchEnd = me.onTargetTouchEnd.bind(me);
  19506. }
  19507. if (supports.PointerEvents) {
  19508. handledDomEvents.push('pointerdown', 'pointermove', 'pointerup', 'pointercancel');
  19509. me.mousePointerType = 'mouse';
  19510. } else if (supports.MSPointerEvents) {
  19511. handledDomEvents.push('MSPointerDown', 'MSPointerMove', 'MSPointerUp', 'MSPointerCancel');
  19512. me.mousePointerType = 4;
  19513. } else if (supportsTouchEvents) {
  19514. handledDomEvents.push('touchstart', 'touchmove', 'touchend', 'touchcancel');
  19515. }
  19516. if (!handledDomEvents.length || (supportsTouchEvents && Ext.os.is.Desktop)) {
  19517. handledDomEvents.push('mousedown', 'mousemove', 'mouseup');
  19518. }
  19519. me.initConfig(config);
  19520. return me.callParent();
  19521. },
  19522. onReady: function() {
  19523. this.callParent();
  19524. Ext.Array.sort(this.recognizers, function(recognizerA, recognizerB) {
  19525. var a = recognizerA.priority,
  19526. b = recognizerB.priority;
  19527. return (a > b) ? 1 : (a < b) ? -1 : 0;
  19528. });
  19529. },
  19530. registerRecognizer: function(recognizer) {
  19531. var me = this,
  19532. handledEvents = recognizer.handledEvents,
  19533. ln = handledEvents.length,
  19534. eventName, i;
  19535. recognizer.setOnRecognized(me.onRecognized);
  19536. recognizer.setCallbackScope(me);
  19537. for (i = 0; i < ln; i++) {
  19538. eventName = handledEvents[i];
  19539. me.handledEvents.push(eventName);
  19540. me.eventToRecognizer[eventName] = recognizer;
  19541. }
  19542. me.registerEvents(handledEvents);
  19543. me.recognizers.push(recognizer);
  19544. },
  19545. onRecognized: function(recognizer, eventName, e, info, isCancel) {
  19546. var me = this,
  19547. touches = e.touches,
  19548. changedTouches = e.changedTouches,
  19549. ln = changedTouches.length,
  19550. events = me.events,
  19551. queueWasEmpty = !events.length,
  19552. cancelEvents = me.cancelEvents,
  19553. targetGroups, targets, i, touch;
  19554. info = info || {};
  19555. info.type = eventName;
  19556. info.target = changedTouches[0].target;
  19557. info.stopped = false;
  19558. info.claimed = false;
  19559. info.isGesture = true;
  19560. e = e.chain(info);
  19561. if (!me.gestureTargets) {
  19562. if (ln > 1) {
  19563. targetGroups = [];
  19564. for (i = 0; i < ln; i++) {
  19565. touch = changedTouches[i];
  19566. targetGroups.push(touch.targets);
  19567. }
  19568. targets = me.getCommonTargets(targetGroups);
  19569. } else {
  19570. targets = changedTouches[0].targets;
  19571. }
  19572. me.gestureTargets = targets;
  19573. }
  19574. if (isCancel && recognizer.isSingleTouch && (touches.length > 1)) {
  19575. e.target = touches[0].target;
  19576. cancelEvents.push(e);
  19577. } else {
  19578. events.push(e);
  19579. }
  19580. if (queueWasEmpty) {
  19581. me.publishGestures();
  19582. }
  19583. },
  19584. getCommonTargets: function(targetGroups) {
  19585. var firstTargetGroup = targetGroups[0],
  19586. ln = targetGroups.length;
  19587. if (ln === 1) {
  19588. return firstTargetGroup;
  19589. }
  19590. var commonTargets = [],
  19591. i = 1,
  19592. target, targets, j;
  19593. while (true) {
  19594. target = firstTargetGroup[firstTargetGroup.length - i];
  19595. if (!target) {
  19596. return commonTargets;
  19597. }
  19598. for (j = 1; j < ln; j++) {
  19599. targets = targetGroups[j];
  19600. if (targets[targets.length - i] !== target) {
  19601. return commonTargets;
  19602. }
  19603. }
  19604. commonTargets.unshift(target);
  19605. i++;
  19606. }
  19607. return commonTargets;
  19608. },
  19609. invokeRecognizers: function(methodName, e) {
  19610. var recognizers = this.recognizers,
  19611. ln = recognizers.length,
  19612. i, recognizer;
  19613. if (methodName === 'onStart') {
  19614. for (i = 0; i < ln; i++) {
  19615. recognizers[i].isActive = true;
  19616. }
  19617. }
  19618. for (i = 0; i < ln; i++) {
  19619. recognizer = recognizers[i];
  19620. if (recognizer.isActive && recognizer[methodName].call(recognizer, e) === false) {
  19621. recognizer.isActive = false;
  19622. }
  19623. }
  19624. },
  19625. filterClaimed: function(events, claimedEvent) {
  19626. var me = this,
  19627. eventToRecognizer = me.eventToRecognizer,
  19628. claimedEventType = claimedEvent.type,
  19629. claimedRecognizer = eventToRecognizer[claimedEventType],
  19630. claimedEventIndex, recognizer, type, i;
  19631. for (i = events.length; i--; ) {
  19632. type = events[i].type;
  19633. if (type === claimedEventType) {
  19634. claimedEventIndex = i;
  19635. } else {
  19636. recognizer = eventToRecognizer[type];
  19637. if (!claimedRecognizer || (recognizer && (recognizer !== claimedRecognizer))) {
  19638. events.splice(i, 1);
  19639. if (claimedEventIndex) {
  19640. claimedEventIndex--;
  19641. }
  19642. }
  19643. }
  19644. }
  19645. me.claimRecognizer(claimedRecognizer, events[0]);
  19646. return claimedEventIndex;
  19647. },
  19648. claimRecognizer: function(claimedRecognizer, e) {
  19649. var me = this,
  19650. recognizers = me.recognizers,
  19651. i, ln, recognizer;
  19652. for (i = 0 , ln = recognizers.length; i < ln; i++) {
  19653. recognizer = recognizers[i];
  19654. if (recognizer !== claimedRecognizer) {
  19655. recognizer.isActive = false;
  19656. recognizer.cancel(e);
  19657. }
  19658. }
  19659. if (me.events.length) {
  19660. me.publishGestures(true);
  19661. }
  19662. },
  19663. publishGestures: function(claimed) {
  19664. var me = this,
  19665. cancelEvents = me.cancelEvents,
  19666. events = me.events,
  19667. gestureTargets = me.gestureTargets;
  19668. if (cancelEvents.length) {
  19669. me.cancelEvents = [];
  19670. me.publish(cancelEvents, me.getPropagatingTargets(cancelEvents[0].target), true);
  19671. }
  19672. if (events.length) {
  19673. me.events = [];
  19674. me.gestureTargets = null;
  19675. me.publish(events, gestureTargets || me.getPropagatingTargets(events[0].target), claimed);
  19676. }
  19677. },
  19678. updateTouches: function(e) {
  19679. var me = this,
  19680. browserEvent = e.browserEvent,
  19681. type = e.type,
  19682. touchSources = browserEvent.changedTouches || [
  19683. browserEvent
  19684. ],
  19685. activeTouches = me.activeTouches,
  19686. activeTouchesMap = me.activeTouchesMap,
  19687. changedTouches = [],
  19688. touchSource, identifier, touch, target, i, ln, x, y;
  19689. for (i = 0 , ln = touchSources.length; i < ln; i++) {
  19690. touchSource = touchSources[i];
  19691. if ('identifier' in touchSource) {
  19692. identifier = touchSource.identifier;
  19693. } else if ('pointerId' in touchSource) {
  19694. identifier = touchSource.pointerId;
  19695. } else {
  19696. identifier = 1;
  19697. }
  19698. touch = activeTouchesMap[identifier];
  19699. if (!touch) {
  19700. target = Ext.event.Event.resolveTextNode(touchSource.target);
  19701. touch = activeTouchesMap[identifier] = {
  19702. identifier: identifier,
  19703. target: target,
  19704. targets: me.getPropagatingTargets(target)
  19705. };
  19706. activeTouches.push(touch);
  19707. }
  19708. if (me.isEndEvent[type] || me.isCancelEvent[type]) {
  19709. delete activeTouchesMap[identifier];
  19710. Ext.Array.remove(activeTouches, touch);
  19711. }
  19712. x = touchSource.pageX;
  19713. y = touchSource.pageY;
  19714. touch.pageX = x;
  19715. touch.pageY = y;
  19716. touch.point = new Ext.util.Point(x, y);
  19717. changedTouches.push(touch);
  19718. }
  19719. e.touches = Ext.Array.clone(activeTouches);
  19720. e.changedTouches = changedTouches;
  19721. },
  19722. publishDelegatedDomEvent: function(e) {
  19723. var me = this;
  19724. if (!e.button || e.button < 1) {
  19725. me.events = [
  19726. e
  19727. ];
  19728. e.browserEvent.$extHandled = true;
  19729. me.handlers[e.type].call(me, e);
  19730. } else {
  19731. me.callParent([
  19732. e
  19733. ]);
  19734. }
  19735. },
  19736. onTouchStart: function(e) {
  19737. var me = this,
  19738. target = e.target,
  19739. touches = e.browserEvent.touches;
  19740. if (e.browserEvent.type === 'touchstart') {
  19741. target.addEventListener('touchmove', me.onTargetTouchMove);
  19742. target.addEventListener('touchend', me.onTargetTouchEnd);
  19743. target.addEventListener('touchcancel', me.onTargetTouchEnd);
  19744. }
  19745. if (touches && touches.length <= me.activeTouches.length) {
  19746. me.removeGhostTouches(touches);
  19747. }
  19748. me.updateTouches(e);
  19749. if (!me.isStarted) {
  19750. if (Ext.enableGarbageCollector) {
  19751. Ext.dom.GarbageCollector.pause();
  19752. }
  19753. me.isStarted = true;
  19754. me.invokeRecognizers('onStart', e);
  19755. }
  19756. me.invokeRecognizers('onTouchStart', e);
  19757. me.publishGestures();
  19758. },
  19759. onTouchMove: function(e) {
  19760. var me = this,
  19761. mousePointerType = me.mousePointerType,
  19762. isStarted = me.isStarted;
  19763. if (isStarted || (e.pointerType !== 'mouse')) {
  19764. me.updateTouches(e);
  19765. }
  19766. if (isStarted) {
  19767. if (mousePointerType && e.browserEvent.pointerType === mousePointerType && e.buttons === 0) {
  19768. e.type = Ext.dom.Element.prototype.eventMap.touchend;
  19769. e.button = 0;
  19770. me.onTouchEnd(e);
  19771. return;
  19772. }
  19773. if (e.changedTouches.length > 0) {
  19774. me.invokeRecognizers('onTouchMove', e);
  19775. }
  19776. }
  19777. me.publishGestures();
  19778. },
  19779. onTouchEnd: function(e) {
  19780. var me = this,
  19781. isStarted = me.isStarted,
  19782. touchCount;
  19783. if (isStarted || (e.pointerType !== 'mouse')) {
  19784. me.updateTouches(e);
  19785. }
  19786. if (!isStarted) {
  19787. me.publishGestures();
  19788. return;
  19789. }
  19790. touchCount = me.activeTouches.length;
  19791. try {
  19792. me.invokeRecognizers(me.isCancelEvent[e.type] ? 'onTouchCancel' : 'onTouchEnd', e);
  19793. } finally {
  19794. try {
  19795. if (!touchCount) {
  19796. me.isStarted = false;
  19797. me.invokeRecognizers('onEnd', e);
  19798. }
  19799. } finally {
  19800. try {
  19801. me.publishGestures();
  19802. } finally {
  19803. if (!touchCount) {
  19804. if (Ext.enableGarbageCollector) {
  19805. Ext.dom.GarbageCollector.resume();
  19806. }
  19807. }
  19808. me.reEnterCountAdjusted = true;
  19809. me.reEnterCount--;
  19810. }
  19811. }
  19812. }
  19813. },
  19814. onTargetTouchMove: function(e) {
  19815. if (Ext.elevateFunction) {
  19816. Ext.elevateFunction(this.doTargetTouchMove, this, [
  19817. e
  19818. ]);
  19819. } else {
  19820. this.doTargetTouchMove(e);
  19821. }
  19822. },
  19823. doTargetTouchMove: function(e) {
  19824. var me = this;
  19825. if (!Ext.getBody().contains(e.target)) {
  19826. me.reEnterCountAdjusted = false;
  19827. me.reEnterCount++;
  19828. this.onTouchMove(new Ext.event.Event(e));
  19829. if (!me.reEnterCountAdjusted) {
  19830. me.reEnterCount--;
  19831. }
  19832. }
  19833. },
  19834. onTargetTouchEnd: function(e) {
  19835. if (Ext.elevateFunction) {
  19836. Ext.elevateFunction(this.doTargetTouchEnd, this, [
  19837. e
  19838. ]);
  19839. } else {
  19840. this.doTargetTouchEnd(e);
  19841. }
  19842. },
  19843. doTargetTouchEnd: function(e) {
  19844. var me = this,
  19845. target = e.target;
  19846. target.removeEventListener('touchmove', me.onTargetTouchMove);
  19847. target.removeEventListener('touchend', me.onTargetTouchEnd);
  19848. target.removeEventListener('touchcancel', me.onTargetTouchEnd);
  19849. if (!Ext.getBody().contains(target)) {
  19850. me.reEnterCountAdjusted = false;
  19851. me.reEnterCount++;
  19852. me.onTouchEnd(new Ext.event.Event(e));
  19853. if (!me.reEnterCountAdjusted) {
  19854. me.reEnterCount--;
  19855. }
  19856. }
  19857. },
  19858. reset: function() {
  19859. var me = this,
  19860. recognizers = me.recognizers,
  19861. ln = recognizers.length,
  19862. i, recognizer;
  19863. me.activeTouchesMap = {};
  19864. me.activeTouches = [];
  19865. me.changedTouches = [];
  19866. me.isStarted = false;
  19867. me.gestureTargets = null;
  19868. me.events = [];
  19869. me.cancelEvents = [];
  19870. for (i = 0; i < ln; i++) {
  19871. recognizer = recognizers[i];
  19872. recognizer.reset();
  19873. recognizer.isActive = false;
  19874. }
  19875. this.callParent();
  19876. },
  19877. privates: {
  19878. removeGhostTouches: function(touches) {
  19879. var ids = {},
  19880. len = touches.length,
  19881. activeTouches = this.activeTouches,
  19882. map = this.activeTouchesMap,
  19883. i, id, touch;
  19884. for (i = 0; i < len; ++i) {
  19885. ids[touches[i].identifier] = true;
  19886. }
  19887. i = activeTouches.length;
  19888. while (i--) {
  19889. touch = activeTouches[i];
  19890. id = touch.identifier;
  19891. if (!touches[id]) {
  19892. Ext.Array.remove(activeTouches, touch);
  19893. delete map[id];
  19894. }
  19895. }
  19896. }
  19897. }
  19898. }, function(Gesture) {
  19899. var EventProto = Event.prototype,
  19900. stopPropagation = EventProto.stopPropagation;
  19901. if (stopPropagation) {
  19902. EventProto.stopPropagation = function() {
  19903. var me = this,
  19904. publisher = Gesture.instance,
  19905. type = me.type,
  19906. e;
  19907. if (!me.$extHandled && publisher.handles[type]) {
  19908. e = new Ext.event.Event(me);
  19909. publisher.updateTouches(e);
  19910. publisher.invokeRecognizers('onTouchCancel', e);
  19911. publisher.reset();
  19912. publisher.reEnterCountAdjusted = true;
  19913. }
  19914. stopPropagation.apply(me, arguments);
  19915. };
  19916. }
  19917. Gesture.instance = Ext.$gesturePublisher = new Gesture();
  19918. });
  19919. Ext.define('Ext.mixin.Templatable', {
  19920. extend: Ext.Mixin,
  19921. mixinConfig: {
  19922. id: 'templatable'
  19923. },
  19924. referenceAttributeName: 'reference',
  19925. referenceSelector: '[reference]',
  19926. getElementConfig: function() {
  19927. return {
  19928. reference: 'element'
  19929. };
  19930. },
  19931. getElementTemplate: function() {
  19932. var elementTemplate = document.createDocumentFragment();
  19933. elementTemplate.appendChild(Ext.Element.create(this.getElementConfig(), true));
  19934. return elementTemplate;
  19935. },
  19936. initElement: function() {
  19937. var prototype = this.self.prototype;
  19938. prototype.elementTemplate = this.getElementTemplate();
  19939. prototype.initElement = prototype.doInitElement;
  19940. this.initElement.apply(this, arguments);
  19941. },
  19942. linkElement: function(reference, node) {
  19943. this.link(reference, node);
  19944. },
  19945. doInitElement: function() {
  19946. var referenceAttributeName = this.referenceAttributeName,
  19947. renderElement, referenceNodes, i, ln, referenceNode, reference;
  19948. renderElement = this.elementTemplate.cloneNode(true);
  19949. referenceNodes = renderElement.querySelectorAll(this.referenceSelector);
  19950. for (i = 0 , ln = referenceNodes.length; i < ln; i++) {
  19951. referenceNode = referenceNodes[i];
  19952. reference = referenceNode.getAttribute(referenceAttributeName);
  19953. referenceNode.removeAttribute(referenceAttributeName);
  19954. this.linkElement(reference, referenceNode);
  19955. }
  19956. }
  19957. });
  19958. Ext.define('Ext.TaskQueue', {
  19959. singleton: true,
  19960. pending: false,
  19961. mode: true,
  19962. protectedReadQueue: [],
  19963. protectedWriteQueue: [],
  19964. readQueue: [],
  19965. writeQueue: [],
  19966. readRequestId: 0,
  19967. writeRequestId: 0,
  19968. timer: null,
  19969. constructor: function() {
  19970. var me = this;
  19971. me.run = me.run.bind(me);
  19972. me.runProtected = Ext.Function.bind(me.run, me, [
  19973. me.protectedReadQueue,
  19974. me.protectedWriteQueue,
  19975. 'runProtected'
  19976. ]);
  19977. me.runProtected.$skipTimerCheck = true;
  19978. if (Ext.os.is.iOS) {
  19979. me.watch.$skipTimerCheck = true;
  19980. me.watchdogTimer = Ext.interval(this.watch, 500, this);
  19981. }
  19982. },
  19983. requestRead: function(fn, scope, args) {
  19984. var request = {
  19985. id: ++this.readRequestId,
  19986. fn: fn,
  19987. scope: scope,
  19988. args: args
  19989. };
  19990. if (arguments[3] === true) {
  19991. this.protectedReadQueue.push(request);
  19992. this.request(true, 'runProtected');
  19993. } else {
  19994. this.readQueue.push(request);
  19995. this.request(true);
  19996. }
  19997. return request.id;
  19998. },
  19999. cancelRead: function(id) {
  20000. this.cancelRequest(this.readQueue, id, true);
  20001. },
  20002. requestWrite: function(fn, scope, args) {
  20003. var me = this,
  20004. request = {
  20005. id: ++me.writeRequestId,
  20006. fn: fn,
  20007. scope: scope,
  20008. args: args
  20009. };
  20010. if (arguments[3] === true) {
  20011. me.protectedWriteQueue.push(request);
  20012. me.request(false, 'runProtected');
  20013. } else {
  20014. me.writeQueue.push(request);
  20015. me.request(false);
  20016. }
  20017. return request.id;
  20018. },
  20019. cancelWrite: function(id) {
  20020. this.cancelRequest(this.writeQueue, id, false);
  20021. },
  20022. request: function(mode, method) {
  20023. var me = this;
  20024. var oldMode = me.mode;
  20025. if (!me.pending) {
  20026. me.pendingTime = Date.now();
  20027. me.pending = true;
  20028. me.mode = mode;
  20029. if (mode) {
  20030. me.timer = Ext.defer(me[method] || me.run, 1);
  20031. } else {
  20032. me.timer = Ext.raf(me[method] || me.run);
  20033. }
  20034. }
  20035. if (me.mode === mode && me.timer) {
  20036. if (oldMode) {
  20037. Ext.undefer(me.timer);
  20038. } else {
  20039. Ext.unraf(me.timer);
  20040. }
  20041. if (mode) {
  20042. me.timer = Ext.defer(me[method] || me.run, 1);
  20043. } else {
  20044. me.timer = Ext.raf(me[method] || me.run);
  20045. }
  20046. }
  20047. },
  20048. cancelRequest: function(queue, id, mode) {
  20049. for (var i = 0; i < queue.length; i++) {
  20050. if (queue[i].id === id) {
  20051. queue.splice(i, 1);
  20052. break;
  20053. }
  20054. }
  20055. if (!queue.length && this.mode === mode && this.timer) {
  20056. Ext.undefer(this.timer);
  20057. }
  20058. },
  20059. watch: function() {
  20060. if (this.pending && Date.now() - this.pendingTime >= 500) {
  20061. this.run();
  20062. }
  20063. },
  20064. run: function(readQueue, writeQueue, method) {
  20065. var me = this,
  20066. mode = null,
  20067. queue, tasks, task, fn, scope, args, i, len;
  20068. readQueue = readQueue || me.readQueue;
  20069. writeQueue = writeQueue || me.writeQueue;
  20070. me.pending = false;
  20071. me.pending = me.timer = false;
  20072. if (me.mode) {
  20073. queue = readQueue;
  20074. if (writeQueue.length > 0) {
  20075. mode = false;
  20076. }
  20077. } else {
  20078. queue = writeQueue;
  20079. if (readQueue.length > 0) {
  20080. mode = true;
  20081. }
  20082. }
  20083. tasks = queue.slice();
  20084. queue.length = 0;
  20085. for (i = 0 , len = tasks.length; i < len; i++) {
  20086. task = tasks[i];
  20087. fn = task.fn;
  20088. scope = task.scope;
  20089. args = task.args;
  20090. if (scope && (scope.destroying || scope.destroyed)) {
  20091. continue;
  20092. }
  20093. if (typeof fn === 'string') {
  20094. fn = scope[fn];
  20095. }
  20096. if (args) {
  20097. fn.apply(scope, args);
  20098. } else {
  20099. fn.call(scope);
  20100. }
  20101. }
  20102. tasks.length = 0;
  20103. if (mode !== null) {
  20104. me.request(mode, method);
  20105. }
  20106. },
  20107. clear: function() {
  20108. var me = this,
  20109. timer = me.timer;
  20110. if (timer) {
  20111. if (me.mode) {
  20112. Ext.undefer(timer);
  20113. } else {
  20114. Ext.unraf(timer);
  20115. }
  20116. }
  20117. me.readQueue.length = me.writeQueue.length = 0;
  20118. me.pending = me.timer = false;
  20119. me.mode = true;
  20120. },
  20121. privates: {
  20122. flush: function() {
  20123. var me = this,
  20124. mode = me.mode;
  20125. while (me.readQueue.length || me.writeQueue.length) {
  20126. if (mode) {
  20127. Ext.undefer(me.timer);
  20128. } else {
  20129. Ext.unraf(me.timer);
  20130. }
  20131. me.run();
  20132. }
  20133. me.mode = true;
  20134. }
  20135. }
  20136. });
  20137. Ext.define('Ext.util.sizemonitor.Abstract', {
  20138. mixins: [
  20139. Ext.mixin.Templatable
  20140. ],
  20141. config: {
  20142. element: null,
  20143. callback: Ext.emptyFn,
  20144. scope: null,
  20145. args: []
  20146. },
  20147. width: null,
  20148. height: null,
  20149. contentWidth: null,
  20150. contentHeight: null,
  20151. constructor: function(config) {
  20152. var me = this;
  20153. me.refresh = me.refresh.bind(me);
  20154. me.info = {
  20155. width: 0,
  20156. height: 0,
  20157. contentWidth: 0,
  20158. contentHeight: 0,
  20159. flag: 0
  20160. };
  20161. me.initElement();
  20162. me.initConfig(config);
  20163. me.bindListeners(true);
  20164. },
  20165. bindListeners: Ext.emptyFn,
  20166. applyElement: function(element) {
  20167. if (element) {
  20168. return Ext.get(element);
  20169. }
  20170. },
  20171. updateElement: function(element) {
  20172. element.append(this.detectorsContainer, true);
  20173. element.addCls(Ext.baseCSSPrefix + 'size-monitored');
  20174. },
  20175. applyArgs: function(args) {
  20176. return args.concat([
  20177. this.info
  20178. ]);
  20179. },
  20180. refreshMonitors: Ext.emptyFn,
  20181. forceRefresh: function() {
  20182. Ext.TaskQueue.requestRead('refresh', this);
  20183. },
  20184. getContentBounds: function() {
  20185. return this.detectorsContainer.getBoundingClientRect();
  20186. },
  20187. getContentWidth: function() {
  20188. return this.detectorsContainer.clientWidth;
  20189. },
  20190. getContentHeight: function() {
  20191. return this.detectorsContainer.clientHeight;
  20192. },
  20193. refreshSize: function() {
  20194. var element = this.getElement();
  20195. if (!element || element.destroyed) {
  20196. return false;
  20197. }
  20198. var me = this,
  20199. size = element.measure(),
  20200. width = size.width,
  20201. height = size.height,
  20202. contentWidth = me.getContentWidth(),
  20203. contentHeight = me.getContentHeight(),
  20204. currentContentWidth = me.contentWidth,
  20205. currentContentHeight = me.contentHeight,
  20206. info = me.info,
  20207. resized = false,
  20208. flag;
  20209. me.width = width;
  20210. me.height = height;
  20211. me.contentWidth = contentWidth;
  20212. me.contentHeight = contentHeight;
  20213. flag = ((currentContentWidth !== contentWidth ? 1 : 0) + (currentContentHeight !== contentHeight ? 2 : 0));
  20214. if (flag > 0) {
  20215. info.width = width;
  20216. info.height = height;
  20217. info.contentWidth = contentWidth;
  20218. info.contentHeight = contentHeight;
  20219. info.flag = flag;
  20220. resized = true;
  20221. me.getCallback().apply(me.getScope(), me.getArgs());
  20222. }
  20223. return resized;
  20224. },
  20225. refresh: function() {
  20226. if (this.destroying || this.destroyed) {
  20227. return;
  20228. }
  20229. this.refreshSize();
  20230. Ext.TaskQueue.requestWrite('refreshMonitors', this);
  20231. },
  20232. destroy: function() {
  20233. var me = this,
  20234. element = me.getElement();
  20235. me.bindListeners(false);
  20236. if (element && !element.destroyed) {
  20237. element.removeCls(Ext.baseCSSPrefix + 'size-monitored');
  20238. }
  20239. delete me._element;
  20240. me.refresh = null;
  20241. me.callParent();
  20242. }
  20243. });
  20244. Ext.define('Ext.util.sizemonitor.Scroll', {
  20245. extend: Ext.util.sizemonitor.Abstract,
  20246. getElementConfig: function() {
  20247. return {
  20248. reference: 'detectorsContainer',
  20249. classList: [
  20250. Ext.baseCSSPrefix + 'size-monitors',
  20251. 'scroll'
  20252. ],
  20253. children: [
  20254. {
  20255. reference: 'expandMonitor',
  20256. className: 'expand'
  20257. },
  20258. {
  20259. reference: 'shrinkMonitor',
  20260. className: 'shrink'
  20261. }
  20262. ]
  20263. };
  20264. },
  20265. constructor: function(config) {
  20266. this.onScroll = this.onScroll.bind(this);
  20267. this.callParent(arguments);
  20268. },
  20269. bindListeners: function(bind) {
  20270. var method = bind ? 'addEventListener' : 'removeEventListener';
  20271. this.expandMonitor[method]('scroll', this.onScroll, true);
  20272. this.shrinkMonitor[method]('scroll', this.onScroll, true);
  20273. },
  20274. onScroll: function() {
  20275. if (!this.destroyed) {
  20276. Ext.TaskQueue.requestRead('refresh', this);
  20277. }
  20278. },
  20279. refreshMonitors: function() {
  20280. var expandMonitor = this.expandMonitor,
  20281. shrinkMonitor = this.shrinkMonitor,
  20282. end = 1000000;
  20283. if (expandMonitor && !expandMonitor.destroyed) {
  20284. expandMonitor.scrollLeft = end;
  20285. expandMonitor.scrollTop = end;
  20286. }
  20287. if (shrinkMonitor && !shrinkMonitor.destroyed) {
  20288. shrinkMonitor.scrollLeft = end;
  20289. shrinkMonitor.scrollTop = end;
  20290. }
  20291. },
  20292. destroy: function() {
  20293. this.onScroll = null;
  20294. this.callParent();
  20295. }
  20296. });
  20297. Ext.define('Ext.util.SizeMonitor', {
  20298. constructor: function(config) {
  20299. return new Ext.util.sizemonitor.Scroll(config);
  20300. }
  20301. });
  20302. Ext.define('Ext.event.publisher.ElementSize', {
  20303. extend: Ext.event.publisher.Publisher,
  20304. type: 'size',
  20305. handledEvents: [
  20306. 'resize'
  20307. ],
  20308. constructor: function() {
  20309. this.monitors = {};
  20310. this.subscribers = {};
  20311. this.callParent(arguments);
  20312. },
  20313. subscribe: function(element) {
  20314. var id = element.id,
  20315. subscribers = this.subscribers,
  20316. monitors = this.monitors;
  20317. if (subscribers[id]) {
  20318. ++subscribers[id];
  20319. } else {
  20320. subscribers[id] = 1;
  20321. monitors[id] = new Ext.util.SizeMonitor({
  20322. element: element,
  20323. callback: this.onElementResize,
  20324. scope: this,
  20325. args: [
  20326. element
  20327. ]
  20328. });
  20329. }
  20330. element.on('painted', 'forceRefresh', monitors[id]);
  20331. return true;
  20332. },
  20333. unsubscribe: function(element) {
  20334. var id = element.id,
  20335. subscribers = this.subscribers,
  20336. monitors = this.monitors,
  20337. sizeMonitor;
  20338. if (subscribers[id] && !--subscribers[id]) {
  20339. delete subscribers[id];
  20340. sizeMonitor = monitors[id];
  20341. element.un('painted', 'forceRefresh', sizeMonitor);
  20342. sizeMonitor.destroy();
  20343. delete monitors[id];
  20344. }
  20345. if (element.activeRead) {
  20346. Ext.TaskQueue.cancelRead(element.activeRead);
  20347. }
  20348. },
  20349. fireElementResize: function(element, info) {
  20350. delete element.activeRead;
  20351. this.fire(element, 'resize', [
  20352. element,
  20353. info
  20354. ]);
  20355. },
  20356. onElementResize: function(element, info) {
  20357. if (!element.activeRead) {
  20358. element.activeRead = Ext.TaskQueue.requestRead('fireElementResize', this, [
  20359. element,
  20360. info
  20361. ],
  20362. !!element.$skipResourceCheck);
  20363. }
  20364. },
  20365. privates: {
  20366. syncRefresh: function(elements) {
  20367. elements = Ext.Array.from(elements);
  20368. var len = elements.length,
  20369. i = 0,
  20370. el, monitor;
  20371. for (i = 0; i < len; ++i) {
  20372. el = elements[i];
  20373. if (typeof el !== 'string') {
  20374. el = el.id;
  20375. }
  20376. monitor = this.monitors[el];
  20377. if (monitor) {
  20378. monitor.forceRefresh();
  20379. }
  20380. }
  20381. Ext.TaskQueue.flush();
  20382. Ext.Function.fireElevatedHandlers();
  20383. }
  20384. }
  20385. },
  20386. function(ElementSize) {
  20387. ElementSize.instance = new ElementSize();
  20388. });
  20389. Ext.define('Ext.util.paintmonitor.Abstract', {
  20390. config: {
  20391. element: null,
  20392. callback: Ext.emptyFn,
  20393. scope: null,
  20394. args: []
  20395. },
  20396. eventName: '',
  20397. monitorClass: '',
  20398. constructor: function(config) {
  20399. this.onElementPainted = this.onElementPainted.bind(this);
  20400. this.initConfig(config);
  20401. },
  20402. bindListeners: function(bind) {
  20403. this.monitorElement[bind ? 'addEventListener' : 'removeEventListener'](this.eventName, this.onElementPainted, true);
  20404. },
  20405. applyElement: function(element) {
  20406. if (element) {
  20407. return Ext.get(element);
  20408. }
  20409. },
  20410. updateElement: function(element) {
  20411. this.monitorElement = Ext.Element.create({
  20412. classList: [
  20413. Ext.baseCSSPrefix + 'paint-monitor',
  20414. this.monitorClass
  20415. ]
  20416. }, true);
  20417. element.appendChild(this.monitorElement, true);
  20418. element.addCls(Ext.baseCSSPrefix + 'paint-monitored');
  20419. this.bindListeners(true);
  20420. },
  20421. onElementPainted: function() {},
  20422. destroy: function() {
  20423. var me = this,
  20424. monitorElement = me.monitorElement,
  20425. parentNode = monitorElement.parentNode,
  20426. element = me.getElement();
  20427. me.bindListeners(false);
  20428. delete me.monitorElement;
  20429. if (element && !element.destroyed) {
  20430. element.removeCls(Ext.baseCSSPrefix + 'paint-monitored');
  20431. delete me._element;
  20432. }
  20433. if (parentNode) {
  20434. parentNode.removeChild(monitorElement);
  20435. }
  20436. me.callParent();
  20437. }
  20438. });
  20439. Ext.define('Ext.util.paintmonitor.CssAnimation', {
  20440. extend: Ext.util.paintmonitor.Abstract,
  20441. eventName: Ext.browser.is.WebKit ? 'webkitAnimationEnd' : 'animationend',
  20442. monitorClass: 'cssanimation',
  20443. onElementPainted: function(e) {
  20444. if (e.animationName === Ext.baseCSSPrefix + 'paint-monitor-helper') {
  20445. this.getCallback().apply(this.getScope(), this.getArgs());
  20446. }
  20447. }
  20448. });
  20449. Ext.define('Ext.util.PaintMonitor', {
  20450. constructor: function(config) {
  20451. return new Ext.util.paintmonitor.CssAnimation(config);
  20452. }
  20453. });
  20454. Ext.define('Ext.event.publisher.ElementPaint', {
  20455. extend: Ext.event.publisher.Publisher,
  20456. type: 'paint',
  20457. handledEvents: [
  20458. 'painted'
  20459. ],
  20460. constructor: function() {
  20461. this.monitors = {};
  20462. this.subscribers = {};
  20463. this.callParent(arguments);
  20464. },
  20465. subscribe: function(element) {
  20466. var me = this,
  20467. id = element.id,
  20468. subscribers = me.subscribers;
  20469. if (subscribers[id]) {
  20470. ++subscribers[id];
  20471. } else {
  20472. subscribers[id] = 1;
  20473. me.monitors[id] = new Ext.util.PaintMonitor({
  20474. element: element,
  20475. callback: me.onElementPainted,
  20476. scope: me,
  20477. args: [
  20478. element
  20479. ]
  20480. });
  20481. }
  20482. },
  20483. unsubscribe: function(element) {
  20484. var id = element.id,
  20485. subscribers = this.subscribers,
  20486. monitors = this.monitors;
  20487. if (subscribers[id] && !--subscribers[id]) {
  20488. delete subscribers[id];
  20489. monitors[id].destroy();
  20490. delete monitors[id];
  20491. }
  20492. if (element.activeRead) {
  20493. Ext.TaskQueue.cancelRead(element.activeRead);
  20494. }
  20495. },
  20496. fireElementPainted: function(element) {
  20497. delete element.activeRead;
  20498. this.fire(element, 'painted', [
  20499. element
  20500. ]);
  20501. },
  20502. onElementPainted: function(element) {
  20503. if (!element.activeRead) {
  20504. element.activeRead = Ext.TaskQueue.requestRead('fireElementPainted', this, [
  20505. element
  20506. ],
  20507. !!element.$skipResourceCheck);
  20508. }
  20509. }
  20510. },
  20511. function(ElementPaint) {
  20512. ElementPaint.instance = new ElementPaint();
  20513. });
  20514. Ext.define('Ext.dom.Element', function(Element) {
  20515. var WIN = window,
  20516. DOC = document,
  20517. docEl = DOC.documentElement,
  20518. WIN_TOP = WIN.top,
  20519. EMPTY = [],
  20520. elementIdCounter, windowId, documentId,
  20521. WIDTH = 'width',
  20522. HEIGHT = 'height',
  20523. MIN_WIDTH = 'min-width',
  20524. MIN_HEIGHT = 'min-height',
  20525. MAX_WIDTH = 'max-width',
  20526. MAX_HEIGHT = 'max-height',
  20527. TOP = 'top',
  20528. RIGHT = 'right',
  20529. BOTTOM = 'bottom',
  20530. LEFT = 'left',
  20531. VISIBILITY = 'visibility',
  20532. HIDDEN = 'hidden',
  20533. DISPLAY = "display",
  20534. NONE = "none",
  20535. ZINDEX = "z-index",
  20536. POSITION = "position",
  20537. RELATIVE = "relative",
  20538. STATIC = "static",
  20539. wordsRe = /\w/g,
  20540. spacesRe = /\s+/,
  20541. classNameSplitRegex = /[\s]+/,
  20542. transparentRe = /^(?:transparent|(?:rgba[(](?:\s*\d+\s*[,]){3}\s*0\s*[)]))$/i,
  20543. endsQuestionRe = /\?$/,
  20544. topRe = /top/i,
  20545. empty = {},
  20546. borders = {
  20547. t: 'border-top-width',
  20548. r: 'border-right-width',
  20549. b: 'border-bottom-width',
  20550. l: 'border-left-width'
  20551. },
  20552. paddings = {
  20553. t: 'padding-top',
  20554. r: 'padding-right',
  20555. b: 'padding-bottom',
  20556. l: 'padding-left'
  20557. },
  20558. margins = {
  20559. t: 'margin-top',
  20560. r: 'margin-right',
  20561. b: 'margin-bottom',
  20562. l: 'margin-left'
  20563. },
  20564. selectDir = {
  20565. b: 'backward',
  20566. back: 'backward',
  20567. f: 'forward'
  20568. },
  20569. paddingsTLRB = [
  20570. paddings.l,
  20571. paddings.r,
  20572. paddings.t,
  20573. paddings.b
  20574. ],
  20575. bordersTLRB = [
  20576. borders.l,
  20577. borders.r,
  20578. borders.t,
  20579. borders.b
  20580. ],
  20581. numberRe = /\d+$/,
  20582. unitRe = /\d+(px|r?em|%|vh|vw|vmin|vmax|en|ch|ex|pt|in|cm|mm|pc)$/i,
  20583. defaultUnit = 'px',
  20584. msRe = /^-ms-/,
  20585. camelRe = /(-[a-z])/gi,
  20586. cssRe = /([a-z0-9\-]+)\s*:\s*([^;\s]+(?:\s*[^;\s]+)*);?/gi,
  20587. pxRe = /^\d+(?:\.\d*)?px$/i,
  20588. relativeUnitRe = /(%|r?em|auto|vh|vw|vmin|vmax|ch|ex)$/i,
  20589. propertyCache = {},
  20590. ORIGINALDISPLAY = 'originalDisplay',
  20591. camelReplaceFn = function(m, a) {
  20592. return a.charAt(1).toUpperCase();
  20593. },
  20594. clearData = function(node, deep) {
  20595. var childNodes, i, len;
  20596. if (node.nodeType === 1) {
  20597. node._extData = null;
  20598. if (deep) {
  20599. childNodes = node.childNodes;
  20600. for (i = 0 , len = childNodes.length; i < len; ++i) {
  20601. clearData(childNodes[i], deep);
  20602. }
  20603. }
  20604. }
  20605. },
  20606. toFloat = function(v) {
  20607. return parseFloat(v) || 0;
  20608. },
  20609. opacityCls = Ext.baseCSSPrefix + 'hidden-opacity',
  20610. visibilityCls = Ext.baseCSSPrefix + 'hidden-visibility',
  20611. displayCls = Ext.baseCSSPrefix + 'hidden-display',
  20612. offsetsCls = Ext.baseCSSPrefix + 'hidden-offsets',
  20613. clipCls = Ext.baseCSSPrefix + 'hidden-clip',
  20614. lastFocusChange = 0,
  20615. lastKeyboardClose = 0,
  20616. editableHasFocus = false,
  20617. isVirtualKeyboardOpen = false,
  20618. inputTypeSelectionSupported = /text|password|search|tel|url/i,
  20619. visFly, scrollFly, caFly, wrapFly, grannyFly, activeElFly;
  20620. try {
  20621. elementIdCounter = WIN_TOP.__elementIdCounter__;
  20622. WIN_TOP.__elementIdCounter__ = elementIdCounter;
  20623. } catch (e) {
  20624. WIN_TOP = WIN;
  20625. }
  20626. WIN_TOP.__elementIdCounter__ = elementIdCounter = (WIN_TOP.__elementIdCounter__ || 0) + 1;
  20627. windowId = 'ext-window-' + elementIdCounter;
  20628. documentId = 'ext-document-' + elementIdCounter;
  20629. if (Object.freeze) {
  20630. Object.freeze(EMPTY);
  20631. }
  20632. return {
  20633. alternateClassName: [
  20634. 'Ext.Element'
  20635. ],
  20636. mixins: [
  20637. Ext.util.Positionable,
  20638. Ext.mixin.Observable
  20639. ],
  20640. observableType: 'element',
  20641. isElement: true,
  20642. skipGarbageCollection: true,
  20643. $applyConfigs: true,
  20644. identifiablePrefix: 'ext-element-',
  20645. _selectDir: selectDir,
  20646. styleHooks: {
  20647. transform: {
  20648. set: function(dom, value, el) {
  20649. var prop,
  20650. result = '';
  20651. if (typeof value !== 'string') {
  20652. for (prop in value) {
  20653. if (result) {
  20654. result += ' ';
  20655. }
  20656. if (prop.indexOf('translate') === 0) {
  20657. result += prop + '(' + Element.addUnits(value[prop], 'px') + ')';
  20658. } else {
  20659. result += prop + '(' + value[prop] + ')';
  20660. }
  20661. }
  20662. value = result;
  20663. }
  20664. dom.style.transform = value;
  20665. }
  20666. }
  20667. },
  20668. validIdRe: Ext.validIdRe,
  20669. blockedEvents: Ext.supports.EmulatedMouseOver ? {
  20670. mouseover: 1
  20671. } : {},
  20672. longpressEvents: {
  20673. longpress: 1,
  20674. taphold: 1
  20675. },
  20676. constructor: function(dom) {
  20677. var me = this,
  20678. id;
  20679. if (typeof dom === 'string') {
  20680. dom = DOC.getElementById(dom);
  20681. }
  20682. if (!dom) {
  20683. Ext.raise("Invalid domNode reference or an id of an existing domNode: " + dom);
  20684. return null;
  20685. }
  20686. if (Ext.cache[dom.id]) {
  20687. Ext.raise("Element cache already contains an entry for id '" + dom.id + "'. Use Ext.get() to create or retrieve Element instances.");
  20688. }
  20689. me.dom = dom;
  20690. id = dom.id;
  20691. if (id) {
  20692. me.id = id;
  20693. } else {
  20694. id = dom.id = me.getUniqueId();
  20695. }
  20696. if (!me.validIdRe.test(me.id)) {
  20697. Ext.raise('Invalid Element "id": "' + me.id + '"');
  20698. }
  20699. me.el = me;
  20700. Ext.cache[id] = me;
  20701. me.longpressListenerCount = 0;
  20702. me.mixins.observable.constructor.call(me);
  20703. },
  20704. inheritableStatics: {
  20705. cache: Ext.cache = {},
  20706. editableSelector: 'input,textarea,[contenteditable="true"]',
  20707. VISIBILITY: 1,
  20708. DISPLAY: 2,
  20709. OFFSETS: 3,
  20710. CLIP: 4,
  20711. OPACITY: 5,
  20712. minKeyboardHeight: 100,
  20713. unitRe: unitRe,
  20714. useDelegatedEvents: true,
  20715. validNodeTypes: {
  20716. 1: 1,
  20717. 9: 1
  20718. },
  20719. namespaceURIs: {
  20720. html: 'http://www.w3.org/1999/xhtml',
  20721. svg: 'http://www.w3.org/2000/svg'
  20722. },
  20723. selectableCls: Ext.baseCSSPrefix + 'selectable',
  20724. unselectableCls: Ext.baseCSSPrefix + 'unselectable',
  20725. maxRippleDiameter: 75,
  20726. addUnits: function(size, units) {
  20727. if (typeof size === 'number') {
  20728. return size + (units || defaultUnit);
  20729. }
  20730. if (size === "" || size === "auto" || size == null) {
  20731. return size || '';
  20732. }
  20733. if (numberRe.test(size)) {
  20734. return size + (units || defaultUnit);
  20735. }
  20736. if (!unitRe.test(size)) {
  20737. if (!(Ext.isString(size) && size.indexOf('calc') === 0)) {
  20738. Ext.Logger.warn("Warning, size detected (" + size + ") not a valid property value on Element.addUnits.");
  20739. }
  20740. return size || '';
  20741. }
  20742. return size;
  20743. },
  20744. create: function(attributes, domNode) {
  20745. var me = this,
  20746. classes, element, elementStyle, tag, value, name, i, ln, tmp, ns;
  20747. attributes = attributes || {};
  20748. if (attributes.isElement) {
  20749. return domNode ? attributes.dom : attributes;
  20750. } else if ('nodeType' in attributes) {
  20751. return domNode ? attributes : Ext.get(attributes);
  20752. }
  20753. if (typeof attributes === 'string') {
  20754. return DOC.createTextNode(attributes);
  20755. }
  20756. tag = attributes.tag;
  20757. if (!tag) {
  20758. tag = 'div';
  20759. }
  20760. ns = attributes.namespace;
  20761. if (ns) {
  20762. element = DOC.createElementNS(me.namespaceURIs[ns] || ns, tag);
  20763. } else {
  20764. element = DOC.createElement(tag);
  20765. }
  20766. elementStyle = element.style;
  20767. for (name in attributes) {
  20768. if (name !== 'tag') {
  20769. value = attributes[name];
  20770. switch (name) {
  20771. case 'style':
  20772. if (typeof value === 'string') {
  20773. element.setAttribute(name, value);
  20774. } else {
  20775. for (i in value) {
  20776. elementStyle[i] = value[i];
  20777. }
  20778. };
  20779. break;
  20780. case 'className':
  20781. case 'cls':
  20782. tmp = value.split(spacesRe);
  20783. classes = classes ? classes.concat(tmp) : tmp;
  20784. break;
  20785. case 'classList':
  20786. classes = classes ? classes.concat(value) : value;
  20787. break;
  20788. case 'text':
  20789. element.textContent = value;
  20790. break;
  20791. case 'html':
  20792. element.innerHTML = value;
  20793. break;
  20794. case 'hidden':
  20795. if (classes) {
  20796. classes.push(displayCls);
  20797. } else {
  20798. classes = [
  20799. displayCls
  20800. ];
  20801. };
  20802. break;
  20803. case 'children':
  20804. if (value != null) {
  20805. for (i = 0 , ln = value.length; i < ln; i++) {
  20806. element.appendChild(me.create(value[i], true));
  20807. }
  20808. };
  20809. break;
  20810. default:
  20811. if (value != null) {
  20812. element.setAttribute(name, value);
  20813. };
  20814. }
  20815. }
  20816. }
  20817. if (classes) {
  20818. element.className = classes.join(' ');
  20819. }
  20820. if (domNode) {
  20821. return element;
  20822. } else {
  20823. return me.get(element);
  20824. }
  20825. },
  20826. fly: function(dom, named) {
  20827. return Ext.fly(dom, named);
  20828. },
  20829. fromPoint: (function() {
  20830. var elementFromPointBug;
  20831. if (Ext.isIE || Ext.isEdge) {
  20832. try {
  20833. elementFromPointBug = window.self !== window.top;
  20834. } catch (e) {
  20835. elementFromPointBug = true;
  20836. }
  20837. }
  20838. return function(x, y, asDom) {
  20839. var el = null;
  20840. el = DOC.elementFromPoint(x, y);
  20841. if (!el && elementFromPointBug) {
  20842. el = DOC.elementFromPoint(x, y);
  20843. }
  20844. return asDom ? el : Ext.get(el);
  20845. };
  20846. })(),
  20847. fromPagePoint: function(x, y, asDom) {
  20848. var scroll = Ext.getDoc().getScroll();
  20849. return Element.fromPoint(x - scroll.left, y - scroll.top, asDom);
  20850. },
  20851. get: function(el) {
  20852. var me = this,
  20853. cache = Ext.cache,
  20854. nodeType, dom, id, entry, isDoc, isWin, isValidNodeType;
  20855. if (!el) {
  20856. return null;
  20857. }
  20858. function warnDuplicate(id) {
  20859. 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()");
  20860. }
  20861. if (el.isFly) {
  20862. el = el.dom;
  20863. }
  20864. if (typeof el === 'string') {
  20865. id = el;
  20866. if (cache.hasOwnProperty(id)) {
  20867. entry = cache[id];
  20868. if (entry.skipGarbageCollection || !Ext.isGarbage(entry.dom)) {
  20869. dom = Ext.getElementById ? Ext.getElementById(id) : DOC.getElementById(id);
  20870. if (dom && (dom !== entry.dom)) {
  20871. warnDuplicate(id);
  20872. }
  20873. return entry;
  20874. } else {
  20875. entry.destroy();
  20876. }
  20877. }
  20878. if (id === windowId) {
  20879. return Element.get(WIN);
  20880. } else if (id === documentId) {
  20881. return Element.get(DOC);
  20882. }
  20883. dom = Ext.getElementById ? Ext.getElementById(id) : DOC.getElementById(id);
  20884. if (dom) {
  20885. return new Element(dom);
  20886. }
  20887. }
  20888. nodeType = el.nodeType;
  20889. if (nodeType) {
  20890. isDoc = (nodeType === 9);
  20891. isValidNodeType = me.validNodeTypes[nodeType];
  20892. } else {
  20893. isWin = (el.window == el);
  20894. }
  20895. if (isValidNodeType || isWin) {
  20896. id = el.id;
  20897. if (cache.hasOwnProperty(id)) {
  20898. entry = cache[id];
  20899. if (entry.skipGarbageCollection || el === entry.dom || !Ext.isGarbage(entry.dom)) {
  20900. if (el !== entry.dom) {
  20901. warnDuplicate(id);
  20902. }
  20903. return entry;
  20904. } else {
  20905. entry.destroy();
  20906. }
  20907. }
  20908. if (el === DOC) {
  20909. el.id = documentId;
  20910. }
  20911. if (el == WIN) {
  20912. el.id = windowId;
  20913. }
  20914. el = new Element(el);
  20915. if (isWin || isDoc) {
  20916. el.skipGarbageCollection = true;
  20917. }
  20918. return el;
  20919. }
  20920. if (el.isElement) {
  20921. return el;
  20922. }
  20923. if (el.isComposite) {
  20924. return el;
  20925. }
  20926. if (Ext.isIterable(el)) {
  20927. return me.select(el);
  20928. }
  20929. return null;
  20930. },
  20931. getActiveElement: function(asElement) {
  20932. var active = DOC.activeElement;
  20933. if (!active || !active.focus) {
  20934. active = DOC.body;
  20935. }
  20936. return asElement ? Ext.get(active) : active;
  20937. },
  20938. getDocumentHeight: function() {
  20939. return Math.max(!Ext.isStrict ? DOC.body.scrollHeight : docEl.scrollHeight, this.getViewportHeight());
  20940. },
  20941. getDocumentWidth: function() {
  20942. return Math.max(!Ext.isStrict ? DOC.body.scrollWidth : docEl.scrollWidth, this.getViewportWidth());
  20943. },
  20944. getOrientation: function() {
  20945. if (Ext.supports.OrientationChange) {
  20946. return (WIN.orientation == 0) ? 'portrait' : 'landscape';
  20947. }
  20948. return (WIN.innerHeight > WIN.innerWidth) ? 'portrait' : 'landscape';
  20949. },
  20950. getViewportHeight: function() {
  20951. var viewportHeight = Element._viewportHeight;
  20952. if (Ext.isIE9m) {
  20953. return DOC.documentElement.clientHeight;
  20954. }
  20955. return (viewportHeight != null) ? viewportHeight : docEl.clientHeight;
  20956. },
  20957. getViewportWidth: function() {
  20958. var viewportWidth = Element._viewportWidth;
  20959. if (Ext.isIE9m) {
  20960. return DOC.documentElement.clientWidth;
  20961. }
  20962. return (viewportWidth != null) ? viewportWidth : docEl.clientWidth;
  20963. },
  20964. getViewportScale: function() {
  20965. var top = WIN_TOP;
  20966. return ((Ext.isiOS || Ext.isAndroid) ? 1 : (top.devicePixelRatio ||
  20967. top.screen.deviceXDPI / top.screen.logicalXDPI)) *
  20968. this.getViewportTouchScale();
  20969. },
  20970. getViewportTouchScale: function(forceRead) {
  20971. var scale = 1,
  20972. top = WIN_TOP,
  20973. cachedScale;
  20974. if (!forceRead) {
  20975. cachedScale = this._viewportTouchScale;
  20976. if (cachedScale) {
  20977. return cachedScale;
  20978. }
  20979. }
  20980. if (Ext.isIE10p || Ext.isEdge || Ext.isiOS) {
  20981. scale = docEl.offsetWidth / WIN.innerWidth;
  20982. } else if (Ext.isChromeMobile) {
  20983. scale = top.outerWidth / top.innerWidth;
  20984. }
  20985. return scale;
  20986. },
  20987. getViewSize: function() {
  20988. return {
  20989. width: Element.getViewportWidth(),
  20990. height: Element.getViewportHeight()
  20991. };
  20992. },
  20993. hasUnit: function(size) {
  20994. return !!(size && unitRe.test(size));
  20995. },
  20996. isRelativeUnit: function(size) {
  20997. return !size || relativeUnitRe.test(size);
  20998. },
  20999. maskIframes: function() {
  21000. var iframes = document.getElementsByTagName('iframe'),
  21001. fly = new Ext.dom.Fly();
  21002. Ext.each(iframes, function(iframe) {
  21003. var myMask;
  21004. myMask = fly.attach(iframe.parentNode).mask();
  21005. myMask.setStyle('background-color', 'transparent');
  21006. });
  21007. },
  21008. normalize: function(prop) {
  21009. return propertyCache[prop] || (propertyCache[prop] = prop.replace(msRe, 'ms-').replace(camelRe, camelReplaceFn));
  21010. },
  21011. _onWindowFocusChange: function(e) {
  21012. if (Ext.fly(e.target).is(Element.editableSelector)) {
  21013. lastFocusChange = new Date();
  21014. editableHasFocus = (e.type === 'focusin' || e.type === 'pointerup');
  21015. }
  21016. },
  21017. _onWindowResize: function() {
  21018. var documentWidth = docEl.clientWidth,
  21019. documentHeight = docEl.clientHeight,
  21020. now = new Date(),
  21021. threshold = 1000,
  21022. deltaX, deltaY;
  21023. deltaX = documentWidth - Element._documentWidth;
  21024. deltaY = documentHeight - Element._documentHeight;
  21025. Element._documentWidth = documentWidth;
  21026. Element._documentHeight = documentHeight;
  21027. if (((now - lastFocusChange) < threshold) || ((now - lastKeyboardClose) < threshold)) {
  21028. if (deltaX === 0 && (editableHasFocus && (deltaY <= -Element.minKeyboardHeight))) {
  21029. isVirtualKeyboardOpen = true;
  21030. return;
  21031. }
  21032. }
  21033. if (isVirtualKeyboardOpen && (deltaX === 0) && (deltaY >= Element.minKeyboardHeight)) {
  21034. isVirtualKeyboardOpen = false;
  21035. lastKeyboardClose = new Date();
  21036. }
  21037. if (isVirtualKeyboardOpen) {
  21038. return;
  21039. }
  21040. Element._viewportWidth = documentWidth;
  21041. Element._viewportHeight = documentHeight;
  21042. },
  21043. parseBox: function(box) {
  21044. box = box || 0;
  21045. var type = typeof box,
  21046. parts, ln;
  21047. if (type === 'number') {
  21048. return {
  21049. top: box,
  21050. right: box,
  21051. bottom: box,
  21052. left: box
  21053. };
  21054. } else if (type !== 'string') {
  21055. return box;
  21056. }
  21057. parts = box.split(' ');
  21058. ln = parts.length;
  21059. if (ln === 1) {
  21060. parts[1] = parts[2] = parts[3] = parts[0];
  21061. } else if (ln === 2) {
  21062. parts[2] = parts[0];
  21063. parts[3] = parts[1];
  21064. } else if (ln === 3) {
  21065. parts[3] = parts[1];
  21066. }
  21067. return {
  21068. top: parseFloat(parts[0]) || 0,
  21069. right: parseFloat(parts[1]) || 0,
  21070. bottom: parseFloat(parts[2]) || 0,
  21071. left: parseFloat(parts[3]) || 0
  21072. };
  21073. },
  21074. parseStyles: function(styles) {
  21075. var out = {},
  21076. matches;
  21077. if (styles) {
  21078. cssRe.lastIndex = 0;
  21079. while ((matches = cssRe.exec(styles))) {
  21080. out[matches[1]] = matches[2] || '';
  21081. }
  21082. }
  21083. return out;
  21084. },
  21085. select: function(selector, composite, root) {
  21086. return Ext.fly(root || DOC).select(selector, composite);
  21087. },
  21088. query: function(selector, asDom, root) {
  21089. return Ext.fly(root || DOC).query(selector, asDom);
  21090. },
  21091. unitizeBox: function(box, units) {
  21092. var me = this;
  21093. box = me.parseBox(box);
  21094. return me.addUnits(box.top, units) + ' ' + me.addUnits(box.right, units) + ' ' + me.addUnits(box.bottom, units) + ' ' + me.addUnits(box.left, units);
  21095. },
  21096. unmaskIframes: function() {
  21097. var iframes = document.getElementsByTagName('iframe'),
  21098. fly = new Ext.dom.Fly();
  21099. Ext.each(iframes, function(iframe) {
  21100. fly.attach(iframe.parentNode).unmask();
  21101. });
  21102. },
  21103. serializeForm: function(form) {
  21104. var fElements = form.elements || (DOC.forms[form] || Ext.getDom(form)).elements,
  21105. hasSubmit = false,
  21106. encoder = encodeURIComponent,
  21107. data = '',
  21108. eLen = fElements.length,
  21109. element, name, type, options, hasValue, e, o, oLen, opt;
  21110. for (e = 0; e < eLen; e++) {
  21111. element = fElements[e];
  21112. name = element.name;
  21113. type = element.type;
  21114. options = element.options;
  21115. if (!element.disabled && name) {
  21116. if (/select-(one|multiple)/i.test(type)) {
  21117. oLen = options.length;
  21118. for (o = 0; o < oLen; o++) {
  21119. opt = options[o];
  21120. if (opt.selected) {
  21121. hasValue = opt.hasAttribute('value');
  21122. data += Ext.String.format('{0}={1}&', encoder(name), encoder(hasValue ? opt.value : opt.text));
  21123. }
  21124. }
  21125. } else if (!(/file|undefined|reset|button/i.test(type))) {
  21126. if (!(/radio|checkbox/i.test(type) && !element.checked) && !(type == 'submit' && hasSubmit)) {
  21127. data += encoder(name) + '=' + encoder(element.value) + '&';
  21128. hasSubmit = /submit/i.test(type);
  21129. }
  21130. }
  21131. }
  21132. }
  21133. return data.substr(0, data.length - 1);
  21134. },
  21135. getCommonAncestor: function(nodeA, nodeB, returnDom) {
  21136. caFly = caFly || new Ext.dom.Fly();
  21137. caFly.attach(Ext.getDom(nodeA));
  21138. while (!caFly.isAncestor(nodeB)) {
  21139. if (caFly.dom.parentNode) {
  21140. caFly.attach(caFly.dom.parentNode);
  21141. } else
  21142. {
  21143. caFly.attach(DOC.body);
  21144. break;
  21145. }
  21146. }
  21147. return returnDom ? caFly.dom : Ext.get(caFly);
  21148. }
  21149. },
  21150. selectable: function() {
  21151. var me = this;
  21152. me.dom.unselectable = '';
  21153. me.removeCls(Element.unselectableCls);
  21154. me.addCls(Element.selectableCls);
  21155. return me;
  21156. },
  21157. unselectable: function() {
  21158. var me = this;
  21159. if (Ext.isOpera) {
  21160. me.dom.unselectable = 'on';
  21161. }
  21162. me.removeCls(Element.selectableCls);
  21163. me.addCls(Element.unselectableCls);
  21164. return me;
  21165. },
  21166. statics: {
  21167. tabbableSelector: Ext.supports.CSS3NegationSelector ? 'a[href],button,iframe,input,select,textarea,[tabindex]:not([tabindex="-1"]),[contenteditable="true"]' : 'a[href],button,iframe,input,select,textarea,[tabindex],[contenteditable="true"]',
  21168. naturallyFocusableTags: {
  21169. BUTTON: true,
  21170. IFRAME: true,
  21171. EMBED: true,
  21172. INPUT: true,
  21173. OBJECT: true,
  21174. SELECT: true,
  21175. TEXTAREA: true,
  21176. HTML: Ext.isIE ? true : false,
  21177. BODY: Ext.isIE ? false : true
  21178. },
  21179. naturallyTabbableTags: {
  21180. BUTTON: true,
  21181. IFRAME: true,
  21182. INPUT: true,
  21183. SELECT: true,
  21184. TEXTAREA: true,
  21185. OBJECT: Ext.isIE8m ? true : false
  21186. },
  21187. inputTags: {
  21188. INPUT: true,
  21189. TEXTAREA: true
  21190. },
  21191. tabbableSavedCounterAttribute: 'data-tabindex-counter',
  21192. tabbableSavedValueAttribute: 'data-tabindex-value',
  21193. splitCls: function(cls) {
  21194. if (typeof cls === 'string') {
  21195. cls = cls.split(spacesRe);
  21196. }
  21197. return cls;
  21198. }
  21199. },
  21200. _init: function(E) {
  21201. E.tabbableSelector += ',[' + E.tabbableSavedCounterAttribute + ']';
  21202. },
  21203. addCls: function(names, prefix, suffix) {
  21204. return this.replaceCls(null, names, prefix, suffix);
  21205. },
  21206. addClsOnClick: function(className, testFn, scope) {
  21207. var me = this,
  21208. hasTest = Ext.isFunction(testFn);
  21209. me.on("mousedown", function() {
  21210. if (hasTest && testFn.call(scope || me, me) === false) {
  21211. return false;
  21212. }
  21213. me.addCls(className);
  21214. Ext.getDoc().on({
  21215. mouseup: function() {
  21216. if (me.dom) {
  21217. me.removeCls(className);
  21218. }
  21219. },
  21220. single: true
  21221. });
  21222. });
  21223. return me;
  21224. },
  21225. addClsOnFocus: function(className, testFn, scope) {
  21226. var me = this,
  21227. hasTest = Ext.isFunction(testFn);
  21228. me.on("focus", function() {
  21229. if (hasTest && testFn.call(scope || me, me) === false) {
  21230. return false;
  21231. }
  21232. me.addCls(className);
  21233. });
  21234. me.on("blur", function() {
  21235. if (me.dom) {
  21236. me.removeCls(className);
  21237. }
  21238. });
  21239. return me;
  21240. },
  21241. addClsOnOver: function(className, testFn, scope) {
  21242. var me = this,
  21243. hasTest = Ext.isFunction(testFn);
  21244. me.hover(function() {
  21245. if (hasTest && testFn.call(scope || me, me) === false) {
  21246. return;
  21247. }
  21248. me.addCls(className);
  21249. }, function() {
  21250. me.removeCls(className);
  21251. });
  21252. return me;
  21253. },
  21254. addStyles: function(sides, styles) {
  21255. var totalSize = 0,
  21256. sidesArr = (sides || '').match(wordsRe),
  21257. i,
  21258. len = sidesArr.length,
  21259. side,
  21260. styleSides = [];
  21261. if (len === 1) {
  21262. totalSize = parseFloat(this.getStyle(styles[sidesArr[0]])) || 0;
  21263. } else if (len) {
  21264. for (i = 0; i < len; i++) {
  21265. side = sidesArr[i];
  21266. styleSides.push(styles[side]);
  21267. }
  21268. styleSides = this.getStyle(styleSides);
  21269. for (i = 0; i < len; i++) {
  21270. side = sidesArr[i];
  21271. totalSize += parseFloat(styleSides[styles[side]]) || 0;
  21272. }
  21273. }
  21274. return totalSize;
  21275. },
  21276. addUnits: function(size, units) {
  21277. return Element.addUnits(size, units);
  21278. },
  21279. animate: function(animation) {
  21280. animation = new Ext.fx.Animation(animation);
  21281. animation.setElement(this);
  21282. this._activeAnimation = animation;
  21283. animation.on({
  21284. animationend: this._onAnimationEnd,
  21285. scope: this
  21286. });
  21287. Ext.Animator.run(animation);
  21288. return animation;
  21289. },
  21290. _onAnimationEnd: function() {
  21291. this._activeAnimation = null;
  21292. },
  21293. getActiveAnimation: function() {
  21294. return this._activeAnimation;
  21295. },
  21296. append: function() {
  21297. return this.appendChild.apply(this, arguments);
  21298. },
  21299. appendChild: function(el, returnDom) {
  21300. var me = this,
  21301. insertEl, eLen, e;
  21302. if (el.nodeType || el.dom || typeof el === 'string') {
  21303. el = Ext.getDom(el);
  21304. me.dom.appendChild(el);
  21305. return !returnDom ? Ext.get(el) : el;
  21306. } else if (el.length) {
  21307. insertEl = Ext.fly(DOC.createDocumentFragment());
  21308. eLen = el.length;
  21309. for (e = 0; e < eLen; e++) {
  21310. insertEl.appendChild(el[e], returnDom);
  21311. }
  21312. el = Ext.Array.toArray(insertEl.dom.childNodes);
  21313. me.dom.appendChild(insertEl.dom);
  21314. return returnDom ? el : new Ext.dom.CompositeElementLite(el);
  21315. } else {
  21316. return me.createChild(el, null, returnDom);
  21317. }
  21318. },
  21319. appendTo: function(el) {
  21320. Ext.getDom(el).appendChild(this.dom);
  21321. return this;
  21322. },
  21323. applyStyles: function(styles) {
  21324. if (styles) {
  21325. if (typeof styles === "function") {
  21326. styles = styles.call();
  21327. }
  21328. if (typeof styles === "string") {
  21329. styles = Element.parseStyles(styles);
  21330. }
  21331. if (typeof styles === "object") {
  21332. this.setStyle(styles);
  21333. }
  21334. }
  21335. return this;
  21336. },
  21337. blur: function() {
  21338. var me = this,
  21339. dom = me.dom;
  21340. if (dom !== DOC.body) {
  21341. try {
  21342. dom.blur();
  21343. } catch (e) {}
  21344. return me;
  21345. } else {
  21346. return me.focus(undefined, dom);
  21347. }
  21348. },
  21349. cacheScrollValues: function() {
  21350. var me = this,
  21351. scrollValues = [],
  21352. scrolledDescendants = [],
  21353. descendants, descendant, i, len;
  21354. scrollFly = scrollFly || new Ext.dom.Fly();
  21355. descendants = me.query('*');
  21356. for (i = 0 , len = descendants.length; i < len; i++) {
  21357. descendant = descendants[i];
  21358. if (descendant.scrollTop > 0 || descendant.scrollLeft !== 0) {
  21359. scrolledDescendants.push(descendant);
  21360. scrollValues.push(scrollFly.attach(descendant).getScroll());
  21361. }
  21362. }
  21363. return function() {
  21364. var scroll, i, len;
  21365. for (i = 0 , len = scrolledDescendants.length; i < len; i++) {
  21366. scroll = scrollValues[i];
  21367. scrollFly.attach(scrolledDescendants[i]);
  21368. scrollFly.setScrollLeft(scroll.left);
  21369. scrollFly.setScrollTop(scroll.top);
  21370. }
  21371. };
  21372. },
  21373. center: function(centerIn) {
  21374. return this.alignTo(centerIn || DOC, 'c-c');
  21375. },
  21376. child: function(selector, returnDom) {
  21377. var me = this,
  21378. id;
  21379. if (Ext.supports.Selectors2) {
  21380. return me.selectNode(':scope>' + selector, !!returnDom);
  21381. } else {
  21382. id = me.id != null ? me.id : Ext.get(me).id;
  21383. return me.selectNode(Ext.makeIdSelector(id) + " > " + selector, !!returnDom);
  21384. }
  21385. },
  21386. clone: function(deep, returnDom) {
  21387. var clone = this.dom.cloneNode(deep);
  21388. if (Ext.supports.CloneNodeCopiesExpando) {
  21389. clearData(clone, deep);
  21390. }
  21391. return returnDom ? clone : Ext.get(clone);
  21392. },
  21393. constrainScrollLeft: function(left) {
  21394. var dom = this.dom;
  21395. return Math.max(Math.min(left, dom.scrollWidth - dom.clientWidth), 0);
  21396. },
  21397. constrainScrollTop: function(top) {
  21398. var dom = this.dom;
  21399. return Math.max(Math.min(top, dom.scrollHeight - dom.clientHeight), 0);
  21400. },
  21401. createChild: function(config, insertBefore, returnDom) {
  21402. config = config || {
  21403. tag: 'div'
  21404. };
  21405. if (insertBefore) {
  21406. return Ext.DomHelper.insertBefore(insertBefore, config, returnDom !== true);
  21407. } else {
  21408. return Ext.DomHelper.append(this.dom, config, returnDom !== true);
  21409. }
  21410. },
  21411. contains: function(element) {
  21412. if (!element) {
  21413. return false;
  21414. }
  21415. var me = this,
  21416. dom = Ext.getDom(element);
  21417. return (dom === me.dom) || me.isAncestor(dom);
  21418. },
  21419. destroy: function() {
  21420. var me = this,
  21421. dom = me.dom;
  21422. if (me.destroyed) {
  21423. Ext.Logger.warn("Cannot destroy Element \"" + me.id + "\". Already destroyed.");
  21424. return;
  21425. }
  21426. if (me.resumeFocusEventsTimer) {
  21427. Ext.unasap(me.resumeFocusEventsTimer);
  21428. me.resumeFocusEventsTimer = null;
  21429. }
  21430. if (me.repaintTimer) {
  21431. me.repaintTimer = Ext.undefer(me.repaintTimer);
  21432. }
  21433. if (me.deferFocusTimer) {
  21434. me.deferFocusTimer = Ext.undefer(me.deferFocusTimer);
  21435. }
  21436. if (dom) {
  21437. if (dom === DOC.body) {
  21438. Ext.raise("Cannot destroy body element.");
  21439. } else if (dom === DOC) {
  21440. Ext.raise("Cannot destroy document object.");
  21441. } else if (dom === WIN) {
  21442. Ext.raise("Cannot destroy window object");
  21443. }
  21444. }
  21445. if (dom && dom.parentNode) {
  21446. dom.parentNode.removeChild(dom);
  21447. }
  21448. if (me.$ripples) {
  21449. me.destroyAllRipples();
  21450. }
  21451. me.collect();
  21452. },
  21453. detach: function() {
  21454. var dom = this.dom,
  21455. component = this.component;
  21456. if (dom && dom.parentNode && dom.tagName !== 'BODY') {
  21457. if (component) {
  21458. component.revertFocus();
  21459. }
  21460. dom.parentNode.removeChild(dom);
  21461. }
  21462. return this;
  21463. },
  21464. disableShadow: function() {
  21465. var shadow = this.shadow;
  21466. if (shadow) {
  21467. shadow.hide();
  21468. shadow.disabled = true;
  21469. }
  21470. },
  21471. disableShim: function() {
  21472. var shim = this.shim;
  21473. if (shim) {
  21474. shim.hide();
  21475. shim.disabled = true;
  21476. }
  21477. },
  21478. doReplaceWith: function(element) {
  21479. var dom = this.dom;
  21480. dom.parentNode.replaceChild(Ext.getDom(element), dom);
  21481. },
  21482. doScrollIntoView: function(container, hscroll, animate, highlight, getScrollX, scrollTo) {
  21483. scrollFly = scrollFly || new Ext.dom.Fly();
  21484. var me = this,
  21485. dom = me.dom,
  21486. scrollX = scrollFly.attach(container)[getScrollX](),
  21487. scrollY = container.scrollTop,
  21488. position = me.getScrollIntoViewXY(container, scrollX, scrollY),
  21489. newScrollX = position.x,
  21490. newScrollY = position.y;
  21491. if (highlight) {
  21492. if (animate) {
  21493. animate = Ext.apply({
  21494. listeners: {
  21495. afteranimate: function() {
  21496. scrollFly.attach(dom).highlight();
  21497. }
  21498. }
  21499. }, animate);
  21500. } else {
  21501. scrollFly.attach(dom).highlight();
  21502. }
  21503. }
  21504. if (newScrollY !== scrollY) {
  21505. scrollFly.attach(container).scrollTo('top', newScrollY, animate);
  21506. }
  21507. if (hscroll !== false && (newScrollX !== scrollX)) {
  21508. scrollFly.attach(container)[scrollTo]('left', newScrollX, animate);
  21509. }
  21510. return me;
  21511. },
  21512. down: function(selector, returnDom) {
  21513. return this.selectNode(selector, !!returnDom);
  21514. },
  21515. enableShadow: function(options, isVisible) {
  21516. var me = this,
  21517. shadow = me.shadow || (me.shadow = new Ext.dom.Shadow(Ext.apply({
  21518. target: me
  21519. }, options))),
  21520. shim = me.shim;
  21521. if (shim) {
  21522. shim.offsets = shadow.outerOffsets;
  21523. shim.shadow = shadow;
  21524. shadow.shim = shim;
  21525. }
  21526. if (isVisible === true || (isVisible !== false && me.isVisible())) {
  21527. shadow.show();
  21528. } else {
  21529. shadow.hide();
  21530. }
  21531. shadow.disabled = false;
  21532. },
  21533. enableShim: function(options, isVisible) {
  21534. var me = this,
  21535. shim = me.shim || (me.shim = new Ext.dom.Shim(Ext.apply({
  21536. target: me
  21537. }, options))),
  21538. shadow = me.shadow;
  21539. if (shadow) {
  21540. shim.offsets = shadow.outerOffsets;
  21541. shim.shadow = shadow;
  21542. shadow.shim = shim;
  21543. }
  21544. if (isVisible === true || (isVisible !== false && me.isVisible())) {
  21545. shim.show();
  21546. } else {
  21547. shim.hide();
  21548. }
  21549. shim.disabled = false;
  21550. return shim;
  21551. },
  21552. findParent: function(simpleSelector, limit, returnEl) {
  21553. var me = this,
  21554. target = me.dom,
  21555. topmost = docEl,
  21556. depth = 0;
  21557. if (limit || limit === 0) {
  21558. if (typeof limit !== 'number') {
  21559. topmost = Ext.getDom(limit);
  21560. limit = Number.MAX_VALUE;
  21561. }
  21562. } else {
  21563. limit = 50;
  21564. }
  21565. while (target && target.nodeType === 1 && depth < limit && target !== topmost) {
  21566. if (Ext.fly(target).is(simpleSelector)) {
  21567. return returnEl ? Ext.get(target) : target;
  21568. }
  21569. depth++;
  21570. target = target.parentNode;
  21571. }
  21572. return null;
  21573. },
  21574. findParentNode: function(simpleSelector, limit, returnEl) {
  21575. var p = Ext.fly(this.dom.parentNode);
  21576. return p ? p.findParent(simpleSelector, limit, returnEl) : null;
  21577. },
  21578. first: function(selector, returnDom) {
  21579. return this.matchNode('nextSibling', 'firstChild', selector, returnDom);
  21580. },
  21581. focus: function(defer, dom) {
  21582. var me = this;
  21583. dom = dom || me.dom;
  21584. if (Number(defer)) {
  21585. Ext.defer(me.focus, defer, me, [
  21586. null,
  21587. dom
  21588. ]);
  21589. } else {
  21590. Ext.GlobalEvents.fireEvent('beforefocus', dom);
  21591. dom.focus();
  21592. }
  21593. return me;
  21594. },
  21595. collect: function() {
  21596. var me = this,
  21597. dom = me.dom,
  21598. shadow = me.shadow,
  21599. shim = me.shim;
  21600. if (!me.isFly) {
  21601. me.mixins.observable.destroy.call(me);
  21602. delete Ext.cache[me.id];
  21603. me.el = null;
  21604. }
  21605. if (dom) {
  21606. dom._extData = me.dom = null;
  21607. }
  21608. if (shadow) {
  21609. shadow.hide();
  21610. me.shadow = null;
  21611. }
  21612. if (shim) {
  21613. shim.hide();
  21614. me.shim = null;
  21615. }
  21616. },
  21617. getAnchorToXY: function(el, anchor, local, mySize) {
  21618. return el.getAnchorXY(anchor, local, mySize);
  21619. },
  21620. getAttribute: function(name, namespace) {
  21621. var dom = this.dom;
  21622. return namespace ? (dom.getAttributeNS(namespace, name) || dom.getAttribute(namespace + ":" + name)) : (dom.getAttribute(name) || dom[name] || null);
  21623. },
  21624. getAttributes: function() {
  21625. var attributes = this.dom.attributes,
  21626. result = {},
  21627. attr, i, len;
  21628. for (i = 0 , len = attributes.length; i < len; i++) {
  21629. attr = attributes[i];
  21630. result[attr.name] = attr.value;
  21631. }
  21632. return result;
  21633. },
  21634. getBottom: function(local) {
  21635. return (local ? this.getLocalY() : this.getY()) + this.getHeight();
  21636. },
  21637. getById: function(id, asDom) {
  21638. var dom = DOC.getElementById(id) || this.dom.querySelector(Ext.makeIdSelector(id));
  21639. return asDom ? dom : (dom ? Ext.get(dom) : null);
  21640. },
  21641. getBorderPadding: function() {
  21642. var paddingWidth = this.getStyle(paddingsTLRB),
  21643. bordersWidth = this.getStyle(bordersTLRB);
  21644. return {
  21645. beforeX: (parseFloat(bordersWidth[borders.l]) || 0) + (parseFloat(paddingWidth[paddings.l]) || 0),
  21646. afterX: (parseFloat(bordersWidth[borders.r]) || 0) + (parseFloat(paddingWidth[paddings.r]) || 0),
  21647. beforeY: (parseFloat(bordersWidth[borders.t]) || 0) + (parseFloat(paddingWidth[paddings.t]) || 0),
  21648. afterY: (parseFloat(bordersWidth[borders.b]) || 0) + (parseFloat(paddingWidth[paddings.b]) || 0)
  21649. };
  21650. },
  21651. getBorders: function() {
  21652. var bordersWidth = this.getStyle(bordersTLRB);
  21653. return {
  21654. beforeX: (parseFloat(bordersWidth[borders.l]) || 0),
  21655. afterX: (parseFloat(bordersWidth[borders.r]) || 0),
  21656. beforeY: (parseFloat(bordersWidth[borders.t]) || 0),
  21657. afterY: (parseFloat(bordersWidth[borders.b]) || 0)
  21658. };
  21659. },
  21660. getBorderWidth: function(side) {
  21661. return this.addStyles(side, borders);
  21662. },
  21663. getClassMap: function(clone) {
  21664. var data = this.getData();
  21665. if (data) {
  21666. data = data.classMap;
  21667. if (clone !== false) {
  21668. data = Ext.apply({}, data);
  21669. }
  21670. }
  21671. return data;
  21672. },
  21673. getData: function(sync) {
  21674. var dom = this.dom,
  21675. data;
  21676. if (dom) {
  21677. data = dom._extData || (dom._extData = {});
  21678. if (sync !== false && !data.isSynchronized) {
  21679. this.synchronize();
  21680. }
  21681. }
  21682. return data || null;
  21683. },
  21684. getFirstChild: function() {
  21685. return Ext.get(this.dom.firstElementChild);
  21686. },
  21687. getLastChild: function() {
  21688. return Ext.get(this.dom.lastElementChild);
  21689. },
  21690. getHeight: function(contentHeight, preciseHeight) {
  21691. var me = this,
  21692. dom = me.dom,
  21693. hidden = me.isStyle('display', 'none'),
  21694. height, floating;
  21695. if (hidden) {
  21696. return 0;
  21697. }
  21698. if (dom.nodeName === 'BODY') {
  21699. height = Element.getViewportHeight();
  21700. } else {
  21701. if (preciseHeight) {
  21702. height = dom.getBoundingClientRect().height;
  21703. } else {
  21704. height = dom.offsetHeight;
  21705. if (height == null) {
  21706. height = dom.getBoundingClientRect().height;
  21707. }
  21708. }
  21709. }
  21710. if (Ext.supports.Direct2DBug) {
  21711. floating = me.adjustDirect2DDimension(HEIGHT);
  21712. if (preciseHeight) {
  21713. height += floating;
  21714. } else if (floating > 0 && floating < 0.5) {
  21715. height++;
  21716. }
  21717. }
  21718. if (contentHeight) {
  21719. height -= me.getBorderWidth("tb") + me.getPadding("tb");
  21720. }
  21721. return (height < 0) ? 0 : height;
  21722. },
  21723. getHtml: function() {
  21724. return this.dom ? this.dom.innerHTML : '';
  21725. },
  21726. getLeft: function(local) {
  21727. return local ? this.getLocalX() : this.getX();
  21728. },
  21729. getLocalX: function() {
  21730. var me = this,
  21731. offsetParent,
  21732. x = me.getStyle('left');
  21733. if (!x || x === 'auto') {
  21734. x = 0;
  21735. } else if (pxRe.test(x)) {
  21736. x = parseFloat(x);
  21737. } else {
  21738. x = me.getX();
  21739. offsetParent = me.dom.offsetParent;
  21740. if (offsetParent) {
  21741. x -= Ext.fly(offsetParent).getX();
  21742. }
  21743. }
  21744. return x;
  21745. },
  21746. getLocalXY: function() {
  21747. var me = this,
  21748. offsetParent,
  21749. style = me.getStyle([
  21750. 'left',
  21751. 'top'
  21752. ]),
  21753. x = style.left,
  21754. y = style.top;
  21755. if (!x || x === 'auto') {
  21756. x = 0;
  21757. } else if (pxRe.test(x)) {
  21758. x = parseFloat(x);
  21759. } else {
  21760. x = me.getX();
  21761. offsetParent = me.dom.offsetParent;
  21762. if (offsetParent) {
  21763. x -= Ext.fly(offsetParent).getX();
  21764. }
  21765. }
  21766. if (!y || y === 'auto') {
  21767. y = 0;
  21768. } else if (pxRe.test(y)) {
  21769. y = parseFloat(y);
  21770. } else {
  21771. y = me.getY();
  21772. offsetParent = me.dom.offsetParent;
  21773. if (offsetParent) {
  21774. y -= Ext.fly(offsetParent).getY();
  21775. }
  21776. }
  21777. return [
  21778. x,
  21779. y
  21780. ];
  21781. },
  21782. getLocalY: function() {
  21783. var me = this,
  21784. offsetParent,
  21785. y = me.getStyle('top');
  21786. if (!y || y === 'auto') {
  21787. y = 0;
  21788. } else if (pxRe.test(y)) {
  21789. y = parseFloat(y);
  21790. } else {
  21791. y = me.getY();
  21792. offsetParent = me.dom.offsetParent;
  21793. if (offsetParent) {
  21794. y -= Ext.fly(offsetParent).getY();
  21795. }
  21796. }
  21797. return y;
  21798. },
  21799. getMargin: (function() {
  21800. var hash = {
  21801. t: "top",
  21802. l: "left",
  21803. r: "right",
  21804. b: "bottom"
  21805. },
  21806. allMargins = [
  21807. 'margin-top',
  21808. 'margin-left',
  21809. 'margin-right',
  21810. 'margin-bottom'
  21811. ];
  21812. return function(side) {
  21813. var me = this,
  21814. style, key, o;
  21815. if (!side) {
  21816. style = me.getStyle(allMargins);
  21817. o = {};
  21818. if (style && typeof style === 'object') {
  21819. o = {};
  21820. for (key in margins) {
  21821. o[key] = o[hash[key]] = parseFloat(style[margins[key]]) || 0;
  21822. }
  21823. }
  21824. } else {
  21825. o = me.addStyles(side, margins);
  21826. }
  21827. return o;
  21828. };
  21829. })(),
  21830. getPadding: function(side) {
  21831. return this.addStyles(side, paddings);
  21832. },
  21833. getParent: function() {
  21834. return Ext.get(this.dom.parentNode);
  21835. },
  21836. getRight: function(local) {
  21837. return (local ? this.getLocalX() : this.getX()) + this.getWidth();
  21838. },
  21839. getScroll: function() {
  21840. var me = this,
  21841. dom = me.dom,
  21842. docElement = docEl,
  21843. left, top,
  21844. body = DOC.body;
  21845. if (dom === DOC || dom === body) {
  21846. left = docElement.scrollLeft || (body ? body.scrollLeft : 0);
  21847. top = docElement.scrollTop || (body ? body.scrollTop : 0);
  21848. } else {
  21849. left = dom.scrollLeft;
  21850. top = dom.scrollTop;
  21851. }
  21852. return {
  21853. left: left,
  21854. top: top
  21855. };
  21856. },
  21857. getScrollIntoViewXY: function(container, scrollX, scrollY, align) {
  21858. align = align || empty;
  21859. var me = this,
  21860. dom = me.dom,
  21861. offsets, clientWidth, clientHeight;
  21862. if (container.isRegion) {
  21863. clientHeight = container.height;
  21864. clientWidth = container.width;
  21865. } else {
  21866. container = Ext.getDom(container);
  21867. clientHeight = container.clientHeight;
  21868. clientWidth = container.clientWidth;
  21869. }
  21870. offsets = me.getOffsetsTo(container);
  21871. return {
  21872. y: me.calcScrollPos(offsets[1] + scrollY, dom.offsetHeight, scrollY, clientHeight, align.y),
  21873. x: me.calcScrollPos(offsets[0] + scrollX, dom.offsetWidth, scrollX, clientWidth, align.x)
  21874. };
  21875. },
  21876. calcScrollPos: function(start, size, viewStart, viewSize, align) {
  21877. var end = start + size,
  21878. viewEnd = viewStart + viewSize,
  21879. force = align && !endsQuestionRe.test(align),
  21880. ret = viewStart;
  21881. if (!force) {
  21882. if (align) {
  21883. align = align.slice(0, -1);
  21884. }
  21885. if (size > viewSize || start < viewStart) {
  21886. align = align || 'start';
  21887. force = true;
  21888. } else if (end > viewEnd) {
  21889. align = align || 'end';
  21890. force = true;
  21891. }
  21892. }
  21893. if (force) {
  21894. if (align === 'start') {
  21895. ret = start;
  21896. } else if (align === 'center') {
  21897. ret = Math.max(0, start - Math.floor((viewSize / 2)));
  21898. } else if (align === 'end') {
  21899. ret = Math.max(0, end - viewSize);
  21900. }
  21901. }
  21902. return ret;
  21903. },
  21904. getScrollLeft: function() {
  21905. var dom = this.dom;
  21906. if (dom === DOC || dom === DOC.body) {
  21907. return this.getScroll().left;
  21908. } else {
  21909. return dom.scrollLeft;
  21910. }
  21911. },
  21912. getScrollTop: function() {
  21913. var dom = this.dom;
  21914. if (dom === DOC || dom === DOC.body) {
  21915. return this.getScroll().top;
  21916. } else {
  21917. return dom.scrollTop;
  21918. }
  21919. },
  21920. getSize: function(contentSize) {
  21921. return {
  21922. width: this.getWidth(contentSize),
  21923. height: this.getHeight(contentSize)
  21924. };
  21925. },
  21926. getStyle: function(property, inline) {
  21927. var me = this,
  21928. dom = me.dom,
  21929. multiple = typeof property !== 'string',
  21930. hooks = me.styleHooks,
  21931. prop = property,
  21932. props = prop,
  21933. len = 1,
  21934. domStyle, camel, values, hook, out, style, i;
  21935. if (multiple) {
  21936. values = {};
  21937. prop = props[0];
  21938. i = 0;
  21939. if (!(len = props.length)) {
  21940. return values;
  21941. }
  21942. }
  21943. if (!dom || dom.documentElement) {
  21944. return values || '';
  21945. }
  21946. domStyle = dom.style;
  21947. if (inline) {
  21948. style = domStyle;
  21949. } else {
  21950. style = dom.ownerDocument.defaultView.getComputedStyle(dom, null);
  21951. if (!style) {
  21952. inline = true;
  21953. style = domStyle;
  21954. }
  21955. }
  21956. do {
  21957. hook = hooks[prop];
  21958. if (!hook) {
  21959. hooks[prop] = hook = {
  21960. name: Element.normalize(prop)
  21961. };
  21962. }
  21963. if (hook.get) {
  21964. out = hook.get(dom, me, inline, style);
  21965. } else {
  21966. camel = hook.name;
  21967. out = style[camel];
  21968. }
  21969. if (!multiple) {
  21970. return out;
  21971. }
  21972. values[prop] = out;
  21973. prop = props[++i];
  21974. } while (i < len);
  21975. return values;
  21976. },
  21977. getStyleValue: function(name) {
  21978. return this.dom.style.getPropertyValue(name);
  21979. },
  21980. getCaretPos: function() {
  21981. var dom = this.dom,
  21982. pos, selection;
  21983. if (inputTypeSelectionSupported.test(dom.type)) {
  21984. pos = dom.selectionStart;
  21985. selection = (typeof pos !== 'number') && this.getTextSelection();
  21986. if (selection) {
  21987. pos = selection[0];
  21988. }
  21989. } else
  21990. {
  21991. Ext.raise('Input type of "' + dom.type + '" does not support selectionStart');
  21992. }
  21993. return pos;
  21994. },
  21995. setCaretPos: function(pos) {
  21996. this.selectText(pos, pos);
  21997. },
  21998. getTextSelection: function() {
  21999. var dom = this.dom;
  22000. if (inputTypeSelectionSupported.test(dom.type)) {
  22001. return [
  22002. dom.selectionStart,
  22003. dom.selectionEnd,
  22004. dom.selectionDirection
  22005. ];
  22006. } else {
  22007. Ext.raise('Input type of "' + this.dom.type + '" does not support selectionStart, selectionEnd and selectionDirection');
  22008. return [];
  22009. }
  22010. },
  22011. selectText: function(start, end, direction) {
  22012. var me = this,
  22013. range,
  22014. dom = me.dom,
  22015. len;
  22016. if (dom && inputTypeSelectionSupported.test(dom.type)) {
  22017. start = start || 0;
  22018. len = dom.value.length;
  22019. if (end === undefined) {
  22020. end = len;
  22021. }
  22022. direction = selectDir[direction] || direction || 'forward';
  22023. if (dom.setSelectionRange) {
  22024. dom.setSelectionRange(start, end, direction);
  22025. }
  22026. else if (dom.createTextRange) {
  22027. if (start > end) {
  22028. start = end;
  22029. }
  22030. range = dom.createTextRange();
  22031. range.moveStart('character', start);
  22032. range.moveEnd('character', -(len - end));
  22033. range.select();
  22034. }
  22035. }
  22036. else if (!inputTypeSelectionSupported.test(dom.type)) {
  22037. Ext.raise('Input type of "' + dom.type + '" does not support setSelectionRange');
  22038. }
  22039. return me;
  22040. },
  22041. getTop: function(local) {
  22042. return local ? this.getLocalY() : this.getY();
  22043. },
  22044. getTouchAction: function() {
  22045. return Ext.dom.TouchAction.get(this.dom);
  22046. },
  22047. getValue: function(asNumber) {
  22048. var value = this.dom.value;
  22049. return asNumber ? parseInt(value, 10) : value;
  22050. },
  22051. getViewSize: function() {
  22052. var dom = this.dom;
  22053. if (dom === DOC || dom === DOC.body) {
  22054. return {
  22055. width: Element.getViewportWidth(),
  22056. height: Element.getViewportHeight()
  22057. };
  22058. } else {
  22059. return {
  22060. width: dom.clientWidth,
  22061. height: dom.clientHeight
  22062. };
  22063. }
  22064. },
  22065. getVisibilityMode: function() {
  22066. var me = this,
  22067. data = me.getData(),
  22068. mode = data.visibilityMode;
  22069. if (mode === undefined) {
  22070. data.visibilityMode = mode = Element.DISPLAY;
  22071. }
  22072. return mode;
  22073. },
  22074. getWidth: function(contentWidth, preciseWidth) {
  22075. var me = this,
  22076. dom = me.dom,
  22077. hidden = me.isStyle('display', 'none'),
  22078. rect, width, floating;
  22079. if (hidden) {
  22080. return 0;
  22081. }
  22082. if (Ext.supports.BoundingClientRect) {
  22083. rect = dom.getBoundingClientRect();
  22084. width = (me.vertical && !Ext.supports.RotatedBoundingClientRect) ? (rect.bottom - rect.top) : (rect.right - rect.left);
  22085. width = preciseWidth ? width : Math.ceil(width);
  22086. } else {
  22087. width = dom.offsetWidth;
  22088. }
  22089. if (Ext.supports.Direct2DBug && !me.vertical) {
  22090. floating = me.adjustDirect2DDimension(WIDTH);
  22091. if (preciseWidth) {
  22092. width += floating;
  22093. }
  22094. else if (floating > 0 && floating < 0.5) {
  22095. width++;
  22096. }
  22097. }
  22098. if (contentWidth) {
  22099. width -= me.getBorderWidth("lr") + me.getPadding("lr");
  22100. }
  22101. return (width < 0) ? 0 : width;
  22102. },
  22103. getX: function() {
  22104. return this.getXY()[0];
  22105. },
  22106. getXY: function() {
  22107. var round = Math.round,
  22108. dom = this.dom,
  22109. body = DOC.body,
  22110. x = 0,
  22111. y = 0,
  22112. bodyRect, rect;
  22113. if (dom !== DOC && dom !== body) {
  22114. try {
  22115. bodyRect = body.getBoundingClientRect();
  22116. rect = dom.getBoundingClientRect();
  22117. x = rect.left - bodyRect.left;
  22118. y = rect.top - bodyRect.top;
  22119. } catch (ex) {}
  22120. }
  22121. return [
  22122. round(x),
  22123. round(y)
  22124. ];
  22125. },
  22126. getY: function() {
  22127. return this.getXY()[1];
  22128. },
  22129. getZIndex: function() {
  22130. return parseInt(this.getStyle('z-index'), 10);
  22131. },
  22132. hasCls: function(name) {
  22133. var classMap = this.getClassMap();
  22134. return classMap.hasOwnProperty(name);
  22135. },
  22136. hide: function() {
  22137. return this.setVisible(false);
  22138. },
  22139. hover: function(overFn, outFn, scope, options) {
  22140. var me = this;
  22141. me.on('mouseenter', overFn, scope || me.dom, options);
  22142. me.on('mouseleave', outFn, scope || me.dom, options);
  22143. return me;
  22144. },
  22145. indexOf: function(childEl) {
  22146. var children = this.dom,
  22147. c = childEl && Ext.getDom(childEl);
  22148. children = children && children.childNodes;
  22149. return (c && children) ? Array.prototype.indexOf.call(children, c) : -1;
  22150. },
  22151. insertAfter: function(el) {
  22152. el = Ext.getDom(el);
  22153. el.parentNode.insertBefore(this.dom, el.nextSibling);
  22154. return this;
  22155. },
  22156. insertBefore: function(el) {
  22157. el = Ext.getDom(el);
  22158. el.parentNode.insertBefore(this.dom, el);
  22159. return this;
  22160. },
  22161. insertFirst: function(el, returnDom) {
  22162. el = el || {};
  22163. if (el.nodeType || el.dom || typeof el === 'string') {
  22164. el = Ext.getDom(el);
  22165. this.dom.insertBefore(el, this.dom.firstChild);
  22166. return !returnDom ? Ext.get(el) : el;
  22167. } else {
  22168. return this.createChild(el, this.dom.firstChild, returnDom);
  22169. }
  22170. },
  22171. insertHtml: function(where, html, returnEl) {
  22172. var el = Ext.DomHelper.insertHtml(where, this.dom, html);
  22173. return returnEl ? Ext.get(el) : el;
  22174. },
  22175. insertSibling: function(el, where, returnDom) {
  22176. var me = this,
  22177. DomHelper = Ext.DomHelper,
  22178. isAfter = (where || 'before').toLowerCase() === 'after',
  22179. rt, insertEl, eLen, e;
  22180. if (Ext.isIterable(el)) {
  22181. eLen = el.length;
  22182. insertEl = Ext.fly(DOC.createDocumentFragment());
  22183. if (Ext.isArray(el)) {
  22184. for (e = 0; e < eLen; e++) {
  22185. rt = insertEl.appendChild(el[e], returnDom);
  22186. }
  22187. } else
  22188. {
  22189. for (e = 0; e < eLen; e++) {
  22190. insertEl.dom.appendChild(rt = el[0]);
  22191. }
  22192. if (returnDom === false) {
  22193. rt = Ext.get(rt);
  22194. }
  22195. }
  22196. me.dom.parentNode.insertBefore(insertEl.dom, isAfter ? me.dom.nextSibling : me.dom);
  22197. return rt;
  22198. }
  22199. el = el || {};
  22200. if (el.nodeType || el.dom) {
  22201. rt = me.dom.parentNode.insertBefore(Ext.getDom(el), isAfter ? me.dom.nextSibling : me.dom);
  22202. if (!returnDom) {
  22203. rt = Ext.get(rt);
  22204. }
  22205. } else {
  22206. if (isAfter && !me.dom.nextSibling) {
  22207. rt = DomHelper.append(me.dom.parentNode, el, !returnDom);
  22208. } else {
  22209. rt = DomHelper[isAfter ? 'insertAfter' : 'insertBefore'](me.dom, el, !returnDom);
  22210. }
  22211. }
  22212. return rt;
  22213. },
  22214. is: function(selector) {
  22215. var dom = this.dom,
  22216. is;
  22217. if (!selector) {
  22218. is = true;
  22219. } else if (!dom.tagName) {
  22220. is = false;
  22221. } else if (Ext.isFunction(selector)) {
  22222. is = selector(dom);
  22223. } else {
  22224. is = dom[Ext.supports.matchesSelector](selector);
  22225. }
  22226. return is;
  22227. },
  22228. isAncestor: function(el) {
  22229. var ret = false,
  22230. dom = this.dom,
  22231. child = Ext.getDom(el);
  22232. if (dom && child) {
  22233. if (!child.nodeType) {
  22234. return false;
  22235. }
  22236. if (dom.contains) {
  22237. return dom.contains(child);
  22238. } else if (dom.compareDocumentPosition) {
  22239. return !!(dom.compareDocumentPosition(child) & 16);
  22240. } else {
  22241. while ((child = child.parentNode)) {
  22242. ret = child === dom || ret;
  22243. }
  22244. }
  22245. }
  22246. return ret;
  22247. },
  22248. isPainted: (function() {
  22249. return !Ext.browser.is.IE ? function() {
  22250. var dom = this.dom;
  22251. return Boolean(dom && dom.offsetParent);
  22252. } : function() {
  22253. var dom = this.dom;
  22254. return Boolean(dom && (dom.offsetHeight !== 0 || dom.offsetWidth !== 0));
  22255. };
  22256. })(),
  22257. isScrollable: function() {
  22258. var dom = this.dom;
  22259. return dom.scrollHeight > dom.clientHeight || dom.scrollWidth > dom.clientWidth;
  22260. },
  22261. isStyle: function(style, val) {
  22262. return this.getStyle(style) === val;
  22263. },
  22264. isVisible: function(deep, mode) {
  22265. var dom = this.dom,
  22266. visible = true,
  22267. end;
  22268. if (!dom) {
  22269. return false;
  22270. }
  22271. mode = mode || 3;
  22272. if (!visFly) {
  22273. visFly = new Ext.dom.Fly();
  22274. }
  22275. for (end = dom.ownerDocument.documentElement; dom !== end; dom = dom.parentNode) {
  22276. if (!dom || dom.nodeType === 11) {
  22277. visible = false;
  22278. }
  22279. if (visible) {
  22280. visFly.attach(dom);
  22281. if (mode & 1) {
  22282. visible = !visFly.isStyle(DISPLAY, NONE);
  22283. }
  22284. if (visible && (mode & 2)) {
  22285. visible = !visFly.isStyle(VISIBILITY, HIDDEN);
  22286. }
  22287. }
  22288. if (!visible || !deep) {
  22289. break;
  22290. }
  22291. }
  22292. return visible;
  22293. },
  22294. last: function(selector, returnDom) {
  22295. return this.matchNode('previousSibling', 'lastChild', selector, returnDom);
  22296. },
  22297. matchNode: function(dir, start, selector, returnDom) {
  22298. var dom = this.dom,
  22299. n;
  22300. if (!dom) {
  22301. return null;
  22302. }
  22303. n = dom[start];
  22304. while (n) {
  22305. if (n.nodeType === 1 && (!selector || Ext.fly(n, '_matchNode').is(selector))) {
  22306. return !returnDom ? Ext.get(n) : n;
  22307. }
  22308. n = n[dir];
  22309. }
  22310. return null;
  22311. },
  22312. measure: function(dimension) {
  22313. var me = this,
  22314. dom = me.dom,
  22315. includeWidth = dimension !== 'h',
  22316. includeHeight = dimension !== 'w',
  22317. width = 0,
  22318. height = 0,
  22319. addPadding = !Ext.supports.ComputedSizeIncludesPadding,
  22320. style, rect, offsetParent;
  22321. if (dom.nodeName === 'BODY') {
  22322. height = includeHeight && Element.getViewportHeight();
  22323. width = includeWidth && Element.getViewportWidth();
  22324. } else {
  22325. offsetParent = dom.offsetParent;
  22326. style = dom.ownerDocument.defaultView.getComputedStyle(dom, null);
  22327. addPadding |= style.boxSizing === 'content-box';
  22328. if (offsetParent !== null || style.position === 'fixed') {
  22329. if (includeHeight) {
  22330. height = toFloat(style.height);
  22331. if (addPadding) {
  22332. height += toFloat(style.paddingTop) + toFloat(style.paddingBottom) + toFloat(style.borderTopWidth) + toFloat(style.borderBottomWidth);
  22333. }
  22334. }
  22335. if (includeWidth) {
  22336. width = toFloat(style.width);
  22337. if (addPadding) {
  22338. width += toFloat(style.paddingLeft) + toFloat(style.paddingRight) + toFloat(style.borderLeftWidth) + toFloat(style.borderRightWidth);
  22339. }
  22340. }
  22341. }
  22342. }
  22343. rect = dimension ? null : {
  22344. width: width,
  22345. height: height
  22346. };
  22347. return dimension ? (includeWidth ? width : height) : rect;
  22348. },
  22349. measureContent: function(dimension) {
  22350. var me = this,
  22351. includeWidth = dimension !== 'h',
  22352. size = me.measure(dimension),
  22353. h = dimension ? size : size.height,
  22354. w = dimension ? size : size.width;
  22355. if (dimension !== 'w') {
  22356. h -= me.getBorderWidth('tb') + me.getPadding('tb');
  22357. }
  22358. if (includeWidth) {
  22359. w -= me.getBorderWidth('lr') + me.getPadding('lr');
  22360. }
  22361. return dimension ? (includeWidth ? w : h) : {
  22362. width: w,
  22363. height: h
  22364. };
  22365. },
  22366. monitorMouseLeave: function(delay, handler, scope) {
  22367. var me = this,
  22368. timer,
  22369. listeners = {
  22370. mouseleave: function(e) {
  22371. if (Ext.isIE9m) {
  22372. e.enableIEAsync();
  22373. }
  22374. timer = Ext.defer(handler, delay, scope || me, [
  22375. e
  22376. ]);
  22377. },
  22378. mouseenter: function() {
  22379. Ext.undefer(timer);
  22380. },
  22381. destroy: function() {
  22382. Ext.undefer(timer);
  22383. if (!me.destroyed) {
  22384. me.un(listeners);
  22385. }
  22386. }
  22387. };
  22388. me.on(listeners);
  22389. return listeners;
  22390. },
  22391. next: function(selector, returnDom) {
  22392. return this.matchNode('nextSibling', 'nextSibling', selector, returnDom);
  22393. },
  22394. parent: function(selector, returnDom) {
  22395. return this.matchNode('parentNode', 'parentNode', selector, returnDom);
  22396. },
  22397. peekData: function() {
  22398. var dom = this.dom;
  22399. return dom && dom._extData || null;
  22400. },
  22401. position: function(pos, zIndex, x, y) {
  22402. var me = this;
  22403. if (me.dom.tagName !== 'BODY') {
  22404. if (!pos && me.isStyle(POSITION, STATIC)) {
  22405. me.setStyle(POSITION, RELATIVE);
  22406. } else if (pos) {
  22407. me.setStyle(POSITION, pos);
  22408. }
  22409. if (zIndex) {
  22410. me.setStyle(ZINDEX, zIndex);
  22411. }
  22412. if (x || y) {
  22413. me.setXY([
  22414. x || false,
  22415. y || false
  22416. ]);
  22417. }
  22418. }
  22419. },
  22420. prev: function(selector, returnDom) {
  22421. return this.matchNode('previousSibling', 'previousSibling', selector, returnDom);
  22422. },
  22423. query: function(selector, asDom, single) {
  22424. var dom = this.dom,
  22425. results, len, nlen, node, nodes, i, j;
  22426. if (!dom) {
  22427. return null;
  22428. }
  22429. asDom = (asDom !== false);
  22430. selector = selector.split(",");
  22431. if (!single) {
  22432. results = [];
  22433. }
  22434. for (i = 0 , len = selector.length; i < len; i++) {
  22435. if (typeof selector[i] === 'string') {
  22436. if (single) {
  22437. node = dom.querySelector(selector[i]);
  22438. return asDom ? node : Ext.get(node);
  22439. }
  22440. nodes = dom.querySelectorAll(selector[i]);
  22441. for (j = 0 , nlen = nodes.length; j < nlen; j++) {
  22442. results.push(asDom ? nodes[j] : Ext.get(nodes[j]));
  22443. }
  22444. }
  22445. }
  22446. return results;
  22447. },
  22448. radioCls: function(className) {
  22449. var cn = this.dom.parentNode.childNodes,
  22450. v;
  22451. className = Ext.isArray(className) ? className : [
  22452. className
  22453. ];
  22454. for (var i = 0,
  22455. len = cn.length; i < len; i++) {
  22456. v = cn[i];
  22457. if (v && v.nodeType === 1) {
  22458. Ext.fly(v).removeCls(className);
  22459. }
  22460. }
  22461. return this.addCls(className);
  22462. },
  22463. redraw: function() {
  22464. var dom = this.dom,
  22465. domStyle = dom.style;
  22466. domStyle.display = 'none';
  22467. dom.offsetHeight;
  22468. domStyle.display = '';
  22469. },
  22470. remove: function() {
  22471. this.destroy();
  22472. },
  22473. removeChild: function(element) {
  22474. this.dom.removeChild(Ext.getDom(element));
  22475. return this;
  22476. },
  22477. removeCls: function(names, prefix, suffix) {
  22478. return this.replaceCls(names, null, prefix, suffix);
  22479. },
  22480. repaint: function() {
  22481. var me = this;
  22482. me.addCls(Ext.baseCSSPrefix + 'repaint');
  22483. if (!me.repaintTimer) {
  22484. me.repaintTimer = Ext.defer(function() {
  22485. me.repaintTimer = null;
  22486. if (me.dom) {
  22487. me.removeCls(Ext.baseCSSPrefix + 'repaint');
  22488. }
  22489. }, 1);
  22490. }
  22491. return me;
  22492. },
  22493. replace: function(el, destroy) {
  22494. el = Ext.getDom(el);
  22495. var parentNode = el.parentNode,
  22496. id = el.id,
  22497. dom = this.dom;
  22498. if (!parentNode) {
  22499. Ext.raise('Cannot replace element "' + id + '". It is not attached to a parent node.');
  22500. }
  22501. if (destroy !== false && id && Ext.cache[id]) {
  22502. parentNode.insertBefore(dom, el);
  22503. Ext.get(el).destroy();
  22504. } else {
  22505. parentNode.replaceChild(dom, el);
  22506. }
  22507. return this;
  22508. },
  22509. replaceCls: function(remove, add, prefix, suffix) {
  22510. var me = this,
  22511. added = 0,
  22512. removed = 0,
  22513. rem = remove,
  22514. data = (add || remove) && me.getData(),
  22515. list, map, i, n, name;
  22516. if (data) {
  22517. list = data.classList;
  22518. map = data.classMap;
  22519. add = add ? ((typeof add === 'string') ? add.split(spacesRe) : add) : EMPTY;
  22520. rem = rem ? ((typeof rem === 'string') ? rem.split(spacesRe) : rem) : EMPTY;
  22521. prefix = prefix || '';
  22522. if (prefix && prefix[prefix.length - 1] !== '-') {
  22523. prefix += '-';
  22524. }
  22525. suffix = suffix || '';
  22526. if (suffix && suffix[0] !== '-') {
  22527. suffix = '-' + suffix;
  22528. }
  22529. for (i = 0 , n = rem.length; i < n; i++) {
  22530. if (!(name = rem[i])) {
  22531. continue;
  22532. }
  22533. name = prefix + name + suffix;
  22534. if (spacesRe.test(name)) {
  22535. Ext.raise('Class names in arrays must not contain spaces');
  22536. }
  22537. if (map[name]) {
  22538. delete map[name];
  22539. ++removed;
  22540. }
  22541. }
  22542. for (i = 0 , n = add.length; i < n; i++) {
  22543. if (!(name = add[i])) {
  22544. continue;
  22545. }
  22546. name = prefix + name + suffix;
  22547. if (spacesRe.test(name)) {
  22548. Ext.raise('Class names in arrays must not contain spaces');
  22549. }
  22550. if (!map[name]) {
  22551. map[name] = true;
  22552. if (!removed) {
  22553. list.push(name);
  22554. ++added;
  22555. }
  22556. }
  22557. }
  22558. if (removed) {
  22559. me.setClassMap(map,
  22560. true);
  22561. } else if (added) {
  22562. me.dom.className = list.join(' ');
  22563. }
  22564. }
  22565. return me;
  22566. },
  22567. replaceWith: function(el) {
  22568. var me = this,
  22569. dom = me.dom,
  22570. parent = dom.parentNode,
  22571. cache = Ext.cache,
  22572. newDom;
  22573. me.clearListeners();
  22574. if (el.nodeType || el.dom || typeof el === 'string') {
  22575. el = Ext.get(el);
  22576. newDom = parent.insertBefore(el.dom, dom);
  22577. } else {
  22578. newDom = Ext.DomHelper.insertBefore(dom, el);
  22579. }
  22580. parent.removeChild(dom);
  22581. me.dom = newDom;
  22582. if (!me.isFly) {
  22583. delete cache[me.id];
  22584. cache[me.id = Ext.id(newDom)] = me;
  22585. }
  22586. return me;
  22587. },
  22588. resolveListenerScope: function(defaultScope) {
  22589. var component = this.component;
  22590. return component ? component.resolveListenerScope(defaultScope) : this;
  22591. },
  22592. scroll: function(direction, distance, animate) {
  22593. if (!this.isScrollable()) {
  22594. return false;
  22595. }
  22596. direction = direction.charAt(0);
  22597. var me = this,
  22598. dom = me.dom,
  22599. side = direction === 'r' || direction === 'l' ? 'left' : 'top',
  22600. scrolled = false,
  22601. currentScroll, constrainedScroll;
  22602. if (direction === 'l' || direction === 't' || direction === 'u') {
  22603. distance = -distance;
  22604. }
  22605. if (side === 'left') {
  22606. currentScroll = dom.scrollLeft;
  22607. constrainedScroll = me.constrainScrollLeft(currentScroll + distance);
  22608. } else {
  22609. currentScroll = dom.scrollTop;
  22610. constrainedScroll = me.constrainScrollTop(currentScroll + distance);
  22611. }
  22612. if (constrainedScroll !== currentScroll) {
  22613. this.scrollTo(side, constrainedScroll, animate);
  22614. scrolled = true;
  22615. }
  22616. return scrolled;
  22617. },
  22618. scrollBy: function(deltaX, deltaY, animate) {
  22619. var me = this,
  22620. dom = me.dom;
  22621. if (deltaX.length) {
  22622. animate = deltaY;
  22623. deltaY = deltaX[1];
  22624. deltaX = deltaX[0];
  22625. } else if (typeof deltaX != 'number') {
  22626. animate = deltaY;
  22627. deltaY = deltaX.y;
  22628. deltaX = deltaX.x;
  22629. }
  22630. if (deltaX) {
  22631. me.scrollTo('left', me.constrainScrollLeft(dom.scrollLeft + deltaX), animate);
  22632. }
  22633. if (deltaY) {
  22634. me.scrollTo('top', me.constrainScrollTop(dom.scrollTop + deltaY), animate);
  22635. }
  22636. return me;
  22637. },
  22638. scrollChildIntoView: function(child, hscroll) {
  22639. Ext.fly(child).scrollIntoView(this, hscroll);
  22640. },
  22641. scrollIntoView: function(container, hscroll, animate, highlight) {
  22642. container = Ext.getDom(container) || Ext.getBody().dom;
  22643. return this.doScrollIntoView(container, hscroll, animate, highlight, 'getScrollLeft', 'scrollTo');
  22644. },
  22645. scrollTo: function(side, value, animate) {
  22646. var top = topRe.test(side),
  22647. me = this,
  22648. prop = top ? 'scrollTop' : 'scrollLeft',
  22649. dom = me.dom,
  22650. animCfg;
  22651. if (!animate || !me.anim) {
  22652. dom[prop] = value;
  22653. dom[prop] = value;
  22654. } else {
  22655. animCfg = {
  22656. to: {}
  22657. };
  22658. animCfg.to[prop] = value;
  22659. if (Ext.isObject(animate)) {
  22660. Ext.applyIf(animCfg, animate);
  22661. }
  22662. me.animate(animCfg);
  22663. }
  22664. return me;
  22665. },
  22666. select: function(selector, composite) {
  22667. var isElementArray, elements;
  22668. if (typeof selector === "string") {
  22669. elements = this.query(selector, !composite);
  22670. }
  22671. else if (selector.length === undefined) {
  22672. Ext.raise("Invalid selector specified: " + selector);
  22673. } else
  22674. {
  22675. elements = selector;
  22676. isElementArray = true;
  22677. }
  22678. return composite ? new Ext.CompositeElement(elements, !isElementArray) : new Ext.CompositeElementLite(elements, true);
  22679. },
  22680. selectNode: function(selector, asDom) {
  22681. return this.query(selector, asDom, true);
  22682. },
  22683. set: function(attributes, useSet) {
  22684. var me = this,
  22685. dom = me.dom,
  22686. attribute, value;
  22687. for (attribute in attributes) {
  22688. if (attributes.hasOwnProperty(attribute)) {
  22689. value = attributes[attribute];
  22690. if (attribute === 'style') {
  22691. me.applyStyles(value);
  22692. } else if (attribute === 'cls') {
  22693. dom.className = value;
  22694. } else if (useSet !== false) {
  22695. if (value === undefined) {
  22696. dom.removeAttribute(attribute);
  22697. } else {
  22698. dom.setAttribute(attribute, value);
  22699. }
  22700. } else {
  22701. dom[attribute] = value;
  22702. }
  22703. }
  22704. }
  22705. return me;
  22706. },
  22707. setBottom: function(bottom) {
  22708. this.dom.style[BOTTOM] = Element.addUnits(bottom);
  22709. return this;
  22710. },
  22711. setClassMap: function(classMap, keep) {
  22712. var data = this.getData(
  22713. false),
  22714. classList;
  22715. if (data) {
  22716. classMap = (keep && classMap) || Ext.apply({}, classMap);
  22717. data.classMap = classMap;
  22718. data.classList = classList = Ext.Object.getKeys(classMap);
  22719. data.isSynchronized = true;
  22720. this.dom.className = classList.join(' ');
  22721. }
  22722. },
  22723. setCls: function(className) {
  22724. var me = this,
  22725. elementData = me.getData(
  22726. false),
  22727. i, ln, map, classList;
  22728. if (typeof className === 'string') {
  22729. className = className.split(spacesRe);
  22730. }
  22731. elementData.classList = classList = className.slice();
  22732. elementData.classMap = map = {};
  22733. for (i = 0 , ln = classList.length; i < ln; i++) {
  22734. map[classList[i]] = true;
  22735. }
  22736. me.dom.className = classList.join(' ');
  22737. },
  22738. setDisplayed: function(value) {
  22739. var me = this;
  22740. if (typeof value === "boolean") {
  22741. value = value ? me._getDisplay() : NONE;
  22742. }
  22743. me.setStyle(DISPLAY, value);
  22744. if (me.shadow || me.shim) {
  22745. me.setUnderlaysVisible(value !== NONE);
  22746. }
  22747. return me;
  22748. },
  22749. setHeight: function(height) {
  22750. var me = this;
  22751. me.dom.style[HEIGHT] = Element.addUnits(height);
  22752. if (me.shadow || me.shim) {
  22753. me.syncUnderlays();
  22754. }
  22755. return me;
  22756. },
  22757. setHtml: function(html) {
  22758. if (this.dom) {
  22759. this.dom.innerHTML = html;
  22760. }
  22761. return this;
  22762. },
  22763. setId: function(id) {
  22764. var me = this,
  22765. currentId = me.id,
  22766. cache = Ext.cache;
  22767. if (currentId) {
  22768. delete cache[currentId];
  22769. }
  22770. me.dom.id = id;
  22771. me.id = id;
  22772. cache[id] = me;
  22773. return me;
  22774. },
  22775. setLeft: function(left) {
  22776. var me = this;
  22777. me.dom.style[LEFT] = Element.addUnits(left);
  22778. if (me.shadow || me.shim) {
  22779. me.syncUnderlays();
  22780. }
  22781. return me;
  22782. },
  22783. setLocalX: function(x) {
  22784. var me = this,
  22785. style = me.dom.style;
  22786. style.right = '';
  22787. style.left = (x === null) ? 'auto' : x + 'px';
  22788. if (me.shadow || me.shim) {
  22789. me.syncUnderlays();
  22790. }
  22791. return me;
  22792. },
  22793. setLocalXY: function(x, y) {
  22794. var me = this,
  22795. style = me.dom.style;
  22796. style.right = '';
  22797. if (x && x.length) {
  22798. y = x[1];
  22799. x = x[0];
  22800. }
  22801. if (x === null) {
  22802. style.left = 'auto';
  22803. } else if (x !== undefined) {
  22804. style.left = x + 'px';
  22805. }
  22806. if (y === null) {
  22807. style.top = 'auto';
  22808. } else if (y !== undefined) {
  22809. style.top = y + 'px';
  22810. }
  22811. if (me.shadow || me.shim) {
  22812. me.syncUnderlays();
  22813. }
  22814. return me;
  22815. },
  22816. setLocalY: function(y) {
  22817. var me = this;
  22818. me.dom.style.top = (y === null) ? 'auto' : y + 'px';
  22819. if (me.shadow || me.shim) {
  22820. me.syncUnderlays();
  22821. }
  22822. return me;
  22823. },
  22824. setMargin: function(margin) {
  22825. var me = this,
  22826. domStyle = me.dom.style;
  22827. if (margin || margin === 0) {
  22828. margin = me.self.unitizeBox((margin === true) ? 5 : margin);
  22829. domStyle.setProperty('margin', margin, 'important');
  22830. } else {
  22831. domStyle.removeProperty('margin-top');
  22832. domStyle.removeProperty('margin-right');
  22833. domStyle.removeProperty('margin-bottom');
  22834. domStyle.removeProperty('margin-left');
  22835. }
  22836. },
  22837. setMaxHeight: function(height) {
  22838. this.dom.style[MAX_HEIGHT] = Element.addUnits(height);
  22839. return this;
  22840. },
  22841. setMaxWidth: function(width) {
  22842. this.dom.style[MAX_WIDTH] = Element.addUnits(width);
  22843. return this;
  22844. },
  22845. setMinHeight: function(height) {
  22846. this.dom.style[MIN_HEIGHT] = Element.addUnits(height);
  22847. return this;
  22848. },
  22849. setMinWidth: function(width) {
  22850. this.dom.style[MIN_WIDTH] = Element.addUnits(width);
  22851. return this;
  22852. },
  22853. setOpacity: function(opacity) {
  22854. var me = this;
  22855. if (me.dom) {
  22856. me.setStyle('opacity', opacity);
  22857. }
  22858. return me;
  22859. },
  22860. setPadding: function(padding) {
  22861. var me = this,
  22862. domStyle = me.dom.style;
  22863. if (padding || padding === 0) {
  22864. padding = me.self.unitizeBox((padding === true) ? 5 : padding);
  22865. domStyle.setProperty('padding', padding, 'important');
  22866. } else {
  22867. domStyle.removeProperty('padding-top');
  22868. domStyle.removeProperty('padding-right');
  22869. domStyle.removeProperty('padding-bottom');
  22870. domStyle.removeProperty('padding-left');
  22871. }
  22872. },
  22873. setRight: function(right) {
  22874. this.dom.style[RIGHT] = Element.addUnits(right);
  22875. return this;
  22876. },
  22877. setScrollLeft: function(left) {
  22878. this.dom.scrollLeft = left;
  22879. return this;
  22880. },
  22881. setScrollTop: function(top) {
  22882. this.dom.scrollTop = top;
  22883. return this;
  22884. },
  22885. setSize: function(width, height) {
  22886. var me = this,
  22887. style = me.dom.style;
  22888. if (Ext.isObject(width)) {
  22889. height = width.height;
  22890. width = width.width;
  22891. }
  22892. if (width !== undefined) {
  22893. style.width = Element.addUnits(width);
  22894. }
  22895. if (height !== undefined) {
  22896. style.height = Element.addUnits(height);
  22897. }
  22898. if (me.shadow || me.shim) {
  22899. me.syncUnderlays();
  22900. }
  22901. return me;
  22902. },
  22903. setStyle: function(prop, value) {
  22904. var me = this,
  22905. dom = me.dom,
  22906. hooks = me.styleHooks,
  22907. style = dom.style,
  22908. name = prop,
  22909. hook;
  22910. if (typeof name === 'string') {
  22911. hook = hooks[name];
  22912. if (!hook) {
  22913. hooks[name] = hook = {
  22914. name: Element.normalize(name)
  22915. };
  22916. }
  22917. value = (value == null) ? '' : value;
  22918. if (hook.set) {
  22919. hook.set(dom, value, me);
  22920. } else {
  22921. style[hook.name] = value;
  22922. }
  22923. if (hook.afterSet) {
  22924. hook.afterSet(dom, value, me);
  22925. }
  22926. } else {
  22927. for (name in prop) {
  22928. hook = hooks[name];
  22929. if (!hook) {
  22930. hooks[name] = hook = {
  22931. name: Element.normalize(name)
  22932. };
  22933. }
  22934. value = prop[name];
  22935. value = (value == null) ? '' : value;
  22936. if (hook.set) {
  22937. hook.set(dom, value, me);
  22938. } else {
  22939. style[hook.name] = value;
  22940. }
  22941. if (hook.afterSet) {
  22942. hook.afterSet(dom, value, me);
  22943. }
  22944. }
  22945. }
  22946. return me;
  22947. },
  22948. setText: function(text) {
  22949. this.dom.textContent = text;
  22950. },
  22951. setTop: function(top) {
  22952. var me = this;
  22953. me.dom.style[TOP] = Element.addUnits(top);
  22954. if (me.shadow || me.shim) {
  22955. me.syncUnderlays();
  22956. }
  22957. return me;
  22958. },
  22959. setTouchAction: function(touchAction) {
  22960. Ext.dom.TouchAction.set(this.dom, touchAction);
  22961. },
  22962. setUnderlaysVisible: function(visible) {
  22963. var shadow = this.shadow,
  22964. shim = this.shim;
  22965. if (shadow && !shadow.disabled) {
  22966. if (visible) {
  22967. shadow.show();
  22968. } else {
  22969. shadow.hide();
  22970. }
  22971. }
  22972. if (shim && !shim.disabled) {
  22973. if (visible) {
  22974. shim.show();
  22975. } else {
  22976. shim.hide();
  22977. }
  22978. }
  22979. },
  22980. setVisibility: function(isVisible) {
  22981. var domStyle = this.dom.style;
  22982. if (isVisible) {
  22983. domStyle.removeProperty('visibility');
  22984. } else {
  22985. domStyle.setProperty('visibility', 'hidden', 'important');
  22986. }
  22987. },
  22988. setVisibilityMode: function(mode) {
  22989. if (mode !== 1 && mode !== 2 && mode !== 3 && mode !== 4 && mode !== 5) {
  22990. Ext.raise("visibilityMode must be one of the following: " + "Ext.Element.DISPLAY, Ext.Element.VISIBILITY, Ext.Element.OFFSETS, " + "Ext.Element.CLIP, or Element.OPACITY");
  22991. }
  22992. this.getData().visibilityMode = mode;
  22993. return this;
  22994. },
  22995. setVisible: function(visible) {
  22996. var me = this,
  22997. mode = me.getVisibilityMode(),
  22998. addOrRemove = visible ? 'removeCls' : 'addCls';
  22999. switch (mode) {
  23000. case Element.DISPLAY:
  23001. me.removeCls([
  23002. visibilityCls,
  23003. offsetsCls,
  23004. clipCls,
  23005. opacityCls
  23006. ]);
  23007. me[addOrRemove](displayCls);
  23008. break;
  23009. case Element.VISIBILITY:
  23010. me.removeCls([
  23011. displayCls,
  23012. offsetsCls,
  23013. clipCls,
  23014. opacityCls
  23015. ]);
  23016. me[addOrRemove](visibilityCls);
  23017. break;
  23018. case Element.OFFSETS:
  23019. me.removeCls([
  23020. visibilityCls,
  23021. displayCls,
  23022. clipCls,
  23023. opacityCls
  23024. ]);
  23025. me[addOrRemove](offsetsCls);
  23026. break;
  23027. case Element.CLIP:
  23028. me.removeCls([
  23029. visibilityCls,
  23030. displayCls,
  23031. offsetsCls,
  23032. opacityCls
  23033. ]);
  23034. me[addOrRemove](clipCls);
  23035. break;
  23036. case Element.OPACITY:
  23037. me.removeCls([
  23038. visibilityCls,
  23039. displayCls,
  23040. offsetsCls,
  23041. clipCls
  23042. ]);
  23043. me[addOrRemove](opacityCls);
  23044. break;
  23045. }
  23046. if (me.shadow || me.shim) {
  23047. me.setUnderlaysVisible(visible);
  23048. }
  23049. if (!visible && me.$ripples) {
  23050. me.destroyAllRipples();
  23051. }
  23052. return me;
  23053. },
  23054. setWidth: function(width) {
  23055. var me = this;
  23056. me.dom.style[WIDTH] = Element.addUnits(width);
  23057. if (me.shadow || me.shim) {
  23058. me.syncUnderlays();
  23059. }
  23060. return me;
  23061. },
  23062. setX: function(x) {
  23063. return this.setXY([
  23064. x,
  23065. false
  23066. ]);
  23067. },
  23068. setXY: function(xy) {
  23069. var me = this,
  23070. pts = me.translatePoints(xy),
  23071. style = me.dom.style,
  23072. pos;
  23073. me.position();
  23074. style.right = '';
  23075. for (pos in pts) {
  23076. if (!isNaN(pts[pos])) {
  23077. style[pos] = pts[pos] + 'px';
  23078. }
  23079. }
  23080. if (me.shadow || me.shim) {
  23081. me.syncUnderlays();
  23082. }
  23083. return me;
  23084. },
  23085. setY: function(y) {
  23086. return this.setXY([
  23087. false,
  23088. y
  23089. ]);
  23090. },
  23091. setZIndex: function(zindex) {
  23092. var me = this;
  23093. if (me.shadow) {
  23094. me.shadow.setZIndex(zindex);
  23095. }
  23096. if (me.shim) {
  23097. me.shim.setZIndex(zindex);
  23098. }
  23099. return me.setStyle('z-index', zindex);
  23100. },
  23101. show: function() {
  23102. return this.setVisible(true);
  23103. },
  23104. swallowEvent: function(eventName, preventDefault) {
  23105. var me = this,
  23106. e, eLen,
  23107. listeners = {
  23108. destroyable: true
  23109. },
  23110. fn = function(e) {
  23111. e.stopPropagation();
  23112. if (preventDefault) {
  23113. e.preventDefault();
  23114. }
  23115. };
  23116. if (Ext.isArray(eventName)) {
  23117. eLen = eventName.length;
  23118. for (e = 0; e < eLen; e++) {
  23119. listeners[eventName[e]] = fn;
  23120. }
  23121. } else {
  23122. listeners[eventName] = fn;
  23123. }
  23124. return me.on(listeners);
  23125. },
  23126. swapCls: function(firstClass, secondClass, flag, prefix) {
  23127. if (flag === undefined) {
  23128. flag = true;
  23129. }
  23130. var me = this,
  23131. addedClass = flag ? firstClass : secondClass,
  23132. removedClass = flag ? secondClass : firstClass;
  23133. if (removedClass) {
  23134. me.removeCls(prefix ? prefix + '-' + removedClass : removedClass);
  23135. }
  23136. if (addedClass) {
  23137. me.addCls(prefix ? prefix + '-' + addedClass : addedClass);
  23138. }
  23139. return me;
  23140. },
  23141. synchronize: function() {
  23142. var me = this,
  23143. dom = me.dom,
  23144. hasClassMap = {},
  23145. className = dom.className,
  23146. classList, i, ln, name,
  23147. elementData = me.getData(
  23148. false);
  23149. if (className && className.length > 0) {
  23150. classList = dom.className.split(classNameSplitRegex);
  23151. for (i = 0 , ln = classList.length; i < ln; i++) {
  23152. name = classList[i];
  23153. hasClassMap[name] = true;
  23154. }
  23155. } else {
  23156. classList = [];
  23157. }
  23158. elementData.classList = classList;
  23159. elementData.classMap = hasClassMap;
  23160. elementData.isSynchronized = true;
  23161. return me;
  23162. },
  23163. syncUnderlays: function() {
  23164. var me = this,
  23165. shadow = me.shadow,
  23166. shim = me.shim,
  23167. dom = me.dom,
  23168. xy, x, y, w, h;
  23169. if (me.isVisible()) {
  23170. xy = me.getXY();
  23171. x = xy[0];
  23172. y = xy[1];
  23173. w = dom.offsetWidth;
  23174. h = dom.offsetHeight;
  23175. if (shadow && !shadow.hidden) {
  23176. shadow.realign(x, y, w, h);
  23177. }
  23178. if (shim && !shim.hidden) {
  23179. shim.realign(x, y, w, h);
  23180. }
  23181. }
  23182. },
  23183. toggleCls: function(className, state) {
  23184. if (state == null) {
  23185. state = !this.hasCls(className);
  23186. }
  23187. return state ? this.addCls(className) : this.removeCls(className);
  23188. },
  23189. toggle: function() {
  23190. this.setVisible(!this.isVisible());
  23191. return this;
  23192. },
  23193. translate: function() {
  23194. var transformStyleName = 'webkitTransform' in DOC.createElement('div').style ? 'webkitTransform' : 'transform';
  23195. return function(x, y, z) {
  23196. x = Math.round(x);
  23197. y = Math.round(y);
  23198. z = Math.round(z);
  23199. this.dom.style[transformStyleName] = 'translate3d(' + (x || 0) + 'px, ' + (y || 0) + 'px, ' + (z || 0) + 'px)';
  23200. };
  23201. }(),
  23202. unwrap: function() {
  23203. var dom = this.dom,
  23204. parentNode = dom.parentNode,
  23205. activeElement = (activeElFly || (activeElFly = new Ext.dom.Fly())).attach(Ext.Element.getActiveElement()),
  23206. grandparentNode, cached, resumeFocus, tabIndex;
  23207. grannyFly = grannyFly || new Ext.dom.Fly();
  23208. cached = Ext.cache[activeElement.dom.id];
  23209. if (cached) {
  23210. activeElement = cached;
  23211. }
  23212. if (this.contains(activeElement)) {
  23213. if (cached) {
  23214. cached.suspendFocusEvents();
  23215. }
  23216. resumeFocus = true;
  23217. }
  23218. if (parentNode) {
  23219. grandparentNode = parentNode.parentNode;
  23220. if (resumeFocus) {
  23221. tabIndex = grandparentNode.getAttribute('tabIndex');
  23222. grannyFly.attach(grandparentNode);
  23223. grannyFly.set({
  23224. tabIndex: -1
  23225. });
  23226. grannyFly.suspendFocusEvents();
  23227. grannyFly.focus();
  23228. }
  23229. grandparentNode.insertBefore(dom, parentNode);
  23230. grandparentNode.removeChild(parentNode);
  23231. } else {
  23232. grandparentNode = DOC.createDocumentFragment();
  23233. grandparentNode.appendChild(dom);
  23234. }
  23235. if (resumeFocus) {
  23236. if (cached) {
  23237. cached.focus();
  23238. cached.resumeFocusEvents();
  23239. } else {
  23240. activeElement.focus();
  23241. }
  23242. if (grannyFly) {
  23243. grannyFly.resumeFocusEvents();
  23244. grannyFly.set({
  23245. tabIndex: tabIndex
  23246. });
  23247. }
  23248. }
  23249. return this;
  23250. },
  23251. up: function(simpleSelector, limit, returnDom) {
  23252. return this.findParentNode(simpleSelector, limit, !returnDom);
  23253. },
  23254. update: function(html) {
  23255. return this.setHtml(html);
  23256. },
  23257. wrap: function(config, returnDom, selector) {
  23258. var me = this,
  23259. dom = me.dom,
  23260. result = Ext.DomHelper.insertBefore(dom, config || {
  23261. tag: "div"
  23262. }, !returnDom),
  23263. newEl = (wrapFly || (wrapFly = new Ext.dom.Fly())).attach(Ext.getDom(result)),
  23264. target = newEl,
  23265. activeElement = (activeElFly || (activeElFly = new Ext.dom.Fly())).attach(Ext.Element.getActiveElement()),
  23266. cached, resumeFocus, tabIndex;
  23267. cached = Ext.cache[activeElement.dom.id];
  23268. if (cached) {
  23269. activeElement = cached;
  23270. }
  23271. if (selector) {
  23272. target = newEl.selectNode(selector, returnDom);
  23273. }
  23274. if (me.contains(activeElement)) {
  23275. if (cached) {
  23276. cached.suspendFocusEvents();
  23277. }
  23278. tabIndex = Ext.getDom(newEl).getAttribute('tabIndex');
  23279. newEl.set({
  23280. tabIndex: -1
  23281. });
  23282. newEl.suspendFocusEvents();
  23283. newEl.focus();
  23284. resumeFocus = true;
  23285. }
  23286. (target.dom || target).appendChild(dom);
  23287. if (resumeFocus) {
  23288. if (cached) {
  23289. cached.focus();
  23290. cached.resumeFocusEvents();
  23291. } else {
  23292. activeElement.focus();
  23293. }
  23294. newEl.resumeFocusEvents();
  23295. newEl.set({
  23296. tabIndex: tabIndex
  23297. });
  23298. }
  23299. return result;
  23300. },
  23301. isFocusable: function(skipVisibility) {
  23302. var dom = this.dom,
  23303. focusable = false,
  23304. nodeName;
  23305. if (dom && !dom.disabled) {
  23306. nodeName = dom.nodeName;
  23307. focusable = !!Ext.Element.naturallyFocusableTags[nodeName] || ((nodeName === 'A' || nodeName === 'LINK') && !!dom.href) || dom.getAttribute('tabIndex') != null || dom.contentEditable === 'true';
  23308. if (Ext.isIE8 && nodeName === 'INPUT' && dom.type === 'hidden') {
  23309. focusable = false;
  23310. }
  23311. focusable = focusable && (skipVisibility || this.isVisible(true));
  23312. }
  23313. return focusable;
  23314. },
  23315. isInputField: function() {
  23316. var dom = this.dom,
  23317. contentEditable = dom.contentEditable;
  23318. if ((Ext.Element.inputTags[dom.tagName] && dom.type !== 'button') || (contentEditable === '' || contentEditable === 'true')) {
  23319. return true;
  23320. }
  23321. return false;
  23322. },
  23323. isTabbable: function(includeHidden) {
  23324. var dom = this.dom,
  23325. tabbable = false,
  23326. nodeName, hasIndex, tabIndex;
  23327. if (dom && !dom.disabled) {
  23328. nodeName = dom.nodeName;
  23329. tabIndex = dom.getAttribute('tabIndex');
  23330. hasIndex = tabIndex != null;
  23331. tabIndex -= 0;
  23332. if (nodeName === 'A' || nodeName === 'LINK') {
  23333. if (dom.href) {
  23334. tabbable = hasIndex && tabIndex < 0 ? false : true;
  23335. } else
  23336. {
  23337. if (dom.contentEditable === 'true') {
  23338. tabbable = !hasIndex || (hasIndex && tabIndex >= 0) ? true : false;
  23339. } else {
  23340. tabbable = hasIndex && tabIndex >= 0 ? true : false;
  23341. }
  23342. }
  23343. }
  23344. else if (dom.contentEditable === 'true' || Ext.Element.naturallyTabbableTags[nodeName]) {
  23345. tabbable = hasIndex && tabIndex < 0 ? false : true;
  23346. } else
  23347. {
  23348. if (hasIndex && tabIndex >= 0) {
  23349. tabbable = true;
  23350. }
  23351. }
  23352. if (Ext.isIE8 && nodeName === 'INPUT' && dom.type === 'hidden') {
  23353. tabbable = false;
  23354. }
  23355. tabbable = tabbable && (includeHidden || ((!this.component || this.component.isVisible(true)) && this.isVisible(true)));
  23356. }
  23357. return tabbable;
  23358. },
  23359. ripplingCls: Ext.baseCSSPrefix + 'rippling',
  23360. ripplingTransitionCls: Ext.baseCSSPrefix + 'ripple-transition',
  23361. ripplingUnboundCls: Ext.baseCSSPrefix + 'rippling-unbound',
  23362. rippleBubbleCls: Ext.baseCSSPrefix + 'ripple-bubble',
  23363. rippleContainerCls: Ext.baseCSSPrefix + 'ripple-container',
  23364. rippleWrapperCls: Ext.baseCSSPrefix + 'ripple-wrapper',
  23365. noRippleDisplayMap: {
  23366. table: 1,
  23367. 'table-row': 1,
  23368. 'table-row-group': 1
  23369. },
  23370. noRippleTagMap: {
  23371. TABLE: 1,
  23372. TR: 1,
  23373. TBODY: 1
  23374. },
  23375. ripple: function(event, options) {
  23376. if (options === true || !options) {
  23377. options = {};
  23378. } else if (Ext.isString(options)) {
  23379. options = {
  23380. color: options
  23381. };
  23382. }
  23383. var me = this,
  23384. rippleParent = Ext.isString(options.delegate) ? me.down(options.delegate) : me,
  23385. rippleMeasureEl = Ext.isString(options.measureSelector) ? me.down(options.measureSelector) : null,
  23386. color = window.getComputedStyle(rippleParent.dom).color,
  23387. unbound = options.bound === false,
  23388. position = options.position,
  23389. ripplingCls = me.ripplingCls,
  23390. ripplingTransitionCls = me.ripplingTransitionCls,
  23391. ripplingUnboundCls = me.ripplingUnboundCls,
  23392. rippleBubbleCls = me.rippleBubbleCls,
  23393. rippleContainerCls = me.rippleContainerCls,
  23394. rippleWrapperCls = me.rippleWrapperCls,
  23395. offset, width, height, rippleDiameter, center, measureElWidth, measureElHeight, rippleSize, pos, posX, posY, rippleWrapper, rippleContainer, rippleBubble, rippleDestructor, rippleClearFn, rippleDestructionTimer, rippleBox, unboundEl, unboundElData, timeout;
  23396. if (rippleParent) {
  23397. offset = rippleParent.getXY();
  23398. width = rippleParent.getWidth();
  23399. height = rippleParent.getHeight();
  23400. timeout = rippleParent.$rippleClearTimeout;
  23401. if (timeout) {
  23402. rippleParent.$rippleClearTimeout = Ext.undefer(timeout);
  23403. }
  23404. if (rippleMeasureEl) {
  23405. measureElWidth = rippleMeasureEl.getWidth();
  23406. measureElHeight = rippleMeasureEl.getHeight();
  23407. rippleDiameter = Math.max(measureElWidth, measureElHeight);
  23408. } else {
  23409. rippleDiameter = width > height ? width : height;
  23410. }
  23411. if (options.diameterLimit === undefined || options.diameterLimit === true) {
  23412. rippleDiameter = Math.min(rippleDiameter, Element.maxRippleDiameter);
  23413. } else if (options.diameterLimit && options.diameterLimit !== false && options.diameterLimit !== 0) {
  23414. rippleDiameter = Math.min(rippleDiameter, options.diameterLimit);
  23415. }
  23416. center = [
  23417. offset[0] + width / 2,
  23418. offset[1] + height / 2
  23419. ];
  23420. if (unbound) {
  23421. if (options.fit !== false) {
  23422. rippleSize = rippleDiameter * 2.15;
  23423. rippleBox = rippleParent.getRegion();
  23424. rippleBox.setPosition(rippleBox.getCenter()).setSize(rippleSize).translateBy(-rippleSize / 2, -rippleSize / 2);
  23425. unboundEl = me.up(function(candidate) {
  23426. var fly = Ext.fly(candidate, 'ripple');
  23427. return !(candidate.tagName in me.noRippleTagMap) && !(fly.getStyle('display') in me.noRippleDisplayMap) && (fly.getRegion().contains(rippleBox));
  23428. }) || Ext.getBody();
  23429. } else {
  23430. unboundEl = rippleParent;
  23431. }
  23432. }
  23433. if (Ext.isString(event)) {
  23434. options.color = event;
  23435. event = null;
  23436. } else if (event && !event.isEvent) {
  23437. event = new Ext.event.Event(event);
  23438. }
  23439. if (event && event.isEvent) {
  23440. if (event.browserEvent.$preventRipple) {
  23441. return;
  23442. }
  23443. position = event.getXY();
  23444. event.browserEvent.$preventRipple = true;
  23445. }
  23446. pos = (!unbound && !options.centered && position) || center;
  23447. posX = pos[0] - offset[0] - (rippleDiameter / 2);
  23448. posY = pos[1] - offset[1] - (rippleDiameter / 2);
  23449. rippleParent.addCls(ripplingTransitionCls);
  23450. if (!unbound) {
  23451. rippleParent.addCls(ripplingCls);
  23452. rippleContainer = rippleParent.child('.' + rippleContainerCls);
  23453. } else {
  23454. unboundElData = unboundEl.getData();
  23455. rippleWrapper = unboundElData.rippleWrapper;
  23456. if (!rippleWrapper) {
  23457. unboundElData.rippleWrapper = rippleWrapper = unboundEl.insertFirst({
  23458. style: 'position: absolute; top: 0; left: 0',
  23459. cls: rippleWrapperCls + ' ' + ripplingCls + ' ' + ripplingUnboundCls
  23460. });
  23461. }
  23462. }
  23463. if (!rippleContainer) {
  23464. if (unbound) {
  23465. rippleContainer = rippleWrapper.append({
  23466. cls: rippleContainerCls
  23467. });
  23468. rippleContainer.setXY(offset);
  23469. } else {
  23470. rippleContainer = rippleParent.append({
  23471. cls: rippleContainerCls
  23472. });
  23473. }
  23474. }
  23475. rippleBubble = rippleContainer.append({
  23476. cls: rippleBubbleCls
  23477. });
  23478. if (options.color !== 'default') {
  23479. rippleBubble.setStyle('backgroundColor', options.color || color);
  23480. }
  23481. rippleBubble.setWidth(rippleDiameter);
  23482. rippleBubble.setHeight(rippleDiameter);
  23483. rippleBubble.setTop(posY);
  23484. rippleBubble.setLeft(posX);
  23485. rippleClearFn = function() {
  23486. if (!rippleParent.destroyed) {
  23487. rippleParent.$rippleClearTimeout = Ext.defer(function() {
  23488. rippleParent.removeCls([
  23489. ripplingCls,
  23490. ripplingTransitionCls
  23491. ]);
  23492. rippleParent.$rippleClearTimeout = null;
  23493. }, 50);
  23494. }
  23495. };
  23496. rippleDestructor = function() {
  23497. var ripple, timeout;
  23498. rippleBubble.destroy();
  23499. if (me.$ripples) {
  23500. delete me.$ripples[rippleBubble.id];
  23501. }
  23502. timeout = rippleParent.$rippleClearTimeout;
  23503. if (timeout) {
  23504. rippleParent.$rippleClearTimeout = Ext.undefer(timeout);
  23505. }
  23506. if (unbound) {
  23507. rippleContainer.destroy();
  23508. ripple = rippleWrapper.child('.' + rippleContainerCls);
  23509. if (!ripple) {
  23510. unboundElData.rippleWrapper = null;
  23511. rippleWrapper.destroy();
  23512. rippleClearFn();
  23513. }
  23514. } else {
  23515. ripple = rippleContainer.child('.' + rippleBubbleCls);
  23516. if (!ripple) {
  23517. rippleContainer.destroy();
  23518. rippleClearFn();
  23519. }
  23520. }
  23521. };
  23522. rippleDestructionTimer = Ext.defer(rippleDestructor, options.destroyTime || 1000, me);
  23523. if (!me.$ripples) {
  23524. me.$ripples = {};
  23525. }
  23526. me.$ripples[rippleBubble.id] = {
  23527. timerId: rippleDestructionTimer,
  23528. destructor: rippleDestructor
  23529. };
  23530. rippleBubble.addCls(Ext.baseCSSPrefix + 'ripple');
  23531. }
  23532. },
  23533. destroyAllRipples: function() {
  23534. var me = this,
  23535. rippleEl, ripple;
  23536. for (rippleEl in me.$ripples) {
  23537. ripple = me.$ripples[rippleEl];
  23538. Ext.undefer(ripple.timerId);
  23539. if (ripple.destructor) {
  23540. ripple.destructor();
  23541. }
  23542. }
  23543. me.$ripples = null;
  23544. },
  23545. privates: {
  23546. findTabbableElements: function(options) {
  23547. var skipSelf, skipChildren, excludeRoot, includeSaved, includeHidden,
  23548. dom = this.dom,
  23549. cAttr = Ext.Element.tabbableSavedCounterAttribute,
  23550. selection = [],
  23551. idx = 0,
  23552. nodes, node, fly, i, len, tabIndex;
  23553. if (!dom) {
  23554. return selection;
  23555. }
  23556. if (options) {
  23557. skipSelf = options.skipSelf;
  23558. skipChildren = options.skipChildren;
  23559. excludeRoot = options.excludeRoot;
  23560. includeSaved = options.includeSaved;
  23561. includeHidden = options.includeHidden;
  23562. }
  23563. excludeRoot = excludeRoot && Ext.getDom(excludeRoot);
  23564. if (excludeRoot && excludeRoot.contains(dom)) {
  23565. return selection;
  23566. }
  23567. if (!skipSelf && ((includeSaved && dom.hasAttribute(cAttr)) || this.isTabbable(includeHidden))) {
  23568. selection[idx++] = dom;
  23569. }
  23570. if (skipChildren) {
  23571. return selection;
  23572. }
  23573. nodes = dom.querySelectorAll(Ext.Element.tabbableSelector);
  23574. len = nodes.length;
  23575. if (!len) {
  23576. return selection;
  23577. }
  23578. fly = new Ext.dom.Fly();
  23579. for (i = 0; i < len; i++) {
  23580. node = nodes[i];
  23581. tabIndex = +node.getAttribute('tabIndex');
  23582. if (((includeSaved && node.hasAttribute(cAttr)) || (!(tabIndex < 0) && fly.attach(node).isTabbable(includeHidden))) && !(excludeRoot && (excludeRoot === node || excludeRoot.contains(node)))) {
  23583. selection[idx++] = node;
  23584. }
  23585. }
  23586. return selection;
  23587. },
  23588. saveTabbableState: function(options) {
  23589. var counterAttr = Ext.Element.tabbableSavedCounterAttribute,
  23590. savedAttr = Ext.Element.tabbableSavedValueAttribute,
  23591. counter, nodes, node, i, len;
  23592. if (!options || options.includeSaved == null) {
  23593. options = Ext.Object.chain(options || null);
  23594. options.includeSaved = true;
  23595. }
  23596. nodes = this.findTabbableElements(options);
  23597. for (i = 0 , len = nodes.length; i < len; i++) {
  23598. node = nodes[i];
  23599. counter = +node.getAttribute(counterAttr);
  23600. if (counter > 0) {
  23601. node.setAttribute(counterAttr, ++counter);
  23602. } else {
  23603. if (node.hasAttribute('tabIndex')) {
  23604. node.setAttribute(savedAttr, node.getAttribute('tabIndex'));
  23605. } else
  23606. {
  23607. node.setAttribute(savedAttr, 'none');
  23608. }
  23609. node.setAttribute('tabIndex', '-1');
  23610. node.setAttribute(counterAttr, '1');
  23611. }
  23612. }
  23613. return nodes;
  23614. },
  23615. restoreTabbableState: function(options) {
  23616. var dom = this.dom,
  23617. counterAttr = Ext.Element.tabbableSavedCounterAttribute,
  23618. savedAttr = Ext.Element.tabbableSavedValueAttribute,
  23619. nodes = [],
  23620. skipSelf = options && options.skipSelf,
  23621. skipChildren = options && options.skipChildren,
  23622. reset = options && options.reset,
  23623. idx, counter, node, i, len;
  23624. if (!dom) {
  23625. return this;
  23626. }
  23627. if (!skipChildren) {
  23628. nodes = Ext.Array.from(dom.querySelectorAll('[' + counterAttr + ']'));
  23629. }
  23630. if (!skipSelf) {
  23631. nodes.unshift(dom);
  23632. }
  23633. for (i = 0 , len = nodes.length; i < len; i++) {
  23634. node = nodes[i];
  23635. if (!node.hasAttribute(counterAttr) || !node.hasAttribute(savedAttr)) {
  23636. continue;
  23637. }
  23638. counter = +node.getAttribute(counterAttr);
  23639. if (!reset && counter > 1) {
  23640. node.setAttribute(counterAttr, --counter);
  23641. continue;
  23642. }
  23643. idx = node.getAttribute(savedAttr);
  23644. if (idx === 'none') {
  23645. node.removeAttribute('tabIndex');
  23646. } else {
  23647. node.setAttribute('tabIndex', idx);
  23648. }
  23649. node.removeAttribute(savedAttr);
  23650. node.removeAttribute(counterAttr);
  23651. }
  23652. return nodes;
  23653. },
  23654. setTabIndex: function(tabIndex) {
  23655. var dom = this.dom,
  23656. savedAttr = Ext.Element.tabbableSavedValueAttribute;
  23657. if (dom.hasAttribute(savedAttr)) {
  23658. if (tabIndex == null) {
  23659. dom.setAttribute(savedAttr, 'none');
  23660. dom.removeAttribute('tabIndex');
  23661. } else {
  23662. dom.setAttribute(savedAttr, tabIndex);
  23663. }
  23664. } else {
  23665. if (tabIndex == null) {
  23666. dom.removeAttribute('tabIndex');
  23667. } else {
  23668. dom.setAttribute('tabIndex', tabIndex);
  23669. }
  23670. }
  23671. },
  23672. doAddListener: function(eventName, fn, scope, options, order, caller, manager) {
  23673. var me = this,
  23674. originalName = eventName,
  23675. observableDoAddListener, additiveEventName, translatedEventName;
  23676. eventName = Ext.canonicalEventName(eventName);
  23677. if (!me.blockedEvents[eventName]) {
  23678. observableDoAddListener = me.mixins.observable.doAddListener;
  23679. options = options || {};
  23680. if (Element.useDelegatedEvents === false) {
  23681. options.delegated = options.delegated || false;
  23682. }
  23683. if (options.translate !== false) {
  23684. additiveEventName = me.additiveEvents[eventName];
  23685. if (additiveEventName) {
  23686. options.type = eventName;
  23687. eventName = additiveEventName;
  23688. observableDoAddListener.call(me, eventName, fn, scope, options, order, caller, manager);
  23689. }
  23690. translatedEventName = me.eventMap[eventName];
  23691. if (translatedEventName) {
  23692. options.type = options.type || eventName;
  23693. if (manager) {
  23694. options.managedName = originalName;
  23695. }
  23696. eventName = translatedEventName;
  23697. }
  23698. }
  23699. if (observableDoAddListener.call(me, eventName, fn, scope, options, order, caller, manager)) {
  23700. if (me.longpressEvents[eventName] && (++me.longpressListenerCount === 1)) {
  23701. me.on('MSHoldVisual', 'preventMsHoldVisual', me);
  23702. }
  23703. }
  23704. if (manager && translatedEventName) {
  23705. delete options.managedName;
  23706. }
  23707. delete options.type;
  23708. }
  23709. },
  23710. doRemoveListener: function(eventName, fn, scope) {
  23711. var me = this,
  23712. observableDoRemoveListener, translatedEventName, additiveEventName, removed;
  23713. eventName = Ext.canonicalEventName(eventName);
  23714. if (!me.blockedEvents[eventName]) {
  23715. observableDoRemoveListener = me.mixins.observable.doRemoveListener;
  23716. additiveEventName = me.additiveEvents[eventName];
  23717. if (additiveEventName) {
  23718. eventName = additiveEventName;
  23719. observableDoRemoveListener.call(me, eventName, fn, scope);
  23720. }
  23721. translatedEventName = me.eventMap[eventName];
  23722. if (translatedEventName) {
  23723. removed = observableDoRemoveListener.call(me, translatedEventName, fn, scope);
  23724. }
  23725. removed = observableDoRemoveListener.call(me, eventName, fn, scope) || removed;
  23726. if (removed) {
  23727. if (me.longpressEvents[eventName] && !--me.longpressListenerCount) {
  23728. me.un('MSHoldVisual', 'preventMsHoldVisual', me);
  23729. }
  23730. }
  23731. }
  23732. },
  23733. _initEvent: function(eventName) {
  23734. return (this.events[eventName] = new Ext.dom.ElementEvent(this, eventName));
  23735. },
  23736. _getDisplay: function() {
  23737. var data = this.getData(),
  23738. display = data[ORIGINALDISPLAY];
  23739. if (display === undefined) {
  23740. data[ORIGINALDISPLAY] = display = '';
  23741. }
  23742. return display;
  23743. },
  23744. _getPublisher: function(eventName, noTranslate) {
  23745. var Publisher = Ext.event.publisher.Publisher,
  23746. publisher = Publisher.publishersByEvent[eventName],
  23747. isNative = noTranslate && !Ext.event.Event.gestureEvents[eventName];
  23748. if (isNative || !publisher || (this.dom === window && eventName === 'resize')) {
  23749. publisher = Publisher.publishers.dom;
  23750. }
  23751. return publisher;
  23752. },
  23753. isFocusSuspended: function() {
  23754. var data = this.peekData();
  23755. return data && data.suspendFocusEvents;
  23756. },
  23757. preventMsHoldVisual: function(e) {
  23758. e.preventDefault();
  23759. },
  23760. suspendFocusEvents: function() {
  23761. if (!this.isFly) {
  23762. this.suspendEvent('focus', 'blur');
  23763. }
  23764. this.getData().suspendFocusEvents = true;
  23765. },
  23766. resumeFocusEvents: function() {
  23767. function resumeFn() {
  23768. var data;
  23769. if (!this.destroyed) {
  23770. data = this.getData();
  23771. if (data) {
  23772. data.suspendFocusEvents = false;
  23773. }
  23774. if (!this.isFly) {
  23775. this.resumeEvent('focus', 'blur');
  23776. }
  23777. }
  23778. }
  23779. if (!this.destroyed && this.getData().suspendFocusEvents) {
  23780. if (Ext.isIE && !this.isFly) {
  23781. this.resumeFocusEventsTimer = Ext.asap(resumeFn, this);
  23782. } else {
  23783. resumeFn.call(this);
  23784. }
  23785. }
  23786. }
  23787. },
  23788. deprecated: {
  23789. '5.0': {
  23790. methods: {
  23791. getHTML: 'getHtml',
  23792. getPageBox: function(getRegion) {
  23793. var me = this,
  23794. dom = me.dom,
  23795. isDoc = dom.nodeName === 'BODY',
  23796. w = isDoc ? Element.getViewportWidth() : dom.offsetWidth,
  23797. h = isDoc ? Element.getViewportHeight() : dom.offsetHeight,
  23798. xy = me.getXY(),
  23799. t = xy[1],
  23800. r = xy[0] + w,
  23801. b = xy[1] + h,
  23802. l = xy[0];
  23803. if (getRegion) {
  23804. return new Ext.util.Region(t, r, b, l);
  23805. } else {
  23806. return {
  23807. left: l,
  23808. top: t,
  23809. width: w,
  23810. height: h,
  23811. right: r,
  23812. bottom: b
  23813. };
  23814. }
  23815. },
  23816. isTransparent: function(prop) {
  23817. var value = this.getStyle(prop);
  23818. return value ? transparentRe.test(value) : false;
  23819. },
  23820. purgeAllListeners: 'clearListeners',
  23821. removeAllListeners: 'clearListeners',
  23822. setHTML: 'setHtml'
  23823. }
  23824. }
  23825. }
  23826. };
  23827. }, function(Element) {
  23828. var DOC = document,
  23829. docEl = DOC.documentElement,
  23830. prototype = Element.prototype,
  23831. supports = Ext.supports,
  23832. pointerdown = 'pointerdown',
  23833. pointermove = 'pointermove',
  23834. pointerup = 'pointerup',
  23835. pointercancel = 'pointercancel',
  23836. MSPointerDown = 'MSPointerDown',
  23837. MSPointerMove = 'MSPointerMove',
  23838. MSPointerUp = 'MSPointerUp',
  23839. MSPointerCancel = 'MSPointerCancel',
  23840. mousedown = 'mousedown',
  23841. mousemove = 'mousemove',
  23842. mouseup = 'mouseup',
  23843. mouseover = 'mouseover',
  23844. mouseout = 'mouseout',
  23845. mouseenter = 'mouseenter',
  23846. mouseleave = 'mouseleave',
  23847. touchstart = 'touchstart',
  23848. touchmove = 'touchmove',
  23849. touchend = 'touchend',
  23850. touchcancel = 'touchcancel',
  23851. click = 'click',
  23852. dblclick = 'dblclick',
  23853. tap = 'tap',
  23854. doubletap = 'doubletap',
  23855. eventMap = prototype.eventMap = {},
  23856. additiveEvents = prototype.additiveEvents = {},
  23857. oldId = Ext.id,
  23858. eventOptions;
  23859. prototype._init(Element);
  23860. delete prototype._init;
  23861. Ext.id = function(obj, prefix) {
  23862. var el = obj && Ext.getDom(obj, true),
  23863. sandboxPrefix, id;
  23864. if (!el) {
  23865. id = oldId(obj, prefix);
  23866. } else if (!(id = el.id)) {
  23867. id = oldId(null, prefix || Element.prototype.identifiablePrefix);
  23868. if (Ext.isSandboxed) {
  23869. sandboxPrefix = Ext.sandboxPrefix || (Ext.sandboxPrefix = Ext.sandboxName.toLowerCase() + '-');
  23870. id = sandboxPrefix + id;
  23871. }
  23872. el.id = id;
  23873. }
  23874. return id;
  23875. };
  23876. if (supports.PointerEvents) {
  23877. eventMap[mousedown] = pointerdown;
  23878. eventMap[mousemove] = pointermove;
  23879. eventMap[mouseup] = pointerup;
  23880. eventMap[touchstart] = pointerdown;
  23881. eventMap[touchmove] = pointermove;
  23882. eventMap[touchend] = pointerup;
  23883. eventMap[touchcancel] = pointercancel;
  23884. eventMap[mouseover] = 'pointerover';
  23885. eventMap[mouseout] = 'pointerout';
  23886. eventMap[mouseenter] = 'pointerenter';
  23887. if (!Ext.isIE11) {
  23888. eventMap[mouseleave] = 'pointerleave';
  23889. }
  23890. } else if (supports.MSPointerEvents) {
  23891. eventMap[pointerdown] = MSPointerDown;
  23892. eventMap[pointermove] = MSPointerMove;
  23893. eventMap[pointerup] = MSPointerUp;
  23894. eventMap[pointercancel] = MSPointerCancel;
  23895. eventMap[mousedown] = MSPointerDown;
  23896. eventMap[mousemove] = MSPointerMove;
  23897. eventMap[mouseup] = MSPointerUp;
  23898. eventMap[touchstart] = MSPointerDown;
  23899. eventMap[touchmove] = MSPointerMove;
  23900. eventMap[touchend] = MSPointerUp;
  23901. eventMap[touchcancel] = MSPointerCancel;
  23902. eventMap[mouseover] = 'MSPointerOver';
  23903. eventMap[mouseout] = 'MSPointerOut';
  23904. } else if (supports.TouchEvents) {
  23905. eventMap[pointerdown] = touchstart;
  23906. eventMap[pointermove] = touchmove;
  23907. eventMap[pointerup] = touchend;
  23908. eventMap[pointercancel] = touchcancel;
  23909. eventMap[mousedown] = touchstart;
  23910. eventMap[mousemove] = touchmove;
  23911. eventMap[mouseup] = touchend;
  23912. eventMap[click] = tap;
  23913. eventMap[dblclick] = doubletap;
  23914. if (Ext.os.is.Desktop) {
  23915. eventMap[touchstart] = mousedown;
  23916. eventMap[touchmove] = mousemove;
  23917. eventMap[touchend] = mouseup;
  23918. eventMap[touchcancel] = mouseup;
  23919. additiveEvents[mousedown] = mousedown;
  23920. additiveEvents[mousemove] = mousemove;
  23921. additiveEvents[mouseup] = mouseup;
  23922. additiveEvents[touchstart] = touchstart;
  23923. additiveEvents[touchmove] = touchmove;
  23924. additiveEvents[touchend] = touchend;
  23925. additiveEvents[touchcancel] = touchcancel;
  23926. additiveEvents[pointerdown] = mousedown;
  23927. additiveEvents[pointermove] = mousemove;
  23928. additiveEvents[pointerup] = mouseup;
  23929. additiveEvents[pointercancel] = mouseup;
  23930. }
  23931. } else {
  23932. eventMap[pointerdown] = mousedown;
  23933. eventMap[pointermove] = mousemove;
  23934. eventMap[pointerup] = mouseup;
  23935. eventMap[pointercancel] = mouseup;
  23936. eventMap[touchstart] = mousedown;
  23937. eventMap[touchmove] = mousemove;
  23938. eventMap[touchend] = mouseup;
  23939. eventMap[touchcancel] = mouseup;
  23940. }
  23941. if (Ext.isWebKit) {
  23942. eventMap.transitionend = Ext.browser.getVendorProperyName('transitionEnd');
  23943. eventMap.animationstart = Ext.browser.getVendorProperyName('animationStart');
  23944. eventMap.animationend = Ext.browser.getVendorProperyName('animationEnd');
  23945. }
  23946. if (!Ext.supports.MouseWheel && !Ext.isOpera) {
  23947. eventMap.mousewheel = 'DOMMouseScroll';
  23948. }
  23949. eventOptions = prototype.$eventOptions = Ext.Object.chain(prototype.$eventOptions);
  23950. eventOptions.translate = eventOptions.capture = eventOptions.delegate = eventOptions.delegated = eventOptions.stopEvent = eventOptions.preventDefault = eventOptions.stopPropagation =
  23951. eventOptions.element = 1;
  23952. prototype.styleHooks.opacity = {
  23953. name: 'opacity',
  23954. afterSet: function(dom, value, el) {
  23955. var shadow = el.shadow;
  23956. if (shadow) {
  23957. shadow.setOpacity(value);
  23958. }
  23959. }
  23960. };
  23961. prototype.getTrueXY = prototype.getXY;
  23962. Ext.getViewportHeight = Element.getViewportHeight;
  23963. Ext.getViewportWidth = Element.getViewportWidth;
  23964. Ext.select = Element.select;
  23965. Ext.query = Element.query;
  23966. Ext.apply(Ext, {
  23967. get: function(element) {
  23968. return Element.get(element);
  23969. },
  23970. getDom: function(el) {
  23971. if (!el || !DOC) {
  23972. return null;
  23973. }
  23974. return typeof el === 'string' ? Ext.getElementById(el) : 'dom' in el ? el.dom : el;
  23975. },
  23976. getBody: function() {
  23977. if (!Ext._bodyEl) {
  23978. if (!DOC.body) {
  23979. throw new Error("[Ext.getBody] document.body does not yet exist");
  23980. }
  23981. Ext._bodyEl = Ext.get(DOC.body);
  23982. Ext._bodyEl.skipGarbageCollection = true;
  23983. }
  23984. return Ext._bodyEl;
  23985. },
  23986. getHead: function() {
  23987. if (!Ext._headEl) {
  23988. Ext._headEl = Ext.get(DOC.head || DOC.getElementsByTagName('head')[0]);
  23989. Ext._headEl.skipGarbageCollection = true;
  23990. }
  23991. return Ext._headEl;
  23992. },
  23993. getDoc: function() {
  23994. if (!Ext._docEl) {
  23995. Ext._docEl = Ext.get(DOC);
  23996. Ext._docEl.skipGarbageCollection = true;
  23997. }
  23998. return Ext._docEl;
  23999. },
  24000. getWin: function() {
  24001. if (!Ext._winEl) {
  24002. Ext._winEl = Ext.get(window);
  24003. Ext._winEl.skipGarbageCollection = true;
  24004. }
  24005. return Ext._winEl;
  24006. },
  24007. removeNode: function(node) {
  24008. node = node.dom || node;
  24009. var id = node && node.id,
  24010. el = Ext.cache[id],
  24011. parent;
  24012. if (el) {
  24013. el.destroy();
  24014. } else if (node && (node.nodeType === 3 || node.tagName.toUpperCase() !== 'BODY')) {
  24015. parent = node.parentNode;
  24016. if (parent) {
  24017. parent.removeChild(node);
  24018. }
  24019. }
  24020. }
  24021. });
  24022. Ext.isGarbage = function(dom) {
  24023. return dom &&
  24024. dom.nodeType === 1 && dom.tagName !== 'BODY' && dom.tagName !== 'HTML' && (
  24025. !dom.parentNode || (
  24026. dom.offsetParent === null &&
  24027. ((Ext.isIE8 ? DOC.all[dom.id] : DOC.getElementById(dom.id)) !== dom) &&
  24028. !(Ext.detachedBodyEl && Ext.detachedBodyEl.isAncestor(dom))));
  24029. };
  24030. Ext.onInternalReady(function() {
  24031. var bodyCls = [],
  24032. theme;
  24033. Ext.getDoc().on('selectstart', function(ev, dom) {
  24034. var selectableCls = Element.selectableCls,
  24035. unselectableCls = Element.unselectableCls,
  24036. tagName = dom && dom.tagName,
  24037. el = new Ext.dom.Fly();
  24038. tagName = tagName && tagName.toLowerCase();
  24039. if (tagName === 'input' || tagName === 'textarea') {
  24040. return;
  24041. }
  24042. while (dom && dom.nodeType === 1 && dom !== DOC.documentElement) {
  24043. el.attach(dom);
  24044. if (el.hasCls(selectableCls)) {
  24045. return;
  24046. }
  24047. if (el.hasCls(unselectableCls)) {
  24048. ev.stopEvent();
  24049. return;
  24050. }
  24051. dom = dom.parentNode;
  24052. }
  24053. });
  24054. if (Ext.os.is.Android || (Ext.os.is.Windows && Ext.supports.Touch)) {
  24055. var win = Ext.getWin();
  24056. Element._documentWidth = Element._viewportWidth = docEl.clientWidth;
  24057. Element._documentHeight = Element._viewportHeight = docEl.clientHeight;
  24058. win.on({
  24059. focusin: '_onWindowFocusChange',
  24060. focusout: '_onWindowFocusChange',
  24061. pointerup: '_onWindowFocusChange',
  24062. capture: true,
  24063. delegated: false,
  24064. delay: 1,
  24065. scope: Element
  24066. });
  24067. win.on({
  24068. resize: '_onWindowResize',
  24069. priority: 2000,
  24070. scope: Element
  24071. });
  24072. }
  24073. if (supports.Touch) {
  24074. bodyCls.push(Ext.baseCSSPrefix + 'touch');
  24075. }
  24076. if (Ext.isIE && Ext.isIE9m) {
  24077. bodyCls.push(Ext.baseCSSPrefix + 'ie', Ext.baseCSSPrefix + 'ie9m');
  24078. bodyCls.push(Ext.baseCSSPrefix + 'ie8p');
  24079. if (Ext.isIE8) {
  24080. bodyCls.push(Ext.baseCSSPrefix + 'ie8');
  24081. } else {
  24082. bodyCls.push(Ext.baseCSSPrefix + 'ie9', Ext.baseCSSPrefix + 'ie9p');
  24083. }
  24084. if (Ext.isIE8m) {
  24085. bodyCls.push(Ext.baseCSSPrefix + 'ie8m');
  24086. }
  24087. }
  24088. if (Ext.isIE10) {
  24089. bodyCls.push(Ext.baseCSSPrefix + 'ie10');
  24090. }
  24091. if (Ext.isIE10p) {
  24092. bodyCls.push(Ext.baseCSSPrefix + 'ie10p');
  24093. }
  24094. if (Ext.isIE11) {
  24095. bodyCls.push(Ext.baseCSSPrefix + 'ie11');
  24096. }
  24097. if (Ext.isEdge) {
  24098. bodyCls.push(Ext.baseCSSPrefix + 'edge');
  24099. }
  24100. if (Ext.isGecko) {
  24101. bodyCls.push(Ext.baseCSSPrefix + 'gecko');
  24102. }
  24103. if (Ext.isOpera) {
  24104. bodyCls.push(Ext.baseCSSPrefix + 'opera');
  24105. }
  24106. if (Ext.isOpera12m) {
  24107. bodyCls.push(Ext.baseCSSPrefix + 'opera12m');
  24108. }
  24109. if (Ext.isWebKit) {
  24110. bodyCls.push(Ext.baseCSSPrefix + 'webkit');
  24111. }
  24112. if (Ext.isSafari) {
  24113. bodyCls.push(Ext.baseCSSPrefix + 'safari');
  24114. }
  24115. if (Ext.isSafari9) {
  24116. bodyCls.push(Ext.baseCSSPrefix + 'safari9');
  24117. }
  24118. if (Ext.isSafari10) {
  24119. bodyCls.push(Ext.baseCSSPrefix + 'safari10');
  24120. }
  24121. if (Ext.isSafari11) {
  24122. bodyCls.push(Ext.baseCSSPrefix + 'safari11');
  24123. }
  24124. if (Ext.isSafari && Ext.browser.version.isLessThan(9)) {
  24125. bodyCls.push(Ext.baseCSSPrefix + 'safari8m');
  24126. }
  24127. if (Ext.isChrome) {
  24128. bodyCls.push(Ext.baseCSSPrefix + 'chrome');
  24129. }
  24130. if (Ext.isMac) {
  24131. bodyCls.push(Ext.baseCSSPrefix + 'mac');
  24132. }
  24133. if (Ext.isWindows) {
  24134. bodyCls.push(Ext.baseCSSPrefix + 'windows');
  24135. }
  24136. if (Ext.isLinux) {
  24137. bodyCls.push(Ext.baseCSSPrefix + 'linux');
  24138. }
  24139. if (!supports.CSS3BorderRadius) {
  24140. bodyCls.push(Ext.baseCSSPrefix + 'nbr');
  24141. }
  24142. if (!supports.CSS3LinearGradient) {
  24143. bodyCls.push(Ext.baseCSSPrefix + 'nlg');
  24144. }
  24145. if (supports.Touch) {
  24146. bodyCls.push(Ext.baseCSSPrefix + 'touch');
  24147. }
  24148. if (Ext.os.deviceType) {
  24149. bodyCls.push(Ext.baseCSSPrefix + Ext.os.deviceType.toLowerCase());
  24150. }
  24151. if (Ext.os.is.BlackBerry) {
  24152. bodyCls.push(Ext.baseCSSPrefix + 'bb');
  24153. if (Ext.browser.userAgent.match(/Kbd/gi)) {
  24154. bodyCls.push(Ext.baseCSSPrefix + 'bb-keyboard');
  24155. }
  24156. }
  24157. if (Ext.os.is.iOS && Ext.isSafari) {
  24158. bodyCls.push(Ext.baseCSSPrefix + 'mobile-safari');
  24159. }
  24160. if (Ext.os.is.iOS && Ext.browser.is.WebView && !Ext.browser.is.Standalone) {
  24161. bodyCls.push(Ext.baseCSSPrefix + 'ios-native');
  24162. }
  24163. if (Ext.supports.FlexBoxBasisBug) {
  24164. bodyCls.push(Ext.baseCSSPrefix + 'has-flexbasis-bug');
  24165. }
  24166. Ext.getBody().addCls(bodyCls);
  24167. theme = Ext.theme;
  24168. if (theme && theme.getDocCls) {
  24169. Ext.fly(document.documentElement).addCls(theme.getDocCls());
  24170. }
  24171. }, null, {
  24172. priority: 1500
  24173. });
  24174. });
  24175. Ext.define('Ext.GlobalEvents', {
  24176. extend: Ext.mixin.Observable,
  24177. alternateClassName: 'Ext.globalEvents',
  24178. observableType: 'global',
  24179. singleton: true,
  24180. resizeBuffer: 100,
  24181. idleEventMask: {
  24182. mousemove: 1,
  24183. touchmove: 1,
  24184. pointermove: 1,
  24185. MSPointerMove: 1,
  24186. unload: 1
  24187. },
  24188. windowListeners: {
  24189. resize: {
  24190. fn: 'fireResize'
  24191. }
  24192. },
  24193. constructor: function() {
  24194. var me = this;
  24195. me.callParent();
  24196. Ext.onInternalReady(function() {
  24197. me.attachListeners();
  24198. });
  24199. },
  24200. setPressedComponent: function(component, e) {
  24201. var me = this,
  24202. pressedComponent = me.pressedComponent;
  24203. if (pressedComponent && pressedComponent.onRelease) {
  24204. pressedComponent.onRelease(e);
  24205. }
  24206. me.pressedComponent = component;
  24207. if (component) {
  24208. me.pressedScrollStart = Ext.on({
  24209. scrollstart: function() {
  24210. me.setPressedComponent(null, e);
  24211. },
  24212. destroyable: true
  24213. });
  24214. } else {
  24215. me.pressedScrollStart = Ext.destroy(me.pressedScrollStart);
  24216. }
  24217. },
  24218. attachListeners: function() {
  24219. var me = this,
  24220. win = Ext.getWin(),
  24221. winListeners = me.windowListeners;
  24222. me.onlineState = Ext.isOnline();
  24223. me.curHeight = Ext.Element.getViewportHeight();
  24224. me.curWidth = Ext.Element.getViewportWidth();
  24225. win.on({
  24226. scope: me,
  24227. online: 'handleOnlineChange',
  24228. offline: 'handleOnlineChange'
  24229. });
  24230. me.fireResize.$skipTimerCheck = true;
  24231. if (winListeners) {
  24232. winListeners.scope = me;
  24233. if (Ext.isModern) {
  24234. winListeners.resize.onFrame = true;
  24235. } else {
  24236. winListeners.resize.buffer = me.resizeBuffer;
  24237. }
  24238. win.on(winListeners);
  24239. }
  24240. Ext.getDoc().on({
  24241. touchstart: 'fireMouseDown',
  24242. mousedown: 'fireMouseDown',
  24243. mouseup: 'fireMouseUp',
  24244. touchend: 'fireMouseUp',
  24245. drop: 'fireMouseUp',
  24246. dragend: 'fireMouseUp',
  24247. scope: me
  24248. });
  24249. },
  24250. fireMouseDown: function(e) {
  24251. this.fireEvent('mousedown', e);
  24252. Ext.ComponentManager.handleDocumentMouseDown(e);
  24253. },
  24254. fireMouseUp: function(e) {
  24255. this.fireEvent('mouseup', e);
  24256. this.setPressedComponent(null, e);
  24257. },
  24258. fireResize: function() {
  24259. var me = this,
  24260. Element = Ext.Element,
  24261. w = Element.getViewportWidth(),
  24262. h = Element.getViewportHeight();
  24263. if (me.curHeight !== h || me.curWidth !== w) {
  24264. me.curHeight = h;
  24265. me.curWidth = w;
  24266. if (me.hasListeners.resize) {
  24267. me.fireEvent('resize', w, h);
  24268. }
  24269. }
  24270. },
  24271. handleOnlineChange: function() {
  24272. var online = Ext.isOnline();
  24273. if (online !== this.onlineState) {
  24274. this.onlineState = online;
  24275. this.fireEvent('onlinechange', online);
  24276. }
  24277. }
  24278. }, function(GlobalEvents) {
  24279. Ext.on = function() {
  24280. return GlobalEvents.addListener.apply(GlobalEvents, arguments);
  24281. };
  24282. Ext.un = function() {
  24283. return GlobalEvents.removeListener.apply(GlobalEvents, arguments);
  24284. };
  24285. Ext.fireEvent = function() {
  24286. return GlobalEvents.fireEvent.apply(GlobalEvents, arguments);
  24287. };
  24288. Ext.fireIdle = function() {
  24289. if (GlobalEvents.hasListeners.idle && !Ext._suppressIdle) {
  24290. GlobalEvents.fireEventArgs('idle');
  24291. }
  24292. Ext._suppressIdle = false;
  24293. };
  24294. Ext._suppressIdle = false;
  24295. });
  24296. Ext.define('Ext.Glyph', {
  24297. isGlyph: true,
  24298. constructor: function(glyph) {
  24299. glyph && this.setGlyph(glyph);
  24300. },
  24301. setGlyph: function(glyph) {
  24302. var glyphParts;
  24303. this.glyphConfig = glyph;
  24304. if (typeof glyph === 'string') {
  24305. glyphParts = glyph.split('@');
  24306. if (isNaN(glyph = isNaN(glyphParts[0]) ? parseInt('0' + glyphParts[0], 16) : parseInt(glyphParts[0], 10)) || !glyph) {
  24307. glyph = glyphParts[0].charCodeAt(0);
  24308. }
  24309. this.fontFamily = glyphParts[1] || Ext._glyphFontFamily;
  24310. } else {
  24311. this.fontFamily = Ext._glyphFontFamily;
  24312. }
  24313. this.codepoint = glyph;
  24314. this.character = Ext.String.fromCodePoint(this.codepoint);
  24315. return this;
  24316. },
  24317. getStyle: function() {
  24318. return {
  24319. 'font-family': this.fontFamily
  24320. };
  24321. },
  24322. isEqual: function(other) {
  24323. return other && other.isGlyph && other.codepoint === this.codepoint && other.fontFamily === this.fontFamily;
  24324. },
  24325. statics: (function() {
  24326. var instance;
  24327. return {
  24328. fly: function(glyph) {
  24329. return glyph.isGlyph ? glyph : (instance || (instance = new Ext.Glyph())).setGlyph(glyph);
  24330. }
  24331. };
  24332. })()
  24333. });
  24334. Ext.USE_NATIVE_JSON = true;
  24335. Ext.JSON = (new (function() {
  24336. var me = this,
  24337. hasNative = window.JSON && JSON.toString() === '[object JSON]',
  24338. useHasOwn = !!{}.hasOwnProperty,
  24339. pad = function(n) {
  24340. return n < 10 ? "0" + n : n;
  24341. },
  24342. doDecode = function(json) {
  24343. return eval("(" + json + ')');
  24344. },
  24345. doEncode = function(o, newline) {
  24346. if (o === null || o === undefined) {
  24347. return "null";
  24348. } else if (Ext.isDate(o)) {
  24349. return me.encodeDate(o);
  24350. } else if (Ext.isString(o)) {
  24351. if (Ext.isMSDate(o)) {
  24352. return me.encodeMSDate(o);
  24353. } else {
  24354. return me.encodeString(o);
  24355. }
  24356. } else if (typeof o === "number") {
  24357. return isFinite(o) ? String(o) : "null";
  24358. } else if (Ext.isBoolean(o)) {
  24359. return String(o);
  24360. }
  24361. else if (typeof o.toJSON === 'function') {
  24362. return doEncode(o.toJSON());
  24363. } else if (Ext.isArray(o)) {
  24364. return encodeArray(o, newline);
  24365. } else if (Ext.isObject(o)) {
  24366. return encodeObject(o, newline);
  24367. } else if (typeof o === "function") {
  24368. return "null";
  24369. }
  24370. return 'undefined';
  24371. },
  24372. m = {
  24373. "\b": '\\b',
  24374. "\t": '\\t',
  24375. "\n": '\\n',
  24376. "\f": '\\f',
  24377. "\r": '\\r',
  24378. '"': '\\"',
  24379. "\\": '\\\\',
  24380. '\v': '\\u000b'
  24381. },
  24382. charToReplace = /[\\\"\x00-\x1f\x7f-\uffff]/g,
  24383. encodeString = function(s) {
  24384. return '"' + s.replace(charToReplace, function(a) {
  24385. var c = m[a];
  24386. return typeof c === 'string' ? c : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
  24387. }) + '"';
  24388. },
  24389. encodeMSDate = function(o) {
  24390. return '"' + o + '"';
  24391. },
  24392. encodeArrayPretty = function(o, newline) {
  24393. var len = o.length,
  24394. cnewline = newline + ' ',
  24395. sep = ',' + cnewline,
  24396. a = [
  24397. "[",
  24398. cnewline
  24399. ],
  24400. i;
  24401. for (i = 0; i < len; i += 1) {
  24402. a.push(me.encodeValue(o[i], cnewline), sep);
  24403. }
  24404. a[a.length - 1] = newline + ']';
  24405. return a.join('');
  24406. },
  24407. encodeObjectPretty = function(o, newline) {
  24408. var cnewline = newline + ' ',
  24409. sep = ',' + cnewline,
  24410. a = [
  24411. "{",
  24412. cnewline
  24413. ],
  24414. i, val;
  24415. for (i in o) {
  24416. val = o[i];
  24417. if (!useHasOwn || o.hasOwnProperty(i)) {
  24418. if (typeof val === 'function' || val === undefined || val.isInstance) {
  24419. continue;
  24420. }
  24421. a.push(me.encodeValue(i) + ': ' + me.encodeValue(val, cnewline), sep);
  24422. }
  24423. }
  24424. a[a.length - 1] = newline + '}';
  24425. return a.join('');
  24426. },
  24427. encodeArray = function(o, newline) {
  24428. if (newline) {
  24429. return encodeArrayPretty(o, newline);
  24430. }
  24431. var a = [
  24432. "[",
  24433. ""
  24434. ],
  24435. len = o.length,
  24436. i;
  24437. for (i = 0; i < len; i += 1) {
  24438. a.push(me.encodeValue(o[i]), ',');
  24439. }
  24440. a[a.length - 1] = ']';
  24441. return a.join("");
  24442. },
  24443. encodeObject = function(o, newline) {
  24444. if (newline) {
  24445. return encodeObjectPretty(o, newline);
  24446. }
  24447. var a = [
  24448. "{",
  24449. ""
  24450. ],
  24451. i, val;
  24452. for (i in o) {
  24453. val = o[i];
  24454. if (!useHasOwn || o.hasOwnProperty(i)) {
  24455. if (typeof val === 'function' || val === undefined) {
  24456. continue;
  24457. }
  24458. a.push(me.encodeValue(i), ":", me.encodeValue(val), ',');
  24459. }
  24460. }
  24461. a[a.length - 1] = '}';
  24462. return a.join("");
  24463. };
  24464. me.encodeString = encodeString;
  24465. me.encodeValue = doEncode;
  24466. me.encodeDate = function(o) {
  24467. return '"' + o.getFullYear() + "-" + pad(o.getMonth() + 1) + "-" + pad(o.getDate()) + "T" + pad(o.getHours()) + ":" + pad(o.getMinutes()) + ":" + pad(o.getSeconds()) + '"';
  24468. };
  24469. me.encode = function(o) {
  24470. if (hasNative && Ext.USE_NATIVE_JSON) {
  24471. return JSON.stringify(o);
  24472. }
  24473. return me.encodeValue(o);
  24474. };
  24475. me.decode = function(json, safe) {
  24476. try {
  24477. if (hasNative && Ext.USE_NATIVE_JSON) {
  24478. return JSON.parse(json);
  24479. }
  24480. return doDecode(json);
  24481. } catch (e) {
  24482. if (safe) {
  24483. return null;
  24484. }
  24485. Ext.raise({
  24486. sourceClass: "Ext.JSON",
  24487. sourceMethod: "decode",
  24488. msg: "You're trying to decode an invalid JSON String: " + json
  24489. });
  24490. }
  24491. };
  24492. me.encodeMSDate = encodeMSDate;
  24493. if (!Ext.util) {
  24494. Ext.util = {};
  24495. }
  24496. Ext.util.JSON = me;
  24497. Ext.encode = me.encode;
  24498. Ext.decode = me.decode;
  24499. })());
  24500. Ext.define('Ext.mixin.Inheritable', {
  24501. extend: Ext.Mixin,
  24502. mixinConfig: {
  24503. id: 'inheritable'
  24504. },
  24505. getInherited: function(inner) {
  24506. var me = this,
  24507. inheritedState = (inner && me.inheritedStateInner) || me.inheritedState,
  24508. ownerCt = me.getRefOwner(),
  24509. isContainer = me.isContainer,
  24510. parent, inheritedStateInner, getInner, ownerLayout;
  24511. if (!inheritedState || inheritedState.invalid) {
  24512. parent = me.getRefOwner();
  24513. ownerLayout = me.ownerLayout;
  24514. if (ownerCt) {
  24515. getInner = ownerLayout ? ownerLayout === ownerCt.layout : true;
  24516. }
  24517. me.inheritedState = inheritedState =
  24518. Ext.Object.chain(parent ? parent.getInherited(getInner) : Ext.rootInheritedState);
  24519. if (isContainer) {
  24520. me.inheritedStateInner = inheritedStateInner = Ext.Object.chain(inheritedState);
  24521. }
  24522. me.initInheritedState(inheritedState, inheritedStateInner);
  24523. inheritedState = (isContainer && inner) ? me.inheritedStateInner : me.inheritedState;
  24524. }
  24525. return inheritedState;
  24526. },
  24527. getInheritedConfig: function(property, skipThis) {
  24528. var state = this.inheritedState,
  24529. old, ret;
  24530. if (!state || state.invalid) {
  24531. state = this.getInherited();
  24532. }
  24533. ret = state[property];
  24534. if (skipThis && state.hasOwnProperty(property)) {
  24535. old = ret;
  24536. delete state[property];
  24537. ret = state[property];
  24538. state[property] = old;
  24539. }
  24540. return ret;
  24541. },
  24542. resolveListenerScope: function(defaultScope, skipThis) {
  24543. var me = this,
  24544. hasSkipThis = (typeof skipThis === 'boolean'),
  24545. namedScope = Ext._namedScopes[defaultScope],
  24546. ret;
  24547. if (!namedScope) {
  24548. ret = me.getInheritedConfig('defaultListenerScope', hasSkipThis ? skipThis : true) || defaultScope || me;
  24549. } else if (namedScope.isController) {
  24550. ret = me.getInheritedConfig('controller', hasSkipThis ? skipThis : !namedScope.isSelf);
  24551. } else if (namedScope.isOwner) {
  24552. ret = me.getRefOwner();
  24553. } else if (namedScope.isSelf) {
  24554. ret = me.getInheritedConfig('defaultListenerScope', hasSkipThis && skipThis) || me;
  24555. } else if (namedScope.isThis) {
  24556. ret = me;
  24557. }
  24558. return ret || null;
  24559. },
  24560. resolveSatelliteListenerScope: function(satellite, defaultScope) {
  24561. var me = this,
  24562. namedScope = Ext._namedScopes[defaultScope],
  24563. ret;
  24564. if (!namedScope) {
  24565. ret = me.getInheritedConfig('defaultListenerScope') || defaultScope || me;
  24566. } else if (namedScope.isController) {
  24567. ret = me.getInheritedConfig('controller');
  24568. } else if (namedScope.isSelf) {
  24569. ret = me.getInheritedConfig('defaultListenerScope') || satellite;
  24570. } else if (namedScope.isThis) {
  24571. ret = satellite;
  24572. }
  24573. return ret || null;
  24574. },
  24575. lookupNameHolder: function(skipThis) {
  24576. return this.getInheritedConfig('nameHolder', skipThis !== false) || null;
  24577. },
  24578. lookupReferenceHolder: function(skipThis) {
  24579. return this.getInheritedConfig('referenceHolder', skipThis !== false) || null;
  24580. },
  24581. getRefOwner: function() {
  24582. var me = this;
  24583. return me.ownerCmp || me.ownerCt || me.parent || me.$initParent || me.floatParent;
  24584. },
  24585. bubble: function(fn, scope, args) {
  24586. for (var target = this; target; target = target.getRefOwner()) {
  24587. if (fn.apply(scope || target, args || [
  24588. target
  24589. ]) === false) {
  24590. break;
  24591. }
  24592. }
  24593. },
  24594. isDescendantOf: function(ancestor) {
  24595. return ancestor ? ancestor.isAncestor(this) : false;
  24596. },
  24597. isAncestor: function(possibleDescendant) {
  24598. while (possibleDescendant) {
  24599. if (possibleDescendant.getRefOwner() === this) {
  24600. return true;
  24601. }
  24602. possibleDescendant = possibleDescendant.getRefOwner();
  24603. }
  24604. return false;
  24605. },
  24606. invalidateInheritedState: function() {
  24607. var inheritedState = this.inheritedState;
  24608. if (inheritedState) {
  24609. inheritedState.invalid = true;
  24610. delete this.inheritedState;
  24611. }
  24612. },
  24613. privates: {
  24614. _fixName: function() {
  24615. var me = this,
  24616. owner;
  24617. if (me.name) {
  24618. owner = me.lookupNameHolder();
  24619. if (owner && !owner.destroyed) {
  24620. owner.attachNameRef(me);
  24621. }
  24622. }
  24623. },
  24624. _fixReference: function() {
  24625. var me = this,
  24626. refHolder;
  24627. if (me.reference) {
  24628. refHolder = me.lookupReferenceHolder();
  24629. if (refHolder) {
  24630. refHolder.attachReference(me);
  24631. }
  24632. }
  24633. },
  24634. onInheritedAdd: function(parent, instanced) {
  24635. var me = this;
  24636. if (me.inheritedState && instanced) {
  24637. me.invalidateInheritedState();
  24638. }
  24639. if (me.name || me.reference) {
  24640. Ext.ComponentManager.markReferencesDirty();
  24641. }
  24642. },
  24643. onInheritedRemove: function(destroying) {
  24644. var me = this;
  24645. if (me.name || me.reference) {
  24646. Ext.ComponentManager.markReferencesDirty();
  24647. }
  24648. if (me.inheritedState && !destroying) {
  24649. me.invalidateInheritedState();
  24650. }
  24651. }
  24652. }
  24653. }, function() {
  24654. Ext.rootInheritedState = {};
  24655. });
  24656. Ext.define('Ext.mixin.Bindable', {
  24657. mixinId: 'bindable',
  24658. config: {
  24659. bind: {
  24660. $value: null,
  24661. lazy: true
  24662. },
  24663. controller: null,
  24664. defaultListenerScope: false,
  24665. publishes: {
  24666. $value: null,
  24667. lazy: true,
  24668. merge: function(newValue, oldValue) {
  24669. return this.mergeSets(newValue, oldValue);
  24670. }
  24671. },
  24672. session: {
  24673. $value: null,
  24674. lazy: true
  24675. },
  24676. twoWayBindable: {
  24677. $value: null,
  24678. lazy: true,
  24679. merge: function(newValue, oldValue) {
  24680. return this.mergeSets(newValue, oldValue);
  24681. }
  24682. },
  24683. viewModel: {
  24684. $value: null,
  24685. lazy: true
  24686. }
  24687. },
  24688. defaultBindProperty: null,
  24689. nameable: false,
  24690. shareableName: false,
  24691. reference: null,
  24692. validRefRe: /^[a-z_][a-z0-9_]*$/i,
  24693. getReference: function() {
  24694. return this.reference;
  24695. },
  24696. initInheritedState: function(inheritedState) {
  24697. var me = this,
  24698. reference = me.reference,
  24699. controller = me.getController(),
  24700. viewModel = me.getConfig('viewModel', true),
  24701. session = me.getConfig('session', true),
  24702. defaultListenerScope = me.getDefaultListenerScope();
  24703. if (controller) {
  24704. inheritedState.controller = controller;
  24705. }
  24706. if (defaultListenerScope) {
  24707. inheritedState.defaultListenerScope = me;
  24708. } else if (controller) {
  24709. inheritedState.defaultListenerScope = controller;
  24710. }
  24711. if (viewModel) {
  24712. if (!viewModel.isViewModel) {
  24713. viewModel = me;
  24714. }
  24715. inheritedState.viewModel = viewModel;
  24716. }
  24717. if (session) {
  24718. if (!session.isSession) {
  24719. session = me;
  24720. }
  24721. inheritedState.session = session;
  24722. }
  24723. if (reference) {
  24724. me.referenceKey = (inheritedState.referencePath || '') + reference;
  24725. me.viewModelKey = (inheritedState.viewModelPath || '') + reference;
  24726. }
  24727. },
  24728. isBound: function(name) {
  24729. var bind = this.getBind();
  24730. return !!(bind && (bind[name || this.defaultBindProperty]));
  24731. },
  24732. lookupController: function(skipThis) {
  24733. return this.getInheritedConfig('controller', skipThis) || null;
  24734. },
  24735. lookupSession: function(skipThis) {
  24736. var ret = skipThis ? null : this.getSession();
  24737. if (!ret) {
  24738. ret = this.getInheritedConfig('session', skipThis);
  24739. if (ret && !ret.isSession) {
  24740. ret = ret.getInherited().session = ret.getSession();
  24741. }
  24742. }
  24743. return ret || null;
  24744. },
  24745. lookupViewModel: function(skipThis) {
  24746. var ret = skipThis ? null : this.getViewModel();
  24747. if (!ret) {
  24748. ret = this.getInheritedConfig('viewModel', skipThis);
  24749. if (ret && !ret.isViewModel) {
  24750. ret = ret.getInherited().viewModel = ret.getViewModel();
  24751. }
  24752. }
  24753. return ret || null;
  24754. },
  24755. publishState: function(property, value) {
  24756. var me = this,
  24757. state = me.publishedState,
  24758. binds = me.getBind(),
  24759. binding = binds && property && binds[property],
  24760. count = 0,
  24761. name, publishes, vm, path;
  24762. if (!(arguments.length === 0 || arguments.length === 2)) {
  24763. Ext.raise('publishState must either be called with no args, or with both name AND value passed');
  24764. }
  24765. if (binding && !binding.syncing && !binding.isReadOnly()) {
  24766. if (binding.calls || !(value == null || value === me.getInitialConfig()[property])) {
  24767. binding.setValue(value);
  24768. }
  24769. }
  24770. if (!(publishes = me.getPublishes())) {
  24771. return;
  24772. }
  24773. if (!(vm = me.lookupViewModel())) {
  24774. return;
  24775. }
  24776. if (!(path = me.viewModelKey)) {
  24777. return;
  24778. }
  24779. state = state || (me.publishedState = {});
  24780. if (property) {
  24781. if (!publishes[property]) {
  24782. return;
  24783. }
  24784. if (!(value && value.constructor === Object) && !(value instanceof Array)) {
  24785. if (state[property] === value) {
  24786. return;
  24787. }
  24788. }
  24789. path += '.';
  24790. path += property;
  24791. } else {
  24792. for (name in publishes) {
  24793. ++count;
  24794. state[name] = me.getConfig(name);
  24795. }
  24796. if (!count) {
  24797. return;
  24798. }
  24799. value = state;
  24800. }
  24801. vm.set(path, value);
  24802. },
  24803. privates: {
  24804. addBindableUpdater: function(property) {
  24805. var me = this,
  24806. configs = me.self.$config.configs,
  24807. cfg = configs[property],
  24808. updateName;
  24809. if (cfg && !me.hasOwnProperty(updateName = cfg.names.update)) {
  24810. me[updateName] = cfg.bindableUpdater || (cfg.root.bindableUpdater = me.makeBindableUpdater(cfg));
  24811. }
  24812. },
  24813. applyBind: function(binds, currentBindings) {
  24814. if (!binds) {
  24815. return binds;
  24816. }
  24817. var me = this,
  24818. viewModel = me.lookupViewModel(),
  24819. twoWayable = me.getTwoWayBindable(),
  24820. getBindTemplateScope = me._getBindTemplateScope,
  24821. b, property, descriptor, destroy;
  24822. me.$hasBinds = true;
  24823. if (!currentBindings || typeof currentBindings === 'string') {
  24824. currentBindings = {};
  24825. }
  24826. if (!viewModel) {
  24827. Ext.raise('Cannot use bind config without a viewModel');
  24828. }
  24829. if (Ext.isString(binds)) {
  24830. if (!me.defaultBindProperty) {
  24831. Ext.raise(me.$className + ' has no defaultBindProperty - ' + 'Please specify a bind object');
  24832. }
  24833. b = binds;
  24834. binds = {};
  24835. binds[me.defaultBindProperty] = b;
  24836. }
  24837. for (property in binds) {
  24838. descriptor = binds[property];
  24839. b = currentBindings[property];
  24840. if (b && b.isBinding) {
  24841. b.destroy();
  24842. b = null;
  24843. destroy = true;
  24844. }
  24845. if (descriptor) {
  24846. b = viewModel.bind(descriptor, me.onBindNotify, me);
  24847. b._config = Ext.Config.get(property);
  24848. b.getTemplateScope = getBindTemplateScope;
  24849. if (!me[b._config.names.set]) {
  24850. Ext.raise('Cannot bind ' + property + ' on ' + me.$className + ' - missing a ' + b._config.names.set + ' method.');
  24851. }
  24852. }
  24853. if (destroy) {
  24854. delete currentBindings[property];
  24855. } else {
  24856. currentBindings[property] = b;
  24857. }
  24858. if (twoWayable && twoWayable[property]) {
  24859. if (destroy) {
  24860. me.clearBindableUpdater(property);
  24861. } else if (!b.isReadOnly()) {
  24862. me.addBindableUpdater(property);
  24863. }
  24864. }
  24865. }
  24866. return currentBindings;
  24867. },
  24868. applyController: function(controller) {
  24869. if (controller) {
  24870. controller = Ext.Factory.controller(controller);
  24871. controller.setView(this);
  24872. }
  24873. this.controller = controller;
  24874. return controller;
  24875. },
  24876. updatePublishes: function(all) {
  24877. var me = this;
  24878. if (me.lookupViewModel()) {
  24879. for (var property in all) {
  24880. me.addBindableUpdater(property);
  24881. }
  24882. }
  24883. return all;
  24884. },
  24885. applySession: function(session) {
  24886. if (!session) {
  24887. return null;
  24888. }
  24889. if (!session.isSession) {
  24890. var parentSession = this.lookupSession(true),
  24891. config = (session === true) ? {} : session;
  24892. if (parentSession) {
  24893. session = parentSession.spawn(config);
  24894. } else {
  24895. session = new Ext.data['Session'](config);
  24896. }
  24897. }
  24898. return session;
  24899. },
  24900. applyViewModel: function(viewModel) {
  24901. var me = this,
  24902. config, session;
  24903. if (!viewModel) {
  24904. return null;
  24905. }
  24906. if (!viewModel.isViewModel) {
  24907. config = {
  24908. parent: me.lookupViewModel(true),
  24909. view: me
  24910. };
  24911. config.session = me.getSession();
  24912. if (!session && !config.parent) {
  24913. config.session = me.lookupSession();
  24914. }
  24915. if (viewModel) {
  24916. if (viewModel.constructor === Object) {
  24917. Ext.apply(config, viewModel);
  24918. } else if (typeof viewModel === 'string') {
  24919. config.type = viewModel;
  24920. }
  24921. }
  24922. viewModel = Ext.Factory.viewModel(config);
  24923. }
  24924. return viewModel;
  24925. },
  24926. _getBindTemplateScope: function() {
  24927. return this.scope.resolveListenerScope();
  24928. },
  24929. clearBindableUpdater: function(property) {
  24930. var me = this,
  24931. configs = me.self.$config.configs,
  24932. cfg = configs[property],
  24933. updateName;
  24934. if (cfg && me.hasOwnProperty(updateName = cfg.names.update)) {
  24935. if (me[updateName].$bindableUpdater) {
  24936. delete me[updateName];
  24937. }
  24938. }
  24939. },
  24940. destroyBindable: function() {
  24941. var me = this,
  24942. viewModel = me.getConfig('viewModel', true),
  24943. session = me.getConfig('session', true),
  24944. controller = me.getController();
  24945. if (viewModel && viewModel.isViewModel) {
  24946. viewModel.destroy();
  24947. me.setViewModel(null);
  24948. }
  24949. if (session && session.isSession) {
  24950. if (session.getAutoDestroy()) {
  24951. session.destroy();
  24952. }
  24953. me.setSession(null);
  24954. }
  24955. if (controller) {
  24956. me.setController(null);
  24957. controller.destroy();
  24958. }
  24959. },
  24960. initBindable: function() {
  24961. var me = this,
  24962. controller = me.controller;
  24963. me.initBindable = Ext.emptyFn;
  24964. me.getBind();
  24965. me.getPublishes();
  24966. if (!me.viewModel) {
  24967. me.getViewModel();
  24968. }
  24969. if (controller) {
  24970. controller.initBindings();
  24971. }
  24972. if (me.reference) {
  24973. me.publishState();
  24974. }
  24975. },
  24976. isSyncing: function(name) {
  24977. var bindings = this.getBind(),
  24978. ret = false,
  24979. binding;
  24980. if (bindings) {
  24981. binding = bindings[name];
  24982. if (binding) {
  24983. ret = binding.syncing > 0;
  24984. }
  24985. }
  24986. return ret;
  24987. },
  24988. makeBindableUpdater: function(cfg) {
  24989. var updateName = cfg.names.update,
  24990. fn = function(newValue, oldValue) {
  24991. var me = this,
  24992. updater = me.self.prototype[updateName];
  24993. if (updater) {
  24994. updater.call(me, newValue, oldValue);
  24995. }
  24996. me.publishState(cfg.name, me[cfg.getInternalName(me)]);
  24997. };
  24998. fn.$bindableUpdater = true;
  24999. return fn;
  25000. },
  25001. notifyIf: function(skipThis) {
  25002. var vm = this.lookupViewModel(skipThis);
  25003. if (vm) {
  25004. vm.notify();
  25005. }
  25006. },
  25007. onBindNotify: function(value, oldValue, binding) {
  25008. binding.syncing = (binding.syncing + 1) || 1;
  25009. this[binding._config.names.set](value);
  25010. --binding.syncing;
  25011. },
  25012. removeBindings: function() {
  25013. var me = this,
  25014. bindings, key, binding;
  25015. if (me.$hasBinds) {
  25016. bindings = me.getBind();
  25017. if (bindings && typeof bindings !== 'string') {
  25018. for (key in bindings) {
  25019. binding = bindings[key];
  25020. binding.destroy();
  25021. binding._config = binding.getTemplateScope = null;
  25022. }
  25023. }
  25024. }
  25025. me.setBind(null);
  25026. },
  25027. updateSession: function(session) {
  25028. var state = this.getInherited();
  25029. if (session) {
  25030. state.session = session;
  25031. } else {
  25032. delete state.session;
  25033. }
  25034. },
  25035. updateViewModel: function(viewModel, oldViewModel) {
  25036. var me = this,
  25037. state = me.getInherited(),
  25038. controller = me.getController();
  25039. if (viewModel) {
  25040. me.hasVM = true;
  25041. state.viewModel = viewModel;
  25042. viewModel.setView(me);
  25043. if (controller) {
  25044. controller.initViewModel(viewModel);
  25045. }
  25046. } else {
  25047. delete state.viewModel;
  25048. }
  25049. me.viewModel = viewModel;
  25050. }
  25051. }
  25052. });
  25053. Ext.define('Ext.mixin.ComponentDelegation', {
  25054. extend: Ext.Mixin,
  25055. mixinConfig: {
  25056. id: 'componentDelegation'
  25057. },
  25058. privates: {
  25059. addDelegatedListener: function(eventName, fn, scope, options, order, caller, manager) {
  25060. var me = this,
  25061. delegatedEvents, event, priority;
  25062. eventName = Ext.canonicalEventName(eventName);
  25063. order = order || options.order;
  25064. if (order) {
  25065. priority = (options && options.priority);
  25066. if (!priority) {
  25067. options = options ? Ext.Object.chain(options) : {};
  25068. options.priority = me.$orderToPriority[order];
  25069. }
  25070. }
  25071. if (options.target) {
  25072. Ext.raise("Cannot add '" + eventName + "' listener to component: '" + me.id + "' - 'delegate' and 'target' event options are incompatible.");
  25073. }
  25074. delegatedEvents = me.$delegatedEvents || (me.$delegatedEvents = {});
  25075. event = delegatedEvents[eventName] || (delegatedEvents[eventName] = new Ext.util.Event(me, eventName));
  25076. if (event.addListener(fn, scope, options, caller, manager)) {
  25077. me.$hasDelegatedListeners._incr_(eventName);
  25078. }
  25079. },
  25080. clearDelegatedListeners: function() {
  25081. var me = this,
  25082. delegatedEvents = me.$delegatedEvents,
  25083. eventName, event, listenerCount;
  25084. if (delegatedEvents) {
  25085. for (eventName in delegatedEvents) {
  25086. event = delegatedEvents[eventName];
  25087. listenerCount = event.listeners.length;
  25088. event.clearListeners();
  25089. me.$hasDelegatedListeners._decr_(eventName, listenerCount);
  25090. delete delegatedEvents[eventName];
  25091. }
  25092. }
  25093. },
  25094. doFireDelegatedEvent: function(eventName, args) {
  25095. var me = this,
  25096. ret = true,
  25097. owner, delegatedEvents, event;
  25098. if (me.$hasDelegatedListeners[eventName]) {
  25099. owner = me.getRefOwner();
  25100. while (owner) {
  25101. delegatedEvents = owner.$delegatedEvents;
  25102. if (delegatedEvents) {
  25103. event = delegatedEvents[eventName];
  25104. if (event) {
  25105. ret = event.fireDelegated(me, args);
  25106. if (ret === false) {
  25107. break;
  25108. }
  25109. }
  25110. }
  25111. owner = owner.getRefOwner();
  25112. }
  25113. }
  25114. return ret;
  25115. },
  25116. removeDelegatedListener: function(eventName, fn, scope) {
  25117. var me = this,
  25118. delegatedEvents = me.$delegatedEvents,
  25119. event;
  25120. if (delegatedEvents) {
  25121. event = delegatedEvents[eventName];
  25122. if (event && event.removeListener(fn, scope)) {
  25123. me.$hasDelegatedListeners._decr_(eventName);
  25124. if (event.listeners.length === 0) {
  25125. delete delegatedEvents[eventName];
  25126. }
  25127. }
  25128. }
  25129. },
  25130. destroyComponentDelegation: function() {
  25131. if (this.clearPropertiesOnDestroy) {
  25132. this.$delegatedEvents = null;
  25133. }
  25134. }
  25135. },
  25136. onClassMixedIn: function(T) {
  25137. function HasListeners() {}
  25138. T.prototype.HasListeners = T.HasListeners = HasListeners;
  25139. HasListeners.prototype = T.hasListeners = new Ext.mixin.ComponentDelegation.HasDelegatedListeners();
  25140. }
  25141. }, function(ComponentDelegation) {
  25142. function HasDelegatedListeners() {}
  25143. ComponentDelegation.HasDelegatedListeners = HasDelegatedListeners;
  25144. HasDelegatedListeners.prototype = ComponentDelegation.prototype.$hasDelegatedListeners = new Ext.mixin.Observable.HasListeners();
  25145. });
  25146. Ext.define('Ext.plugin.Abstract', {
  25147. alternateClassName: 'Ext.AbstractPlugin',
  25148. isPlugin: true,
  25149. constructor: function(config) {
  25150. if (config) {
  25151. this.pluginConfig = config;
  25152. this.initConfig(config);
  25153. }
  25154. },
  25155. clonePlugin: function(overrideCfg) {
  25156. return new this.self(Ext.apply({}, overrideCfg, this.pluginConfig));
  25157. },
  25158. getCmp: function() {
  25159. return this.cmp;
  25160. },
  25161. setCmp: function(host) {
  25162. this.cmp = host;
  25163. },
  25164. init: Ext.emptyFn,
  25165. destroy: function() {
  25166. this.cmp = this.pluginConfig = null;
  25167. this.callParent();
  25168. },
  25169. onClassExtended: function(cls, data, hooks) {
  25170. var alias = data.alias,
  25171. prototype = cls.prototype;
  25172. if (alias && !data.ptype) {
  25173. if (Ext.isArray(alias)) {
  25174. alias = alias[0];
  25175. }
  25176. prototype.ptype = alias.split('plugin.')[1];
  25177. }
  25178. },
  25179. resolveListenerScope: function(defaultScope) {
  25180. var me = this,
  25181. cmp = me.getCmp(),
  25182. scope;
  25183. if (cmp) {
  25184. scope = cmp.resolveSatelliteListenerScope(me, defaultScope);
  25185. }
  25186. return scope || me.mixins.observable.resolveListenerScope.call(me, defaultScope);
  25187. },
  25188. statics: {
  25189. decode: function(plugins, typeProp, include) {
  25190. if (plugins) {
  25191. var type = Ext.typeOf(plugins),
  25192. entry, key, obj, value;
  25193. if (type === 'string') {
  25194. obj = {};
  25195. obj[typeProp] = plugins;
  25196. plugins = [
  25197. obj
  25198. ];
  25199. } else if (plugins.isInstance) {
  25200. plugins = [
  25201. plugins
  25202. ];
  25203. } else if (type === 'object') {
  25204. if (plugins[typeProp]) {
  25205. plugins = [
  25206. plugins
  25207. ];
  25208. } else {
  25209. obj = include ? Ext.merge(Ext.clone(include), plugins) : plugins;
  25210. plugins = [];
  25211. for (key in obj) {
  25212. if (!(value = obj[key])) {
  25213. continue;
  25214. }
  25215. entry = {
  25216. id: key
  25217. };
  25218. entry[typeProp] = key;
  25219. if (key === 'responsive') {
  25220. entry.weight = -1000;
  25221. }
  25222. Ext.apply(entry, value);
  25223. plugins.push(entry);
  25224. }
  25225. plugins.sort(Ext.weightSortFn);
  25226. }
  25227. }
  25228. else if (type !== 'array') {
  25229. Ext.raise('Invalid value for "plugins" config ("' + type + '"');
  25230. } else
  25231. {
  25232. plugins = plugins.slice();
  25233. }
  25234. }
  25235. return plugins;
  25236. }
  25237. }
  25238. });
  25239. Ext.define('Ext.mixin.Pluggable', function(Pluggable) {
  25240. return {
  25241. config: {
  25242. plugins: null
  25243. },
  25244. addPlugin: function(plugin) {
  25245. var me = this,
  25246. plugins = me.getPlugins();
  25247. if (plugins) {
  25248. plugin = me.createPlugin(plugin);
  25249. plugin.init(me);
  25250. plugins.push(plugin);
  25251. } else {
  25252. me.setPlugins(plugin);
  25253. plugin = me.getPlugins()[0];
  25254. }
  25255. return plugin;
  25256. },
  25257. destroyPlugin: function(plugin) {
  25258. return this.removePlugin(plugin, true);
  25259. },
  25260. findPlugin: function(type) {
  25261. var plugins = this.getPlugins(),
  25262. n = plugins && plugins.length,
  25263. i, plugin, ret;
  25264. for (i = 0; i < n && !ret; i++) {
  25265. plugin = plugins[i];
  25266. if (plugin.type === type || plugin.ptype === type) {
  25267. ret = plugin;
  25268. }
  25269. }
  25270. return ret || null;
  25271. },
  25272. getPlugin: function(id) {
  25273. var plugins = this.getPlugins(),
  25274. n = plugins && plugins.length,
  25275. i, plugin, ret;
  25276. for (i = 0; i < n && !ret; i++) {
  25277. plugin = plugins[i];
  25278. if (plugin.id === id || plugin.pluginId === id) {
  25279. ret = plugin;
  25280. }
  25281. }
  25282. return ret || null;
  25283. },
  25284. removePlugin: function(plugin, destroy) {
  25285. var plugins = this.getPlugins(),
  25286. i = plugins && plugins.length || 0,
  25287. p;
  25288. while (i-- > 0) {
  25289. p = plugins[i];
  25290. if (p === plugin || p.id === plugin) {
  25291. plugins.splice(i, 1);
  25292. if (destroy) {
  25293. if (p.destroy) {
  25294. p.destroy();
  25295. }
  25296. } else if (p.detachCmp) {
  25297. p.detachCmp();
  25298. if (p.setCmp) {
  25299. p.setCmp(null);
  25300. }
  25301. }
  25302. break;
  25303. }
  25304. p = null;
  25305. }
  25306. return p;
  25307. },
  25308. privates: {
  25309. statics: {
  25310. idSeed: 0
  25311. },
  25312. activatePlugin: function(type) {
  25313. var me = this,
  25314. config = me.initialConfig,
  25315. plugins = config && config.plugins,
  25316. ret = null,
  25317. i, include, p;
  25318. if (plugins) {
  25319. include = me.config.plugins;
  25320. include = (include && typeof include === 'object') ? include : null;
  25321. plugins = Ext.plugin.Abstract.decode(plugins, 'type', include);
  25322. for (i = plugins.length; i-- > 0; ) {
  25323. p = plugins[i];
  25324. if (p === type || p.type === type) {
  25325. me.initialConfig = config = Ext.apply({}, config);
  25326. config.plugins = plugins;
  25327. plugins[i] = ret = me.createPlugin(p);
  25328. break;
  25329. }
  25330. }
  25331. }
  25332. return ret;
  25333. },
  25334. applyPlugins: function(plugins, oldPlugins) {
  25335. var me = this,
  25336. oldCount = oldPlugins && oldPlugins.length || 0,
  25337. count, i, plugin;
  25338. if (plugins) {
  25339. plugins = Ext.plugin.Abstract.decode(plugins, 'type');
  25340. }
  25341. for (i = 0; i < oldCount; ++i) {
  25342. oldPlugins[i].$dead = true;
  25343. }
  25344. count = plugins && plugins.length || 0;
  25345. for (i = 0; i < count; ++i) {
  25346. plugins[i] = me.createPlugin(plugins[i]);
  25347. }
  25348. for (i = 0; i < count; ++i) {
  25349. plugin = plugins[i];
  25350. if (plugin.$dead) {
  25351. delete plugin.$dead;
  25352. } else
  25353. {
  25354. plugin.init(me);
  25355. }
  25356. }
  25357. for (i = 0; i < oldCount; ++i) {
  25358. if ((plugin = oldPlugins[i]).$dead) {
  25359. delete plugin.$dead;
  25360. Ext.destroy(plugin);
  25361. }
  25362. }
  25363. return plugins;
  25364. },
  25365. createPlugin: function(config) {
  25366. if (typeof config === 'string') {
  25367. config = {
  25368. type: config
  25369. };
  25370. }
  25371. var ret = config;
  25372. if (!config.isInstance) {
  25373. config.cmp = this;
  25374. ret = Ext.factory(config, null, null, 'plugin');
  25375. delete config.cmp;
  25376. }
  25377. if (!ret.id) {
  25378. ret.id = ++Pluggable.idSeed;
  25379. }
  25380. if (ret.setCmp) {
  25381. ret.setCmp(this);
  25382. }
  25383. return ret;
  25384. }
  25385. }
  25386. };
  25387. });
  25388. Ext.define('Ext.mixin.Keyboard', function(Keyboard) {
  25389. return {
  25390. extend: Ext.Mixin,
  25391. mixinConfig: {
  25392. id: 'keyboard'
  25393. },
  25394. config: {
  25395. keyMap: {
  25396. $value: null,
  25397. cached: true,
  25398. merge: function(value, baseValue, cls, mixin) {
  25399. if (value === null) {
  25400. return value;
  25401. }
  25402. var ret = (baseValue && !cls.isInstance) ? Ext.Object.chain(baseValue) : {},
  25403. key, ucKey, v, vs;
  25404. for (key in value) {
  25405. if (key !== 'scope') {
  25406. ucKey = key.toUpperCase();
  25407. if (!mixin || ret[ucKey] === undefined) {
  25408. v = value[key];
  25409. if (v) {
  25410. if (typeof v === 'string' || typeof v === 'function') {
  25411. v = {
  25412. handler: v
  25413. };
  25414. } else {
  25415. v = Ext.apply({
  25416. handler: v.fn
  25417. },
  25418. v);
  25419. }
  25420. vs = v.scope || value.scope || 'self';
  25421. v.scope = (vs === 'controller') ? 'self.controller' : vs;
  25422. }
  25423. ret[ucKey] = v;
  25424. }
  25425. }
  25426. }
  25427. return ret;
  25428. }
  25429. },
  25430. keyMapEnabled: null
  25431. },
  25432. keyMapTarget: 'el',
  25433. applyKeyMap: function(keyMap, existingKeyMap) {
  25434. var me = this,
  25435. own = me.hasOwnProperty('config');
  25436. if (own && existingKeyMap && existingKeyMap.$owner !== me) {
  25437. existingKeyMap = Ext.apply({}, existingKeyMap);
  25438. }
  25439. keyMap = keyMap ? Keyboard.combineKeyMaps(existingKeyMap, keyMap, own && me) : null;
  25440. if (me._keyMapReady) {
  25441. me.setKeyMapListener(keyMap && me.getKeyMapEnabled());
  25442. }
  25443. return keyMap;
  25444. },
  25445. initKeyMap: function() {
  25446. var me = this,
  25447. enabled = me.getKeyMapEnabled();
  25448. me._keyMapReady = true;
  25449. if (enabled === null) {
  25450. me.setKeyMapEnabled(true);
  25451. } else {
  25452. me.setKeyMapListener(enabled && me.getKeyMap());
  25453. }
  25454. },
  25455. disableKeyMapGroup: function(group) {
  25456. this.setKeyMapGroupEnabled(group, false);
  25457. },
  25458. enableKeyMapGroup: function(group) {
  25459. this.setKeyMapGroupEnabled(group, true);
  25460. },
  25461. setKeyMapGroupEnabled: function(group, state) {
  25462. var me = this,
  25463. disabledGroups = me.disabledKeyMapGroups || (me.disabledKeyMapGroups = {});
  25464. disabledGroups[group] = !state;
  25465. },
  25466. updateKeyMapEnabled: function(enabled) {
  25467. this.setKeyMapListener(enabled && this._keyMapReady && this.getKeyMap());
  25468. },
  25469. privates: {
  25470. _keyMapListenCount: 0,
  25471. _keyMapReady: false,
  25472. comparePriorities: function(lhs, rhs) {
  25473. return (rhs.priority || 0) - (lhs.priority || 0);
  25474. },
  25475. findKeyMapEntries: function(e) {
  25476. var me = this,
  25477. disabledGroups = me.disabledKeyMapGroups,
  25478. keyMap = me.getKeyMap(),
  25479. entries = keyMap && Keyboard.getKeyName(e),
  25480. entry, len, i,
  25481. result = [];
  25482. entries = entries && keyMap[entries];
  25483. if (entries) {
  25484. if (!entries.sorted) {
  25485. Ext.Array.sort(entries, me.comparePriorities);
  25486. entries.sorted = true;
  25487. }
  25488. len = entries.length;
  25489. for (i = 0; i < len; i++) {
  25490. entry = entries[i];
  25491. if (!disabledGroups || !disabledGroups[entry.group]) {
  25492. if (Keyboard.matchEntry(entry, e)) {
  25493. result.push(entry);
  25494. }
  25495. }
  25496. }
  25497. }
  25498. return result;
  25499. },
  25500. onKeyMapEvent: function(e) {
  25501. var me = this,
  25502. entries = me.getKeyMapEnabled() ? me.findKeyMapEntries(e) : null,
  25503. len = entries && entries.length,
  25504. i, entry, result;
  25505. for (i = 0; i < len && result !== false; i++) {
  25506. entry = entries[i];
  25507. result = Ext.callback(entry.handler, entry.scope, [
  25508. e,
  25509. this
  25510. ], 0, this);
  25511. }
  25512. return result;
  25513. },
  25514. setKeyMapListener: function(enabled) {
  25515. var me = this,
  25516. listener = me._keyMapListener,
  25517. eventSource;
  25518. if (listener) {
  25519. listener.destroy();
  25520. listener = null;
  25521. }
  25522. if (enabled) {
  25523. ++me._keyMapListenCount;
  25524. if (enabled) {
  25525. eventSource = me[me.keyMapTarget];
  25526. if (typeof eventSource === 'function') {
  25527. eventSource = eventSource.call(me);
  25528. }
  25529. listener = eventSource.on({
  25530. destroyable: true,
  25531. scope: me,
  25532. keydown: 'onKeyMapEvent',
  25533. keypress: 'onKeyMapEvent'
  25534. });
  25535. }
  25536. }
  25537. me._keyMapListener = listener || null;
  25538. },
  25539. statics: {
  25540. _charCodeRe: /^#([\d]+)$/,
  25541. _keySpecRe: /^(?:(?:(\*)[\+\-])|(?:([a-z\+\-]*)[\+\-]))?(?:([a-z0-9_]+|[\+\-]|(?:#?\d+))(?:\:([a-z]+))?)$/i,
  25542. _delimiterRe: /\-|\+/,
  25543. _keyMapEvents: {
  25544. charCode: 'keypress',
  25545. keyCode: 'keydown'
  25546. },
  25547. combineKeyMaps: function(existingKeyMap, keyMap, owner) {
  25548. var defaultScope = keyMap.scope || 'controller',
  25549. entry, key, mapping, existingMapping;
  25550. for (key in keyMap) {
  25551. if (key === 'scope') {
  25552. continue;
  25553. }
  25554. if (!(mapping = keyMap[key])) {
  25555. if (mapping === undefined) {
  25556. Ext.raise('keyMap entry "' + key + '" is undefined');
  25557. }
  25558. if (!existingKeyMap) {
  25559. continue;
  25560. }
  25561. } else {
  25562. if (typeof mapping === 'string' || typeof mapping === 'function') {
  25563. mapping = {
  25564. handler: mapping,
  25565. scope: defaultScope
  25566. };
  25567. } else if (mapping) {
  25568. mapping = Ext.apply({
  25569. handler: mapping.fn,
  25570. scope: defaultScope
  25571. },
  25572. mapping);
  25573. }
  25574. existingKeyMap = existingKeyMap || {};
  25575. }
  25576. if (Keyboard.parseEntry(key, entry = mapping || {})) {
  25577. existingMapping = existingKeyMap[entry.name];
  25578. if (existingMapping) {
  25579. if (owner && existingMapping.$owner !== owner) {
  25580. existingKeyMap[entry.name] = existingMapping = existingMapping.slice();
  25581. existingMapping.$owner = owner;
  25582. }
  25583. existingMapping.push(mapping);
  25584. existingMapping.sorted = false;
  25585. } else {
  25586. existingMapping = existingKeyMap[entry.name] = [
  25587. mapping
  25588. ];
  25589. existingMapping.$owner = owner;
  25590. existingMapping.sorted = true;
  25591. }
  25592. } else
  25593. {
  25594. Ext.raise('Invalid keyMap key specification "' + key + '"');
  25595. }
  25596. }
  25597. if (existingKeyMap && owner) {
  25598. existingKeyMap.$owner = owner;
  25599. }
  25600. return existingKeyMap || null;
  25601. },
  25602. getKeyName: function(event) {
  25603. var keyCode;
  25604. if (event.isEvent) {
  25605. keyCode = event.keyCode || event.charCode;
  25606. event = event.browserEvent;
  25607. if (keyCode === 229 && 'code' in event) {
  25608. if (Ext.String.startsWith(event.code, 'Key')) {
  25609. return event.key.substr(3);
  25610. }
  25611. if (Ext.String.startsWith(event.code, 'Digit')) {
  25612. return event.key.substr(5);
  25613. }
  25614. }
  25615. } else {
  25616. keyCode = event;
  25617. }
  25618. return Ext.event.Event.keyCodes[keyCode] || String.fromCharCode(keyCode);
  25619. },
  25620. matchEntry: function(entry, e) {
  25621. var ev = e.browserEvent,
  25622. code;
  25623. if (e.type !== entry.event) {
  25624. return false;
  25625. }
  25626. if (!(code = entry.charCode)) {
  25627. if (entry.keyCode !== e.keyCode || (!entry.ignoreModifiers && !entry.shiftKey !== !ev.shiftKey)) {
  25628. return false;
  25629. }
  25630. } else if (e.getCharCode() !== code) {
  25631. return false;
  25632. }
  25633. return entry.ignoreModifiers || (!entry.ctrlKey === !ev.ctrlKey && !entry.altKey === !ev.altKey && !entry.metaKey === !ev.metaKey && !entry.shiftKey === !ev.shiftKey);
  25634. },
  25635. parseEntry: function(key, entry) {
  25636. key = key.toUpperCase();
  25637. var me = this,
  25638. Event = Ext.event.Event,
  25639. keyFlags = Event.keyFlags,
  25640. parts = me._keySpecRe.exec(key),
  25641. type = 'keyCode',
  25642. name, code, i, match, n;
  25643. if (parts) {
  25644. name = parts[3];
  25645. if (parts[4]) {
  25646. entry.group = parts[4];
  25647. }
  25648. if (!(entry.ignoreModifiers = !!parts[1]) && parts[2]) {
  25649. parts = parts[2].split(me._delimiterRe);
  25650. n = parts.length;
  25651. for (i = 0; i < n; i++) {
  25652. if (!keyFlags[parts[i]]) {
  25653. return false;
  25654. }
  25655. entry[keyFlags[parts[i]]] = true;
  25656. }
  25657. }
  25658. entry.name = name;
  25659. if (isNaN(code = Event[name])) {
  25660. if (!(match = me._charCodeRe.exec(name))) {
  25661. if (name.length === 1) {
  25662. code = name.charCodeAt(0);
  25663. }
  25664. } else {
  25665. code = +match[1];
  25666. }
  25667. if (code) {
  25668. type = 'charCode';
  25669. } else {
  25670. code = +name;
  25671. }
  25672. entry.name = Keyboard.getKeyName(code);
  25673. }
  25674. entry.event = entry.event || me._keyMapEvents[type];
  25675. return !isNaN(code) && (entry[type] = code);
  25676. }
  25677. }
  25678. }
  25679. }
  25680. };
  25681. });
  25682. Ext.define('Ext.mixin.Focusable', {
  25683. mixinId: 'focusable',
  25684. $isFocusableEntity: true,
  25685. focusable: false,
  25686. hasFocus: false,
  25687. containsFocus: false,
  25688. focusCls: Ext.baseCSSPrefix + 'focused',
  25689. focusEl: 'el',
  25690. getFocusEl: function()
  25691. {
  25692. var focusEl = this.focusEl;
  25693. return focusEl && focusEl.dom ? focusEl : null;
  25694. },
  25695. getFocusClsEl: function() {
  25696. return this.getFocusEl();
  25697. },
  25698. initFocusable: Ext.emptyFn,
  25699. initFocusableEvents: function(force) {
  25700. this.initFocusableElement(force);
  25701. },
  25702. enableFocusable: Ext.emptyFn,
  25703. disableFocusable: function() {
  25704. var me = this;
  25705. if (me.hasFocus) {
  25706. me.revertFocus();
  25707. }
  25708. me.removeFocusCls();
  25709. },
  25710. destroyFocusable: function() {
  25711. var me = this;
  25712. Ext.destroy(me.focusListeners);
  25713. me.focusListeners = me.focusEnterEvent = me.focusTask = null;
  25714. me.focusEl = me.ariaEl = null;
  25715. },
  25716. isFocusable: function(deep) {
  25717. var me = this,
  25718. focusEl;
  25719. if (!me.focusable && (!me.isContainer || !deep)) {
  25720. return false;
  25721. }
  25722. focusEl = me.getFocusEl();
  25723. if (focusEl && me.canFocus()) {
  25724. return focusEl && !focusEl.destroyed && focusEl.isFocusable(deep);
  25725. }
  25726. return false;
  25727. },
  25728. isDestructing: function() {
  25729. for (var c = this; c; c = c.getRefOwner()) {
  25730. if (c.destroying || c.destroyed) {
  25731. return true;
  25732. }
  25733. }
  25734. return false;
  25735. },
  25736. canFocus: function(skipVisibility, includeFocusTarget) {
  25737. var me = this,
  25738. ownerFC = me.ownerFocusableContainer,
  25739. focusableIfDisabled = ownerFC && ownerFC.allowFocusingDisabledChildren,
  25740. canFocus;
  25741. canFocus = !me.destroyed && me.rendered && !me.isDestructing() && (me.isContainer || me.focusable) && (!me.isDisabled() || focusableIfDisabled) && (skipVisibility || me.isVisible(true));
  25742. return canFocus || (includeFocusTarget && !!me.findFocusTarget());
  25743. },
  25744. focus: function(selectText) {
  25745. var me = this,
  25746. focusTarget, focusElDom;
  25747. if ((!me.focusable && !me.isContainer) || me.destroyed || me.destroying) {
  25748. return false;
  25749. }
  25750. if (me.canFocus() && (focusTarget = me.getFocusEl())) {
  25751. if (focusTarget.$isFocusableEntity) {
  25752. return focusTarget.focus.apply(focusTarget, arguments);
  25753. }
  25754. focusElDom = focusTarget.dom;
  25755. if (focusElDom) {
  25756. focusTarget.focus();
  25757. if (selectText && (me.selectText || focusElDom.select)) {
  25758. if (me.selectText) {
  25759. if (Ext.isArray(selectText)) {
  25760. me.selectText.apply(me, selectText);
  25761. } else {
  25762. me.selectText();
  25763. }
  25764. } else {
  25765. focusElDom.select();
  25766. }
  25767. }
  25768. }
  25769. else if (focusTarget.focus) {
  25770. focusTarget.focus();
  25771. } else {
  25772. return false;
  25773. }
  25774. } else {
  25775. focusTarget = me.findFocusTarget();
  25776. if (focusTarget && focusTarget != me) {
  25777. return focusTarget.focus.apply(focusTarget, arguments);
  25778. } else {
  25779. return false;
  25780. }
  25781. }
  25782. return true;
  25783. },
  25784. onBlur: function(e) {
  25785. var me = this,
  25786. container = me.ownerFocusableContainer;
  25787. me.hasFocus = false;
  25788. if (me.beforeBlur && !me.beforeBlur.$emptyFn) {
  25789. me.beforeBlur(e);
  25790. }
  25791. if (container) {
  25792. container.beforeFocusableChildBlur(me, e);
  25793. }
  25794. me.removeFocusCls(e);
  25795. if (me.hasListeners.blur) {
  25796. me.fireEvent('blur', me, e);
  25797. }
  25798. if (me.postBlur && !me.postBlur.$emptyFn) {
  25799. me.postBlur(e);
  25800. }
  25801. if (container) {
  25802. container.afterFocusableChildBlur(me, e);
  25803. }
  25804. },
  25805. onFocus: function(e) {
  25806. var me = this,
  25807. container = me.ownerFocusableContainer;
  25808. if (me.canFocus()) {
  25809. if (me.beforeFocus && !me.beforeFocus.$emptyFn) {
  25810. me.beforeFocus(e);
  25811. }
  25812. if (container) {
  25813. container.beforeFocusableChildFocus(me, e);
  25814. }
  25815. me.addFocusCls(e);
  25816. if (!me.hasFocus) {
  25817. me.hasFocus = true;
  25818. me.fireEvent('focus', me, e);
  25819. }
  25820. if (me.postFocus && !me.postFocus.$emptyFn) {
  25821. me.postFocus(e);
  25822. }
  25823. if (container) {
  25824. container.afterFocusableChildFocus(me, e);
  25825. }
  25826. }
  25827. },
  25828. getTabIndex: function() {
  25829. var me = this,
  25830. el, index;
  25831. if (!me.focusable) {
  25832. return;
  25833. }
  25834. el = me.getFocusEl();
  25835. if (el) {
  25836. if (el.$isFocusableEntity) {
  25837. index = el.getTabIndex();
  25838. } else if (el.isElement && el.dom) {
  25839. index = el.dom.getAttribute('tabIndex');
  25840. if (index !== null) {
  25841. index -= 0;
  25842. }
  25843. } else
  25844. {
  25845. return;
  25846. }
  25847. }
  25848. if (typeof index !== 'number') {
  25849. index = me.tabIndex;
  25850. }
  25851. return index;
  25852. },
  25853. setTabIndex: function(newTabIndex, focusEl) {
  25854. var me = this,
  25855. ownerFC = me.ownerFocusableContainer,
  25856. focusableIfDisabled = ownerFC && ownerFC.allowFocusingDisabledChildren,
  25857. el;
  25858. if (!me.focusable && !me.forceTabIndex) {
  25859. return;
  25860. }
  25861. me.tabIndex = newTabIndex;
  25862. if (me.destroying || me.destroyed || (me.isDisabled() && !focusableIfDisabled)) {
  25863. return;
  25864. }
  25865. el = focusEl || me.getFocusEl();
  25866. if (el) {
  25867. if (el.$isFocusableEntity) {
  25868. el.setTabIndex(newTabIndex);
  25869. }
  25870. else if (el.isElement && el.dom) {
  25871. el.setTabIndex(newTabIndex);
  25872. }
  25873. }
  25874. },
  25875. onFocusEnter: function(e) {
  25876. var me = this;
  25877. if (me.destroying || me.destroyed) {
  25878. return;
  25879. }
  25880. me.focusEnterEvent = e;
  25881. me.containsFocus = true;
  25882. if (me.hasListeners.focusenter) {
  25883. me.fireEvent('focusenter', me, e);
  25884. }
  25885. },
  25886. onFocusLeave: function(e) {
  25887. var me = this;
  25888. if (me.destroying || me.destroyed) {
  25889. return;
  25890. }
  25891. me.focusEnterEvent = null;
  25892. me.containsFocus = false;
  25893. if (me.hasListeners.focusleave) {
  25894. me.fireEvent('focusleave', me, e);
  25895. }
  25896. },
  25897. onFocusMove: Ext.emptyFn,
  25898. privates: {
  25899. forceTabIndex: false,
  25900. revertFocus: function() {
  25901. var me = this,
  25902. focusEvent = me.focusEnterEvent,
  25903. activeElement = Ext.Element.getActiveElement(),
  25904. focusTarget, fromComponent, reverted;
  25905. if (focusEvent && !me.preventRefocus && me.el.contains(activeElement)) {
  25906. fromComponent = focusEvent.fromComponent;
  25907. if (fromComponent && (fromComponent.destroyed || fromComponent.isDestructing())) {
  25908. focusTarget = document.body;
  25909. } else
  25910. {
  25911. focusTarget = focusEvent.relatedTarget;
  25912. }
  25913. if (focusTarget === document.body) {
  25914. fromComponent = me.findFocusTarget();
  25915. if (fromComponent) {
  25916. focusTarget = fromComponent.getFocusEl();
  25917. }
  25918. }
  25919. if (focusTarget && focusTarget.$isFocusableEntity) {
  25920. if (!focusTarget.destroyed && focusTarget.isFocusable()) {
  25921. focusTarget.focus();
  25922. }
  25923. }
  25924. else if (Ext.getDoc().contains(focusTarget) && Ext.fly(focusTarget).isFocusable()) {
  25925. fromComponent = Ext.Component.from(focusTarget);
  25926. if (fromComponent) {
  25927. fromComponent.revertFocusTo(focusTarget);
  25928. } else {
  25929. focusTarget.focus();
  25930. }
  25931. }
  25932. else if (focusEvent.fromComponent && focusEvent.fromComponent.focus) {
  25933. reverted = focusEvent.fromComponent.focus();
  25934. if (!reverted) {
  25935. activeElement.blur();
  25936. }
  25937. }
  25938. }
  25939. },
  25940. revertFocusTo: function(target) {
  25941. target.focus();
  25942. },
  25943. findFocusTarget: function() {
  25944. var me = this,
  25945. parentAxis, candidate, len, i, focusTargets, focusIndex;
  25946. if (me.preventRefocus) {
  25947. return null;
  25948. }
  25949. for (parentAxis = [] , candidate = me.getRefOwner(); candidate; candidate = candidate.getRefOwner()) {
  25950. if (!candidate.isDisabled()) {
  25951. parentAxis.unshift(candidate);
  25952. }
  25953. }
  25954. for (i = 0 , len = parentAxis.length; i < len; i++) {
  25955. candidate = parentAxis[i];
  25956. if (candidate.destroying || !candidate.isVisible()) {
  25957. parentAxis.length = i;
  25958. break;
  25959. }
  25960. }
  25961. for (i = parentAxis.length - 1; i >= 0; i--) {
  25962. candidate = parentAxis[i];
  25963. focusTargets = Ext.ComponentQuery.query(':canfocus()', candidate);
  25964. if (focusTargets.length) {
  25965. focusIndex = Ext.Array.indexOf(focusTargets, Ext.ComponentManager.getActiveComponent());
  25966. return focusTargets[focusIndex + 1] || focusTargets[focusIndex - 1] || focusTargets[0];
  25967. }
  25968. if (candidate.isFocusable && candidate.isFocusable()) {
  25969. return candidate;
  25970. }
  25971. }
  25972. },
  25973. initFocusableElement: function(force) {
  25974. var me = this,
  25975. tabIndex = me.getTabIndex(),
  25976. focusEl = me.getFocusEl();
  25977. if (focusEl && !focusEl.$isFocusableEntity) {
  25978. if (tabIndex != null && (force || me.canFocus(true))) {
  25979. me.setTabIndex(tabIndex, focusEl);
  25980. }
  25981. if (!focusEl.dom.hasAttribute('data-componentid')) {
  25982. focusEl.dom.setAttribute('data-componentid', me.id);
  25983. }
  25984. }
  25985. },
  25986. addFocusCls: function(e) {
  25987. var focusCls = this.focusCls,
  25988. el;
  25989. el = this.getFocusClsEl();
  25990. if (focusCls) {
  25991. el = this.getFocusClsEl(e);
  25992. if (el) {
  25993. el.addCls(focusCls);
  25994. }
  25995. }
  25996. },
  25997. removeFocusCls: function(e) {
  25998. var focusCls = this.focusCls,
  25999. el;
  26000. if (focusCls) {
  26001. el = this.getFocusClsEl(e);
  26002. if (el) {
  26003. el.removeCls(focusCls);
  26004. }
  26005. }
  26006. },
  26007. handleFocusEvent: function(e) {
  26008. var me = this,
  26009. event;
  26010. if (!me.focusable || me.destroying || me.destroyed) {
  26011. return;
  26012. }
  26013. if (me.isFocusing(e)) {
  26014. event = new Ext.event.Event(e.event);
  26015. event.type = 'focus';
  26016. event.relatedTarget = e.fromElement;
  26017. event.target = e.toElement;
  26018. me.onFocus(event);
  26019. }
  26020. },
  26021. handleBlurEvent: function(e) {
  26022. var me = this,
  26023. event;
  26024. if (!me.focusable || me.destroying || me.destroyed) {
  26025. return;
  26026. }
  26027. if (e.toElement === document.body || me.isBlurring(e)) {
  26028. event = new Ext.event.Event(e.event);
  26029. event.type = 'blur';
  26030. event.target = e.fromElement;
  26031. event.relatedTarget = e.toElement;
  26032. me.onBlur(event);
  26033. }
  26034. },
  26035. isFocusing: function(e) {
  26036. var focusEl = this.getFocusEl();
  26037. if (focusEl) {
  26038. if (focusEl.isFocusing) {
  26039. return focusEl.isFocusing(e);
  26040. } else {
  26041. return focusEl.dom === document.activeElement && e.toElement === focusEl.dom && e.fromElement !== e.toElement;
  26042. }
  26043. }
  26044. return false;
  26045. },
  26046. isBlurring: function(e) {
  26047. var focusEl = this.getFocusEl();
  26048. if (focusEl) {
  26049. if (focusEl.isFocusing) {
  26050. return focusEl.isBlurring(e);
  26051. } else {
  26052. return focusEl.dom !== document.activeElement && e.fromElement === focusEl.dom && e.fromElement !== e.toElement;
  26053. }
  26054. }
  26055. return false;
  26056. },
  26057. blur: function() {
  26058. var me = this,
  26059. focusEl;
  26060. if (!me.focusable || !me.canFocus()) {
  26061. return;
  26062. }
  26063. focusEl = me.getFocusEl();
  26064. if (focusEl) {
  26065. me.blurring = true;
  26066. focusEl.blur();
  26067. delete me.blurring;
  26068. }
  26069. },
  26070. isTabbable: function() {
  26071. var me = this,
  26072. focusEl;
  26073. if (me.focusable) {
  26074. focusEl = me.getFocusEl();
  26075. if (focusEl && focusEl.isTabbable()) {
  26076. return focusEl.isTabbable();
  26077. }
  26078. }
  26079. return false;
  26080. },
  26081. disableTabbing: function() {
  26082. var me = this,
  26083. el = me.el,
  26084. focusEl;
  26085. if (me.destroying || me.destroyed) {
  26086. return;
  26087. }
  26088. if (el) {
  26089. el.saveTabbableState();
  26090. }
  26091. focusEl = me.getFocusEl();
  26092. if (focusEl) {
  26093. if (focusEl.$isFocusableEntity) {
  26094. focusEl.disableTabbing();
  26095. }
  26096. else if (focusEl.isElement && el && !el.contains(focusEl)) {
  26097. focusEl.saveTabbableState();
  26098. }
  26099. }
  26100. },
  26101. enableTabbing: function(reset) {
  26102. var me = this,
  26103. el = me.el,
  26104. focusEl;
  26105. if (me.destroying || me.destroyed) {
  26106. return;
  26107. }
  26108. focusEl = me.getFocusEl();
  26109. if (focusEl) {
  26110. if (focusEl.$isFocusableEntity) {
  26111. focusEl.enableTabbing();
  26112. } else if (focusEl.isElement && el && !el.contains(focusEl)) {
  26113. focusEl.restoreTabbableState();
  26114. }
  26115. }
  26116. if (el) {
  26117. el.restoreTabbableState({
  26118. reset: reset
  26119. });
  26120. }
  26121. }
  26122. }
  26123. }, function() {
  26124. var keyboardModeCls = Ext.baseCSSPrefix + 'keyboard-mode',
  26125. keyboardMode = false;
  26126. Ext.enableKeyboardMode = Ext.isModern || !Ext.os.is.Desktop;
  26127. Ext.setKeyboardMode = Ext.setKeyboardMode || function(keyboardMode) {
  26128. Ext.keyboardMode = keyboardMode;
  26129. Ext.getBody().toggleCls(keyboardModeCls, keyboardMode);
  26130. };
  26131. Ext.isTouchMode = function() {
  26132. return (Ext.now() - Ext.lastTouchTime) < 500;
  26133. };
  26134. Ext.syncKeyboardMode = function(e) {
  26135. if (!Ext.enableKeyboardMode) {
  26136. return;
  26137. }
  26138. var type = e.type;
  26139. if (type === 'pointermove') {
  26140. keyboardMode = false;
  26141. } else {
  26142. keyboardMode = (type === 'keydown');
  26143. Ext.lastTouchTime = e.pointerType === 'touch' && Ext.now();
  26144. Ext.setKeyboardMode(keyboardMode);
  26145. }
  26146. };
  26147. function keyboardModeFocusHandler() {
  26148. if (keyboardMode !== Ext.getBody().hasCls(keyboardModeCls)) {
  26149. Ext.setKeyboardMode(keyboardMode);
  26150. }
  26151. }
  26152. Ext.getEnableKeyboardMode = function() {
  26153. return Ext.enableKeyboardMode;
  26154. };
  26155. Ext.setEnableKeyboardMode = function(enable) {
  26156. var listeners = {
  26157. pointerdown: Ext.syncKeyboardMode,
  26158. pointermove: Ext.syncKeyboardMode,
  26159. keydown: Ext.syncKeyboardMode,
  26160. capture: true,
  26161. delegated: false
  26162. };
  26163. Ext.enableKeyboardMode = !!enable;
  26164. if (Ext.enableKeyboardMode) {
  26165. Ext.getWin().on(listeners);
  26166. Ext.on('focus', keyboardModeFocusHandler);
  26167. } else {
  26168. Ext.getWin().un(listeners);
  26169. Ext.un('focus', keyboardModeFocusHandler);
  26170. }
  26171. };
  26172. Ext.onReady(function() {
  26173. if (!Ext.enableKeyboardMode) {
  26174. Ext.getBody().addCls(keyboardModeCls);
  26175. }
  26176. Ext.setEnableKeyboardMode(Ext.enableKeyboardMode);
  26177. });
  26178. });
  26179. Ext.define('Ext.mixin.Accessible', {
  26180. extend: Ext.Mixin,
  26181. mixinConfig: {
  26182. id: 'accessible'
  26183. },
  26184. config: {
  26185. ariaAttributes: {
  26186. $value: null,
  26187. lazy: true
  26188. }
  26189. },
  26190. ariaEl: 'el',
  26191. privates: {
  26192. getAriaLabelEl: function(reference) {
  26193. var ids = [],
  26194. refHolder, i, len, cmp, result;
  26195. if (reference) {
  26196. if (Ext.isFunction(reference)) {
  26197. return reference.call(this);
  26198. } else {
  26199. if (!Ext.isArray(reference)) {
  26200. reference = [
  26201. reference
  26202. ];
  26203. }
  26204. refHolder = this.lookupReferenceHolder();
  26205. if (refHolder) {
  26206. for (i = 0 , len = reference.length; i < len; i++) {
  26207. cmp = refHolder.lookupReference(reference[i]);
  26208. if (cmp) {
  26209. ids.push(cmp.ariaEl.id);
  26210. }
  26211. }
  26212. }
  26213. }
  26214. }
  26215. return ids.length ? ids.join(' ') : null;
  26216. }
  26217. }
  26218. });
  26219. Ext.define('Ext.Widget', {
  26220. extend: Ext.Evented,
  26221. xtype: 'widget',
  26222. alternateClassName: 'Ext.Gadget',
  26223. mixins: [
  26224. Ext.mixin.Inheritable,
  26225. Ext.mixin.Bindable,
  26226. Ext.mixin.ComponentDelegation,
  26227. Ext.mixin.Pluggable,
  26228. Ext.mixin.Keyboard,
  26229. Ext.mixin.Factoryable,
  26230. Ext.mixin.Focusable,
  26231. Ext.mixin.Accessible
  26232. ],
  26233. isWidget: true,
  26234. factoryConfig: {
  26235. creator: null,
  26236. defaultProperty: 'xtype',
  26237. defaultType: 'component',
  26238. typeProperty: 'xtype'
  26239. },
  26240. element: {
  26241. reference: 'element'
  26242. },
  26243. observableType: 'component',
  26244. cachedConfig: {
  26245. cls: null,
  26246. style: null,
  26247. border: null,
  26248. touchAction: null,
  26249. eventHandlers: {
  26250. focus: 'handleFocusEvent',
  26251. blur: 'handleBlurEvent'
  26252. }
  26253. },
  26254. name: null,
  26255. config: {
  26256. renderTo: null,
  26257. ui: null,
  26258. userCls: null,
  26259. ripple: null,
  26260. hideMode: null,
  26261. instanceCls: null
  26262. },
  26263. eventedConfig: {
  26264. width: null,
  26265. height: null,
  26266. hidden: null,
  26267. disabled: null
  26268. },
  26269. template: [],
  26270. baseCls: null,
  26271. classCls: null,
  26272. classClsRoot: true,
  26273. classClsList: [],
  26274. clearPropertiesOnDestroy: 'async',
  26275. focusEl: 'element',
  26276. ariaEl: 'element',
  26277. spaceRe: /\s+/,
  26278. noBorderCls: Ext.baseCSSPrefix + 'noborder-trbl',
  26279. borderedCls: Ext.baseCSSPrefix + 'bordered',
  26280. disabledCls: Ext.baseCSSPrefix + 'disabled',
  26281. heightedCls: Ext.baseCSSPrefix + 'heighted',
  26282. widthedCls: Ext.baseCSSPrefix + 'widthed',
  26283. constructor: function(config) {
  26284. var me = this,
  26285. baseCls = me.baseCls,
  26286. renderTo = config && config.renderTo,
  26287. controller;
  26288. me.$iid = ++Ext.$nextIid;
  26289. if (baseCls == null || baseCls === true) {
  26290. me.baseCls = me.classCls || Ext.baseCSSPrefix + me.xtype;
  26291. }
  26292. if (config && ('baseCls' in config)) {
  26293. Ext.raise('baseCls cannot be used as an instance config. It must be specified at class definition time.');
  26294. }
  26295. if ((config && config.controller) || me.config.controller) {
  26296. me.referenceHolder = true;
  26297. }
  26298. me.initId(config);
  26299. me.initElement();
  26300. if (renderTo) {
  26301. config = Ext.apply({}, config);
  26302. delete config.renderTo;
  26303. }
  26304. me.mixins.observable.constructor.call(me, config);
  26305. if (me.focusable) {
  26306. me.initFocusableEvents(true);
  26307. }
  26308. if (renderTo) {
  26309. me.setRenderTo(renderTo);
  26310. }
  26311. me.syncUiCls();
  26312. Ext.ComponentManager.register(me);
  26313. controller = me.getController();
  26314. if (controller) {
  26315. controller.init(me);
  26316. }
  26317. },
  26318. afterCachedConfig: function() {
  26319. var me = this,
  26320. prototype = me.self.prototype,
  26321. referenceList = me.referenceList,
  26322. renderElement = me.renderElement,
  26323. renderTemplate, element, i, ln, reference, elements;
  26324. prototype.renderTemplate = renderTemplate = document.createDocumentFragment();
  26325. renderTemplate.appendChild(renderElement.clone(true, true));
  26326. elements = renderTemplate.querySelectorAll('[id]');
  26327. for (i = 0 , ln = elements.length; i < ln; i++) {
  26328. element = elements[i];
  26329. element.removeAttribute('id');
  26330. }
  26331. for (i = 0 , ln = referenceList.length; i < ln; i++) {
  26332. reference = referenceList[i];
  26333. me[reference].dom.removeAttribute('reference');
  26334. }
  26335. },
  26336. applyHidden: function(hidden) {
  26337. return !!hidden;
  26338. },
  26339. applyDisabled: function(disabled) {
  26340. return !!disabled;
  26341. },
  26342. updateDisabled: function(disabled) {
  26343. var me = this,
  26344. container = me.ownerFocusableContainer;
  26345. if (container) {
  26346. if (disabled) {
  26347. if (!container.beforeFocusableChildDisable.$nullFn) {
  26348. container.beforeFocusableChildDisable(me);
  26349. }
  26350. } else {
  26351. if (!container.beforeFocusableChildEnable.$nullFn) {
  26352. container.beforeFocusableChildEnable(me);
  26353. }
  26354. }
  26355. }
  26356. me.element.toggleCls(me.disabledCls, disabled);
  26357. if (me.focusable) {
  26358. if (disabled) {
  26359. me.disableFocusable();
  26360. } else {
  26361. me.enableFocusable();
  26362. }
  26363. }
  26364. if (container) {
  26365. if (disabled) {
  26366. if (!container.onFocusableChildDisable.$nullFn) {
  26367. container.onFocusableChildDisable(me);
  26368. }
  26369. } else {
  26370. if (!container.onFocusableChildEnable.$nullFn) {
  26371. container.onFocusableChildEnable(me);
  26372. }
  26373. }
  26374. }
  26375. },
  26376. disable: function() {
  26377. this.setDisabled(true);
  26378. },
  26379. enable: function() {
  26380. this.setDisabled(false);
  26381. },
  26382. isDisabled: function() {
  26383. return this.getDisabled();
  26384. },
  26385. isEnabled: function() {
  26386. return !this.getDisabled();
  26387. },
  26388. applyTouchAction: function(touchAction, oldTouchAction) {
  26389. if (oldTouchAction != null) {
  26390. touchAction = Ext.merge({}, oldTouchAction, touchAction);
  26391. }
  26392. return touchAction;
  26393. },
  26394. applyWidth: function(width) {
  26395. return this.filterLengthValue(width);
  26396. },
  26397. applyHeight: function(height) {
  26398. return this.filterLengthValue(height);
  26399. },
  26400. updateBorder: function(border) {
  26401. var me = this;
  26402. border = border || border === null;
  26403. me.toggleCls(me.noBorderCls, !border);
  26404. me.toggleCls(me.borderedCls, !!border);
  26405. },
  26406. clearListeners: function() {
  26407. var me = this;
  26408. me.mixins.observable.clearListeners.call(me);
  26409. me.mixins.componentDelegation.clearDelegatedListeners.call(me);
  26410. },
  26411. destroy: function() {
  26412. var me = this;
  26413. me.isDestroying = me.destroying = true;
  26414. me.doDestroy();
  26415. me.clearListeners();
  26416. me.isDestroying = me.destroying = false;
  26417. me.mixins.componentDelegation.destroyComponentDelegation.call(me);
  26418. me.callParent();
  26419. },
  26420. doDestroy: function() {
  26421. var me = this,
  26422. referenceList = me.referenceList,
  26423. container = me.ownerFocusableContainer,
  26424. i, ln, reference;
  26425. me.ownerCmp = null;
  26426. if (container && !container.onFocusableChildDestroy.$nullFn) {
  26427. container.onFocusableChildDestroy(me);
  26428. }
  26429. for (i = 0 , ln = referenceList.length; i < ln; i++) {
  26430. reference = referenceList[i];
  26431. if (me.hasOwnProperty(reference)) {
  26432. me[reference].destroy();
  26433. me[reference] = null;
  26434. }
  26435. }
  26436. me.destroyBindable();
  26437. Ext.ComponentManager.unregister(me);
  26438. },
  26439. doFireEvent: function(eventName, args, bubbles) {
  26440. var me = this,
  26441. ret;
  26442. ret = me.mixins.observable.doFireEvent.call(me, eventName, args, bubbles);
  26443. if (ret !== false && !me.destroyed) {
  26444. ret = me.mixins.componentDelegation.doFireDelegatedEvent.call(me, eventName, args);
  26445. }
  26446. return ret;
  26447. },
  26448. getBubbleTarget: function() {
  26449. return this.getRefOwner();
  26450. },
  26451. getElementConfig: function() {
  26452. var me = this,
  26453. el = me.element;
  26454. if (!('children' in el)) {
  26455. el = Ext.apply({
  26456. children: me.getTemplate()
  26457. }, el);
  26458. }
  26459. return el;
  26460. },
  26461. getSize: function() {
  26462. return this.el.getSize();
  26463. },
  26464. getTemplate: function() {
  26465. return Ext.clone(this.template);
  26466. },
  26467. getClassCls: function() {
  26468. var proto = this.self.prototype,
  26469. prototype = proto,
  26470. classes, classCls, i, ln;
  26471. while (prototype) {
  26472. classCls = prototype.hasOwnProperty('classCls') ? prototype.classCls : null;
  26473. if (classCls) {
  26474. if (classCls instanceof Array) {
  26475. for (i = 0 , ln = classCls.length; i < ln; i++) {
  26476. (classes || (classes = [])).push(classCls[i]);
  26477. }
  26478. } else {
  26479. (classes || (classes = [])).push(classCls);
  26480. }
  26481. }
  26482. if (prototype.classClsRoot && prototype.hasOwnProperty('classClsRoot')) {
  26483. break;
  26484. }
  26485. prototype = prototype.superclass;
  26486. }
  26487. if (classes) {
  26488. proto.classClsList = classes;
  26489. }
  26490. return classes;
  26491. },
  26492. hide: function() {
  26493. this.setHidden(true);
  26494. },
  26495. initElement: function() {
  26496. var me = this,
  26497. prototype = me.self.prototype,
  26498. id = me.getId(),
  26499. referenceList = me.referenceList = me.referenceList = [],
  26500. isFirstInstance = !prototype.hasOwnProperty('renderTemplate'),
  26501. uiReferences = prototype.hasOwnProperty('uiReferences') ? prototype.uiReferences : (prototype.uiReferences = {
  26502. element: ''
  26503. }),
  26504. renderTemplate, renderElement, renderConfig, element, referenceNodes, i, ln, referenceNode, reference, classCls, uiCls, baseCls, referenceElement;
  26505. if (isFirstInstance) {
  26506. renderTemplate = document.createDocumentFragment();
  26507. renderConfig = me.processElementConfig.call(prototype);
  26508. renderElement = Ext.Element.create(renderConfig, true);
  26509. renderTemplate.appendChild(renderElement);
  26510. referenceNodes = renderTemplate.querySelectorAll('[uiCls]');
  26511. for (i = 0 , ln = referenceNodes.length; i < ln; i++) {
  26512. referenceNode = referenceNodes[i];
  26513. reference = referenceNode.getAttribute('reference');
  26514. uiCls = referenceNode.getAttribute('uiCls');
  26515. if (!reference) {
  26516. Ext.raise('Cannot render element with uiCls="' + uiCls + '". uiCls is only allowed on elements that have a reference name.');
  26517. }
  26518. uiReferences[reference] = uiCls;
  26519. referenceNode.removeAttribute('uiCls');
  26520. }
  26521. } else {
  26522. renderTemplate = me.renderTemplate.cloneNode(true);
  26523. renderElement = renderTemplate.firstChild;
  26524. }
  26525. referenceNodes = renderTemplate.querySelectorAll('[reference]');
  26526. for (i = 0 , ln = referenceNodes.length; i < ln; i++) {
  26527. referenceNode = referenceNodes[i];
  26528. reference = referenceNode.getAttribute('reference');
  26529. if (!isFirstInstance) {
  26530. referenceNode.removeAttribute('reference');
  26531. }
  26532. if (reference === 'element') {
  26533. if (element) {
  26534. Ext.raise("Duplicate 'element' reference detected in '" + me.$className + "' template.");
  26535. }
  26536. referenceNode.id = id;
  26537. element = me.el = me.addElementReference(reference, referenceNode);
  26538. element.dom.setAttribute('data-componentid', id);
  26539. if (isFirstInstance) {
  26540. classCls = me.getClassCls();
  26541. if (classCls) {
  26542. element.addCls(classCls);
  26543. }
  26544. baseCls = me.baseCls;
  26545. if (baseCls && (baseCls !== me.classCls)) {
  26546. element.addCls(baseCls);
  26547. }
  26548. }
  26549. } else {
  26550. uiCls = uiReferences[reference];
  26551. if (uiCls && isFirstInstance) {
  26552. referenceElement = me.addElementReference(reference, referenceNode);
  26553. me.initUiReference(reference, uiCls, false);
  26554. } else {
  26555. me.addElementReferenceOnDemand(reference, referenceNode);
  26556. }
  26557. }
  26558. if (reference === me.focusEl) {
  26559. me.addElementReference('focusEl', referenceNode);
  26560. }
  26561. if (reference === me.ariaEl) {
  26562. me.addElementReferenceOnDemand('ariaEl', referenceNode);
  26563. }
  26564. referenceList.push(reference);
  26565. }
  26566. if (!element) {
  26567. Ext.raise("No 'element' reference found in '" + me.$className + "' template.");
  26568. }
  26569. if (renderElement === element.dom) {
  26570. me.renderElement = element;
  26571. } else {
  26572. me.addElementReferenceOnDemand('renderElement', renderElement);
  26573. }
  26574. renderElement.setAttribute(me.dataXid, me.$iid);
  26575. },
  26576. dataXid: 'data-' + Ext.baseCSSPrefix.substr(0, Ext.baseCSSPrefix.length - 1) + 'id',
  26577. is: function(selector) {
  26578. return Ext.ComponentQuery.is(this, selector);
  26579. },
  26580. isHidden: function(deep) {
  26581. var hidden = !!this.getHidden(),
  26582. owner;
  26583. if (!hidden && deep) {
  26584. owner = this.getRefOwner();
  26585. while (owner && owner !== deep && !hidden) {
  26586. hidden = !!owner.getHidden();
  26587. owner = owner.getRefOwner();
  26588. }
  26589. }
  26590. return hidden;
  26591. },
  26592. isVisible: function(deep) {
  26593. return this.rendered && !this.destroyed && !this.isHidden(deep);
  26594. },
  26595. isXType: function(xtype, shallow) {
  26596. return shallow ? (Ext.Array.indexOf(this.xtypes, xtype) !== -1) : !!this.xtypesMap[xtype];
  26597. },
  26598. lookupTpl: function(name) {
  26599. return Ext.XTemplate.getTpl(this, name);
  26600. },
  26601. owns: function(element) {
  26602. var result = false,
  26603. cmp;
  26604. if (element.isEvent) {
  26605. element = element.target;
  26606. } else if (element.isElement) {
  26607. element = element.dom;
  26608. }
  26609. cmp = Ext.Component.from(element);
  26610. if (cmp) {
  26611. result = (cmp === this) || (!!cmp.up(this));
  26612. }
  26613. return result;
  26614. },
  26615. render: function(container, insertBeforeElement) {
  26616. if (container && container.isWidget) {
  26617. container = container.el;
  26618. }
  26619. var dom = this.renderElement.dom,
  26620. containerDom = Ext.getDom(container),
  26621. insertBeforeChildDom;
  26622. if (Ext.isNumber(insertBeforeChildDom)) {
  26623. insertBeforeElement = containerDom.childNodes[insertBeforeElement];
  26624. }
  26625. insertBeforeChildDom = Ext.getDom(insertBeforeElement);
  26626. if (containerDom) {
  26627. if (insertBeforeChildDom) {
  26628. containerDom.insertBefore(dom, insertBeforeChildDom);
  26629. } else {
  26630. containerDom.appendChild(dom);
  26631. }
  26632. this.setRendered(Ext.getBody().contains(dom), true);
  26633. }
  26634. },
  26635. toggleCls: function(className, state) {
  26636. this.element.toggleCls(className, state);
  26637. return this;
  26638. },
  26639. resolveListenerScope: function(defaultScope, skipThis) {
  26640. return this.mixins.inheritable.resolveListenerScope.call(this, defaultScope, skipThis);
  26641. },
  26642. setSize: function(width, height) {
  26643. if (width && typeof width === 'object') {
  26644. return this.setSize(width.width, width.height);
  26645. }
  26646. if (width !== undefined) {
  26647. this.setWidth(width);
  26648. }
  26649. if (height !== undefined) {
  26650. this.setHeight(height);
  26651. }
  26652. },
  26653. show: function() {
  26654. this.setHidden(false);
  26655. },
  26656. addCls: function(cls, prefix, suffix) {
  26657. if (!this.destroyed) {
  26658. this.el.replaceCls(null, cls, prefix, suffix);
  26659. }
  26660. },
  26661. applyCls: function(cls) {
  26662. return cls && Ext.dom.Element.splitCls(cls);
  26663. },
  26664. applyUi: function(ui) {
  26665. return this.parseUi(ui, true);
  26666. },
  26667. removeCls: function(cls, prefix, suffix) {
  26668. if (!this.destroyed) {
  26669. this.el.replaceCls(cls, null, prefix, suffix);
  26670. }
  26671. },
  26672. replaceCls: function(oldCls, newCls, prefix, suffix) {
  26673. if (!this.destroyed) {
  26674. this.el.replaceCls(oldCls, newCls, prefix, suffix);
  26675. }
  26676. },
  26677. hasCls: function(className) {
  26678. return this.el.hasCls(className);
  26679. },
  26680. updateCls: function(newCls, oldCls) {
  26681. this.element.replaceCls(oldCls, newCls);
  26682. },
  26683. updateHidden: function(hidden) {
  26684. var me = this,
  26685. element = me.renderElement,
  26686. container = me.ownerFocusableContainer;
  26687. if (container) {
  26688. if (hidden) {
  26689. if (!container.beforeFocusableChildHide.$nullFn) {
  26690. container.beforeFocusableChildHide(me);
  26691. }
  26692. } else {
  26693. if (!container.beforeFocusableChildShow.$nullFn) {
  26694. container.beforeFocusableChildShow(me);
  26695. }
  26696. }
  26697. }
  26698. else if (hidden) {
  26699. me.revertFocus();
  26700. }
  26701. if (element && !element.destroyed) {
  26702. if (hidden) {
  26703. element.hide();
  26704. } else {
  26705. element.show();
  26706. }
  26707. }
  26708. if (me.focusableContainer && me.activateFocusableContainer) {
  26709. me.activateFocusableContainer(!hidden);
  26710. }
  26711. if (container) {
  26712. if (hidden) {
  26713. if (!container.onFocusableChildHide.$nullFn) {
  26714. container.onFocusableChildHide(me);
  26715. }
  26716. } else {
  26717. if (!container.onFocusableChildShow.$nullFn) {
  26718. container.onFocusableChildShow(me);
  26719. }
  26720. }
  26721. }
  26722. },
  26723. updateRipple: function(ripple) {
  26724. var me = this,
  26725. el = me.el;
  26726. if (el) {
  26727. el.un('touchstart', 'onRippleStart', me);
  26728. el.un('touchend', 'onRippleStart', me);
  26729. el.destroyAllRipples();
  26730. if (ripple.release) {
  26731. el.on('touchend', 'onRippleStart', me);
  26732. } else {
  26733. el.on('touchstart', 'onRippleStart', me);
  26734. }
  26735. }
  26736. },
  26737. shouldRipple: function(e) {
  26738. var me = this,
  26739. disabled = me.getDisabled && me.getDisabled(),
  26740. el = me.el,
  26741. ripple = !disabled && me.getRipple(),
  26742. target;
  26743. if (ripple && e) {
  26744. target = e.getTarget(me.noRippleSelector);
  26745. if (target) {
  26746. if ((el.dom === target) || el.contains(target)) {
  26747. ripple = null;
  26748. }
  26749. }
  26750. }
  26751. return ripple;
  26752. },
  26753. onRippleStart: function(e) {
  26754. var ripple = this.shouldRipple(e);
  26755. if (e.button === 0 && ripple) {
  26756. this.el.ripple(e, ripple);
  26757. }
  26758. },
  26759. applyStyle: function(style, oldStyle) {
  26760. if (oldStyle && style === oldStyle && Ext.isObject(oldStyle)) {
  26761. style = Ext.apply({}, style);
  26762. }
  26763. this.element.applyStyles(style);
  26764. return null;
  26765. },
  26766. getStyle: function() {
  26767. Ext.Error.raise("'style' is a write-only config. To query element styles use the Ext.dom.Element API.");
  26768. },
  26769. updateRenderTo: function(newContainer) {
  26770. this.render(newContainer);
  26771. },
  26772. updateTouchAction: function(touchAction) {
  26773. var name, childEl, value, hasRootActions;
  26774. for (name in touchAction) {
  26775. childEl = this[name];
  26776. value = touchAction[name];
  26777. if (childEl && childEl.isElement) {
  26778. childEl.setTouchAction(value);
  26779. } else {
  26780. hasRootActions = true;
  26781. }
  26782. }
  26783. if (hasRootActions) {
  26784. this.el.setTouchAction(touchAction);
  26785. }
  26786. },
  26787. updateUi: function() {
  26788. if (!this.isConfiguring) {
  26789. this.syncUiCls();
  26790. }
  26791. },
  26792. updateWidth: function(width) {
  26793. var el = this.el;
  26794. el.setWidth(width);
  26795. el.toggleCls(this.widthedCls, width != null && width !== 'auto');
  26796. },
  26797. updateHeight: function(height) {
  26798. var el = this.el;
  26799. el.setHeight(height);
  26800. el.toggleCls(this.heightedCls, height != null && height !== 'auto');
  26801. },
  26802. isWidthed: function() {
  26803. var width = this.getWidth();
  26804. return width != null && width !== 'auto';
  26805. },
  26806. isHeighted: function() {
  26807. var height = this.getHeight();
  26808. return height != null && height !== 'auto';
  26809. },
  26810. up: function(selector, limit) {
  26811. var result = this.getRefOwner(),
  26812. limitSelector = typeof limit === 'string',
  26813. limitCount = typeof limit === 'number',
  26814. limitComponent = limit && limit.isComponent,
  26815. steps = 0;
  26816. if (selector) {
  26817. for (; result; result = result.getRefOwner()) {
  26818. if (result.destroyed) {
  26819. return null;
  26820. }
  26821. steps++;
  26822. if (selector.isComponent || selector.isWidget) {
  26823. if (result === selector) {
  26824. return result;
  26825. }
  26826. } else {
  26827. if (Ext.ComponentQuery.is(result, selector)) {
  26828. return result;
  26829. }
  26830. }
  26831. if (limitSelector && result.is(limit)) {
  26832. return;
  26833. }
  26834. if (limitCount && steps === limit) {
  26835. return;
  26836. }
  26837. if (limitComponent && result === limit) {
  26838. return;
  26839. }
  26840. }
  26841. }
  26842. return result;
  26843. },
  26844. updateLayout: Ext.emptyFn,
  26845. updateInstanceCls: function(instanceCls, oldInstanceCls) {
  26846. var me = this,
  26847. el = me.el,
  26848. classClsList = me.classClsList,
  26849. Array = Ext.Array,
  26850. uiReferences = me.uiReferences,
  26851. referenceName, referenceElement, i, ln, cls, uiCls;
  26852. if (oldInstanceCls) {
  26853. el.removeCls(oldInstanceCls);
  26854. oldInstanceCls = Array.from(oldInstanceCls);
  26855. for (i = 0 , ln = oldInstanceCls.length; i < ln; i++) {
  26856. cls = oldInstanceCls[i];
  26857. Array.remove(classClsList, cls);
  26858. for (referenceName in uiReferences) {
  26859. referenceElement = me[referenceName];
  26860. uiCls = uiReferences[referenceName];
  26861. referenceElement.removeCls(cls + '-' + uiCls);
  26862. }
  26863. }
  26864. }
  26865. if (instanceCls) {
  26866. el.addCls(instanceCls);
  26867. instanceCls = Array.from(instanceCls);
  26868. me.classClsList = classClsList.concat(instanceCls);
  26869. for (i = 0 , ln = instanceCls.length; i < ln; i++) {
  26870. cls = instanceCls[i];
  26871. for (referenceName in uiReferences) {
  26872. referenceElement = me[referenceName];
  26873. uiCls = uiReferences[referenceName];
  26874. referenceElement.addCls(cls + '-' + uiCls);
  26875. }
  26876. }
  26877. }
  26878. if (!me.isConfiguring) {
  26879. me.syncUiCls();
  26880. }
  26881. },
  26882. getBaseCls: function() {
  26883. return this.baseCls;
  26884. },
  26885. setBaseCls: function() {
  26886. Ext.raise('baseCls cannot be reconfigured. It must be specified at class definition time.');
  26887. },
  26888. onClassExtended: function(Class, members) {
  26889. if (members.config && members.config.baseCls) {
  26890. Ext.raise('baseCls must be declared directly on the class body. Please move it outside of the config block.');
  26891. }
  26892. },
  26893. privates: {
  26894. _hideModes: {
  26895. clip: 'CLIP',
  26896. display: 'DISPLAY',
  26897. offsets: 'OFFSETS',
  26898. opacity: 'OPACITY',
  26899. visibility: 'VISIBILITY'
  26900. },
  26901. noRippleSelector: '.' + Ext.baseCSSPrefix + 'no-ripple',
  26902. addElementReferenceOnDemand: function(name, domNode) {
  26903. if (this._elementListeners[name]) {
  26904. this.addElementReference(name, domNode);
  26905. } else {
  26906. Ext.Object.defineProperty(this, name, {
  26907. get: function() {
  26908. if (this.destroyed) {
  26909. return;
  26910. }
  26911. delete this[name];
  26912. return this.addElementReference(name, domNode);
  26913. },
  26914. configurable: true
  26915. });
  26916. }
  26917. },
  26918. addElementReference: function(name, domNode) {
  26919. var me = this,
  26920. referenceEl = me[name] = Ext.get(domNode),
  26921. listeners = me._elementListeners[name],
  26922. eventName, listener;
  26923. referenceEl.skipGarbageCollection = true;
  26924. referenceEl.component = me;
  26925. if (listeners) {
  26926. listeners = Ext.clone(listeners);
  26927. for (eventName in listeners) {
  26928. listener = listeners[eventName];
  26929. if (typeof listener === 'object') {
  26930. listener.scope = me;
  26931. }
  26932. }
  26933. listeners.scope = me;
  26934. referenceEl.on(listeners);
  26935. }
  26936. return referenceEl;
  26937. },
  26938. detachFromBody: function() {
  26939. Ext.getDetachedBody().appendChild(this.element, true);
  26940. this.isDetached = true;
  26941. },
  26942. reattachToBody: function() {
  26943. var detachedBody;
  26944. if (this.isDetached) {
  26945. detachedBody = Ext.getDetachedBody();
  26946. if (detachedBody.contains(this.element)) {
  26947. Ext.getBody().appendChild(this.element, true);
  26948. }
  26949. }
  26950. this.isDetached = false;
  26951. },
  26952. doAddListener: function(name, fn, scope, options, order, caller, manager) {
  26953. var me = this,
  26954. elementName = options && options.element,
  26955. delegate = options && options.delegate,
  26956. listeners, eventOptions, option;
  26957. if (elementName) {
  26958. if (Ext.Array.indexOf(me.referenceList, elementName) === -1) {
  26959. Ext.Logger.error("Adding event listener with an invalid element reference of '" + elementName + "' for this component. Available values are: '" + me.referenceList.join("', '") + "'", me);
  26960. }
  26961. listeners = {};
  26962. listeners[name] = fn;
  26963. if (scope) {
  26964. listeners.scope = scope;
  26965. }
  26966. eventOptions = Ext.Element.prototype.$eventOptions;
  26967. for (option in options) {
  26968. if (eventOptions[option]) {
  26969. listeners[option] = options[option];
  26970. }
  26971. }
  26972. me.mon(me[elementName], listeners);
  26973. return;
  26974. } else if (delegate) {
  26975. me.mixins.componentDelegation.addDelegatedListener.call(me, name, fn, scope, options, order, caller, manager);
  26976. return;
  26977. }
  26978. me.callParent([
  26979. name,
  26980. fn,
  26981. scope,
  26982. options,
  26983. order,
  26984. caller,
  26985. manager
  26986. ]);
  26987. },
  26988. doRemoveListener: function(eventName, fn, scope) {
  26989. var me = this;
  26990. me.mixins.observable.doRemoveListener.call(me, eventName, fn, scope);
  26991. me.mixins.componentDelegation.removeDelegatedListener.call(me, eventName, fn, scope);
  26992. },
  26993. filterLengthValue: function(value) {
  26994. if (!value && value !== 0) {
  26995. return null;
  26996. }
  26997. return value;
  26998. },
  26999. initElementListeners: function(elementConfig) {
  27000. var prototype = this,
  27001. superPrototype = prototype.self.superclass,
  27002. superElementListeners = superPrototype._elementListeners,
  27003. reference = elementConfig.reference,
  27004. children = elementConfig.children,
  27005. elementListeners, listeners, superListeners, ln, i;
  27006. if (prototype.hasOwnProperty('_elementListeners')) {
  27007. elementListeners = prototype._elementListeners;
  27008. } else {
  27009. elementListeners = prototype._elementListeners = (superElementListeners ? Ext.Object.chain(superElementListeners) : {});
  27010. }
  27011. if (reference) {
  27012. listeners = elementConfig.listeners;
  27013. if (listeners) {
  27014. if (superElementListeners) {
  27015. superListeners = superElementListeners[reference];
  27016. if (superListeners) {
  27017. listeners = Ext.Object.chain(superListeners);
  27018. Ext.apply(listeners, elementConfig.listeners);
  27019. }
  27020. }
  27021. elementListeners[reference] = listeners;
  27022. elementConfig.listeners = null;
  27023. }
  27024. }
  27025. if (children) {
  27026. for (i = 0 , ln = children.length; i < ln; i++) {
  27027. prototype.initElementListeners(children[i]);
  27028. }
  27029. }
  27030. },
  27031. initId: function(config) {
  27032. var me = this,
  27033. defaultConfig = me.config,
  27034. id = (config && config.id) || (defaultConfig && defaultConfig.id);
  27035. if (id) {
  27036. me.setId(id);
  27037. me.id = id;
  27038. } else {
  27039. me.getId();
  27040. }
  27041. },
  27042. measure: function(dimension) {
  27043. return this.element.measure(dimension);
  27044. },
  27045. processElementConfig: function() {
  27046. var prototype = this,
  27047. superPrototype = prototype.self.superclass,
  27048. elementConfig;
  27049. if (prototype.hasOwnProperty('_elementConfig')) {
  27050. elementConfig = prototype._elementConfig;
  27051. } else {
  27052. elementConfig = prototype._elementConfig = prototype.getElementConfig();
  27053. if (superPrototype.isWidget) {
  27054. prototype.processElementConfig.call(superPrototype);
  27055. }
  27056. prototype.initElementListeners(elementConfig);
  27057. }
  27058. return elementConfig;
  27059. },
  27060. parseUi: function(ui, asString) {
  27061. ui = Ext.String.splitWords(ui);
  27062. if (asString) {
  27063. ui = ui.join(' ');
  27064. }
  27065. return ui;
  27066. },
  27067. addUi: function(ui) {
  27068. this.setUi(this.doAddUi(ui, this.getUi()));
  27069. },
  27070. doAddUi: function(ui, oldUi) {
  27071. var me = this,
  27072. newUi = null,
  27073. i, u, len;
  27074. if (ui) {
  27075. ui = me.parseUi(ui);
  27076. len = ui.length;
  27077. oldUi = me.parseUi(oldUi);
  27078. for (i = 0; i < len; i++) {
  27079. u = ui[i];
  27080. if (Ext.Array.indexOf(oldUi, u) === -1) {
  27081. oldUi.push(u);
  27082. }
  27083. }
  27084. newUi = oldUi.join(' ');
  27085. }
  27086. return newUi;
  27087. },
  27088. removeUi: function(ui) {
  27089. this.setUi(this.doRemoveUi(ui, this.getUi()));
  27090. },
  27091. doRemoveUi: function(ui, oldUi) {
  27092. var me = this,
  27093. newUi = null,
  27094. i, u, index, len;
  27095. if (ui) {
  27096. ui = me.parseUi(ui);
  27097. len = ui.length;
  27098. oldUi = me.parseUi(oldUi);
  27099. for (i = 0; i < len; i++) {
  27100. u = ui[i];
  27101. index = Ext.Array.indexOf(oldUi, u);
  27102. if (index !== -1) {
  27103. oldUi.splice(index, 1);
  27104. }
  27105. }
  27106. newUi = oldUi.join(' ');
  27107. }
  27108. return newUi;
  27109. },
  27110. initUiReference: function(referenceName, uiCls, isInstance) {
  27111. var me = this,
  27112. referenceElement = me[referenceName],
  27113. baseCls = me.baseCls,
  27114. classClsList = me.classClsList,
  27115. cls = [],
  27116. i, n;
  27117. isInstance = (isInstance !== false);
  27118. if (isInstance) {
  27119. if (!me.hasOwnProperty('uiReferences')) {
  27120. me.uiReferences = Ext.clone(me.uiReferences);
  27121. }
  27122. me.uiReferences[referenceName] = uiCls;
  27123. }
  27124. uiCls = '-' + uiCls;
  27125. if (baseCls && (baseCls !== me.classCls)) {
  27126. cls.push(baseCls + uiCls);
  27127. }
  27128. if (classClsList) {
  27129. for (i = 0 , n = classClsList.length; i < n; i++) {
  27130. cls.push(classClsList[i] + uiCls);
  27131. }
  27132. }
  27133. referenceElement.addCls(cls);
  27134. if (isInstance && !me.isConfiguring) {
  27135. me.syncUiCls();
  27136. }
  27137. },
  27138. syncUiCls: function(refs) {
  27139. var me = this,
  27140. ui = me.getUi(),
  27141. currentUiCls = me.currentUiCls || (me.currentUiCls = {}),
  27142. baseCls = me.baseCls,
  27143. uiReferences = refs || me.uiReferences,
  27144. classClsList = me.classClsList,
  27145. classClsListLen = classClsList ? classClsList.length : 0,
  27146. uiCls, uiLen, refName, refEl, cls, suffix, uiSuffix, i, j;
  27147. if (ui) {
  27148. ui = me.parseUi(ui);
  27149. uiLen = ui.length;
  27150. }
  27151. for (refName in uiReferences) {
  27152. refEl = me[refName];
  27153. uiCls = [];
  27154. if (refEl) {
  27155. cls = currentUiCls[refName];
  27156. if (cls) {
  27157. refEl.removeCls(cls);
  27158. }
  27159. if (ui) {
  27160. suffix = uiReferences[refName];
  27161. suffix = suffix ? ('-' + suffix) : '';
  27162. for (i = 0; i < uiLen; i++) {
  27163. uiSuffix = '-' + ui[i] + suffix;
  27164. if (baseCls && (baseCls !== me.classCls)) {
  27165. uiCls.push(baseCls + uiSuffix);
  27166. }
  27167. if (classClsList) {
  27168. for (j = 0; j < classClsListLen; j++) {
  27169. uiCls.push(classClsList[j] + uiSuffix);
  27170. }
  27171. }
  27172. }
  27173. refEl.addCls(uiCls);
  27174. currentUiCls[refName] = uiCls;
  27175. }
  27176. }
  27177. }
  27178. },
  27179. applyHideMode: function(mode) {
  27180. return mode || 'display';
  27181. },
  27182. updateHideMode: function(mode) {
  27183. var me = this,
  27184. el = me.el,
  27185. shouldToggle = me.getHidden();
  27186. if (!me._hideModes[mode]) {
  27187. Ext.raise('Invalid hideMode: "' + mode + '" (must be one of: "' + Object.keys(me._hideModes).join('", "') + '")');
  27188. }
  27189. if (shouldToggle) {
  27190. el.show();
  27191. }
  27192. me.renderElement.setVisibilityMode(Ext.Element[me._hideModes[mode]]);
  27193. if (shouldToggle) {
  27194. el.hide();
  27195. }
  27196. },
  27197. updateUserCls: function(newCls, oldCls) {
  27198. this.element.replaceCls(oldCls, newCls);
  27199. }
  27200. }
  27201. }, function(Widget) {
  27202. var prototype = Widget.prototype;
  27203. (prototype.$elementEventOptions = Ext.Object.chain(Ext.Element.prototype.$eventOptions)).element = 1;
  27204. (prototype.$eventOptions = Ext.Object.chain(prototype.$eventOptions)).delegate = 1;
  27205. Ext.updateWidget = Ext.Factory.widget.update;
  27206. });
  27207. Ext.define('Ext.mixin.Traversable', {
  27208. extend: Ext.Mixin,
  27209. mixinConfig: {
  27210. id: 'traversable'
  27211. },
  27212. setParent: function(parent) {
  27213. this.parent = parent;
  27214. return this;
  27215. },
  27216. hasParent: function() {
  27217. return Boolean(this.getParent());
  27218. },
  27219. is: function() {
  27220. return true;
  27221. },
  27222. getParent: function() {
  27223. return this.parent || this.$initParent;
  27224. },
  27225. getAncestors: function() {
  27226. var ancestors = [],
  27227. parent = this.getParent();
  27228. while (parent) {
  27229. ancestors.push(parent);
  27230. parent = parent.getParent();
  27231. }
  27232. return ancestors;
  27233. },
  27234. getAncestorIds: function() {
  27235. var ancestorIds = [],
  27236. parent = this.getParent();
  27237. while (parent) {
  27238. ancestorIds.push(parent.getId());
  27239. parent = parent.getParent();
  27240. }
  27241. return ancestorIds;
  27242. },
  27243. previousNode: function(selector, includeSelf) {
  27244. var node = this,
  27245. parent = node.getRefOwner(),
  27246. result, it, i, sibling;
  27247. if (includeSelf && node.is(selector)) {
  27248. return node;
  27249. }
  27250. if (parent) {
  27251. for (it = parent.items.items , i = Ext.Array.indexOf(it, node) - 1; i > -1; i--) {
  27252. sibling = it[i];
  27253. if (sibling.query) {
  27254. result = sibling.query(selector);
  27255. result = result[result.length - 1];
  27256. if (result) {
  27257. return result;
  27258. }
  27259. }
  27260. if (!selector || sibling.is(selector)) {
  27261. return sibling;
  27262. }
  27263. }
  27264. return parent.previousNode(selector, true);
  27265. }
  27266. return null;
  27267. },
  27268. previousSibling: function(selector) {
  27269. var parent = this.getRefOwner(),
  27270. it, idx, sibling;
  27271. if (parent) {
  27272. it = parent.items;
  27273. idx = it.indexOf(this);
  27274. if (idx !== -1) {
  27275. if (selector) {
  27276. for (--idx; idx >= 0; idx--) {
  27277. if ((sibling = it.getAt(idx)).is(selector)) {
  27278. return sibling;
  27279. }
  27280. }
  27281. } else {
  27282. if (idx) {
  27283. return it.getAt(--idx);
  27284. }
  27285. }
  27286. }
  27287. }
  27288. return null;
  27289. },
  27290. nextNode: function(selector, includeSelf) {
  27291. var node = this,
  27292. parent = node.getRefOwner(),
  27293. result, it, len, i, sibling;
  27294. if (includeSelf && node.is(selector)) {
  27295. return node;
  27296. }
  27297. if (parent) {
  27298. for (it = parent.items.items , i = Ext.Array.indexOf(it, node) + 1 , len = it.length; i < len; i++) {
  27299. sibling = it[i];
  27300. if (!selector || sibling.is(selector)) {
  27301. return sibling;
  27302. }
  27303. if (sibling.down) {
  27304. result = sibling.down(selector);
  27305. if (result) {
  27306. return result;
  27307. }
  27308. }
  27309. }
  27310. return parent.nextNode(selector);
  27311. }
  27312. return null;
  27313. },
  27314. nextSibling: function(selector) {
  27315. var parent = this.getRefOwner(),
  27316. it, last, idx, sibling;
  27317. if (parent) {
  27318. it = parent.items;
  27319. idx = it.indexOf(this) + 1;
  27320. if (idx) {
  27321. if (selector) {
  27322. for (last = it.getCount(); idx < last; idx++) {
  27323. if ((sibling = it.getAt(idx)).is(selector)) {
  27324. return sibling;
  27325. }
  27326. }
  27327. } else {
  27328. if (idx < it.getCount()) {
  27329. return it.getAt(idx);
  27330. }
  27331. }
  27332. }
  27333. }
  27334. return null;
  27335. }
  27336. });
  27337. Ext.define('Ext.fx.easing.Abstract', {
  27338. config: {
  27339. startTime: 0,
  27340. startValue: 0
  27341. },
  27342. isEasing: true,
  27343. isEnded: false,
  27344. constructor: function(config) {
  27345. this.initConfig(config);
  27346. return this;
  27347. },
  27348. applyStartTime: function(startTime) {
  27349. if (!startTime) {
  27350. startTime = Ext.Date.now();
  27351. }
  27352. return startTime;
  27353. },
  27354. updateStartTime: function(startTime) {
  27355. this.reset();
  27356. },
  27357. reset: function() {
  27358. this.isEnded = false;
  27359. },
  27360. getValue: Ext.emptyFn
  27361. });
  27362. Ext.define('Ext.fx.easing.Linear', {
  27363. extend: Ext.fx.easing.Abstract,
  27364. alias: 'easing.linear',
  27365. config: {
  27366. duration: 0,
  27367. endValue: 0
  27368. },
  27369. updateStartValue: function(startValue) {
  27370. this.distance = this.getEndValue() - startValue;
  27371. },
  27372. updateEndValue: function(endValue) {
  27373. this.distance = endValue - this.getStartValue();
  27374. },
  27375. getValue: function() {
  27376. var deltaTime = Ext.Date.now() - this.getStartTime(),
  27377. duration = this.getDuration();
  27378. if (deltaTime > duration) {
  27379. this.isEnded = true;
  27380. return this.getEndValue();
  27381. } else {
  27382. return this.getStartValue() + ((deltaTime / duration) * this.distance);
  27383. }
  27384. }
  27385. });
  27386. Ext.define('Ext.util.translatable.Abstract', {
  27387. extend: Ext.Evented,
  27388. mixins: [
  27389. Ext.mixin.Factoryable
  27390. ],
  27391. factoryConfig: {
  27392. type: 'translatable',
  27393. defaultType: 'csstransform'
  27394. },
  27395. config: {
  27396. easing: null,
  27397. easingX: {
  27398. duration: 300
  27399. },
  27400. easingY: {
  27401. duration: 300
  27402. }
  27403. },
  27404. x: 0,
  27405. y: 0,
  27406. activeEasingX: null,
  27407. activeEasingY: null,
  27408. isAnimating: false,
  27409. isTranslatable: true,
  27410. constructor: function(config) {
  27411. this.callParent([
  27412. config
  27413. ]);
  27414. this.position = {
  27415. x: 0,
  27416. y: 0
  27417. };
  27418. },
  27419. factoryEasing: function(easing) {
  27420. return Ext.factory(easing, Ext.fx.easing.Linear, null, 'easing');
  27421. },
  27422. applyEasing: function(easing) {
  27423. if (!this.getEasingX()) {
  27424. this.setEasingX(this.factoryEasing(easing));
  27425. }
  27426. if (!this.getEasingY()) {
  27427. this.setEasingY(this.factoryEasing(easing));
  27428. }
  27429. },
  27430. applyEasingX: function(easing) {
  27431. return this.factoryEasing(easing);
  27432. },
  27433. applyEasingY: function(easing) {
  27434. return this.factoryEasing(easing);
  27435. },
  27436. doTranslate: function(x, y) {
  27437. if (this.hasListeners.translate) {
  27438. this.fireEvent('translate', this, x, y);
  27439. }
  27440. },
  27441. translate: function(x, y, animation) {
  27442. if (animation) {
  27443. return this.translateAnimated(x, y, animation);
  27444. }
  27445. if (this.isAnimating) {
  27446. this.stopAnimation();
  27447. }
  27448. if (!isNaN(x) && typeof x === 'number') {
  27449. this.x = x;
  27450. }
  27451. if (!isNaN(y) && typeof y === 'number') {
  27452. this.y = y;
  27453. }
  27454. this.doTranslate(x, y);
  27455. },
  27456. translateAxis: function(axis, value, animation) {
  27457. var x, y;
  27458. if (axis === 'x') {
  27459. x = value;
  27460. } else {
  27461. y = value;
  27462. }
  27463. return this.translate(x, y, animation);
  27464. },
  27465. getPosition: function() {
  27466. var me = this,
  27467. position = me.position;
  27468. position.x = -me.x;
  27469. position.y = -me.y;
  27470. return position;
  27471. },
  27472. animate: function(easingX, easingY) {
  27473. var me = this;
  27474. me.activeEasingX = easingX;
  27475. me.activeEasingY = easingY;
  27476. me.isAnimating = true;
  27477. if (me.ownerCmp) {
  27478. me.ownerCmp.isTranslating = true;
  27479. }
  27480. me.lastX = null;
  27481. me.lastY = null;
  27482. Ext.AnimationQueue.start(me.doAnimationFrame, me);
  27483. me.fireEvent('animationstart', me, me.x, me.y);
  27484. return me;
  27485. },
  27486. translateAnimated: function(x, y, animation) {
  27487. var me = this,
  27488. now, easing, easingX, easingY;
  27489. if (!Ext.isObject(animation)) {
  27490. animation = {};
  27491. }
  27492. if (me.isAnimating) {
  27493. me.stopAnimation();
  27494. }
  27495. me.callback = animation.callback;
  27496. me.callbackScope = animation.scope;
  27497. now = Ext.Date.now();
  27498. easing = animation.easing;
  27499. easingX = (typeof x === 'number') ? (animation.easingX || easing || me.getEasingX() || true) : null;
  27500. easingY = (typeof y === 'number') ? (animation.easingY || easing || me.getEasingY() || true) : null;
  27501. if (easingX) {
  27502. easingX = me.factoryEasing(easingX);
  27503. easingX.setStartTime(now);
  27504. easingX.setStartValue(me.x);
  27505. easingX.setEndValue(x);
  27506. if ('duration' in animation) {
  27507. easingX.setDuration(animation.duration);
  27508. }
  27509. }
  27510. if (easingY) {
  27511. easingY = me.factoryEasing(easingY);
  27512. easingY.setStartTime(now);
  27513. easingY.setStartValue(me.y);
  27514. easingY.setEndValue(y);
  27515. if ('duration' in animation) {
  27516. easingY.setDuration(animation.duration);
  27517. }
  27518. }
  27519. return me.animate(easingX, easingY);
  27520. },
  27521. doAnimationFrame: function() {
  27522. var me = this,
  27523. easingX = me.activeEasingX,
  27524. easingY = me.activeEasingY,
  27525. now = Date.now(),
  27526. x, y;
  27527. if (!me.isAnimating) {
  27528. return;
  27529. }
  27530. me.lastRun = now;
  27531. if (easingX === null && easingY === null) {
  27532. me.stopAnimation();
  27533. return;
  27534. }
  27535. if (easingX !== null) {
  27536. me.x = x = Math.round(easingX.getValue());
  27537. if (easingX.isEnded) {
  27538. me.activeEasingX = null;
  27539. me.fireEvent('axisanimationend', me, 'x', x);
  27540. }
  27541. } else {
  27542. x = me.x;
  27543. }
  27544. if (easingY !== null) {
  27545. me.y = y = Math.round(easingY.getValue());
  27546. if (easingY.isEnded) {
  27547. me.activeEasingY = null;
  27548. me.fireEvent('axisanimationend', me, 'y', y);
  27549. }
  27550. } else {
  27551. y = me.y;
  27552. }
  27553. if (me.lastX !== x || me.lastY !== y) {
  27554. me.doTranslate(x, y);
  27555. me.lastX = x;
  27556. me.lastY = y;
  27557. }
  27558. me.fireEvent('animationframe', me, x, y);
  27559. },
  27560. stopAnimation: function() {
  27561. var me = this;
  27562. if (!me.isAnimating) {
  27563. return;
  27564. }
  27565. me.activeEasingX = null;
  27566. me.activeEasingY = null;
  27567. me.isAnimating = false;
  27568. if (me.ownerCmp) {
  27569. me.ownerCmp.isTranslating = false;
  27570. }
  27571. Ext.AnimationQueue.stop(me.doAnimationFrame, me);
  27572. me.fireEvent('animationend', me, me.x, me.y);
  27573. if (me.callback) {
  27574. me.callback.call(me.callbackScope);
  27575. me.callback = null;
  27576. }
  27577. },
  27578. refresh: function() {
  27579. this.translate(this.x, this.y);
  27580. },
  27581. resolveListenerScope: function() {
  27582. var ownerCmp = this.ownerCmp,
  27583. a = arguments;
  27584. if (ownerCmp) {
  27585. return ownerCmp.resolveListenerScope.apply(ownerCmp, a);
  27586. }
  27587. return this.callParent(a);
  27588. },
  27589. destroy: function() {
  27590. var me = this;
  27591. me.destroying = true;
  27592. if (me.isAnimating) {
  27593. me.stopAnimation();
  27594. }
  27595. me.callParent();
  27596. me.destroying = false;
  27597. me.destroyed = true;
  27598. }
  27599. });
  27600. Ext.define('Ext.util.Format', function() {
  27601. var me;
  27602. return {
  27603. singleton: true,
  27604. defaultDateFormat: 'm/d/Y',
  27605. thousandSeparator: ',',
  27606. decimalSeparator: '.',
  27607. currencyPrecision: 2,
  27608. currencySign: '$',
  27609. currencySpacer: '',
  27610. percentSign: '%',
  27611. currencyAtEnd: false,
  27612. stripTagsRe: /<\/?[^>]+>/gi,
  27613. stripScriptsRe: /(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)/ig,
  27614. nl2brRe: /\r?\n/g,
  27615. hashRe: /#+$/,
  27616. allHashes: /^#+$/,
  27617. formatPattern: /[\d,\.#]+/,
  27618. formatCleanRe: /[^\d\.#]/g,
  27619. I18NFormatCleanRe: null,
  27620. formatFns: {},
  27621. constructor: function() {
  27622. me = this;
  27623. },
  27624. nbsp: function(value, strict) {
  27625. strict = strict !== false;
  27626. if (strict ? value === '' || value == null : !value) {
  27627. value = '\xa0';
  27628. }
  27629. return value;
  27630. },
  27631. undef: function(value) {
  27632. return value !== undefined ? value : "";
  27633. },
  27634. defaultValue: function(value, defaultValue) {
  27635. return value !== undefined && value !== '' ? value : defaultValue;
  27636. },
  27637. substr: 'ab'.substr(-1) != 'b' ? function(value, start, length) {
  27638. var str = String(value);
  27639. return (start < 0) ? str.substr(Math.max(str.length + start, 0), length) : str.substr(start, length);
  27640. } : function(value, start, length) {
  27641. return String(value).substr(start, length);
  27642. },
  27643. lowercase: function(value) {
  27644. return String(value).toLowerCase();
  27645. },
  27646. uppercase: function(value) {
  27647. return String(value).toUpperCase();
  27648. },
  27649. usMoney: function(value) {
  27650. return me.currency(value, '$', 2);
  27651. },
  27652. currency: function(value, currencySign, decimals, end, currencySpacer) {
  27653. var negativeSign = '',
  27654. format = ",0",
  27655. i = 0;
  27656. value = value - 0;
  27657. if (value < 0) {
  27658. value = -value;
  27659. negativeSign = '-';
  27660. }
  27661. decimals = Ext.isDefined(decimals) ? decimals : me.currencyPrecision;
  27662. format += (decimals > 0 ? '.' : '');
  27663. for (; i < decimals; i++) {
  27664. format += '0';
  27665. }
  27666. value = me.number(value, format);
  27667. if (currencySpacer == null) {
  27668. currencySpacer = me.currencySpacer;
  27669. }
  27670. if ((end || me.currencyAtEnd) === true) {
  27671. return Ext.String.format("{0}{1}{2}{3}", negativeSign, value, currencySpacer, currencySign || me.currencySign);
  27672. } else {
  27673. return Ext.String.format("{0}{1}{2}{3}", negativeSign, currencySign || me.currencySign, currencySpacer, value);
  27674. }
  27675. },
  27676. date: function(value, format) {
  27677. if (!value) {
  27678. return "";
  27679. }
  27680. if (!Ext.isDate(value)) {
  27681. value = new Date(Date.parse(value));
  27682. }
  27683. return Ext.Date.dateFormat(value, format || Ext.Date.defaultFormat);
  27684. },
  27685. dateRenderer: function(format) {
  27686. return function(v) {
  27687. return me.date(v, format);
  27688. };
  27689. },
  27690. hex: function(value, digits) {
  27691. var s = parseInt(value || 0, 10).toString(16);
  27692. if (digits) {
  27693. if (digits < 0) {
  27694. digits = -digits;
  27695. if (s.length > digits) {
  27696. s = s.substring(s.length - digits);
  27697. }
  27698. }
  27699. while (s.length < digits) {
  27700. s = '0' + s;
  27701. }
  27702. }
  27703. return s;
  27704. },
  27705. or: function(value, orValue) {
  27706. return value || orValue;
  27707. },
  27708. pick: function(value, firstValue, secondValue) {
  27709. if (Ext.isNumber(value)) {
  27710. var ret = arguments[value + 1];
  27711. if (ret) {
  27712. return ret;
  27713. }
  27714. }
  27715. return value ? secondValue : firstValue;
  27716. },
  27717. lessThanElse: function(value, threshold, below, above, equal) {
  27718. var v = Ext.Number.from(value, 0),
  27719. t = Ext.Number.from(threshold, 0),
  27720. missing = !Ext.isDefined(equal);
  27721. return v < t ? below : (v > t ? above : (missing ? above : equal));
  27722. },
  27723. sign: function(value, negative, positive, zero) {
  27724. if (zero === undefined) {
  27725. zero = positive;
  27726. }
  27727. return me.lessThanElse(value, 0, negative, positive, zero);
  27728. },
  27729. stripTags: function(value) {
  27730. return !value ? value : String(value).replace(me.stripTagsRe, "");
  27731. },
  27732. stripScripts: function(value) {
  27733. return !value ? value : String(value).replace(me.stripScriptsRe, "");
  27734. },
  27735. fileSize: (function() {
  27736. var byteLimit = 1024,
  27737. kbLimit = 1048576,
  27738. mbLimit = 1073741824;
  27739. return function(size) {
  27740. var out;
  27741. if (size < byteLimit) {
  27742. if (size === 1) {
  27743. out = '1 byte';
  27744. } else {
  27745. out = size + ' bytes';
  27746. }
  27747. } else if (size < kbLimit) {
  27748. out = (Math.round(((size * 10) / byteLimit)) / 10) + ' KB';
  27749. } else if (size < mbLimit) {
  27750. out = (Math.round(((size * 10) / kbLimit)) / 10) + ' MB';
  27751. } else {
  27752. out = (Math.round(((size * 10) / mbLimit)) / 10) + ' GB';
  27753. }
  27754. return out;
  27755. };
  27756. })(),
  27757. math: (function() {
  27758. var fns = {};
  27759. return function(v, a) {
  27760. if (!fns[a]) {
  27761. fns[a] = Ext.functionFactory('v', 'return v ' + a + ';');
  27762. }
  27763. return fns[a](v);
  27764. };
  27765. }()),
  27766. round: function(value, precision) {
  27767. var result = Number(value);
  27768. if (typeof precision === 'number') {
  27769. precision = Math.pow(10, precision);
  27770. result = Math.round(value * precision) / precision;
  27771. } else if (precision === undefined) {
  27772. result = Math.round(result);
  27773. }
  27774. return result;
  27775. },
  27776. number: function(v, formatString) {
  27777. if (!formatString) {
  27778. return v;
  27779. }
  27780. if (isNaN(v)) {
  27781. return '';
  27782. }
  27783. var formatFn = me.formatFns[formatString];
  27784. if (!formatFn) {
  27785. var originalFormatString = formatString,
  27786. comma = me.thousandSeparator,
  27787. decimalSeparator = me.decimalSeparator,
  27788. precision = 0,
  27789. trimPart = '',
  27790. hasComma, splitFormat, extraChars, trimTrailingZeroes, code, len;
  27791. if (formatString.substr(formatString.length - 2) === '/i') {
  27792. if (!me.I18NFormatCleanRe || me.lastDecimalSeparator !== decimalSeparator) {
  27793. me.I18NFormatCleanRe = new RegExp('[^\\d\\' + decimalSeparator + '#]', 'g');
  27794. me.lastDecimalSeparator = decimalSeparator;
  27795. }
  27796. formatString = formatString.substr(0, formatString.length - 2);
  27797. hasComma = formatString.indexOf(comma) !== -1;
  27798. splitFormat = formatString.replace(me.I18NFormatCleanRe, '').split(decimalSeparator);
  27799. } else {
  27800. hasComma = formatString.indexOf(',') !== -1;
  27801. splitFormat = formatString.replace(me.formatCleanRe, '').split('.');
  27802. }
  27803. extraChars = formatString.replace(me.formatPattern, '');
  27804. if (splitFormat.length > 2) {
  27805. Ext.raise({
  27806. sourceClass: "Ext.util.Format",
  27807. sourceMethod: "number",
  27808. value: v,
  27809. formatString: formatString,
  27810. msg: "Invalid number format, should have no more than 1 decimal"
  27811. });
  27812. }
  27813. else if (splitFormat.length === 2) {
  27814. precision = splitFormat[1].length;
  27815. trimTrailingZeroes = splitFormat[1].match(me.hashRe);
  27816. if (trimTrailingZeroes) {
  27817. len = trimTrailingZeroes[0].length;
  27818. trimPart = 'trailingZeroes=new RegExp(Ext.String.escapeRegex(utilFormat.decimalSeparator) + "*0{0,' + len + '}$")';
  27819. }
  27820. }
  27821. code = [
  27822. 'var utilFormat=Ext.util.Format,extNumber=Ext.Number,neg,absVal,fnum,parts' + (hasComma ? ',thousandSeparator,thousands=[],j,n,i' : '') + (extraChars ? ',formatString="' + formatString + '",formatPattern=/[\\d,\\.#]+/' : '') + ',trailingZeroes;' + 'return function(v){' + 'if(typeof v!=="number"&&isNaN(v=extNumber.from(v,NaN)))return"";' + 'neg=v<0;',
  27823. 'absVal=Math.abs(v);',
  27824. 'fnum=Ext.Number.toFixed(absVal, ' + precision + ');',
  27825. trimPart,
  27826. ';'
  27827. ];
  27828. if (hasComma) {
  27829. if (precision) {
  27830. code[code.length] = 'parts=fnum.split(".");';
  27831. code[code.length] = 'fnum=parts[0];';
  27832. }
  27833. code[code.length] = 'if(absVal>=1000) {';
  27834. 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);' + '}';
  27835. if (precision) {
  27836. code[code.length] = 'fnum += utilFormat.decimalSeparator+parts[1];';
  27837. }
  27838. } else if (precision) {
  27839. code[code.length] = 'if(utilFormat.decimalSeparator!=="."){' + 'parts=fnum.split(".");' + 'fnum=parts[0]+utilFormat.decimalSeparator+parts[1];' + '}';
  27840. }
  27841. code[code.length] = 'if(neg&&fnum!=="' + (precision ? '0.' + Ext.String.repeat('0', precision) : '0') + '") { fnum="-"+fnum; }';
  27842. if (trimTrailingZeroes) {
  27843. code[code.length] = 'fnum=fnum.replace(trailingZeroes,"");';
  27844. }
  27845. code[code.length] = 'return ';
  27846. if (extraChars) {
  27847. code[code.length] = 'formatString.replace(formatPattern, fnum);';
  27848. } else {
  27849. code[code.length] = 'fnum;';
  27850. }
  27851. code[code.length] = '};';
  27852. formatFn = me.formatFns[originalFormatString] = Ext.functionFactory('Ext', code.join(''))(Ext);
  27853. }
  27854. return formatFn(v);
  27855. },
  27856. numberRenderer: function(format) {
  27857. return function(v) {
  27858. return me.number(v, format);
  27859. };
  27860. },
  27861. percent: function(value, formatString) {
  27862. return me.number(value * 100, formatString || '0') + me.percentSign;
  27863. },
  27864. repeat: function(value, text, sep) {
  27865. return Ext.String.repeat(text, value, sep);
  27866. },
  27867. attributes: function(attributes) {
  27868. if (typeof attributes === 'object') {
  27869. var result = [],
  27870. name;
  27871. for (name in attributes) {
  27872. if (attributes.hasOwnProperty(name)) {
  27873. result.push(name, '="', name === 'style' ? Ext.DomHelper.generateStyles(attributes[name], null, true) : Ext.htmlEncode(attributes[name]), '" ');
  27874. }
  27875. }
  27876. attributes = result.join('');
  27877. }
  27878. return attributes || '';
  27879. },
  27880. plural: function(value, singular, plural) {
  27881. return value + ' ' + (value === 1 ? singular : (plural ? plural : singular + 's'));
  27882. },
  27883. nl2br: function(v) {
  27884. return Ext.isEmpty(v) ? '' : v.replace(me.nl2brRe, '<br/>');
  27885. },
  27886. capitalize: Ext.String.capitalize,
  27887. uncapitalize: Ext.String.uncapitalize,
  27888. ellipsis: Ext.String.ellipsis,
  27889. escape: Ext.String.escape,
  27890. escapeRegex: Ext.String.escapeRegex,
  27891. htmlDecode: Ext.String.htmlDecode,
  27892. htmlEncode: Ext.String.htmlEncode,
  27893. leftPad: Ext.String.leftPad,
  27894. toggle: Ext.String.toggle,
  27895. trim: Ext.String.trim,
  27896. parseBox: function(box) {
  27897. box = box || 0;
  27898. if (typeof box === 'number') {
  27899. return {
  27900. top: box,
  27901. right: box,
  27902. bottom: box,
  27903. left: box
  27904. };
  27905. }
  27906. var parts = box.split(' '),
  27907. ln = parts.length;
  27908. if (ln === 1) {
  27909. parts[1] = parts[2] = parts[3] = parts[0];
  27910. } else if (ln === 2) {
  27911. parts[2] = parts[0];
  27912. parts[3] = parts[1];
  27913. } else if (ln === 3) {
  27914. parts[3] = parts[1];
  27915. }
  27916. return {
  27917. top: parseInt(parts[0], 10) || 0,
  27918. right: parseInt(parts[1], 10) || 0,
  27919. bottom: parseInt(parts[2], 10) || 0,
  27920. left: parseInt(parts[3], 10) || 0
  27921. };
  27922. },
  27923. resource: function(url, prefix) {
  27924. prefix = prefix || '';
  27925. return Ext.resolveResource(prefix + url);
  27926. },
  27927. uri: function(value) {
  27928. return encodeURI(value);
  27929. },
  27930. uriCmp: function(value) {
  27931. return encodeURIComponent(value);
  27932. },
  27933. wordBreakRe: /[\W\s]+/,
  27934. word: function(value, index, sep) {
  27935. var re = sep ? (typeof sep === 'string' ? new RegExp(sep) : sep) : me.wordBreakRe,
  27936. parts = (value || '').split(re);
  27937. return parts[index || 0] || '';
  27938. }
  27939. };
  27940. });
  27941. Ext.define('Ext.Template', {
  27942. inheritableStatics: {
  27943. from: function(el, config) {
  27944. el = Ext.getDom(el);
  27945. return new this(el.value || el.innerHTML, config || '');
  27946. }
  27947. },
  27948. useEval: Ext.isGecko,
  27949. constructor: function(html) {
  27950. var me = this,
  27951. args = arguments,
  27952. buffer = [],
  27953. length = args.length,
  27954. i, value;
  27955. me.initialConfig = {};
  27956. if (length === 1 && Ext.isArray(html)) {
  27957. args = html;
  27958. length = args.length;
  27959. }
  27960. if (length > 1) {
  27961. for (i = 0; i < length; i++) {
  27962. value = args[i];
  27963. if (typeof value === 'object') {
  27964. Ext.apply(me.initialConfig, value);
  27965. Ext.apply(me, value);
  27966. } else {
  27967. buffer.push(value);
  27968. }
  27969. }
  27970. } else {
  27971. buffer.push(html);
  27972. }
  27973. me.html = buffer.join('');
  27974. },
  27975. isTemplate: true,
  27976. disableFormats: false,
  27977. tokenRe: /\{(?:(?:(\d+)|([a-z_$][\w\-$]*))(?::([a-z_\.]+)(?:\(([^\)]*?)?\))?)?)\}/gi,
  27978. apply: function(values) {
  27979. var me = this;
  27980. if (me.compiled) {
  27981. if (!me.fn) {
  27982. me.compile();
  27983. }
  27984. return me.fn(values).join('');
  27985. }
  27986. return me.evaluate(values);
  27987. },
  27988. evaluate: function(values) {
  27989. var me = this,
  27990. useFormat = !me.disableFormats,
  27991. fm = Ext.util.Format,
  27992. tpl = me;
  27993. function fn(match, index, name, formatFn, args) {
  27994. if (name == null || name === '') {
  27995. name = index;
  27996. }
  27997. if (formatFn && useFormat) {
  27998. if (args) {
  27999. args = [
  28000. values[name]
  28001. ].concat(Ext.functionFactory('return [' + args + '];')());
  28002. } else {
  28003. args = [
  28004. values[name]
  28005. ];
  28006. }
  28007. if (formatFn.substr(0, 5) === "this.") {
  28008. return tpl[formatFn.substr(5)].apply(tpl, args);
  28009. }
  28010. else if (fm[formatFn]) {
  28011. return fm[formatFn].apply(fm, args);
  28012. } else
  28013. {
  28014. return match;
  28015. }
  28016. } else {
  28017. return values[name] !== undefined ? values[name] : "";
  28018. }
  28019. }
  28020. return me.html.replace(me.tokenRe, fn);
  28021. },
  28022. applyOut: function(values, out) {
  28023. var me = this;
  28024. if (me.compiled) {
  28025. if (!me.fn) {
  28026. me.compile();
  28027. }
  28028. out.push.apply(out, me.fn(values));
  28029. } else {
  28030. out.push(me.apply(values));
  28031. }
  28032. return out;
  28033. },
  28034. applyTemplate: function() {
  28035. return this.apply.apply(this, arguments);
  28036. },
  28037. set: function(html, compile) {
  28038. var me = this;
  28039. me.html = html;
  28040. me.compiled = !!compile;
  28041. me.fn = null;
  28042. return me;
  28043. },
  28044. compileARe: /\\/g,
  28045. compileBRe: /(\r\n|\n)/g,
  28046. compileCRe: /'/g,
  28047. compile: function() {
  28048. var me = this,
  28049. code;
  28050. code = me.html.replace(me.compileARe, '\\\\').replace(me.compileBRe, '\\n').replace(me.compileCRe, "\\'").replace(me.tokenRe, me.regexReplaceFn.bind(me));
  28051. code = (this.disableFormats !== true ? 'var fm=Ext.util.Format;' : '') + (me.useEval ? '$=' : 'return') + " function(v){return ['" + code + "'];};";
  28052. me.fn = me.useEval ? me.evalCompiled(code) : (new Function('Ext', code))(Ext);
  28053. me.compiled = true;
  28054. return me;
  28055. },
  28056. evalCompiled: function($) {
  28057. eval($);
  28058. return $;
  28059. },
  28060. regexReplaceFn: function(match, index, name, formatFn, args) {
  28061. if (index == null || index === '') {
  28062. index = '"' + name + '"';
  28063. }
  28064. else if (this.stringFormat) {
  28065. index = parseInt(index) + 1;
  28066. }
  28067. if (formatFn && this.disableFormats !== true) {
  28068. args = args ? ',' + args : "";
  28069. if (formatFn.substr(0, 5) === "this.") {
  28070. formatFn = formatFn + '(';
  28071. }
  28072. else if (Ext.util.Format[formatFn]) {
  28073. formatFn = "fm." + formatFn + '(';
  28074. } else
  28075. {
  28076. return match;
  28077. }
  28078. return "'," + formatFn + "v[" + index + "]" + args + "),'";
  28079. } else {
  28080. return "',v[" + index + "] == undefined ? '' : v[" + index + "],'";
  28081. }
  28082. },
  28083. insertFirst: function(el, values, returnElement) {
  28084. return this.doInsert('afterBegin', el, values, returnElement);
  28085. },
  28086. insertBefore: function(el, values, returnElement) {
  28087. return this.doInsert('beforeBegin', el, values, returnElement);
  28088. },
  28089. insertAfter: function(el, values, returnElement) {
  28090. return this.doInsert('afterEnd', el, values, returnElement);
  28091. },
  28092. append: function(el, values, returnElement) {
  28093. return this.doInsert('beforeEnd', el, values, returnElement);
  28094. },
  28095. doInsert: function(where, el, values, returnElement) {
  28096. var newNode = Ext.DomHelper.insertHtml(where, Ext.getDom(el), this.apply(values));
  28097. return returnElement ? Ext.get(newNode) : newNode;
  28098. },
  28099. overwrite: function(el, values, returnElement) {
  28100. var newNode = Ext.DomHelper.overwrite(Ext.getDom(el), this.apply(values));
  28101. return returnElement ? Ext.get(newNode) : newNode;
  28102. }
  28103. }, function(Template) {
  28104. var formatRe = /\{\d+\}/,
  28105. generateFormatFn = function(format) {
  28106. if (formatRe.test(format)) {
  28107. format = new Template(format, formatTplConfig);
  28108. return function() {
  28109. return format.apply(arguments);
  28110. };
  28111. } else
  28112. {
  28113. return function() {
  28114. return format;
  28115. };
  28116. }
  28117. },
  28118. formatTplConfig = {
  28119. useFormat: false,
  28120. compiled: true,
  28121. stringFormat: true
  28122. },
  28123. formatFns = {};
  28124. Ext.String.format = Ext.util.Format.format = function(format) {
  28125. var formatFn = formatFns[format] || (formatFns[format] = generateFormatFn(format));
  28126. return formatFn.apply(this, arguments);
  28127. };
  28128. Ext.String.formatEncode = function() {
  28129. return Ext.String.htmlEncode(Ext.String.format.apply(this, arguments));
  28130. };
  28131. });
  28132. Ext.define('Ext.util.XTemplateParser', {
  28133. constructor: function(config) {
  28134. Ext.apply(this, config);
  28135. },
  28136. doTpl: Ext.emptyFn,
  28137. parse: function(str) {
  28138. var me = this,
  28139. len = str.length,
  28140. aliases = {
  28141. elseif: 'elif'
  28142. },
  28143. topRe = me.topRe,
  28144. actionsRe = me.actionsRe,
  28145. index, stack, s, m, t, prev, frame, subMatch, begin, end, actions, prop, expectTplNext;
  28146. me.level = 0;
  28147. me.stack = stack = [];
  28148. for (index = 0; index < len; index = end) {
  28149. topRe.lastIndex = index;
  28150. m = topRe.exec(str);
  28151. if (!m) {
  28152. me.doText(str.substring(index, len));
  28153. break;
  28154. }
  28155. begin = m.index;
  28156. end = topRe.lastIndex;
  28157. if (index < begin) {
  28158. s = str.substring(index, begin);
  28159. if (!(expectTplNext && Ext.String.trim(s) === '')) {
  28160. me.doText(s);
  28161. }
  28162. }
  28163. expectTplNext = false;
  28164. if (m[1]) {
  28165. end = str.indexOf('%}', begin + 2);
  28166. me.doEval(str.substring(begin + 2, end));
  28167. end += 2;
  28168. } else if (m[2]) {
  28169. end = str.indexOf(']}', begin + 2);
  28170. me.doExpr(str.substring(begin + 2, end));
  28171. end += 2;
  28172. } else if (m[3]) {
  28173. me.doTag(m[3]);
  28174. } else if (m[4]) {
  28175. actions = null;
  28176. while ((subMatch = actionsRe.exec(m[4])) !== null) {
  28177. s = subMatch[2] || subMatch[3];
  28178. if (s) {
  28179. s = Ext.String.htmlDecode(s);
  28180. t = subMatch[1];
  28181. t = aliases[t] || t;
  28182. actions = actions || {};
  28183. prev = actions[t];
  28184. if (typeof prev == 'string') {
  28185. actions[t] = [
  28186. prev,
  28187. s
  28188. ];
  28189. } else if (prev) {
  28190. actions[t].push(s);
  28191. } else {
  28192. actions[t] = s;
  28193. }
  28194. }
  28195. }
  28196. if (!actions) {
  28197. if (me.elseRe.test(m[4])) {
  28198. me.doElse();
  28199. } else if (me.defaultRe.test(m[4])) {
  28200. me.doDefault();
  28201. } else {
  28202. me.doTpl();
  28203. stack.push({
  28204. type: 'tpl'
  28205. });
  28206. }
  28207. } else if (actions['if']) {
  28208. me.doIf(actions['if'], actions);
  28209. stack.push({
  28210. type: 'if'
  28211. });
  28212. } else if (actions['switch']) {
  28213. me.doSwitch(actions['switch'], actions);
  28214. stack.push({
  28215. type: 'switch'
  28216. });
  28217. expectTplNext = true;
  28218. } else if (actions['case']) {
  28219. me.doCase(actions['case'], actions);
  28220. } else if (actions['elif']) {
  28221. me.doElseIf(actions['elif'], actions);
  28222. } else if (actions['for']) {
  28223. ++me.level;
  28224. if (prop = me.propRe.exec(m[4])) {
  28225. actions.propName = prop[1] || prop[2];
  28226. }
  28227. me.doFor(actions['for'], actions);
  28228. stack.push({
  28229. type: 'for',
  28230. actions: actions
  28231. });
  28232. } else if (actions['foreach']) {
  28233. ++me.level;
  28234. if (prop = me.propRe.exec(m[4])) {
  28235. actions.propName = prop[1] || prop[2];
  28236. }
  28237. me.doForEach(actions['foreach'], actions);
  28238. stack.push({
  28239. type: 'foreach',
  28240. actions: actions
  28241. });
  28242. } else if (actions.exec) {
  28243. me.doExec(actions.exec, actions);
  28244. stack.push({
  28245. type: 'exec',
  28246. actions: actions
  28247. });
  28248. }
  28249. }
  28250. else if (m[0].length === 5) {
  28251. stack.push({
  28252. type: 'tpl'
  28253. });
  28254. } else {
  28255. frame = stack.pop();
  28256. me.doEnd(frame.type, frame.actions);
  28257. if (frame.type == 'for' || frame.type == 'foreach') {
  28258. --me.level;
  28259. }
  28260. }
  28261. }
  28262. },
  28263. topRe: /(?:(\{\%)|(\{\[)|\{([^{}]+)\})|(?:<tpl([^>]*)\>)|(?:<\/tpl>)/g,
  28264. actionsRe: /\s*(elif|elseif|if|for|foreach|exec|switch|case|eval|between)\s*\=\s*(?:(?:"([^"]*)")|(?:'([^']*)'))\s*/g,
  28265. propRe: /prop=(?:(?:"([^"]*)")|(?:'([^']*)'))/,
  28266. defaultRe: /^\s*default\s*$/,
  28267. elseRe: /^\s*else\s*$/
  28268. });
  28269. Ext.define('Ext.util.XTemplateCompiler', {
  28270. extend: Ext.util.XTemplateParser,
  28271. useEval: Ext.isGecko,
  28272. useIndex: Ext.isIE8m,
  28273. useFormat: true,
  28274. propNameRe: /^[\w\d\$]*$/,
  28275. compile: function(tpl) {
  28276. var me = this,
  28277. code = me.generate(tpl);
  28278. return me.useEval ? me.evalTpl(code) : (new Function('Ext', code))(Ext);
  28279. },
  28280. generate: function(tpl) {
  28281. var me = this,
  28282. definitions = 'var fm=Ext.util.Format,ts=Object.prototype.toString;',
  28283. code;
  28284. me.maxLevel = 0;
  28285. me.body = [
  28286. 'var c0=values, a0=' + me.createArrayTest(0) + ', p0=parent, n0=xcount, i0=xindex, k0, v;\n'
  28287. ];
  28288. if (me.definitions) {
  28289. if (typeof me.definitions === 'string') {
  28290. me.definitions = [
  28291. me.definitions,
  28292. definitions
  28293. ];
  28294. } else {
  28295. me.definitions.push(definitions);
  28296. }
  28297. } else {
  28298. me.definitions = [
  28299. definitions
  28300. ];
  28301. }
  28302. me.switches = [];
  28303. me.parse(tpl);
  28304. me.definitions.push((me.useEval ? '$=' : 'return') + ' function (' + me.fnArgs + ') {', me.body.join(''), '}');
  28305. code = me.definitions.join('\n');
  28306. me.definitions.length = me.body.length = me.switches.length = 0;
  28307. me.definitions = me.body = me.switches = 0;
  28308. return code;
  28309. },
  28310. doText: function(text) {
  28311. var me = this,
  28312. out = me.body;
  28313. text = text.replace(me.aposRe, "\\'").replace(me.newLineRe, '\\n');
  28314. if (me.useIndex) {
  28315. out.push('out[out.length]=\'', text, '\'\n');
  28316. } else {
  28317. out.push('out.push(\'', text, '\')\n');
  28318. }
  28319. },
  28320. doExpr: function(expr) {
  28321. var out = this.body;
  28322. out.push('if ((v=' + expr + ') != null) out');
  28323. if (this.useIndex) {
  28324. out.push('[out.length]=v\n');
  28325. } else {
  28326. out.push('.push(v)\n');
  28327. }
  28328. },
  28329. doTag: function(tag) {
  28330. var expr = this.parseTag(tag);
  28331. if (expr) {
  28332. this.doExpr(expr);
  28333. } else {
  28334. this.doText('{' + tag + '}');
  28335. }
  28336. },
  28337. doElse: function() {
  28338. this.body.push('} else {\n');
  28339. },
  28340. doEval: function(text) {
  28341. this.body.push(text, '\n');
  28342. },
  28343. doIf: function(action, actions) {
  28344. var me = this;
  28345. if (action === '.') {
  28346. me.body.push('if (values) {\n');
  28347. } else if (me.propNameRe.test(action)) {
  28348. me.body.push('if (', me.parseTag(action), ') {\n');
  28349. } else
  28350. {
  28351. me.body.push('if (', me.addFn(action), me.callFn, ') {\n');
  28352. }
  28353. if (actions.exec) {
  28354. me.doExec(actions.exec);
  28355. }
  28356. },
  28357. doElseIf: function(action, actions) {
  28358. var me = this;
  28359. if (action === '.') {
  28360. me.body.push('else if (values) {\n');
  28361. } else if (me.propNameRe.test(action)) {
  28362. me.body.push('} else if (', me.parseTag(action), ') {\n');
  28363. } else
  28364. {
  28365. me.body.push('} else if (', me.addFn(action), me.callFn, ') {\n');
  28366. }
  28367. if (actions.exec) {
  28368. me.doExec(actions.exec);
  28369. }
  28370. },
  28371. doSwitch: function(action) {
  28372. var me = this,
  28373. key;
  28374. if (action === '.' || action === '#') {
  28375. key = action === '.' ? 'values' : 'xindex';
  28376. me.body.push('switch (', key, ') {\n');
  28377. } else if (me.propNameRe.test(action)) {
  28378. me.body.push('switch (', me.parseTag(action), ') {\n');
  28379. } else
  28380. {
  28381. me.body.push('switch (', me.addFn(action), me.callFn, ') {\n');
  28382. }
  28383. me.switches.push(0);
  28384. },
  28385. doCase: function(action) {
  28386. var me = this,
  28387. cases = Ext.isArray(action) ? action : [
  28388. action
  28389. ],
  28390. n = me.switches.length - 1,
  28391. match, i;
  28392. if (me.switches[n]) {
  28393. me.body.push('break;\n');
  28394. } else {
  28395. me.switches[n]++;
  28396. }
  28397. for (i = 0 , n = cases.length; i < n; ++i) {
  28398. match = me.intRe.exec(cases[i]);
  28399. cases[i] = match ? match[1] : ("'" + cases[i].replace(me.aposRe, "\\'") + "'");
  28400. }
  28401. me.body.push('case ', cases.join(': case '), ':\n');
  28402. },
  28403. doDefault: function() {
  28404. var me = this,
  28405. n = me.switches.length - 1;
  28406. if (me.switches[n]) {
  28407. me.body.push('break;\n');
  28408. } else {
  28409. me.switches[n]++;
  28410. }
  28411. me.body.push('default:\n');
  28412. },
  28413. doEnd: function(type, actions) {
  28414. var me = this,
  28415. L = me.level - 1;
  28416. if (type == 'for' || type == 'foreach') {
  28417. if (actions.exec) {
  28418. me.doExec(actions.exec);
  28419. }
  28420. me.body.push('}\n');
  28421. me.body.push('parent=p', L, ';values=r', L + 1, ';xcount=n' + L + ';xindex=i', L, '+1;xkey=k', L, ';\n');
  28422. } else if (type == 'if' || type == 'switch') {
  28423. me.body.push('}\n');
  28424. }
  28425. },
  28426. doFor: function(action, actions) {
  28427. var me = this,
  28428. s,
  28429. L = me.level,
  28430. up = L - 1,
  28431. parentAssignment;
  28432. if (action === '.') {
  28433. s = 'values';
  28434. } else if (me.propNameRe.test(action)) {
  28435. s = me.parseTag(action);
  28436. } else
  28437. {
  28438. s = me.addFn(action) + me.callFn;
  28439. }
  28440. if (me.maxLevel < L) {
  28441. me.maxLevel = L;
  28442. me.body.push('var ');
  28443. }
  28444. if (action == '.') {
  28445. parentAssignment = 'c' + L;
  28446. } else {
  28447. parentAssignment = 'a' + up + '?c' + up + '[i' + up + ']:c' + up;
  28448. }
  28449. 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, ']');
  28450. if (actions.propName) {
  28451. me.body.push('.', actions.propName);
  28452. }
  28453. me.body.push('\n', 'xindex=i', L, '+1\n');
  28454. if (actions.between) {
  28455. me.body.push('if(xindex>1){ out.push("', actions.between, '"); } \n');
  28456. }
  28457. },
  28458. doForEach: function(action, actions) {
  28459. var me = this,
  28460. s,
  28461. L = me.level,
  28462. up = L - 1,
  28463. parentAssignment;
  28464. if (action === '.') {
  28465. s = 'values';
  28466. } else if (me.propNameRe.test(action)) {
  28467. s = me.parseTag(action);
  28468. } else
  28469. {
  28470. s = me.addFn(action) + me.callFn;
  28471. }
  28472. if (me.maxLevel < L) {
  28473. me.maxLevel = L;
  28474. me.body.push('var ');
  28475. }
  28476. if (action == '.') {
  28477. parentAssignment = 'c' + L;
  28478. } else {
  28479. parentAssignment = 'a' + up + '?c' + up + '[i' + up + ']:c' + up;
  28480. }
  28481. 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, '];');
  28482. if (actions.propName) {
  28483. me.body.push('.', actions.propName);
  28484. }
  28485. if (actions.between) {
  28486. me.body.push('if(xindex>1){ out.push("', actions.between, '"); } \n');
  28487. }
  28488. },
  28489. createArrayTest: ('isArray' in Array) ? function(L) {
  28490. return 'Array.isArray(c' + L + ')';
  28491. } : function(L) {
  28492. return 'ts.call(c' + L + ')==="[object Array]"';
  28493. },
  28494. doExec: function(action, actions) {
  28495. var me = this,
  28496. name = 'f' + me.definitions.length,
  28497. guards = me.guards[me.strict ? 0 : 1];
  28498. me.definitions.push('function ' + name + '(' + me.fnArgs + ') {', guards.doTry, ' var $v = values; with($v) {', ' ' + action, ' }', guards.doCatch, '}');
  28499. me.body.push(name + me.callFn + '\n');
  28500. },
  28501. guards: [
  28502. {
  28503. doTry: '',
  28504. doCatch: ''
  28505. },
  28506. {
  28507. doTry: 'try { ',
  28508. doCatch: ' } catch(e) {\n' +
  28509. 'Ext.log.warn("XTemplate evaluation exception: " + e.message);\n' +
  28510. '}'
  28511. }
  28512. ],
  28513. addFn: function(body) {
  28514. var me = this,
  28515. name = 'f' + me.definitions.length,
  28516. guards = me.guards[me.strict ? 0 : 1];
  28517. if (body === '.') {
  28518. me.definitions.push('function ' + name + '(' + me.fnArgs + ') {', ' return values', '}');
  28519. } else if (body === '..') {
  28520. me.definitions.push('function ' + name + '(' + me.fnArgs + ') {', ' return parent', '}');
  28521. } else {
  28522. me.definitions.push('function ' + name + '(' + me.fnArgs + ') {', guards.doTry, ' var $v = values; with($v) {', ' return(' + body + ')', ' }', guards.doCatch, '}');
  28523. }
  28524. return name;
  28525. },
  28526. parseTag: function(tag) {
  28527. var me = this,
  28528. m = me.tagRe.exec(tag),
  28529. name, format, args, math, v;
  28530. if (!m) {
  28531. return null;
  28532. }
  28533. name = m[1];
  28534. format = m[2];
  28535. args = m[3];
  28536. math = m[4];
  28537. if (name == '.') {
  28538. if (!me.validTypes) {
  28539. me.definitions.push('var validTypes={string:1,number:1,boolean:1};');
  28540. me.validTypes = true;
  28541. }
  28542. v = 'validTypes[typeof values] || ts.call(values) === "[object Date]" ? values : ""';
  28543. }
  28544. else if (name == '#') {
  28545. v = 'xindex';
  28546. }
  28547. else if (name == '$') {
  28548. v = 'xkey';
  28549. } else if (name.substr(0, 7) == "parent.") {
  28550. v = name;
  28551. }
  28552. else if (isNaN(name) && name.indexOf('-') == -1 && name.indexOf('.') != -1) {
  28553. v = "values." + name;
  28554. } else
  28555. {
  28556. v = "values['" + name + "']";
  28557. }
  28558. if (math) {
  28559. v = '(' + v + math + ')';
  28560. }
  28561. if (format && me.useFormat) {
  28562. args = args ? ',' + args : "";
  28563. if (format.substr(0, 5) != "this.") {
  28564. format = "fm." + format + '(';
  28565. } else {
  28566. format += '(';
  28567. }
  28568. } else {
  28569. return v;
  28570. }
  28571. return format + v + args + ')';
  28572. },
  28573. evalTpl: function($) {
  28574. eval($);
  28575. return $;
  28576. },
  28577. newLineRe: /\r\n|\r|\n/g,
  28578. aposRe: /[']/g,
  28579. intRe: /^\s*(\d+)\s*$/,
  28580. tagRe: /^([\w-\.\#\$]+)(?:\:([\w\.]*)(?:\((.*?)?\))?)?(\s?[\+\-\*\/]\s?[\d\.\+\-\*\/\(\)]+)?$/
  28581. }, function() {
  28582. var proto = this.prototype;
  28583. proto.fnArgs = 'out,values,parent,xindex,xcount,xkey';
  28584. proto.callFn = '.call(this,' + proto.fnArgs + ')';
  28585. });
  28586. Ext.define('Ext.XTemplate', {
  28587. extend: Ext.Template,
  28588. isXTemplate: true,
  28589. emptyObj: {},
  28590. fn: null,
  28591. strict: false,
  28592. apply: function(values, parent, xindex, xcount) {
  28593. var buffer = this.applyOut(values, [], parent, xindex, xcount);
  28594. return buffer.length === 1 ? buffer[0] : buffer.join('');
  28595. },
  28596. applyOut: function(values, out, parent, xindex, xcount) {
  28597. var me = this,
  28598. compiler;
  28599. if (!me.fn) {
  28600. compiler = new Ext.util.XTemplateCompiler({
  28601. useFormat: me.disableFormats !== true,
  28602. definitions: me.definitions,
  28603. strict: me.strict
  28604. });
  28605. me.fn = compiler.compile(me.html);
  28606. }
  28607. xindex = xindex || 1;
  28608. xcount = xcount || 1;
  28609. if (me.strict) {
  28610. me.fn(out, values, parent || me.emptyObj, xindex, xcount);
  28611. } else {
  28612. try {
  28613. me.fn(out, values, parent || me.emptyObj, xindex, xcount);
  28614. } catch (e) {
  28615. Ext.log.warn('XTemplate evaluation exception: ' + e.message);
  28616. }
  28617. }
  28618. return out;
  28619. },
  28620. compile: function() {
  28621. return this;
  28622. },
  28623. statics: {
  28624. get: function(config, source, defaultTpl) {
  28625. var ret = config;
  28626. if (config == null) {
  28627. if (source && defaultTpl) {
  28628. ret = this.getTpl(source, defaultTpl);
  28629. }
  28630. } else if ((config || config === '') && !config.isTemplate) {
  28631. ret = new this(config);
  28632. }
  28633. return ret;
  28634. },
  28635. getTpl: function(instance, name) {
  28636. var tpl = instance[name],
  28637. owner;
  28638. if (tpl) {
  28639. if (!tpl.isTemplate) {
  28640. tpl = Ext.XTemplate.get(tpl);
  28641. }
  28642. if (!tpl.owner) {
  28643. if (instance.hasOwnProperty(name)) {
  28644. owner = instance;
  28645. } else {
  28646. for (owner = instance.self.prototype; owner && !owner.hasOwnProperty(name); owner = owner.superclass) {}
  28647. }
  28648. owner[name] = tpl;
  28649. tpl.owner = owner;
  28650. }
  28651. }
  28652. return tpl || null;
  28653. }
  28654. }
  28655. });
  28656. Ext.define('Ext.util.translatable.Dom', {
  28657. extend: Ext.util.translatable.Abstract,
  28658. alias: 'translatable.dom',
  28659. config: {
  28660. element: null
  28661. },
  28662. applyElement: function(element) {
  28663. if (!element) {
  28664. return;
  28665. }
  28666. return Ext.get(element);
  28667. },
  28668. updateElement: function() {
  28669. this.refresh();
  28670. }
  28671. });
  28672. Ext.define('Ext.util.translatable.CssPosition', {
  28673. extend: Ext.util.translatable.Dom,
  28674. alias: 'translatable.cssposition',
  28675. doTranslate: function(x, y) {
  28676. var domStyle = this.getElement().dom.style;
  28677. if (typeof x === 'number') {
  28678. domStyle.left = x + 'px';
  28679. }
  28680. if (typeof y === 'number') {
  28681. domStyle.top = y + 'px';
  28682. }
  28683. this.callParent([
  28684. x,
  28685. y
  28686. ]);
  28687. },
  28688. syncPosition: function() {
  28689. var domStyle = this.getElement().dom.style;
  28690. return [
  28691. this.x = parseFloat(domStyle.left),
  28692. this.y = parseFloat(domStyle.top)
  28693. ];
  28694. },
  28695. destroy: function() {
  28696. var domStyle = this.getElement().dom.style;
  28697. domStyle.left = null;
  28698. domStyle.top = null;
  28699. this.callParent();
  28700. }
  28701. });
  28702. Ext.define('Ext.util.translatable.CssTransform', {
  28703. extend: Ext.util.translatable.Dom,
  28704. alias: 'translatable.csstransform',
  28705. isCssTransform: true,
  28706. posRegex: /(\d+)px[^\d]*(\d+)px/,
  28707. doTranslate: function(x, y) {
  28708. var me = this,
  28709. element = me.getElement();
  28710. if (!me.destroyed && !element.destroyed) {
  28711. element.translate(x, y);
  28712. }
  28713. me.callParent([
  28714. x,
  28715. y
  28716. ]);
  28717. },
  28718. syncPosition: function() {
  28719. var pos = this.posRegex.exec(this.getElement().dom.style.tranform);
  28720. if (pos) {
  28721. this.x = parseFloat(pos[1]);
  28722. this.y = parseFloat(pos[2]);
  28723. }
  28724. return [
  28725. this.x,
  28726. this.y
  28727. ];
  28728. },
  28729. destroy: function() {
  28730. var element = this.getElement();
  28731. if (element && !element.destroyed) {
  28732. element.dom.style.webkitTransform = null;
  28733. }
  28734. this.callParent();
  28735. }
  28736. });
  28737. Ext.define('Ext.util.CSS', function() {
  28738. var CSS,
  28739. rules = null,
  28740. doc = document,
  28741. camelRe = /(-[a-z])/gi,
  28742. camelFn = function(m, a) {
  28743. return a.charAt(1).toUpperCase();
  28744. };
  28745. return {
  28746. singleton: true,
  28747. rules: rules,
  28748. initialized: false,
  28749. constructor: function() {
  28750. CSS = this;
  28751. },
  28752. createStyleSheet: function(cssText, id) {
  28753. var ss,
  28754. head = doc.getElementsByTagName('head')[0],
  28755. styleEl = doc.createElement('style');
  28756. styleEl.setAttribute('type', 'text/css');
  28757. if (id) {
  28758. styleEl.setAttribute('id', id);
  28759. }
  28760. ss = styleEl.styleSheet;
  28761. if (ss) {
  28762. head.appendChild(styleEl);
  28763. ss.cssText = cssText;
  28764. } else {
  28765. styleEl.appendChild(doc.createTextNode(cssText));
  28766. head.appendChild(styleEl);
  28767. ss = styleEl.sheet;
  28768. }
  28769. CSS.cacheStyleSheet(ss);
  28770. return ss;
  28771. },
  28772. removeStyleSheet: function(stylesheet) {
  28773. var styleEl = (typeof stylesheet === 'string') ? doc.getElementById(stylesheet) : stylesheet.ownerNode;
  28774. if (styleEl) {
  28775. styleEl.parentNode.removeChild(styleEl);
  28776. }
  28777. },
  28778. swapStyleSheet: function(id, url) {
  28779. var ss;
  28780. CSS.removeStyleSheet(id);
  28781. ss = doc.createElement("link");
  28782. ss.setAttribute("rel", "stylesheet");
  28783. ss.setAttribute("type", "text/css");
  28784. ss.setAttribute("id", id);
  28785. ss.setAttribute("href", url);
  28786. doc.getElementsByTagName("head")[0].appendChild(ss);
  28787. },
  28788. cacheStyleSheet: function(ss) {
  28789. if (!rules) {
  28790. rules = CSS.rules = {};
  28791. }
  28792. try {
  28793. var ssRules = ss.cssRules || ss.rules,
  28794. i = ssRules.length - 1,
  28795. imports = ss.imports,
  28796. len = imports ? imports.length : 0,
  28797. rule, j;
  28798. for (j = 0; j < len; ++j) {
  28799. CSS.cacheStyleSheet(imports[j]);
  28800. }
  28801. for (; i >= 0; --i) {
  28802. rule = ssRules[i];
  28803. if (rule.styleSheet) {
  28804. CSS.cacheStyleSheet(rule.styleSheet);
  28805. }
  28806. CSS.cacheRule(rule, ss);
  28807. }
  28808. } catch (e) {}
  28809. },
  28810. cacheRule: function(cssRule, styleSheet) {
  28811. if (cssRule.styleSheet) {
  28812. return CSS.cacheStyleSheet(cssRule.styleSheet);
  28813. }
  28814. var selectorText = cssRule.selectorText,
  28815. selectorCount, j;
  28816. if (selectorText) {
  28817. selectorText = selectorText.split(',');
  28818. selectorCount = selectorText.length;
  28819. for (j = 0; j < selectorCount; j++) {
  28820. rules[Ext.String.trim(selectorText[j]).toLowerCase()] = {
  28821. parentStyleSheet: styleSheet,
  28822. cssRule: cssRule
  28823. };
  28824. }
  28825. }
  28826. },
  28827. getRules: function(refreshCache) {
  28828. var result = {},
  28829. selector;
  28830. if (rules === null || refreshCache) {
  28831. CSS.refreshCache();
  28832. }
  28833. for (selector in rules) {
  28834. result[selector] = rules[selector].cssRule;
  28835. }
  28836. return result;
  28837. },
  28838. refreshCache: function() {
  28839. var ds = doc.styleSheets,
  28840. i = 0,
  28841. len = ds.length;
  28842. rules = CSS.rules = {};
  28843. for (; i < len; i++) {
  28844. try {
  28845. if (!ds[i].disabled) {
  28846. CSS.cacheStyleSheet(ds[i]);
  28847. }
  28848. } catch (e) {}
  28849. }
  28850. },
  28851. getRule: function(selector, refreshCache, rawCache) {
  28852. var i, result;
  28853. if (!rules || refreshCache) {
  28854. CSS.refreshCache();
  28855. }
  28856. if (!Ext.isArray(selector)) {
  28857. result = rules[selector.toLowerCase()];
  28858. if (result && !rawCache) {
  28859. result = result.cssRule;
  28860. }
  28861. return result || null;
  28862. }
  28863. for (i = 0; i < selector.length; i++) {
  28864. if (rules[selector[i]]) {
  28865. return rawCache ? rules[selector[i].toLowerCase()] : rules[selector[i].toLowerCase()].cssRule;
  28866. }
  28867. }
  28868. return null;
  28869. },
  28870. createRule: function(styleSheet, selector, cssText) {
  28871. var result,
  28872. ruleSet = styleSheet.cssRules || styleSheet.rules,
  28873. index = ruleSet.length;
  28874. if (styleSheet.insertRule) {
  28875. styleSheet.insertRule(selector + ' {' + cssText + '}', index);
  28876. } else {
  28877. styleSheet.addRule(selector, cssText || ' ');
  28878. }
  28879. CSS.cacheRule(result = ruleSet[index], styleSheet);
  28880. return result;
  28881. },
  28882. updateRule: function(selector, property, value) {
  28883. var rule, i, styles;
  28884. if (!Ext.isArray(selector)) {
  28885. rule = CSS.getRule(selector);
  28886. if (rule) {
  28887. if (arguments.length === 2) {
  28888. styles = Ext.Element.parseStyles(property);
  28889. for (property in styles) {
  28890. rule.style[property.replace(camelRe, camelFn)] = styles[property];
  28891. }
  28892. } else {
  28893. rule.style[property.replace(camelRe, camelFn)] = value;
  28894. }
  28895. return true;
  28896. }
  28897. } else {
  28898. for (i = 0; i < selector.length; i++) {
  28899. if (CSS.updateRule(selector[i], property, value)) {
  28900. return true;
  28901. }
  28902. }
  28903. }
  28904. return false;
  28905. },
  28906. deleteRule: function(selector) {
  28907. var rule = CSS.getRule(selector, false, true),
  28908. styleSheet, index;
  28909. if (rule) {
  28910. styleSheet = rule.parentStyleSheet;
  28911. index = Ext.Array.indexOf(styleSheet.cssRules || styleSheet.rules, rule.cssRule);
  28912. if (styleSheet.deleteRule) {
  28913. styleSheet.deleteRule(index);
  28914. } else {
  28915. styleSheet.removeRule(index);
  28916. }
  28917. delete rules[selector];
  28918. }
  28919. }
  28920. };
  28921. });
  28922. Ext.define('Ext.util.translatable.ScrollPosition', {
  28923. extend: Ext.util.translatable.Dom,
  28924. alias: 'translatable.scrollposition',
  28925. constructor: function(config) {
  28926. if (config && config.element) {
  28927. this.x = config.element.getScrollLeft();
  28928. this.y = config.element.getScrollTop();
  28929. }
  28930. this.callParent([
  28931. config
  28932. ]);
  28933. },
  28934. translateAnimated: function() {
  28935. var element = this.getElement();
  28936. this.x = element.getScrollLeft();
  28937. this.y = element.getScrollTop();
  28938. this.callParent(arguments);
  28939. },
  28940. doTranslate: function(x, y) {
  28941. var element = this.getElement();
  28942. element.setScrollLeft(Math.round(x));
  28943. element.setScrollTop(Math.round(y));
  28944. },
  28945. getPosition: function() {
  28946. var me = this,
  28947. position = me.position,
  28948. element = me.getElement();
  28949. position.x = element.getScrollLeft();
  28950. position.y = element.getScrollTop();
  28951. return position;
  28952. }
  28953. });
  28954. Ext.define('Ext.scroll.Scroller', {
  28955. extend: Ext.Evented,
  28956. alias: 'scroller.scroller',
  28957. mixins: [
  28958. Ext.mixin.Factoryable,
  28959. Ext.mixin.Bufferable
  28960. ],
  28961. factoryConfig: {
  28962. defaultType: 'scroller'
  28963. },
  28964. bufferableMethods: {
  28965. onDomScrollEnd: 100
  28966. },
  28967. isScroller: true,
  28968. config: {
  28969. direction: undefined,
  28970. element: undefined,
  28971. scrollbars: null,
  28972. snapSelector: null,
  28973. snapOffset: null,
  28974. msSnapInterval: null,
  28975. x: true,
  28976. y: true,
  28977. scrollElement: null,
  28978. size: null,
  28979. spacerXY: null,
  28980. touchAction: null
  28981. },
  28982. snappableCls: Ext.baseCSSPrefix + 'scroller-snappable',
  28983. elementCls: Ext.baseCSSPrefix + 'scroller',
  28984. spacerCls: Ext.baseCSSPrefix + 'scroller-spacer',
  28985. noScrollbarsCls: Ext.baseCSSPrefix + 'no-scrollbars',
  28986. statics: {
  28987. create: function(config, type) {
  28988. return Ext.Factory.scroller(config, type);
  28989. },
  28990. getScrollingElement: function() {
  28991. var doc = document,
  28992. standard = this.$standardScrollElement,
  28993. el = doc.scrollingElement,
  28994. iframe, frameDoc;
  28995. if (el) {
  28996. return el;
  28997. }
  28998. if (standard === undefined) {
  28999. iframe = document.createElement('iframe');
  29000. iframe.style.height = '1px';
  29001. document.body.appendChild(iframe);
  29002. frameDoc = iframe.contentWindow.document;
  29003. frameDoc.write('<!DOCTYPE html><div style="height:9999em">x</div>');
  29004. frameDoc.close();
  29005. standard = frameDoc.documentElement.scrollHeight > frameDoc.body.scrollHeight;
  29006. iframe.parentNode.removeChild(iframe);
  29007. this.$standardScrollElement = standard;
  29008. }
  29009. return standard ? doc.documentElement : doc.body;
  29010. },
  29011. initViewportScroller: function() {
  29012. var scroller = Ext.getViewportScroller();
  29013. if (!scroller.getElement()) {
  29014. scroller.setElement(Ext.getBody());
  29015. }
  29016. }
  29017. },
  29018. constructor: function(config) {
  29019. var me = this;
  29020. me.position = {
  29021. x: 0,
  29022. y: 0
  29023. };
  29024. me.callParent([
  29025. config
  29026. ]);
  29027. },
  29028. destroy: function() {
  29029. var me = this,
  29030. partners = me._partners,
  29031. key;
  29032. Ext.undefer(me.restoreTimer);
  29033. me.setX(Ext.emptyString);
  29034. me.setY(Ext.emptyString);
  29035. if (me._spacer) {
  29036. me._spacer.destroy();
  29037. }
  29038. if (me.scrollListener) {
  29039. me.scrollListener.destroy();
  29040. }
  29041. if (partners) {
  29042. for (key in partners) {
  29043. me.removePartner(partners[key].scroller);
  29044. }
  29045. }
  29046. me.setElement(null);
  29047. me._partners = me.component = null;
  29048. if (me.translatable) {
  29049. me.translatable.destroy();
  29050. me.translatable = null;
  29051. }
  29052. me.removeSnapStylesheet();
  29053. me.callParent();
  29054. },
  29055. addPartner: function(partner, axis) {
  29056. var me = this,
  29057. partners = me._partners || (me._partners = {}),
  29058. otherPartners = partner._partners || (partner._partners = {});
  29059. axis = me.axisConfigs[axis || 'both'];
  29060. partners[partner.getId()] = {
  29061. scroller: partner,
  29062. axes: axis
  29063. };
  29064. otherPartners[me.getId()] = {
  29065. scroller: me,
  29066. axes: axis
  29067. };
  29068. },
  29069. applyElement: function(element, oldElement) {
  29070. var me = this;
  29071. if (oldElement && me.scrollListener) {
  29072. me.scrollListener.destroy();
  29073. }
  29074. if (element) {
  29075. if (typeof element === 'string' && !Ext.get(element)) {
  29076. Ext.raise("Cannot create Ext.scroll.Scroller instance. " + "Element with id '" + element + "' not found.");
  29077. }
  29078. element = Ext.get(element);
  29079. }
  29080. return element;
  29081. },
  29082. applySize: function(size, oldSize) {
  29083. var x, y;
  29084. if (size === null || typeof size === 'number') {
  29085. x = y = size;
  29086. } else if (size) {
  29087. x = size.x;
  29088. y = size.y;
  29089. }
  29090. if (x === null) {
  29091. x = 0;
  29092. } else if (x === undefined) {
  29093. x = (oldSize ? oldSize.x : 0);
  29094. }
  29095. if (y === null) {
  29096. y = 0;
  29097. } else if (y === undefined) {
  29098. y = (oldSize ? oldSize.y : 0);
  29099. }
  29100. if (!oldSize || x !== oldSize.x || y !== oldSize.y) {
  29101. return {
  29102. x: x,
  29103. y: y
  29104. };
  29105. }
  29106. },
  29107. getClientSize: function() {
  29108. var dom = this.getElement().dom;
  29109. return {
  29110. x: dom.clientWidth,
  29111. y: dom.clientHeight
  29112. };
  29113. },
  29114. getScrollbarSize: function() {
  29115. var me = this,
  29116. width = 0,
  29117. height = 0,
  29118. element = me.getElement(),
  29119. dom, x, y, hasXScroll, hasYScroll, scrollbarSize;
  29120. if (element && !element.destroyed) {
  29121. x = me.getX();
  29122. y = me.getY();
  29123. dom = element.dom;
  29124. if (x || y) {
  29125. scrollbarSize = Ext.getScrollbarSize();
  29126. }
  29127. if (x === 'scroll') {
  29128. hasXScroll = true;
  29129. } else if (x) {
  29130. hasXScroll = dom.scrollWidth > dom.clientWidth;
  29131. }
  29132. if (y === 'scroll') {
  29133. hasYScroll = true;
  29134. } else if (y) {
  29135. hasYScroll = dom.scrollHeight > dom.clientHeight;
  29136. }
  29137. if (hasXScroll) {
  29138. height = scrollbarSize.height;
  29139. }
  29140. if (hasYScroll) {
  29141. width = scrollbarSize.width;
  29142. }
  29143. }
  29144. return {
  29145. width: width,
  29146. height: height
  29147. };
  29148. },
  29149. getPosition: function() {
  29150. var me = this;
  29151. if (me.positionDirty) {
  29152. me.updateDomScrollPosition();
  29153. }
  29154. return me.position;
  29155. },
  29156. getSize: function() {
  29157. var element = this.getElement(),
  29158. size, dom;
  29159. if (element && !element.destroyed) {
  29160. dom = element.dom;
  29161. size = {
  29162. x: dom.scrollWidth,
  29163. y: dom.scrollHeight
  29164. };
  29165. } else {
  29166. size = {
  29167. x: 0,
  29168. y: 0
  29169. };
  29170. }
  29171. return size;
  29172. },
  29173. getMaxPosition: function() {
  29174. var element = this.getElement(),
  29175. x = 0,
  29176. y = 0,
  29177. dom;
  29178. if (element && !element.destroyed) {
  29179. dom = element.dom;
  29180. x = dom.scrollWidth - dom.clientWidth;
  29181. y = dom.scrollHeight - dom.clientHeight;
  29182. }
  29183. return {
  29184. x: x,
  29185. y: y
  29186. };
  29187. },
  29188. getMaxUserPosition: function() {
  29189. var me = this,
  29190. element = me.getElement(),
  29191. x = 0,
  29192. y = 0,
  29193. dom;
  29194. if (element && !element.destroyed) {
  29195. dom = element.dom;
  29196. if (me.getX()) {
  29197. x = dom.scrollWidth - dom.clientWidth;
  29198. }
  29199. if (me.getY()) {
  29200. y = dom.scrollHeight - dom.clientHeight;
  29201. }
  29202. }
  29203. return {
  29204. x: x,
  29205. y: y
  29206. };
  29207. },
  29208. refresh: function() {
  29209. this.positionDirty = true;
  29210. this.fireEvent('refresh', this);
  29211. return this;
  29212. },
  29213. removePartner: function(partner) {
  29214. var partners = this._partners,
  29215. otherPartners = partner._partners;
  29216. if (partners) {
  29217. delete partners[partner.getId()];
  29218. }
  29219. if (otherPartners) {
  29220. delete (otherPartners[this.getId()]);
  29221. }
  29222. },
  29223. scrollBy: function(deltaX, deltaY, animate) {
  29224. var position = this.getPosition();
  29225. if (deltaX) {
  29226. if (deltaX.length) {
  29227. animate = deltaY;
  29228. deltaY = deltaX[1];
  29229. deltaX = deltaX[0];
  29230. } else if (typeof deltaX !== 'number') {
  29231. animate = deltaY;
  29232. deltaY = deltaX.y;
  29233. deltaX = deltaX.x;
  29234. }
  29235. }
  29236. deltaX = (typeof deltaX === 'number') ? deltaX + position.x : null;
  29237. deltaY = (typeof deltaY === 'number') ? deltaY + position.y : null;
  29238. return this.doScrollTo(deltaX, deltaY, animate);
  29239. },
  29240. ensureVisible: function(el, options) {
  29241. var me = this,
  29242. position = me.getPosition(),
  29243. highlight, newPosition, ret;
  29244. if (el) {
  29245. if (el && el.element && !el.isElement) {
  29246. options = el;
  29247. el = options.element;
  29248. }
  29249. options = options || {};
  29250. highlight = options.highlight;
  29251. newPosition = me.getEnsureVisibleXY(el, options);
  29252. if (newPosition.y !== position.y || newPosition.x !== position.x) {
  29253. if (highlight) {
  29254. me.on({
  29255. scrollend: 'doHighlight',
  29256. scope: me,
  29257. single: true,
  29258. args: [
  29259. el,
  29260. highlight
  29261. ]
  29262. });
  29263. }
  29264. ret = me.doScrollTo(newPosition.x, newPosition.y, options.animation);
  29265. } else {
  29266. if (highlight) {
  29267. me.doHighlight(el, highlight);
  29268. }
  29269. ret = Ext.Deferred.getCachedResolved();
  29270. }
  29271. } else {
  29272. ret = Ext.Deferred.getCachedRejected();
  29273. }
  29274. return ret;
  29275. },
  29276. scrollIntoView: function(el, hscroll, animate, highlight) {
  29277. return this.ensureVisible(el, {
  29278. animation: animate,
  29279. highlight: highlight,
  29280. x: hscroll
  29281. });
  29282. },
  29283. isInView: function(el) {
  29284. return this.doIsInView(el);
  29285. },
  29286. scrollTo: function(x, y, animation) {
  29287. var maxPosition;
  29288. if (x) {
  29289. if (x.length) {
  29290. animation = y;
  29291. y = x[1];
  29292. x = x[0];
  29293. } else if (typeof x !== 'number') {
  29294. animation = y;
  29295. y = x.y;
  29296. x = x.x;
  29297. }
  29298. }
  29299. if (x < 0 || y < 0) {
  29300. maxPosition = this.getMaxPosition();
  29301. if (x < 0) {
  29302. x += maxPosition.x;
  29303. }
  29304. if (y < 0) {
  29305. y += maxPosition.y;
  29306. }
  29307. }
  29308. return this.doScrollTo(x, y, animation);
  29309. },
  29310. updateDirection: function(direction) {
  29311. var me = this,
  29312. x, y;
  29313. if (!direction) {
  29314. x = me.getX();
  29315. y = me.getY();
  29316. if (x && y) {
  29317. direction = (y === 'scroll' && x === 'scroll') ? 'both' : 'auto';
  29318. } else if (y) {
  29319. direction = 'vertical';
  29320. } else if (x) {
  29321. direction = 'horizontal';
  29322. }
  29323. me._direction = direction;
  29324. } else {
  29325. if (direction === 'auto') {
  29326. x = true;
  29327. y = true;
  29328. } else if (direction === 'vertical') {
  29329. x = false;
  29330. y = true;
  29331. } else if (direction === 'horizontal') {
  29332. x = true;
  29333. y = false;
  29334. } else if (direction === 'both') {
  29335. x = 'scroll';
  29336. y = 'scroll';
  29337. }
  29338. me.setX(x);
  29339. me.setY(y);
  29340. }
  29341. },
  29342. updateScrollbars: function(scrollbars, oldScrollbars) {
  29343. this.syncScrollbarCls();
  29344. },
  29345. updateSize: function(size) {
  29346. var me = this,
  29347. element = me.getElement(),
  29348. x = size.x,
  29349. y = size.y,
  29350. spacer;
  29351. if (element) {
  29352. me.positionDirty = true;
  29353. spacer = me.getSpacer();
  29354. if (!x && !y) {
  29355. spacer.hide();
  29356. } else {
  29357. if (x > 0) {
  29358. x -= 1;
  29359. }
  29360. if (y > 0) {
  29361. y -= 1;
  29362. }
  29363. me.setSpacerXY({
  29364. x: x,
  29365. y: y
  29366. });
  29367. spacer.show();
  29368. }
  29369. }
  29370. },
  29371. updateMsSnapInterval: function() {
  29372. this.initMsSnapInterval();
  29373. },
  29374. updateSnapSelector: function() {
  29375. this.initSnap();
  29376. },
  29377. updateSnapOffset: function() {
  29378. this.initSnap();
  29379. },
  29380. updateTouchAction: function(touchAction) {
  29381. var element = this.getElement();
  29382. if (element) {
  29383. element.setTouchAction(touchAction);
  29384. }
  29385. },
  29386. updateElement: function(element, oldElement) {
  29387. var me = this,
  29388. touchAction = me.getTouchAction(),
  29389. scrollListener = me.scrollListener,
  29390. elementCls = me.elementCls,
  29391. eventSource, scrollEl;
  29392. if (scrollListener) {
  29393. scrollListener.destroy();
  29394. me.scrollListener = null;
  29395. me.setScrollElement(null);
  29396. }
  29397. if (oldElement && !oldElement.destroyed) {
  29398. oldElement.setStyle('overflow', 'hidden');
  29399. oldElement.removeCls(elementCls);
  29400. }
  29401. if (element) {
  29402. if (element.dom === document.documentElement || element.dom === document.body) {
  29403. eventSource = Ext.getWin();
  29404. scrollEl = Ext.scroll.Scroller.getScrollingElement();
  29405. } else {
  29406. scrollEl = eventSource = element;
  29407. }
  29408. me.setScrollElement(Ext.get(scrollEl));
  29409. me.scrollListener = eventSource.on({
  29410. scroll: me.onDomScroll,
  29411. scope: me,
  29412. destroyable: true
  29413. });
  29414. if (touchAction) {
  29415. element.setTouchAction(touchAction);
  29416. }
  29417. me.initXStyle();
  29418. me.initYStyle();
  29419. element.addCls(elementCls);
  29420. me.initSnap();
  29421. me.initMsSnapInterval();
  29422. me.syncScrollbarCls();
  29423. }
  29424. },
  29425. updateX: function(x) {
  29426. this.initXStyle();
  29427. },
  29428. updateY: function(y) {
  29429. this.initYStyle();
  29430. },
  29431. deprecated: {
  29432. '5': {
  29433. methods: {
  29434. getScroller: function() {
  29435. return this;
  29436. }
  29437. }
  29438. },
  29439. '5.1.0': {
  29440. methods: {
  29441. scrollToTop: function(animate) {
  29442. return this.scrollTo(0, 0, animate);
  29443. },
  29444. scrollToEnd: function(animate) {
  29445. return this.scrollTo(Infinity, Infinity, animate);
  29446. }
  29447. }
  29448. }
  29449. },
  29450. privates: {
  29451. axisConfigs: {
  29452. x: {
  29453. x: true
  29454. },
  29455. y: {
  29456. y: true
  29457. },
  29458. both: {
  29459. x: true,
  29460. y: true
  29461. }
  29462. },
  29463. getEnsureVisibleXY: function(el, options) {
  29464. var position = this.getPosition(),
  29465. viewport = this.component ? this.component.getScrollableClientRegion() : this.getElement(),
  29466. newPosition, align;
  29467. if (el && el.element && !el.isElement) {
  29468. options = el;
  29469. el = options.element;
  29470. }
  29471. options = options || {};
  29472. align = options.align;
  29473. if (align) {
  29474. if (Ext.isString(align)) {
  29475. align = {
  29476. x: options.x === false ? null : align,
  29477. y: options.y === false ? null : align
  29478. };
  29479. } else if (Ext.isObject(align)) {
  29480. if (align.x && options.x === false) {
  29481. align.x = null;
  29482. }
  29483. if (align.y && options.y === false) {
  29484. align.y = null;
  29485. }
  29486. }
  29487. }
  29488. newPosition = Ext.fly(el).getScrollIntoViewXY(viewport, position.x, position.y, align);
  29489. newPosition.x = options.x === false ? position.x : newPosition.x;
  29490. newPosition.y = options.y === false ? position.y : newPosition.y;
  29491. return newPosition;
  29492. },
  29493. getSpacer: function() {
  29494. var me = this,
  29495. spacer = me._spacer,
  29496. element;
  29497. if (!spacer) {
  29498. element = me.getElement();
  29499. spacer = me._spacer = element.createChild({
  29500. cls: me.spacerCls,
  29501. role: 'presentation'
  29502. }, element.dom.firstChild);
  29503. spacer.setVisibilityMode(2);
  29504. spacer.hide();
  29505. element.position();
  29506. }
  29507. return spacer;
  29508. },
  29509. applySpacerXY: function(pos, oldPos) {
  29510. if (oldPos && pos.x === oldPos.x && pos.y === oldPos.y) {
  29511. pos = undefined;
  29512. }
  29513. return pos;
  29514. },
  29515. updateSpacerXY: function(pos) {
  29516. var me = this,
  29517. spacer = me.getSpacer(),
  29518. sStyle = spacer.dom.style,
  29519. scrollHeight = pos.y,
  29520. shortfall;
  29521. sStyle.marginTop = '';
  29522. me.translateSpacer(pos.x, me.constrainScrollRange(scrollHeight));
  29523. sStyle.lineHeight = Number(!parseInt(sStyle.lineHeight, 10)) + 'px';
  29524. if (scrollHeight > 1000000) {
  29525. shortfall = scrollHeight - me.getElement().dom.scrollHeight;
  29526. if (shortfall > 0) {
  29527. sStyle.marginTop = Math.min(shortfall, me.maxSpacerMargin || 0) + 'px';
  29528. }
  29529. }
  29530. },
  29531. translateSpacer: function(x, y) {
  29532. this.getSpacer().translate(x, y);
  29533. },
  29534. doIsInView: function(el, skipCheck) {
  29535. var me = this,
  29536. c = me.component,
  29537. result = {
  29538. x: false,
  29539. y: false
  29540. },
  29541. elRegion,
  29542. myEl = me.getElement(),
  29543. myElRegion;
  29544. if (el && (skipCheck || (myEl.contains(el) || (c && c.owns(el))))) {
  29545. myElRegion = myEl.getRegion();
  29546. elRegion = Ext.fly(el).getRegion();
  29547. result.x = elRegion.right > myElRegion.left && elRegion.left < myElRegion.right;
  29548. result.y = elRegion.bottom > myElRegion.top && elRegion.top < myElRegion.bottom;
  29549. }
  29550. return result;
  29551. },
  29552. contains: function(component) {
  29553. var el = this.getElement(),
  29554. owner = component;
  29555. while (owner && owner !== Ext.Viewport) {
  29556. if (el.contains(owner.el)) {
  29557. return true;
  29558. }
  29559. owner = owner.getRefOwner();
  29560. }
  29561. return false;
  29562. },
  29563. constrainScrollRange: function(scrollRange) {
  29564. if (scrollRange < 1000000) {
  29565. return scrollRange;
  29566. }
  29567. if (!this.maxSpacerTranslate) {
  29568. var maxScrollHeight = Math.pow(2, 32),
  29569. tooHigh = maxScrollHeight,
  29570. tooLow = 500,
  29571. scrollTest = Ext.getBody().createChild({
  29572. style: {
  29573. position: 'absolute',
  29574. left: '-10000px',
  29575. top: '0',
  29576. width: '500px',
  29577. height: '500px'
  29578. },
  29579. cn: {
  29580. cls: this.spacerCls
  29581. }
  29582. }, null, true),
  29583. stretcher = Ext.get(scrollTest.firstChild),
  29584. sStyle = stretcher.dom.style;
  29585. stretcher.translate(0, maxScrollHeight - 1);
  29586. sStyle.lineHeight = Number(!parseInt(sStyle.lineHeight, 10)) + 'px';
  29587. while (tooHigh !== tooLow + 1) {
  29588. stretcher.translate(0, (maxScrollHeight = tooLow + Math.floor((tooHigh - tooLow) / 2)));
  29589. sStyle.lineHeight = Number(!parseInt(sStyle.lineHeight, 10)) + 'px';
  29590. if (scrollTest.scrollHeight < maxScrollHeight) {
  29591. tooHigh = maxScrollHeight;
  29592. } else {
  29593. tooLow = maxScrollHeight;
  29594. }
  29595. }
  29596. stretcher.translate(0, Ext.scroll.Scroller.prototype.maxSpacerTranslate = tooLow);
  29597. tooHigh = tooLow * 2;
  29598. while (tooHigh !== tooLow + 1) {
  29599. stretcher.dom.style.marginTop = ((maxScrollHeight = tooLow + Math.floor((tooHigh - tooLow) / 2))) + 'px';
  29600. sStyle.lineHeight = Number(!parseInt(sStyle.lineHeight, 10)) + 'px';
  29601. if (scrollTest.scrollHeight < maxScrollHeight) {
  29602. tooHigh = maxScrollHeight;
  29603. } else {
  29604. tooLow = maxScrollHeight;
  29605. }
  29606. }
  29607. Ext.fly(scrollTest).destroy();
  29608. Ext.scroll.Scroller.prototype.maxSpacerMargin = tooLow - Ext.scroll.Scroller.prototype.maxSpacerTranslate;
  29609. }
  29610. return Math.min(scrollRange, this.maxSpacerTranslate);
  29611. },
  29612. convertX: function(x) {
  29613. return x;
  29614. },
  29615. doHighlight: function(el, highlight) {
  29616. if (highlight !== true) {
  29617. Ext.fly(el).highlight(highlight);
  29618. } else {
  29619. Ext.fly(el).highlight();
  29620. }
  29621. },
  29622. doScrollTo: function(x, y, animate) {
  29623. var me = this,
  29624. element = me.getScrollElement(),
  29625. maxPosition, dom, xInf, yInf, ret, translatable, deferred;
  29626. if (element && !element.destroyed) {
  29627. dom = element.dom;
  29628. xInf = (x === Infinity);
  29629. yInf = (y === Infinity);
  29630. if (xInf || yInf) {
  29631. maxPosition = me.getMaxPosition();
  29632. if (xInf) {
  29633. x = maxPosition.x;
  29634. }
  29635. if (yInf) {
  29636. y = maxPosition.y;
  29637. }
  29638. }
  29639. if (x !== null) {
  29640. x = me.convertX(x);
  29641. }
  29642. if (animate) {
  29643. translatable = me.translatable;
  29644. if (!translatable) {
  29645. me.translatable = translatable = new Ext.util.translatable.ScrollPosition({
  29646. element: element
  29647. });
  29648. }
  29649. deferred = new Ext.Deferred();
  29650. translatable.on('animationend', function() {
  29651. if (me.destroyed) {
  29652. deferred.reject();
  29653. } else {
  29654. deferred.resolve();
  29655. }
  29656. }, Ext.global, {
  29657. single: true,
  29658. onFrame: true
  29659. });
  29660. translatable.translate(x, y, animate);
  29661. ret = deferred.promise;
  29662. } else {
  29663. if (y != null) {
  29664. dom.scrollTop = y;
  29665. }
  29666. if (x != null) {
  29667. dom.scrollLeft = x;
  29668. }
  29669. ret = Ext.Deferred.getCachedResolved();
  29670. }
  29671. me.positionDirty = true;
  29672. } else {
  29673. ret = Ext.Deferred.getCachedRejected();
  29674. }
  29675. return ret;
  29676. },
  29677. fireScrollStart: function(x, y, xDelta, yDelta) {
  29678. var me = this,
  29679. component = me.component;
  29680. me.invokePartners('onPartnerScrollStart', x, y, xDelta, yDelta);
  29681. me.startX = x - xDelta;
  29682. me.startY = y - yDelta;
  29683. if (me.hasListeners.scrollstart) {
  29684. me.fireEvent('scrollstart', me, x, y);
  29685. }
  29686. if (component && component.onScrollStart) {
  29687. component.onScrollStart(x, y);
  29688. }
  29689. Ext.GlobalEvents.fireEvent('scrollstart', me, x, y);
  29690. },
  29691. fireScroll: function(x, y, xDelta, yDelta) {
  29692. var me = this,
  29693. component = me.component;
  29694. me.invokePartners('onPartnerScroll', x, y, xDelta, yDelta);
  29695. if (me.hasListeners.scroll) {
  29696. me.fireEvent('scroll', me, x, y, xDelta, yDelta);
  29697. }
  29698. if (component && component.onScrollMove) {
  29699. component.onScrollMove(x, y);
  29700. }
  29701. Ext.GlobalEvents.fireEvent('scroll', me, x, y, xDelta, yDelta);
  29702. },
  29703. fireScrollEnd: function(x, y, xDelta, yDelta) {
  29704. var me = this,
  29705. component = me.component,
  29706. dx = x - me.startX,
  29707. dy = y - me.startY;
  29708. me.startX = me.startY = null;
  29709. me.invokePartners('onPartnerScrollEnd', x, y, xDelta, yDelta);
  29710. if (me.hasListeners.scrollend) {
  29711. me.fireEvent('scrollend', me, x, y, dx, dy);
  29712. }
  29713. if (component && component.onScrollEnd) {
  29714. component.onScrollEnd(x, y);
  29715. }
  29716. Ext.GlobalEvents.fireEvent('scrollend', me, x, y, dx, dy);
  29717. },
  29718. getElementScroll: function(element) {
  29719. return element.getScroll();
  29720. },
  29721. initSnap: function() {
  29722. var me = this,
  29723. snapOffset = me.getSnapOffset(),
  29724. snapSelector = me.getSnapSelector(),
  29725. element = me.getElement(),
  29726. offsetX, offsetY, snapCoordinate;
  29727. if (element && snapSelector) {
  29728. element.addCls(me.snappableCls);
  29729. me.removeSnapStylesheet();
  29730. if (snapOffset) {
  29731. offsetX = snapOffset.x || 0;
  29732. offsetY = snapOffset.y || 0;
  29733. if (offsetX) {
  29734. offsetX = -offsetX + 'px';
  29735. }
  29736. if (offsetY) {
  29737. offsetY = -offsetY + 'px';
  29738. }
  29739. }
  29740. snapCoordinate = offsetX + ' ' + offsetY + ';';
  29741. me.snapStylesheet = Ext.util.CSS.createStyleSheet('#' + element.id + ' ' + snapSelector + '{-webkit-scroll-snap-coordinate:' + snapCoordinate + 'scroll-snap-coordinate:' + snapCoordinate + '}');
  29742. }
  29743. },
  29744. initMsSnapInterval: function() {
  29745. var element = this.getElement(),
  29746. interval, x, y, style;
  29747. if (element) {
  29748. interval = this.getMsSnapInterval();
  29749. if (interval) {
  29750. x = interval.x;
  29751. y = interval.y;
  29752. style = element.dom.style;
  29753. if (x) {
  29754. style['-ms-scroll-snap-points-x'] = 'snapInterval(0px, ' + x + 'px)';
  29755. }
  29756. if (y) {
  29757. style['-ms-scroll-snap-points-y'] = 'snapInterval(0px, ' + y + 'px)';
  29758. }
  29759. }
  29760. }
  29761. },
  29762. initXStyle: function() {
  29763. var element = this.getElement(),
  29764. x = this.getX();
  29765. if (element && element.dom) {
  29766. if (!x) {
  29767. x = 'hidden';
  29768. } else if (x === true) {
  29769. x = 'auto';
  29770. }
  29771. element.setStyle('overflow-x', x);
  29772. }
  29773. },
  29774. initYStyle: function() {
  29775. var element = this.getElement(),
  29776. y = this.getY();
  29777. if (element && element.dom) {
  29778. if (!y) {
  29779. y = 'hidden';
  29780. } else if (y === true) {
  29781. y = 'auto';
  29782. }
  29783. element.setStyle('overflow-y', y);
  29784. }
  29785. },
  29786. invokePartners: function(method, x, y, xDelta, yDelta) {
  29787. var me = this,
  29788. partners = me._partners,
  29789. partner, id, axes;
  29790. if (!me.suspendSync) {
  29791. me.invokingPartners = true;
  29792. for (id in partners) {
  29793. axes = partners[id].axes;
  29794. partner = partners[id].scroller;
  29795. if (!partner.invokingPartners && (xDelta && axes.x || yDelta && axes.y)) {
  29796. partner[method](me, axes.x ? x : null, axes.y ? y : null, xDelta, yDelta);
  29797. }
  29798. }
  29799. me.invokingPartners = false;
  29800. }
  29801. },
  29802. suspendPartnerSync: function() {
  29803. this.suspendSync = (this.suspendSync || 0) + 1;
  29804. },
  29805. resumePartnerSync: function(syncNow) {
  29806. var me = this,
  29807. position;
  29808. if (me.suspendSync) {
  29809. me.suspendSync--;
  29810. }
  29811. if (!me.suspendSync && syncNow) {
  29812. position = me.getPosition();
  29813. me.invokePartners('onPartnerScroll', position.x, position.y);
  29814. me.invokePartners('onPartnerScrollEnd', position.x, position.y);
  29815. }
  29816. },
  29817. readPosition: function(position) {
  29818. var me = this,
  29819. element = me.getScrollElement(),
  29820. elScroll;
  29821. position = position || {};
  29822. if (element && !element.destroyed) {
  29823. elScroll = me.getElementScroll(element);
  29824. position.x = elScroll.left;
  29825. position.y = elScroll.top;
  29826. }
  29827. return position;
  29828. },
  29829. updateDomScrollPosition: function(silent) {
  29830. var me = this,
  29831. position = me.position,
  29832. oldX = position.x,
  29833. oldY = position.y,
  29834. x, y, xDelta, yDelta;
  29835. me.readPosition(position);
  29836. x = position.x;
  29837. y = position.y;
  29838. me.positionDirty = false;
  29839. if (!silent) {
  29840. xDelta = x - oldX;
  29841. yDelta = y - oldY;
  29842. if (xDelta || yDelta) {
  29843. if (!me.isScrolling) {
  29844. me.isScrolling = Ext.isScrolling = true;
  29845. me.fireScrollStart(x, y, xDelta, yDelta);
  29846. }
  29847. me.fireScroll(x, y, xDelta, yDelta);
  29848. me.onDomScrollEnd(x, y, xDelta, yDelta);
  29849. }
  29850. }
  29851. return position;
  29852. },
  29853. syncWithPartners: function() {
  29854. var me = this,
  29855. partners = me._partners,
  29856. id, partner, position;
  29857. me.suspendPartnerSync();
  29858. for (id in partners) {
  29859. partner = partners[id].scroller;
  29860. position = partner.getPosition();
  29861. me.onPartnerScroll(partner, position.x, position.y);
  29862. }
  29863. me.resumePartnerSync();
  29864. },
  29865. syncScrollbarCls: function() {
  29866. var element = this.getElement();
  29867. if (element) {
  29868. element.toggleCls(this.noScrollbarsCls, this.getScrollbars() === false);
  29869. }
  29870. },
  29871. onDomScroll: function() {
  29872. var hasTimer = !!this.restoreTimer;
  29873. this.updateDomScrollPosition(hasTimer);
  29874. if (hasTimer) {
  29875. Ext.undefer(this.onDomScrollEnd.timer);
  29876. return;
  29877. }
  29878. },
  29879. doOnDomScrollEnd: function(x, y, xDelta, yDelta) {
  29880. var me = this;
  29881. if (me.destroying || me.destroyed) {
  29882. return;
  29883. }
  29884. me.isScrolling = Ext.isScrolling = false;
  29885. if (x === undefined) {
  29886. return;
  29887. }
  29888. me.trackingScrollLeft = x;
  29889. me.trackingScrollTop = y;
  29890. me.fireScrollEnd(x, y, xDelta, yDelta);
  29891. },
  29892. onPartnerScrollStart: function(partner, x, y, xDelta, yDelta) {
  29893. this.isScrolling = true;
  29894. this.fireScrollStart(x, y, xDelta, yDelta);
  29895. },
  29896. onPartnerScroll: function(partner, x, y, xDelta, yDelta) {
  29897. this.doScrollTo(x, y, false);
  29898. this.updateDomScrollPosition(true);
  29899. this.fireScroll(x, y, xDelta, yDelta);
  29900. },
  29901. onPartnerScrollEnd: function(partner, x, y, xDelta, yDelta) {
  29902. this.cancelOnDomScrollEnd();
  29903. this.doOnDomScrollEnd(x, y, xDelta, yDelta);
  29904. },
  29905. removeSnapStylesheet: function() {
  29906. var stylesheet = this.snapStylesheet;
  29907. if (stylesheet) {
  29908. Ext.util.CSS.removeStyleSheet(stylesheet);
  29909. this.snapStylesheet = null;
  29910. }
  29911. },
  29912. restoreState: function() {
  29913. var me = this,
  29914. el = me.getScrollElement();
  29915. if (el) {
  29916. if (me.trackingScrollTop !== undefined) {
  29917. if (!me.restoreTimer) {
  29918. me.restoreTimer = Ext.defer(function() {
  29919. me.restoreTimer = null;
  29920. }, 50);
  29921. }
  29922. me.doScrollTo(me.trackingScrollLeft, me.trackingScrollTop, false);
  29923. }
  29924. }
  29925. }
  29926. }
  29927. },
  29928. function(Scroller) {
  29929. Ext.getViewportScroller = function() {
  29930. var scroller = Scroller.viewport;
  29931. if (!scroller) {
  29932. Scroller.viewport = scroller = new Scroller();
  29933. Scroller.initViewportScroller();
  29934. }
  29935. return scroller;
  29936. };
  29937. Ext.setViewportScroller = function(scroller) {
  29938. if (Scroller.viewport !== scroller) {
  29939. Ext.destroy(Scroller.viewport);
  29940. if (scroller && !scroller.isScroller) {
  29941. scroller = new Scroller(scroller);
  29942. }
  29943. Scroller.viewport = scroller;
  29944. }
  29945. };
  29946. Ext.onReady(function() {
  29947. Scroller.initViewportScrollerTimer = Ext.defer(Scroller.initViewportScroller, 100);
  29948. });
  29949. });
  29950. Ext.define('Ext.ProgressBase', {
  29951. mixinId: 'progressbase',
  29952. config: {
  29953. value: 0,
  29954. textTpl: null
  29955. },
  29956. applyTextTpl: function(textTpl) {
  29957. if (!textTpl.isTemplate) {
  29958. textTpl = new Ext.XTemplate(textTpl);
  29959. }
  29960. return textTpl;
  29961. },
  29962. applyValue: function(value) {
  29963. return value || 0;
  29964. }
  29965. });
  29966. Ext.define('Ext.Progress', {
  29967. extend: Ext.Gadget,
  29968. xtype: [
  29969. 'progress',
  29970. 'progressbarwidget'
  29971. ],
  29972. alternateClassName: 'Ext.ProgressBarWidget',
  29973. mixins: [
  29974. Ext.ProgressBase
  29975. ],
  29976. config: {
  29977. text: null,
  29978. animate: false
  29979. },
  29980. cachedConfig: {
  29981. textCls: Ext.baseCSSPrefix + 'progress-text',
  29982. cls: null
  29983. },
  29984. baseCls: Ext.baseCSSPrefix + 'progress',
  29985. template: [
  29986. {
  29987. reference: 'backgroundEl'
  29988. },
  29989. {
  29990. reference: 'barEl',
  29991. cls: Ext.baseCSSPrefix + 'progress-bar',
  29992. children: [
  29993. {
  29994. reference: 'textEl'
  29995. }
  29996. ]
  29997. }
  29998. ],
  29999. defaultBindProperty: 'value',
  30000. updateCls: function(cls, oldCls) {
  30001. var el = this.element;
  30002. if (oldCls) {
  30003. el.removeCls(oldCls);
  30004. }
  30005. if (cls) {
  30006. el.addCls(cls);
  30007. }
  30008. },
  30009. updateUi: function(ui, oldUi) {
  30010. var element = this.element,
  30011. barEl = this.barEl,
  30012. baseCls = this.baseCls + '-';
  30013. this.callParent([
  30014. ui,
  30015. oldUi
  30016. ]);
  30017. if (oldUi) {
  30018. element.removeCls(baseCls + oldUi);
  30019. barEl.removeCls(baseCls + 'bar-' + oldUi);
  30020. }
  30021. element.addCls(baseCls + ui);
  30022. barEl.addCls(baseCls + 'bar-' + ui);
  30023. },
  30024. updateTextCls: function(textCls) {
  30025. this.backgroundEl.addCls(textCls + ' ' + textCls + '-back');
  30026. this.textEl.addCls(textCls);
  30027. },
  30028. updateValue: function(value, oldValue) {
  30029. var me = this,
  30030. textTpl = me.getTextTpl();
  30031. if (textTpl) {
  30032. me.setText(textTpl.apply({
  30033. value: value,
  30034. percent: Math.round(value * 100)
  30035. }));
  30036. }
  30037. if (!me.isConfiguring && me.getAnimate()) {
  30038. me.stopBarAnimation();
  30039. me.startBarAnimation(Ext.apply({
  30040. from: {
  30041. width: (oldValue * 100) + '%'
  30042. },
  30043. to: {
  30044. width: (value * 100) + '%'
  30045. }
  30046. }, me.animate));
  30047. } else {
  30048. me.barEl.setStyle('width', (value * 100) + '%');
  30049. }
  30050. },
  30051. updateText: function(text) {
  30052. this.backgroundEl.setHtml(text);
  30053. this.textEl.setHtml(text);
  30054. },
  30055. doDestroy: function() {
  30056. this.stopBarAnimation();
  30057. this.callParent();
  30058. },
  30059. privates: {
  30060. startBarAnimation: Ext.privateFn,
  30061. stopBarAnimation: Ext.privateFn
  30062. }
  30063. });
  30064. Ext.define('Ext.fx.State', {
  30065. isAnimatable: {
  30066. 'background-color': true,
  30067. 'background-image': true,
  30068. 'background-position': true,
  30069. 'border-bottom-color': true,
  30070. 'border-bottom-width': true,
  30071. 'border-color': true,
  30072. 'border-left-color': true,
  30073. 'border-left-width': true,
  30074. 'border-right-color': true,
  30075. 'border-right-width': true,
  30076. 'border-spacing': true,
  30077. 'border-top-color': true,
  30078. 'border-top-width': true,
  30079. 'border-width': true,
  30080. 'bottom': true,
  30081. 'color': true,
  30082. 'crop': true,
  30083. 'font-size': true,
  30084. 'font-weight': true,
  30085. 'height': true,
  30086. 'left': true,
  30087. 'letter-spacing': true,
  30088. 'line-height': true,
  30089. 'margin-bottom': true,
  30090. 'margin-left': true,
  30091. 'margin-right': true,
  30092. 'margin-top': true,
  30093. 'max-height': true,
  30094. 'max-width': true,
  30095. 'min-height': true,
  30096. 'min-width': true,
  30097. 'opacity': true,
  30098. 'outline-color': true,
  30099. 'outline-offset': true,
  30100. 'outline-width': true,
  30101. 'padding-bottom': true,
  30102. 'padding-left': true,
  30103. 'padding-right': true,
  30104. 'padding-top': true,
  30105. 'right': true,
  30106. 'text-indent': true,
  30107. 'text-shadow': true,
  30108. 'top': true,
  30109. 'vertical-align': true,
  30110. 'visibility': true,
  30111. 'width': true,
  30112. 'word-spacing': true,
  30113. 'z-index': true,
  30114. 'zoom': true,
  30115. 'transform': true
  30116. },
  30117. constructor: function(data) {
  30118. this.data = {};
  30119. this.set(data);
  30120. },
  30121. setConfig: function(data) {
  30122. this.set(data);
  30123. return this;
  30124. },
  30125. setRaw: function(data) {
  30126. this.data = data;
  30127. return this;
  30128. },
  30129. clear: function() {
  30130. return this.setRaw({});
  30131. },
  30132. setTransform: function(name, value) {
  30133. var data = this.data,
  30134. isArray = Ext.isArray(value),
  30135. transform = data.transform,
  30136. ln, key;
  30137. if (!transform) {
  30138. transform = data.transform = {
  30139. translateX: 0,
  30140. translateY: 0,
  30141. translateZ: 0,
  30142. scaleX: 1,
  30143. scaleY: 1,
  30144. scaleZ: 1,
  30145. rotate: 0,
  30146. rotateX: 0,
  30147. rotateY: 0,
  30148. rotateZ: 0,
  30149. skewX: 0,
  30150. skewY: 0
  30151. };
  30152. }
  30153. if (typeof name == 'string') {
  30154. switch (name) {
  30155. case 'translate':
  30156. if (isArray) {
  30157. ln = value.length;
  30158. if (ln == 0) {
  30159. break;
  30160. }
  30161. transform.translateX = value[0];
  30162. if (ln == 1) {
  30163. break;
  30164. }
  30165. transform.translateY = value[1];
  30166. if (ln == 2) {
  30167. break;
  30168. }
  30169. transform.translateZ = value[2];
  30170. } else {
  30171. transform.translateX = value;
  30172. };
  30173. break;
  30174. case 'rotate':
  30175. if (isArray) {
  30176. ln = value.length;
  30177. if (ln == 0) {
  30178. break;
  30179. }
  30180. transform.rotateX = value[0];
  30181. if (ln == 1) {
  30182. break;
  30183. }
  30184. transform.rotateY = value[1];
  30185. if (ln == 2) {
  30186. break;
  30187. }
  30188. transform.rotateZ = value[2];
  30189. } else {
  30190. transform.rotate = value;
  30191. };
  30192. break;
  30193. case 'scale':
  30194. if (isArray) {
  30195. ln = value.length;
  30196. if (ln == 0) {
  30197. break;
  30198. }
  30199. transform.scaleX = value[0];
  30200. if (ln == 1) {
  30201. break;
  30202. }
  30203. transform.scaleY = value[1];
  30204. if (ln == 2) {
  30205. break;
  30206. }
  30207. transform.scaleZ = value[2];
  30208. } else {
  30209. transform.scaleX = value;
  30210. transform.scaleY = value;
  30211. };
  30212. break;
  30213. case 'skew':
  30214. if (isArray) {
  30215. ln = value.length;
  30216. if (ln == 0) {
  30217. break;
  30218. }
  30219. transform.skewX = value[0];
  30220. if (ln == 1) {
  30221. break;
  30222. }
  30223. transform.skewY = value[1];
  30224. } else {
  30225. transform.skewX = value;
  30226. };
  30227. break;
  30228. default:
  30229. transform[name] = value;
  30230. }
  30231. } else {
  30232. for (key in name) {
  30233. if (name.hasOwnProperty(key)) {
  30234. value = name[key];
  30235. this.setTransform(key, value);
  30236. }
  30237. }
  30238. }
  30239. },
  30240. set: function(name, value) {
  30241. var data = this.data,
  30242. key;
  30243. if (typeof name != 'string') {
  30244. for (key in name) {
  30245. value = name[key];
  30246. if (key === 'transform') {
  30247. this.setTransform(value);
  30248. } else {
  30249. data[key] = value;
  30250. }
  30251. }
  30252. } else {
  30253. if (name === 'transform') {
  30254. this.setTransform(value);
  30255. } else {
  30256. data[name] = value;
  30257. }
  30258. }
  30259. return this;
  30260. },
  30261. unset: function(name) {
  30262. var data = this.data;
  30263. if (data.hasOwnProperty(name)) {
  30264. delete data[name];
  30265. }
  30266. return this;
  30267. },
  30268. getData: function() {
  30269. return this.data;
  30270. }
  30271. });
  30272. Ext.define('Ext.fx.animation.Abstract', {
  30273. extend: Ext.Evented,
  30274. mixins: [
  30275. Ext.mixin.Factoryable
  30276. ],
  30277. factoryConfig: {
  30278. type: 'animation'
  30279. },
  30280. isAnimation: true,
  30281. config: {
  30282. name: '',
  30283. element: null,
  30284. before: null,
  30285. from: {},
  30286. to: {},
  30287. after: null,
  30288. states: {},
  30289. duration: 300,
  30290. easing: 'linear',
  30291. iteration: 1,
  30292. direction: 'normal',
  30293. delay: 0,
  30294. onBeforeStart: null,
  30295. callback: null,
  30296. onEnd: null,
  30297. onBeforeEnd: null,
  30298. scope: null,
  30299. reverse: null,
  30300. preserveEndState: false,
  30301. replacePrevious: true
  30302. },
  30303. STATE_FROM: '0%',
  30304. STATE_TO: '100%',
  30305. DIRECTION_UP: 'up',
  30306. DIRECTION_TOP: 'top',
  30307. DIRECTION_DOWN: 'down',
  30308. DIRECTION_BOTTOM: 'bottom',
  30309. DIRECTION_LEFT: 'left',
  30310. DIRECTION_RIGHT: 'right',
  30311. stateNameRegex: /^(?:[\d\.]+)%$/,
  30312. constructor: function() {
  30313. this.states = {};
  30314. this.callParent(arguments);
  30315. return this;
  30316. },
  30317. applyElement: function(element) {
  30318. return Ext.get(element);
  30319. },
  30320. applyBefore: function(before, current) {
  30321. if (before) {
  30322. return Ext.factory(before, Ext.fx.State, current);
  30323. }
  30324. },
  30325. applyAfter: function(after, current) {
  30326. if (after) {
  30327. return Ext.factory(after, Ext.fx.State, current);
  30328. }
  30329. },
  30330. setFrom: function(from) {
  30331. return this.setState(this.STATE_FROM, from);
  30332. },
  30333. setTo: function(to) {
  30334. return this.setState(this.STATE_TO, to);
  30335. },
  30336. getFrom: function() {
  30337. return this.getState(this.STATE_FROM);
  30338. },
  30339. getTo: function() {
  30340. return this.getState(this.STATE_TO);
  30341. },
  30342. setStates: function(states) {
  30343. var validNameRegex = this.stateNameRegex,
  30344. name;
  30345. for (name in states) {
  30346. if (validNameRegex.test(name)) {
  30347. this.setState(name, states[name]);
  30348. }
  30349. }
  30350. return this;
  30351. },
  30352. getStates: function() {
  30353. return this.states;
  30354. },
  30355. updateCallback: function(callback) {
  30356. if (callback) {
  30357. this.setOnEnd(callback);
  30358. }
  30359. },
  30360. end: function() {
  30361. this.stop();
  30362. },
  30363. stop: function() {
  30364. this.fireEvent('stop', this);
  30365. },
  30366. destroy: function() {
  30367. this.destroying = true;
  30368. this.stop();
  30369. this.callParent();
  30370. this.destroying = false;
  30371. this.destroyed = true;
  30372. },
  30373. setState: function(name, state) {
  30374. var states = this.getStates(),
  30375. stateInstance;
  30376. stateInstance = Ext.factory(state, Ext.fx.State, states[name]);
  30377. if (stateInstance) {
  30378. states[name] = stateInstance;
  30379. }
  30380. else if (name === this.STATE_TO) {
  30381. Ext.Logger.error("Setting and invalid '100%' / 'to' state of: " + state);
  30382. }
  30383. return this;
  30384. },
  30385. getState: function(name) {
  30386. return this.getStates()[name];
  30387. },
  30388. getData: function() {
  30389. var me = this,
  30390. states = me.getStates(),
  30391. statesData = {},
  30392. before = me.getBefore(),
  30393. after = me.getAfter(),
  30394. from = states[me.STATE_FROM],
  30395. to = states[me.STATE_TO],
  30396. fromData = from.getData(),
  30397. toData = to.getData(),
  30398. data, name, state;
  30399. for (name in states) {
  30400. if (states.hasOwnProperty(name)) {
  30401. state = states[name];
  30402. data = state.getData();
  30403. statesData[name] = data;
  30404. }
  30405. }
  30406. return {
  30407. before: before ? before.getData() : {},
  30408. after: after ? after.getData() : {},
  30409. states: statesData,
  30410. from: fromData,
  30411. to: toData,
  30412. duration: me.getDuration(),
  30413. iteration: me.getIteration(),
  30414. direction: me.getDirection(),
  30415. easing: me.getEasing(),
  30416. delay: me.getDelay(),
  30417. onEnd: me.getOnEnd(),
  30418. onBeforeEnd: me.getOnBeforeEnd(),
  30419. onBeforeStart: me.getOnBeforeStart(),
  30420. scope: me.getScope(),
  30421. preserveEndState: me.getPreserveEndState(),
  30422. replacePrevious: me.getReplacePrevious()
  30423. };
  30424. }
  30425. });
  30426. Ext.define('Ext.fx.animation.Slide', {
  30427. extend: Ext.fx.animation.Abstract,
  30428. alternateClassName: 'Ext.fx.animation.SlideIn',
  30429. alias: [
  30430. 'animation.slide',
  30431. 'animation.slideIn'
  30432. ],
  30433. config: {
  30434. direction: 'left',
  30435. out: false,
  30436. offset: 0,
  30437. easing: 'auto',
  30438. containerBox: 'auto',
  30439. elementBox: 'auto',
  30440. isElementBoxFit: true,
  30441. useCssTransform: true
  30442. },
  30443. reverseDirectionMap: {
  30444. up: 'down',
  30445. top: 'down',
  30446. down: 'up',
  30447. bottom: 'up',
  30448. left: 'right',
  30449. right: 'left'
  30450. },
  30451. applyEasing: function(easing) {
  30452. if (easing === 'auto') {
  30453. return 'ease-' + ((this.getOut()) ? 'in' : 'out');
  30454. }
  30455. return easing;
  30456. },
  30457. getContainerBox: function() {
  30458. var box = this._containerBox;
  30459. if (box === 'auto') {
  30460. box = this.getElement().getParent().getBox();
  30461. }
  30462. return box;
  30463. },
  30464. getElementBox: function() {
  30465. var box = this._elementBox;
  30466. if (this.getIsElementBoxFit()) {
  30467. return this.getContainerBox();
  30468. }
  30469. if (box === 'auto') {
  30470. box = this.getElement().getBox();
  30471. }
  30472. return box;
  30473. },
  30474. getData: function() {
  30475. var elementBox = this.getElementBox(),
  30476. containerBox = this.getContainerBox(),
  30477. box = elementBox ? elementBox : containerBox,
  30478. from = this.getFrom(),
  30479. to = this.getTo(),
  30480. out = this.getOut(),
  30481. offset = this.getOffset(),
  30482. direction = this.getDirection(),
  30483. useCssTransform = this.getUseCssTransform(),
  30484. reverse = this.getReverse(),
  30485. translateX = 0,
  30486. translateY = 0,
  30487. offsetPct, fromX, fromY, toX, toY;
  30488. if (typeof offset === 'string') {
  30489. offsetPct = true;
  30490. offset = parseFloat(offset);
  30491. }
  30492. if (reverse) {
  30493. direction = this.reverseDirectionMap[direction];
  30494. }
  30495. switch (direction) {
  30496. case this.DIRECTION_UP:
  30497. case this.DIRECTION_TOP:
  30498. if (offsetPct) {
  30499. offset = box.height * offset / 100;
  30500. };
  30501. if (out) {
  30502. translateY = containerBox.top - box.top - box.height - offset;
  30503. } else {
  30504. translateY = containerBox.bottom - box.bottom + box.height + offset;
  30505. };
  30506. break;
  30507. case this.DIRECTION_DOWN:
  30508. case this.DIRECTION_BOTTOM:
  30509. if (offsetPct) {
  30510. offset = box.height * offset / 100;
  30511. };
  30512. if (out) {
  30513. translateY = containerBox.bottom - box.bottom + box.height + offset;
  30514. } else {
  30515. translateY = containerBox.top - box.height - box.top - offset;
  30516. };
  30517. break;
  30518. case this.DIRECTION_RIGHT:
  30519. if (offsetPct) {
  30520. offset = box.width * offset / 100;
  30521. };
  30522. if (out) {
  30523. translateX = containerBox.right - box.right + box.width + offset;
  30524. } else {
  30525. translateX = containerBox.left - box.left - box.width - offset;
  30526. };
  30527. break;
  30528. case this.DIRECTION_LEFT:
  30529. if (offsetPct) {
  30530. offset = box.width * offset / 100;
  30531. };
  30532. if (out) {
  30533. translateX = containerBox.left - box.left - box.width - offset;
  30534. } else {
  30535. translateX = containerBox.right - box.right + box.width + offset;
  30536. };
  30537. break;
  30538. }
  30539. fromX = (out) ? 0 : translateX;
  30540. fromY = (out) ? 0 : translateY;
  30541. if (useCssTransform) {
  30542. from.setTransform({
  30543. translateX: fromX,
  30544. translateY: fromY
  30545. });
  30546. } else {
  30547. from.set('left', fromX);
  30548. from.set('top', fromY);
  30549. }
  30550. toX = (out) ? translateX : 0;
  30551. toY = (out) ? translateY : 0;
  30552. if (useCssTransform) {
  30553. to.setTransform({
  30554. translateX: toX,
  30555. translateY: toY
  30556. });
  30557. } else {
  30558. to.set('left', toX);
  30559. to.set('top', toY);
  30560. }
  30561. return this.callParent(arguments);
  30562. }
  30563. });
  30564. Ext.define('Ext.fx.animation.SlideOut', {
  30565. extend: Ext.fx.animation.Slide,
  30566. alias: [
  30567. 'animation.slideOut'
  30568. ],
  30569. config: {
  30570. out: true
  30571. }
  30572. });
  30573. Ext.define('Ext.fx.animation.Fade', {
  30574. extend: Ext.fx.animation.Abstract,
  30575. alternateClassName: 'Ext.fx.animation.FadeIn',
  30576. alias: [
  30577. 'animation.fade',
  30578. 'animation.fadeIn'
  30579. ],
  30580. config: {
  30581. out: false,
  30582. before: {
  30583. display: null,
  30584. opacity: 0
  30585. },
  30586. after: {
  30587. opacity: null
  30588. },
  30589. reverse: null
  30590. },
  30591. updateOut: function(newOut) {
  30592. var to = this.getTo(),
  30593. from = this.getFrom();
  30594. if (newOut) {
  30595. from.set('opacity', 1);
  30596. to.set('opacity', 0);
  30597. } else {
  30598. from.set('opacity', 0);
  30599. to.set('opacity', 1);
  30600. }
  30601. }
  30602. });
  30603. Ext.define('Ext.fx.animation.FadeOut', {
  30604. extend: Ext.fx.animation.Fade,
  30605. alias: 'animation.fadeOut',
  30606. config: {
  30607. out: true,
  30608. before: {}
  30609. }
  30610. });
  30611. Ext.define('Ext.fx.animation.Flip', {
  30612. extend: Ext.fx.animation.Abstract,
  30613. alias: 'animation.flip',
  30614. config: {
  30615. easing: 'ease-in',
  30616. direction: 'right',
  30617. half: false,
  30618. out: null
  30619. },
  30620. getData: function() {
  30621. var me = this,
  30622. from = me.getFrom(),
  30623. to = me.getTo(),
  30624. direction = me.getDirection(),
  30625. out = me.getOut(),
  30626. half = me.getHalf(),
  30627. rotate = half ? 90 : 180,
  30628. fromScale = 1,
  30629. toScale = 1,
  30630. fromRotateX = 0,
  30631. fromRotateY = 0,
  30632. toRotateX = 0,
  30633. toRotateY = 0;
  30634. if (out) {
  30635. toScale = 0.8;
  30636. } else {
  30637. fromScale = 0.8;
  30638. }
  30639. switch (direction) {
  30640. case this.DIRECTION_UP:
  30641. case this.DIRECTION_TOP:
  30642. if (out) {
  30643. toRotateX = rotate;
  30644. } else {
  30645. fromRotateX = -rotate;
  30646. };
  30647. break;
  30648. case this.DIRECTION_DOWN:
  30649. case this.DIRECTION_BOTTOM:
  30650. if (out) {
  30651. toRotateX = -rotate;
  30652. } else {
  30653. fromRotateX = rotate;
  30654. };
  30655. break;
  30656. case this.DIRECTION_RIGHT:
  30657. if (out) {
  30658. toRotateY = rotate;
  30659. } else {
  30660. fromRotateY = -rotate;
  30661. };
  30662. break;
  30663. case this.DIRECTION_LEFT:
  30664. if (out) {
  30665. toRotateY = -rotate;
  30666. } else {
  30667. fromRotateY = rotate;
  30668. };
  30669. break;
  30670. }
  30671. from.setTransform({
  30672. rotateX: fromRotateX,
  30673. rotateY: fromRotateY,
  30674. scale: fromScale
  30675. });
  30676. to.setTransform({
  30677. rotateX: toRotateX,
  30678. rotateY: toRotateY,
  30679. scale: toScale
  30680. });
  30681. return this.callParent();
  30682. }
  30683. });
  30684. Ext.define('Ext.fx.animation.Pop', {
  30685. extend: Ext.fx.animation.Abstract,
  30686. alias: [
  30687. 'animation.pop',
  30688. 'animation.popIn'
  30689. ],
  30690. alternateClassName: 'Ext.fx.animation.PopIn',
  30691. config: {
  30692. out: false,
  30693. before: {
  30694. display: null,
  30695. opacity: 0
  30696. },
  30697. after: {
  30698. opacity: null
  30699. }
  30700. },
  30701. getData: function() {
  30702. var to = this.getTo(),
  30703. from = this.getFrom(),
  30704. out = this.getOut();
  30705. if (out) {
  30706. from.set('opacity', 1);
  30707. from.setTransform({
  30708. scale: 1
  30709. });
  30710. to.set('opacity', 0);
  30711. to.setTransform({
  30712. scale: 0
  30713. });
  30714. } else {
  30715. from.set('opacity', 0);
  30716. from.setTransform({
  30717. scale: 0
  30718. });
  30719. to.set('opacity', 1);
  30720. to.setTransform({
  30721. scale: 1
  30722. });
  30723. }
  30724. return this.callParent(arguments);
  30725. }
  30726. });
  30727. Ext.define('Ext.fx.animation.PopOut', {
  30728. extend: Ext.fx.animation.Pop,
  30729. alias: 'animation.popOut',
  30730. config: {
  30731. out: true,
  30732. before: {}
  30733. }
  30734. });
  30735. Ext.define('Ext.fx.Animation', {
  30736. constructor: function(config) {
  30737. var defaultClass = Ext.fx.animation.Abstract,
  30738. type;
  30739. if (typeof config == 'string') {
  30740. type = config;
  30741. config = {};
  30742. } else if (config && config.type) {
  30743. type = config.type;
  30744. }
  30745. if (type) {
  30746. defaultClass = Ext.ClassManager.getByAlias('animation.' + type);
  30747. if (!defaultClass) {
  30748. Ext.Logger.error("Invalid animation type of: '" + type + "'");
  30749. }
  30750. }
  30751. return Ext.factory(config, defaultClass);
  30752. }
  30753. });
  30754. Ext.define('Ext.app.EventDomain', {
  30755. statics: {
  30756. instances: {}
  30757. },
  30758. isEventDomain: true,
  30759. isInstance: false,
  30760. constructor: function() {
  30761. var me = this;
  30762. if (!me.isInstance) {
  30763. Ext.app.EventDomain.instances[me.type] = me;
  30764. }
  30765. me.bus = {};
  30766. me.monitoredClasses = [];
  30767. },
  30768. dispatch: function(target, ev, args) {
  30769. ev = Ext.canonicalEventName(ev);
  30770. var me = this,
  30771. bus = me.bus,
  30772. selectors = bus[ev],
  30773. selector, controllers, id, info, events, len, i, event;
  30774. if (!selectors) {
  30775. return true;
  30776. }
  30777. for (selector in selectors) {
  30778. if (selectors.hasOwnProperty(selector) && me.match(target, selector, me.controller)) {
  30779. controllers = selectors[selector];
  30780. for (id in controllers) {
  30781. if (controllers.hasOwnProperty(id)) {
  30782. info = controllers[id];
  30783. if (info.controller.isActive()) {
  30784. events = info.list;
  30785. len = events.length;
  30786. for (i = 0; i < len; i++) {
  30787. event = events[i];
  30788. if (event.fire.apply(event, args) === false) {
  30789. return false;
  30790. }
  30791. }
  30792. }
  30793. }
  30794. }
  30795. }
  30796. }
  30797. return true;
  30798. },
  30799. listen: function(selectors, controller) {
  30800. var me = this,
  30801. bus = me.bus,
  30802. idProperty = me.idProperty,
  30803. monitoredClasses = me.monitoredClasses,
  30804. monitoredClassesCount = monitoredClasses.length,
  30805. controllerId = controller.getId(),
  30806. isComponentDomain = (me.type === 'component'),
  30807. refMap = isComponentDomain ? controller.getRefMap() : null,
  30808. i, tree, info, selector, options, listener, scope, event, listeners, ev, classHasListeners;
  30809. for (selector in selectors) {
  30810. listeners = selectors[selector];
  30811. if (isComponentDomain) {
  30812. selector = refMap[selector] || selector;
  30813. }
  30814. if (listeners) {
  30815. if (idProperty) {
  30816. if (!/^[*#]/.test(selector)) {
  30817. Ext.raise('Selectors containing id should begin with #');
  30818. }
  30819. selector = selector === '*' ? selector : selector.substring(1);
  30820. }
  30821. for (ev in listeners) {
  30822. options = null;
  30823. listener = listeners[ev];
  30824. scope = controller;
  30825. ev = Ext.canonicalEventName(ev);
  30826. event = new Ext.util.Event(controller, ev);
  30827. if (Ext.isObject(listener)) {
  30828. options = listener;
  30829. listener = options.fn;
  30830. scope = options.scope || controller;
  30831. delete options.fn;
  30832. delete options.scope;
  30833. }
  30834. if ((!options || !options.scope) && typeof listener === 'string') {
  30835. if (!scope[listener]) {
  30836. Ext.raise('Cannot resolve "' + listener + '" on controller.');
  30837. }
  30838. scope = null;
  30839. }
  30840. else if (typeof listener === 'string') {
  30841. listener = scope[listener];
  30842. }
  30843. event.addListener(listener, scope, options);
  30844. for (i = 0; i < monitoredClassesCount; ++i) {
  30845. classHasListeners = monitoredClasses[i].hasListeners;
  30846. if (classHasListeners) {
  30847. classHasListeners._incr_(ev);
  30848. }
  30849. }
  30850. tree = bus[ev] || (bus[ev] = {});
  30851. tree = tree[selector] || (tree[selector] = {});
  30852. info = tree[controllerId] || (tree[controllerId] = {
  30853. controller: controller,
  30854. list: []
  30855. });
  30856. info.list.push(event);
  30857. }
  30858. }
  30859. }
  30860. },
  30861. match: function(target, selector) {
  30862. var idProperty = this.idProperty;
  30863. if (idProperty) {
  30864. return selector === '*' || target[idProperty] === selector;
  30865. }
  30866. return false;
  30867. },
  30868. monitor: function(observable) {
  30869. var domain = this,
  30870. prototype = observable.isInstance ? observable : observable.prototype,
  30871. doFireEvent = prototype.doFireEvent;
  30872. domain.monitoredClasses.push(observable);
  30873. prototype.doFireEvent = function(ev, args) {
  30874. var me = this,
  30875. ret;
  30876. ret = doFireEvent.apply(me, arguments);
  30877. if (ret !== false && !me.destroyed && !me.isSuspended(ev)) {
  30878. ret = domain.dispatch(me, ev, args);
  30879. }
  30880. return ret;
  30881. };
  30882. },
  30883. unlisten: function(controllerId) {
  30884. var bus = this.bus,
  30885. id = controllerId,
  30886. monitoredClasses = this.monitoredClasses,
  30887. monitoredClassesCount = monitoredClasses.length,
  30888. controllers, ev, events, len, item, selector, selectors, i, j, info, classHasListeners;
  30889. if (controllerId.isController) {
  30890. id = controllerId.getId();
  30891. }
  30892. for (ev in bus) {
  30893. ev = Ext.canonicalEventName(ev);
  30894. if (bus.hasOwnProperty(ev) && (selectors = bus[ev])) {
  30895. for (selector in selectors) {
  30896. controllers = selectors[selector];
  30897. info = controllers[id];
  30898. if (info) {
  30899. events = info.list;
  30900. if (events) {
  30901. for (i = 0 , len = events.length; i < len; ++i) {
  30902. item = events[i];
  30903. item.clearListeners();
  30904. for (j = 0; j < monitoredClassesCount; ++j) {
  30905. classHasListeners = monitoredClasses[j].hasListeners;
  30906. if (classHasListeners) {
  30907. classHasListeners._decr_(item.name);
  30908. }
  30909. }
  30910. }
  30911. delete controllers[id];
  30912. }
  30913. }
  30914. }
  30915. }
  30916. }
  30917. },
  30918. destroy: function() {
  30919. this.monitoredClasses = this.bus = null;
  30920. this.callParent();
  30921. }
  30922. });
  30923. Ext.define('Ext.app.domain.Component', {
  30924. extend: Ext.app.EventDomain,
  30925. singleton: true,
  30926. type: 'component',
  30927. constructor: function() {
  30928. this.callParent();
  30929. this.monitor(Ext.Widget);
  30930. },
  30931. dispatch: function(target, ev, args) {
  30932. var controller = target.lookupController(false),
  30933. domain, view;
  30934. while (controller) {
  30935. domain = controller.compDomain;
  30936. if (domain) {
  30937. if (domain.dispatch(target, ev, args) === false) {
  30938. return false;
  30939. }
  30940. }
  30941. view = controller.getView();
  30942. controller = view ? view.lookupController(true) : null;
  30943. }
  30944. return this.callParent([
  30945. target,
  30946. ev,
  30947. args
  30948. ]);
  30949. },
  30950. match: function(target, selector) {
  30951. return target.is(selector);
  30952. }
  30953. });
  30954. Ext.define('Ext.app.EventBus', {
  30955. singleton: true,
  30956. constructor: function() {
  30957. var me = this,
  30958. domains = Ext.app.EventDomain.instances;
  30959. me.callParent();
  30960. me.domains = domains;
  30961. me.bus = domains.component.bus;
  30962. },
  30963. control: function(selectors, controller) {
  30964. return this.domains.component.listen(selectors, controller);
  30965. },
  30966. listen: function(to, controller) {
  30967. var domains = this.domains,
  30968. domain;
  30969. for (domain in to) {
  30970. if (to.hasOwnProperty(domain)) {
  30971. domains[domain].listen(to[domain], controller);
  30972. }
  30973. }
  30974. },
  30975. unlisten: function(controllerId) {
  30976. var domains = Ext.app.EventDomain.instances,
  30977. domain;
  30978. for (domain in domains) {
  30979. domains[domain].unlisten(controllerId);
  30980. }
  30981. }
  30982. });
  30983. Ext.define('Ext.app.domain.Global', {
  30984. extend: Ext.app.EventDomain,
  30985. singleton: true,
  30986. type: 'global',
  30987. constructor: function() {
  30988. var me = this;
  30989. me.callParent();
  30990. me.monitor(Ext.GlobalEvents);
  30991. },
  30992. listen: function(listeners, controller) {
  30993. this.callParent([
  30994. {
  30995. global: listeners
  30996. },
  30997. controller
  30998. ]);
  30999. },
  31000. match: Ext.returnTrue
  31001. });
  31002. Ext.define('Ext.route.Handler', {
  31003. lazy: false,
  31004. statics: {
  31005. fromRouteConfig: function(config, scope) {
  31006. var handler = {
  31007. action: config.action,
  31008. before: config.before,
  31009. lazy: config.lazy,
  31010. exit: config.exit,
  31011. scope: scope,
  31012. single: config.single
  31013. };
  31014. return new this(handler);
  31015. }
  31016. },
  31017. constructor: function(config) {
  31018. Ext.apply(this, config);
  31019. }
  31020. });
  31021. Ext.define('Ext.route.Action', {
  31022. config: {
  31023. actions: null,
  31024. befores: null,
  31025. urlParams: []
  31026. },
  31027. started: false,
  31028. stopped: false,
  31029. constructor: function(config) {
  31030. var me = this;
  31031. me.deferred = new Ext.Deferred();
  31032. me.resume = me.resume.bind(me);
  31033. me.stop = me.stop.bind(me);
  31034. me.initConfig(config);
  31035. me.callParent([
  31036. config
  31037. ]);
  31038. },
  31039. applyActions: function(actions) {
  31040. if (actions) {
  31041. actions = Ext.Array.from(actions);
  31042. }
  31043. return actions;
  31044. },
  31045. applyBefores: function(befores) {
  31046. if (befores) {
  31047. befores = Ext.Array.from(befores);
  31048. }
  31049. return befores;
  31050. },
  31051. destroy: function() {
  31052. this.deferred = null;
  31053. this.setBefores(null).setActions(null).setUrlParams(null);
  31054. this.callParent();
  31055. },
  31056. resume: function() {
  31057. return this.next();
  31058. },
  31059. stop: function() {
  31060. this.stopped = true;
  31061. return this.done();
  31062. },
  31063. next: function() {
  31064. var me = this,
  31065. actions = me.getActions(),
  31066. befores = me.getBefores(),
  31067. urlParams = me.getUrlParams(),
  31068. config, ret, args;
  31069. if (Ext.isArray(urlParams)) {
  31070. args = urlParams.slice();
  31071. } else {
  31072. args = [
  31073. urlParams
  31074. ];
  31075. }
  31076. if (me.stopped || (befores ? !befores.length : true) && (actions ? !actions.length : true)) {
  31077. me.done();
  31078. } else {
  31079. if (befores && befores.length) {
  31080. config = befores.shift();
  31081. args.push(me);
  31082. ret = Ext.callback(config.fn, config.scope, args);
  31083. if (ret && ret.then) {
  31084. ret.then(function(arg) {
  31085. me.resume(arg);
  31086. }, function(arg) {
  31087. me.stop(arg);
  31088. });
  31089. }
  31090. } else if (actions && actions.length) {
  31091. config = actions.shift();
  31092. Ext.callback(config.fn, config.scope, args);
  31093. me.next();
  31094. } else {
  31095. me.next();
  31096. }
  31097. }
  31098. return me;
  31099. },
  31100. run: function() {
  31101. var deferred = this.deferred;
  31102. if (!this.started) {
  31103. this.next();
  31104. this.started = true;
  31105. }
  31106. return deferred.promise;
  31107. },
  31108. done: function() {
  31109. var deferred = this.deferred;
  31110. if (this.stopped) {
  31111. deferred.reject();
  31112. } else {
  31113. deferred.resolve();
  31114. }
  31115. this.destroy();
  31116. return this;
  31117. },
  31118. before: function(first, fn, scope) {
  31119. if (!Ext.isBoolean(first)) {
  31120. scope = fn;
  31121. fn = first;
  31122. first = false;
  31123. }
  31124. var befores = this.getBefores(),
  31125. config = {
  31126. fn: fn,
  31127. scope: scope
  31128. };
  31129. if (this.destroyed) {
  31130. Ext.raise('This action has has already resolved and therefore will never execute this function.');
  31131. return;
  31132. }
  31133. if (befores) {
  31134. if (first) {
  31135. befores.unshift(config);
  31136. } else {
  31137. befores.push(config);
  31138. }
  31139. } else {
  31140. this.setBefores(config);
  31141. }
  31142. return this;
  31143. },
  31144. action: function(first, fn, scope) {
  31145. if (!Ext.isBoolean(first)) {
  31146. scope = fn;
  31147. fn = first;
  31148. first = false;
  31149. }
  31150. var actions = this.getActions(),
  31151. config = {
  31152. fn: fn,
  31153. scope: scope
  31154. };
  31155. if (this.destroyed) {
  31156. Ext.raise('This action has has already resolved and therefore will never execute this function.');
  31157. return;
  31158. }
  31159. if (actions) {
  31160. if (first) {
  31161. actions.unshift(config);
  31162. } else {
  31163. actions.push(config);
  31164. }
  31165. } else {
  31166. this.setActions(config);
  31167. }
  31168. return this;
  31169. },
  31170. then: function(resolve, reject) {
  31171. if (this.destroyed) {
  31172. Ext.raise('This action has has already resolved and therefore will never execute either function.');
  31173. return;
  31174. }
  31175. return this.deferred.then(resolve, reject);
  31176. }
  31177. });
  31178. Ext.define('Ext.route.Route', {
  31179. config: {
  31180. name: null,
  31181. url: null,
  31182. allowInactive: false,
  31183. conditions: {},
  31184. caseInsensitive: false,
  31185. handlers: [],
  31186. types: {
  31187. cached: true,
  31188. $value: {
  31189. alpha: {
  31190. re: '([a-zA-Z]+)'
  31191. },
  31192. alphanum: {
  31193. re: '([a-zA-Z0-9]+|[0-9]+(?:\\.[0-9]+)?|[0-9]*(?:\\.[0-9]+){1})',
  31194. parse: function(value) {
  31195. var test;
  31196. if (value && this.numRe.test(value)) {
  31197. test = parseFloat(value);
  31198. if (!isNaN(test)) {
  31199. value = test;
  31200. }
  31201. }
  31202. return value;
  31203. }
  31204. },
  31205. num: {
  31206. re: '([0-9]+(?:\\.[0-9]+)?|[0-9]*(?:\\.[0-9]+){1})',
  31207. parse: function(value) {
  31208. if (value) {
  31209. value = parseFloat(value);
  31210. }
  31211. return value;
  31212. }
  31213. },
  31214. '...': {
  31215. re: '(.+)?',
  31216. split: '/',
  31217. parse: function(values) {
  31218. var length, i, value;
  31219. if (values) {
  31220. length = values.length;
  31221. for (i = 0; i < length; i++) {
  31222. value = parseFloat(values[i]);
  31223. if (!isNaN(value)) {
  31224. values[i] = value;
  31225. }
  31226. }
  31227. }
  31228. return values;
  31229. }
  31230. }
  31231. }
  31232. }
  31233. },
  31234. defaultMatcher: '([%a-zA-Z0-9\\-\\_\\s,]+)',
  31235. numRe: /^[0-9]*(?:\.[0-9]*)?$/,
  31236. typeParamRegex: /:{([0-9A-Za-z\_]+)(?::?([0-9A-Za-z\_]+|.{3})?)}/g,
  31237. optionalGroupRegex: /\((.+?)\)/g,
  31238. paramMatchingRegex: /:([0-9A-Za-z\_]+)/g,
  31239. isRoute: true,
  31240. constructor: function(config) {
  31241. var me = this,
  31242. url;
  31243. this.initConfig(config);
  31244. url = me.getUrl().replace(me.optionalGroupRegex, function(match, middle) {
  31245. return '(?:' + middle + ')?';
  31246. });
  31247. if (url.match(me.typeParamRegex)) {
  31248. me.handleNamedPattern(url);
  31249. } else {
  31250. me.handlePositionalPattern(url);
  31251. }
  31252. },
  31253. handlePositionalPattern: function(url) {
  31254. var me = this;
  31255. me.paramsInMatchString = url.match(me.paramMatchingRegex) || [];
  31256. me.matcherRegex = me.createMatcherRegex(url);
  31257. me.mode = 'positional';
  31258. },
  31259. handleNamedPattern: function(url) {
  31260. var me = this,
  31261. typeParamRegex = me.typeParamRegex,
  31262. conditions = me.getConditions(),
  31263. types = me.getTypes(),
  31264. defaultMatcher = me.defaultMatcher,
  31265. params = {},
  31266. re = url.replace(typeParamRegex, function(match, param, typeMatch) {
  31267. var type = typeMatch && types[typeMatch],
  31268. matcher = conditions[param] || type || defaultMatcher;
  31269. if (params[param]) {
  31270. Ext.raise('"' + param + '" already defined in route "' + url + '"');
  31271. }
  31272. if (typeMatch && !type) {
  31273. Ext.raise('Unknown parameter type "' + typeMatch + '" in route "' + url + '"');
  31274. }
  31275. if (Ext.isObject(matcher)) {
  31276. matcher = matcher.re;
  31277. }
  31278. params[param] = {
  31279. matcher: matcher,
  31280. type: typeMatch
  31281. };
  31282. return matcher;
  31283. });
  31284. if (re.search(me.paramMatchingRegex) !== -1) {
  31285. Ext.raise('URL parameter mismatch. Positional url parameter found while in named mode.');
  31286. }
  31287. me.paramsInMatchString = params;
  31288. me.matcherRegex = new RegExp('^' + re + '$', me.getCaseInsensitive() ? 'i' : '');
  31289. me.mode = 'named';
  31290. },
  31291. recognize: function(url) {
  31292. var me = this,
  31293. recognized = me.recognizes(url),
  31294. handlers, length, hasHandler, i, handler, matches, urlParams, arg, params;
  31295. if (recognized) {
  31296. handlers = me.getHandlers();
  31297. length = handlers.length;
  31298. for (i = 0; i < length; i++) {
  31299. handler = handlers[i];
  31300. if (handler.lastToken !== url) {
  31301. hasHandler = true;
  31302. break;
  31303. }
  31304. }
  31305. if (!hasHandler && url === me.lastToken) {
  31306. return true;
  31307. }
  31308. matches = me.matchesFor(url);
  31309. urlParams = me.getUrlParams(url);
  31310. return Ext.applyIf(matches, {
  31311. historyUrl: url,
  31312. urlParams: urlParams
  31313. });
  31314. }
  31315. return false;
  31316. },
  31317. getUrlParams: function(url) {
  31318. if (this.mode === 'named') {
  31319. return this.getNamedUrlParams(url);
  31320. } else {
  31321. return this.getPositionalUrlParams(url);
  31322. }
  31323. },
  31324. getPositionalUrlParams: function(url) {
  31325. var params = [],
  31326. conditions = this.getConditions(),
  31327. keys = this.paramsInMatchString,
  31328. values = url.match(this.matcherRegex),
  31329. length = keys.length,
  31330. i, key, type, value;
  31331. values.shift();
  31332. for (i = 0; i < length; i++) {
  31333. key = keys[i];
  31334. value = values[i];
  31335. if (conditions[key]) {
  31336. type = conditions[key];
  31337. } else if (key[0] === ':') {
  31338. key = key.substr(1);
  31339. if (conditions[key]) {
  31340. type = conditions[key];
  31341. }
  31342. }
  31343. value = this.parseValue(value, type);
  31344. if (Ext.isDefined(value) && value !== '') {
  31345. if (Ext.isArray(value)) {
  31346. params.push.apply(params, value);
  31347. } else {
  31348. params.push(value);
  31349. }
  31350. }
  31351. }
  31352. return params;
  31353. },
  31354. getNamedUrlParams: function(url) {
  31355. var conditions = this.getConditions(),
  31356. types = this.getTypes(),
  31357. params = {},
  31358. keys = this.paramsInMatchString,
  31359. values = url.match(this.matcherRegex),
  31360. name, obj, value, type, condition;
  31361. values.shift();
  31362. for (name in keys) {
  31363. obj = keys[name];
  31364. value = values.shift();
  31365. condition = conditions[name];
  31366. type = types[obj.type];
  31367. if (condition || type) {
  31368. type = Ext.merge({}, condition, types[obj.type]);
  31369. }
  31370. params[name] = this.parseValue(value, type);
  31371. }
  31372. return params;
  31373. },
  31374. parseValue: function(value, type) {
  31375. if (type) {
  31376. if (value && type.split) {
  31377. value = value.split(type.split);
  31378. if (!value[0]) {
  31379. value.shift();
  31380. }
  31381. if (!value[value.length - 1]) {
  31382. value.pop();
  31383. }
  31384. }
  31385. if (type.parse) {
  31386. value = type.parse.call(this, value);
  31387. }
  31388. }
  31389. if (!value && Ext.isString(value)) {
  31390. value = undefined;
  31391. }
  31392. return value;
  31393. },
  31394. recognizes: function(url) {
  31395. return this.matcherRegex.test(url);
  31396. },
  31397. execute: function(token, argConfig) {
  31398. var me = this,
  31399. allowInactive = me.getAllowInactive(),
  31400. handlers = me.getHandlers(),
  31401. queue = Ext.route.Router.getQueueRoutes(),
  31402. length = handlers.length,
  31403. befores = [],
  31404. actions = [],
  31405. urlParams = (argConfig && argConfig.urlParams) || [],
  31406. i, handler, scope, action, promises, single, remover;
  31407. me.lastToken = token;
  31408. if (!queue) {
  31409. promises = [];
  31410. }
  31411. return new Ext.Promise(function(resolve, reject) {
  31412. if (argConfig === false) {
  31413. reject();
  31414. } else {
  31415. if (queue) {
  31416. action = new Ext.route.Action({
  31417. urlParams: urlParams
  31418. });
  31419. }
  31420. for (i = 0; i < length; i++) {
  31421. handler = handlers[i];
  31422. if (token != null && handler.lastToken === token) {
  31423. continue;
  31424. }
  31425. scope = handler.scope;
  31426. handler.lastToken = token;
  31427. if (!allowInactive && scope.isActive && !scope.isActive()) {
  31428. continue;
  31429. }
  31430. if (!queue) {
  31431. action = new Ext.route.Action({
  31432. urlParams: urlParams
  31433. });
  31434. }
  31435. single = handler.single;
  31436. if (handler.before) {
  31437. action.before(handler.before, scope);
  31438. }
  31439. if (handler.action) {
  31440. action.action(handler.action, scope);
  31441. }
  31442. if (single) {
  31443. remover = Ext.bind(me.removeHandler, me, [
  31444. null,
  31445. handler
  31446. ]);
  31447. if (single === true) {
  31448. if (handler.action) {
  31449. action.action(remover, me);
  31450. } else {
  31451. action.before(function() {
  31452. remover();
  31453. return Ext.Promise.resolve();
  31454. }, me);
  31455. }
  31456. } else {
  31457. action.before(single === 'before', function() {
  31458. remover();
  31459. return Ext.Promise.resolve();
  31460. }, me);
  31461. }
  31462. }
  31463. if (!queue) {
  31464. if (Ext.fireEvent('beforeroute', action, me) === false) {
  31465. action.destroy();
  31466. } else {
  31467. promises.push(action.run());
  31468. }
  31469. }
  31470. }
  31471. if (queue) {
  31472. if (Ext.fireEvent('beforeroute', action, me) === false) {
  31473. action.destroy();
  31474. reject();
  31475. } else {
  31476. action.run().then(resolve, reject);
  31477. }
  31478. } else {
  31479. Ext.Promise.all(promises).then(resolve, reject);
  31480. }
  31481. }
  31482. });
  31483. },
  31484. matchesFor: function(url) {
  31485. var params = {},
  31486. keys = this.mode === 'named' ? Ext.Object.getKeys(this.paramsInMatchString) : this.paramsInMatchString,
  31487. values = url.match(this.matcherRegex),
  31488. length = keys.length,
  31489. i;
  31490. values.shift();
  31491. for (i = 0; i < length; i++) {
  31492. params[keys[i].replace(':', '')] = values[i];
  31493. }
  31494. return params;
  31495. },
  31496. createMatcherRegex: function(url) {
  31497. var me = this,
  31498. paramsInMatchString = me.paramsInMatchString,
  31499. conditions = me.getConditions(),
  31500. defaultMatcher = me.defaultMatcher,
  31501. length = paramsInMatchString.length,
  31502. modifiers = me.getCaseInsensitive() ? 'i' : '',
  31503. i, param, matcher;
  31504. if (url === '*') {
  31505. url = url.replace('*', '\\*');
  31506. } else {
  31507. for (i = 0; i < length; i++) {
  31508. param = paramsInMatchString[i];
  31509. if (conditions[param]) {
  31510. matcher = conditions[param];
  31511. }
  31512. else if (param[0] === ':' && conditions[param.substr(1)]) {
  31513. matcher = conditions[param.substr(1)];
  31514. } else {
  31515. matcher = defaultMatcher;
  31516. }
  31517. if (Ext.isObject(matcher)) {
  31518. matcher = matcher.re;
  31519. }
  31520. url = url.replace(new RegExp(param), matcher || defaultMatcher);
  31521. }
  31522. }
  31523. return new RegExp('^' + url + '$', modifiers);
  31524. },
  31525. addHandler: function(handler) {
  31526. var handlers = this.getHandlers();
  31527. if (!handler.isInstance) {
  31528. handler = new Ext.route.Handler(handler);
  31529. }
  31530. handlers.push(handler);
  31531. return handler.route = this;
  31532. },
  31533. removeHandler: function(scope, handler) {
  31534. var handlers = this.getHandlers(),
  31535. length = handlers.length,
  31536. newHandlers = [],
  31537. i, item;
  31538. for (i = 0; i < length; i++) {
  31539. item = handlers[i];
  31540. if (handler) {
  31541. if (item !== handler) {
  31542. newHandlers.push(item);
  31543. }
  31544. } else if (item.scope !== scope) {
  31545. newHandlers.push(item);
  31546. }
  31547. }
  31548. this.setHandlers(newHandlers);
  31549. return this;
  31550. },
  31551. clearLastTokens: function() {
  31552. var handlers = this.getHandlers(),
  31553. length = handlers.length,
  31554. i;
  31555. for (i = 0; i < length; i++) {
  31556. handlers[i].lastToken = null;
  31557. }
  31558. this.lastToken = null;
  31559. },
  31560. onExit: function() {
  31561. var me = this,
  31562. handlers = me.getHandlers(),
  31563. allowInactive = me.getAllowInactive(),
  31564. length = handlers.length,
  31565. action = new Ext.route.Action({
  31566. urlParams: [
  31567. me.lastToken
  31568. ]
  31569. }),
  31570. i, handler, scope;
  31571. me.clearLastTokens();
  31572. for (i = 0; i < length; i++) {
  31573. handler = handlers[i];
  31574. if (handler.exit) {
  31575. scope = handler.scope;
  31576. if (!allowInactive && scope.isActive && !scope.isActive()) {
  31577. continue;
  31578. }
  31579. action.action(handler.exit, scope);
  31580. }
  31581. }
  31582. if (Ext.fireEvent('beforerouteexit', action, me) === false) {
  31583. action.destroy();
  31584. } else {
  31585. action.run();
  31586. }
  31587. }
  31588. });
  31589. Ext.define('Ext.util.Observable', {
  31590. extend: Ext.mixin.Observable,
  31591. $applyConfigs: true
  31592. }, function(Observable) {
  31593. var Super = Ext.mixin.Observable;
  31594. Observable.releaseCapture = Super.releaseCapture;
  31595. Observable.capture = Super.capture;
  31596. Observable.captureArgs = Super.captureArgs;
  31597. Observable.observe = Observable.observeClass = Super.observe;
  31598. });
  31599. Ext.define('Ext.util.History', {
  31600. singleton: true,
  31601. alternateClassName: 'Ext.History',
  31602. mixins: {
  31603. observable: Ext.util.Observable
  31604. },
  31605. useTopWindow: false,
  31606. hashRe: /^(#?!?)/,
  31607. constructor: function() {
  31608. var me = this;
  31609. me.ready = false;
  31610. me.currentToken = null;
  31611. me.mixins.observable.constructor.call(me);
  31612. },
  31613. getHash: function() {
  31614. return (this.win.location.hash || '').replace(this.hashRe, '');
  31615. },
  31616. setHash: function(hash, replace) {
  31617. var me = this,
  31618. hashRe = me.hashRe,
  31619. loc = me.win.location;
  31620. hash = hash.replace(hashRe, me.hashbang ? '#!' : '#');
  31621. try {
  31622. if (replace) {
  31623. loc.replace(hash);
  31624. } else {
  31625. loc.hash = hash;
  31626. }
  31627. me.currentToken = hash.replace(hashRe, '');
  31628. } catch (e) {}
  31629. },
  31630. handleStateChange: function(token) {
  31631. token = token.replace(this.hashRe, '');
  31632. this.fireEvent('change', this.currentToken = token);
  31633. },
  31634. startUp: function() {
  31635. var me = this;
  31636. me.currentToken = me.getHash();
  31637. Ext.get(me.win).on('hashchange', me.onHashChange, me);
  31638. me.ready = true;
  31639. me.fireEvent('ready', me);
  31640. },
  31641. onHashChange: function() {
  31642. var me = this,
  31643. newHash = me.getHash();
  31644. if (newHash !== me.hash) {
  31645. me.hash = newHash;
  31646. me.handleStateChange(newHash);
  31647. }
  31648. },
  31649. init: function(onReady, scope) {
  31650. var me = this;
  31651. if (me.ready) {
  31652. Ext.callback(onReady, scope, [
  31653. me
  31654. ]);
  31655. return;
  31656. }
  31657. if (!Ext.isReady) {
  31658. Ext.onInternalReady(function() {
  31659. me.init(onReady, scope);
  31660. });
  31661. return;
  31662. }
  31663. me.win = me.useTopWindow ? window.top : window;
  31664. me.hash = me.getHash();
  31665. if (onReady) {
  31666. me.on('ready', onReady, scope, {
  31667. single: true
  31668. });
  31669. }
  31670. me.startUp();
  31671. },
  31672. add: function(token, preventDuplicates) {
  31673. var me = this,
  31674. set = false;
  31675. if (preventDuplicates === false || me.getToken() !== token) {
  31676. me.setHash(token);
  31677. set = true;
  31678. }
  31679. return set;
  31680. },
  31681. replace: function(token, preventDuplicates) {
  31682. var me = this,
  31683. set = false;
  31684. if (preventDuplicates === false || me.getToken() !== token) {
  31685. this.setHash(token, true);
  31686. set = true;
  31687. }
  31688. return set;
  31689. },
  31690. back: function() {
  31691. this.win.history.go(-1);
  31692. },
  31693. forward: function() {
  31694. this.win.history.go(1);
  31695. },
  31696. getToken: function() {
  31697. return this.ready ? this.currentToken : this.getHash();
  31698. }
  31699. });
  31700. Ext.define('Ext.route.Router', {
  31701. singleton: true,
  31702. config: {
  31703. hashbang: null,
  31704. multipleToken: '|',
  31705. queueRoutes: true
  31706. },
  31707. constructor: function() {
  31708. var History = Ext.util.History;
  31709. if (!History.ready) {
  31710. History.init();
  31711. }
  31712. History.on('change', this.onStateChange, this);
  31713. this.initConfig();
  31714. this.clear();
  31715. },
  31716. updateHashbang: function(hashbang) {
  31717. Ext.util.History.hashbang = hashbang;
  31718. },
  31719. onStateChange: function(token) {
  31720. var me = this,
  31721. tokens = token.split(me.getMultipleToken()),
  31722. queue, i, length;
  31723. if (me.isSuspended) {
  31724. queue = me.suspendedQueue;
  31725. i = 0;
  31726. length = tokens.length;
  31727. if (queue) {
  31728. for (; i < length; i++) {
  31729. token = tokens[i];
  31730. if (!Ext.Array.contains(queue, token)) {
  31731. queue.push(token);
  31732. }
  31733. }
  31734. }
  31735. } else {
  31736. me.handleBefore(tokens);
  31737. }
  31738. },
  31739. handleBefore: function(tokens) {
  31740. var me = this,
  31741. action = new Ext.route.Action();
  31742. if (Ext.fireEvent('beforeroutes', action, tokens) === false) {
  31743. action.destroy();
  31744. } else {
  31745. action.run().then(me.handleBeforeRoute.bind(me, tokens), Ext.emptyFn);
  31746. }
  31747. },
  31748. handleBeforeRoute: function(tokens) {
  31749. var me = this,
  31750. beforeRoute = me.getByName('*');
  31751. if (beforeRoute) {
  31752. beforeRoute.execute().then(me.doRun.bind(me, tokens), Ext.emptyFn);
  31753. } else {
  31754. me.doRun(tokens);
  31755. }
  31756. },
  31757. doRun: function(tokens) {
  31758. var me = this,
  31759. app = me.application,
  31760. routes = me.routes,
  31761. i = 0,
  31762. length = tokens.length,
  31763. matched = {},
  31764. unmatched = [],
  31765. token, found, name, route, recognize;
  31766. for (; i < length; i++) {
  31767. token = tokens[i];
  31768. found = false;
  31769. for (name in routes) {
  31770. route = routes[name];
  31771. recognize = route.recognize(token);
  31772. if (recognize) {
  31773. found = true;
  31774. if (recognize !== true) {
  31775. route.execute(token, recognize).then(null, Ext.bind(me.onRouteRejection, me, [
  31776. route
  31777. ], 0));
  31778. }
  31779. Ext.Array.remove(unmatched, route);
  31780. if (!matched[name]) {
  31781. matched[name] = 1;
  31782. }
  31783. } else if (!matched[name]) {
  31784. unmatched.push(route);
  31785. }
  31786. }
  31787. if (!found) {
  31788. if (app) {
  31789. app.fireEvent('unmatchedroute', token);
  31790. }
  31791. Ext.fireEvent('unmatchedroute', token);
  31792. }
  31793. }
  31794. i = 0;
  31795. length = unmatched.length;
  31796. for (; i < length; i++) {
  31797. unmatched[i].onExit();
  31798. }
  31799. },
  31800. onRouteRejection: function(route, error) {
  31801. Ext.fireEvent('routereject', route, error);
  31802. if (error) {
  31803. Ext.raise(error);
  31804. }
  31805. },
  31806. connect: function(url, config, instance) {
  31807. var routes = this.routes,
  31808. delimiter = this.getMultipleToken(),
  31809. name = config.name || url,
  31810. handler, route;
  31811. if (url[0] === '!') {
  31812. if (!Ext.util.History.hashbang) {
  31813. Ext.log({
  31814. level: 'error',
  31815. 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'
  31816. });
  31817. }
  31818. url = url.substr(1);
  31819. this.setHashbang(true);
  31820. }
  31821. if (Ext.isString(config)) {
  31822. config = {
  31823. action: config
  31824. };
  31825. }
  31826. handler = Ext.route.Handler.fromRouteConfig(config, instance);
  31827. route = routes[name];
  31828. if (!route) {
  31829. config.name = name;
  31830. config.url = url;
  31831. route = routes[name] = new Ext.route.Route(config);
  31832. }
  31833. route.addHandler(handler);
  31834. if (handler.lazy) {
  31835. var currentHash = Ext.util.History.getToken(),
  31836. tokens = currentHash.split(delimiter),
  31837. length = tokens.length,
  31838. matched = [],
  31839. i, token;
  31840. for (i = 0; i < length; i++) {
  31841. token = tokens[i];
  31842. if (Ext.Array.indexOf(matched, token) === -1 && route.recognize(token)) {
  31843. matched.push(token);
  31844. }
  31845. }
  31846. this.onStateChange(matched.join(delimiter));
  31847. }
  31848. return handler;
  31849. },
  31850. disconnect: function(instance, config) {
  31851. var routes = this.routes,
  31852. route, name;
  31853. if (config) {
  31854. route = config.route || this.getByName(config.name || config.url);
  31855. if (route) {
  31856. route.removeHandler(instance, config);
  31857. }
  31858. } else {
  31859. for (name in routes) {
  31860. route = routes[name];
  31861. route.removeHandler(instance);
  31862. }
  31863. }
  31864. },
  31865. recognize: function(url) {
  31866. var routes = this.routes,
  31867. matches = [],
  31868. name, arr, i, length, route, urlParams;
  31869. for (name in routes) {
  31870. arr = routes[name];
  31871. length = arr && arr.length;
  31872. if (length) {
  31873. i = 0;
  31874. for (; i < length; i++) {
  31875. route = arr[i];
  31876. urlParams = route.recognize(url);
  31877. if (urlParams) {
  31878. matches.push({
  31879. route: route,
  31880. urlParams: urlParams
  31881. });
  31882. }
  31883. }
  31884. }
  31885. }
  31886. return matches.length ? matches : false;
  31887. },
  31888. draw: function(fn) {
  31889. fn.call(this, this);
  31890. },
  31891. clear: function() {
  31892. this.routes = {};
  31893. },
  31894. clearLastTokens: function(token) {
  31895. var routes = this.routes,
  31896. name, route;
  31897. for (name in routes) {
  31898. route = routes[name];
  31899. if (!token || route.recognize(token)) {
  31900. route.clearLastTokens();
  31901. }
  31902. }
  31903. },
  31904. getByName: function(name) {
  31905. var routes = this.routes;
  31906. if (routes) {
  31907. return routes[name];
  31908. }
  31909. },
  31910. suspend: function(trackTokens) {
  31911. this.isSuspended = true;
  31912. if (!this.suspendedQueue && trackTokens !== false) {
  31913. this.suspendedQueue = [];
  31914. }
  31915. },
  31916. resume: function(discardQueue) {
  31917. var me = this,
  31918. queue = me.suspendedQueue,
  31919. token;
  31920. if (me.isSuspended) {
  31921. me.isSuspended = false;
  31922. me.suspendedQueue = null;
  31923. if (!discardQueue && queue) {
  31924. token = queue.join(me.getMultipleToken());
  31925. me.onStateChange(token);
  31926. }
  31927. }
  31928. }
  31929. });
  31930. Ext.define('Ext.route.Mixin', {
  31931. extend: Ext.Mixin,
  31932. mixinConfig: {
  31933. id: 'routerable',
  31934. before: {
  31935. destroy: 'destroyRouterable'
  31936. }
  31937. },
  31938. config: {
  31939. routes: null
  31940. },
  31941. destroyRouterable: function() {
  31942. Ext.route.Router.disconnect(this);
  31943. },
  31944. applyRoutes: function(routes, oldRoutes) {
  31945. var Router = Ext.route.Router,
  31946. url;
  31947. if (routes) {
  31948. for (url in routes) {
  31949. routes[url] = Router.connect(url, routes[url], this);
  31950. }
  31951. }
  31952. if (oldRoutes) {
  31953. for (url in oldRoutes) {
  31954. Router.disconnect(this, oldRoutes[url]);
  31955. }
  31956. }
  31957. return routes;
  31958. },
  31959. redirectTo: function(hash, opt) {
  31960. var me = this,
  31961. currentHash = Ext.util.History.getToken(),
  31962. Router = Ext.route.Router,
  31963. delimiter = Router.getMultipleToken(),
  31964. tokens = currentHash ? currentHash.split(delimiter) : [],
  31965. length = tokens.length,
  31966. force, i, name, obj, route, token, match;
  31967. if (hash === -1) {
  31968. return Ext.util.History.back();
  31969. } else if (hash === 1) {
  31970. return Ext.util.History.forward();
  31971. } else if (hash.isModel) {
  31972. hash = hash.toUrl();
  31973. } else if (Ext.isObject(hash)) {
  31974. for (name in hash) {
  31975. obj = hash[name];
  31976. if (!Ext.isObject(obj)) {
  31977. obj = {
  31978. token: obj
  31979. };
  31980. }
  31981. if (length) {
  31982. route = Router.getByName(name);
  31983. if (route) {
  31984. match = false;
  31985. for (i = 0; i < length; i++) {
  31986. token = tokens[i];
  31987. if (route.matcherRegex.test(token)) {
  31988. match = true;
  31989. if (obj.token) {
  31990. if (obj.fn && obj.fn.call(this, token, tokens, obj) === false) {
  31991. continue;
  31992. }
  31993. tokens[i] = obj.token;
  31994. if (obj.force) {
  31995. route.lastToken = null;
  31996. }
  31997. } else {
  31998. tokens.splice(i, 1);
  31999. i--;
  32000. length--;
  32001. route.lastToken = null;
  32002. }
  32003. }
  32004. }
  32005. if (obj && obj.token && !match) {
  32006. tokens.push(obj.token);
  32007. }
  32008. }
  32009. } else if (obj && obj.token) {
  32010. tokens.push(obj.token);
  32011. }
  32012. }
  32013. hash = tokens.join(delimiter);
  32014. }
  32015. if (opt === true) {
  32016. force = opt;
  32017. opt = null;
  32018. } else if (opt) {
  32019. force = opt.force;
  32020. }
  32021. length = tokens.length;
  32022. if (force && length) {
  32023. for (i = 0; i < length; i++) {
  32024. token = tokens[i];
  32025. Router.clearLastTokens(token);
  32026. }
  32027. }
  32028. if (currentHash === hash) {
  32029. if (force) {
  32030. Router.onStateChange(hash);
  32031. }
  32032. return false;
  32033. }
  32034. if (opt && opt.replace) {
  32035. Ext.util.History.replace(hash);
  32036. } else {
  32037. Ext.util.History.add(hash);
  32038. }
  32039. return true;
  32040. },
  32041. privates: {
  32042. afterClassMixedIn: function(targetClass) {
  32043. var proto = targetClass.prototype,
  32044. routes = proto.routes;
  32045. if (routes) {
  32046. delete proto.routes;
  32047. targetClass.getConfigurator().add({
  32048. routes: routes
  32049. });
  32050. }
  32051. }
  32052. }
  32053. });
  32054. Ext.define('Ext.app.BaseController', {
  32055. mixins: [
  32056. Ext.mixin.Observable,
  32057. Ext.route.Mixin
  32058. ],
  32059. isController: true,
  32060. config: {
  32061. id: undefined,
  32062. control: null,
  32063. listen: null
  32064. },
  32065. constructor: function(config) {
  32066. var me = this;
  32067. Ext.apply(me, config);
  32068. delete me.control;
  32069. delete me.listen;
  32070. me.eventbus = Ext.app.EventBus;
  32071. me.mixins.observable.constructor.call(me, config);
  32072. },
  32073. updateId: function(id) {
  32074. this.id = id;
  32075. },
  32076. applyListen: function(listen) {
  32077. if (Ext.isObject(listen)) {
  32078. listen = Ext.clone(listen);
  32079. }
  32080. return listen;
  32081. },
  32082. applyControl: function(control) {
  32083. if (Ext.isObject(control)) {
  32084. control = Ext.clone(control);
  32085. }
  32086. return control;
  32087. },
  32088. updateControl: function(control) {
  32089. this.getId();
  32090. if (control) {
  32091. this.control(control);
  32092. }
  32093. },
  32094. updateListen: function(listen) {
  32095. this.getId();
  32096. if (listen) {
  32097. this.listen(listen);
  32098. }
  32099. },
  32100. isActive: function() {
  32101. return true;
  32102. },
  32103. control: function(selectors, listeners, controller) {
  32104. var me = this,
  32105. ctrl = controller,
  32106. obj;
  32107. if (Ext.isString(selectors)) {
  32108. obj = {};
  32109. obj[selectors] = listeners;
  32110. } else {
  32111. obj = selectors;
  32112. ctrl = listeners;
  32113. }
  32114. me.eventbus.control(obj, ctrl || me);
  32115. },
  32116. listen: function(to, controller) {
  32117. this.eventbus.listen(to, controller || this);
  32118. },
  32119. destroy: function() {
  32120. var me = this,
  32121. bus = me.eventbus;
  32122. if (bus) {
  32123. bus.unlisten(me);
  32124. me.eventbus = null;
  32125. }
  32126. me.callParent();
  32127. }
  32128. });
  32129. Ext.define('Ext.app.Util', {}, function() {
  32130. Ext.apply(Ext.app, {
  32131. namespaces: {
  32132. Ext: {}
  32133. },
  32134. addNamespaces: function(namespace) {
  32135. var namespaces = Ext.app.namespaces,
  32136. i, l;
  32137. if (!Ext.isArray(namespace)) {
  32138. namespace = [
  32139. namespace
  32140. ];
  32141. }
  32142. for (i = 0 , l = namespace.length; i < l; i++) {
  32143. namespaces[namespace[i]] = true;
  32144. }
  32145. },
  32146. clearNamespaces: function() {
  32147. Ext.app.namespaces = {};
  32148. },
  32149. getNamespace: function(className) {
  32150. var namespaces = Ext.apply({}, Ext.ClassManager.paths, Ext.app.namespaces),
  32151. deepestPrefix = '',
  32152. prefix;
  32153. for (prefix in namespaces) {
  32154. if (namespaces.hasOwnProperty(prefix) && prefix.length > deepestPrefix.length && (prefix + '.' === className.substring(0, prefix.length + 1))) {
  32155. deepestPrefix = prefix;
  32156. }
  32157. }
  32158. return deepestPrefix === '' ? undefined : deepestPrefix;
  32159. },
  32160. setupPaths: function(appName, appFolder, paths) {
  32161. var manifestPaths = Ext.manifest,
  32162. ns;
  32163. if (appName && appFolder !== null) {
  32164. manifestPaths = manifestPaths && manifestPaths.paths;
  32165. if (!manifestPaths || appFolder !== undefined) {
  32166. Ext.Loader.setPath(appName, (appFolder === undefined) ? 'app' : appFolder);
  32167. }
  32168. }
  32169. if (paths) {
  32170. for (ns in paths) {
  32171. if (paths.hasOwnProperty(ns)) {
  32172. Ext.Loader.setPath(ns, paths[ns]);
  32173. }
  32174. }
  32175. }
  32176. }
  32177. });
  32178. Ext.getNamespace = Ext.app.getNamespace;
  32179. });
  32180. Ext.define('Ext.util.Filter', {
  32181. isFilter: true,
  32182. config: {
  32183. property: null,
  32184. value: null,
  32185. filterFn: null,
  32186. id: null,
  32187. anyMatch: false,
  32188. exactMatch: false,
  32189. caseSensitive: false,
  32190. disabled: false,
  32191. disableOnEmpty: false,
  32192. operator: null,
  32193. root: null,
  32194. serializer: null,
  32195. convert: null
  32196. },
  32197. scope: null,
  32198. $configStrict: false,
  32199. generation: 0,
  32200. statics: {
  32201. createFilterFn: function(filters) {
  32202. if (!filters) {
  32203. return Ext.returnTrue;
  32204. }
  32205. return function(candidate) {
  32206. var items = filters.isCollection ? filters.items : filters,
  32207. length = items.length,
  32208. match = true,
  32209. i, filter;
  32210. for (i = 0; match && i < length; i++) {
  32211. filter = items[i];
  32212. if (!filter.getDisabled()) {
  32213. match = filter.filter(candidate);
  32214. }
  32215. }
  32216. return match;
  32217. };
  32218. },
  32219. isEqual: function(filter1, filter2) {
  32220. if (filter1.getProperty() !== filter2.getProperty()) {
  32221. return false;
  32222. }
  32223. if (filter1.getOperator() !== filter2.getOperator()) {
  32224. return false;
  32225. }
  32226. if (filter1.getValue() === filter2.getValue()) {
  32227. return true;
  32228. } else if (Ext.isArray(filter1) && Ext.isArray(filter2) && Ext.Array.equals(filter1, filter2)) {
  32229. return true;
  32230. }
  32231. return false;
  32232. },
  32233. isInvalid: function(cfg) {
  32234. if (!cfg.filterFn) {
  32235. if (!cfg.property) {
  32236. return 'A Filter requires either a property or a filterFn to be set';
  32237. }
  32238. if (!cfg.hasOwnProperty('value') && !cfg.operator) {
  32239. return 'A Filter requires either a property and value, or a filterFn to be set';
  32240. }
  32241. }
  32242. return false;
  32243. }
  32244. },
  32245. constructor: function(config) {
  32246. var warn = Ext.util.Filter.isInvalid(config);
  32247. if (warn) {
  32248. Ext.log.warn(warn);
  32249. }
  32250. this.initConfig(config);
  32251. },
  32252. preventConvert: {
  32253. 'in': 1,
  32254. notin: 1
  32255. },
  32256. filter: function(item) {
  32257. var me = this,
  32258. filterFn = me._filterFn || me.getFilterFn(),
  32259. convert = me.getConvert(),
  32260. value = me._value;
  32261. me._filterValue = value;
  32262. me.isDateValue = Ext.isDate(value);
  32263. if (me.isDateValue) {
  32264. me.dateValue = value.getTime();
  32265. }
  32266. if (convert && !me.preventConvert[me.getOperator()]) {
  32267. me._filterValue = convert.call(me.scope || me, value);
  32268. }
  32269. return filterFn.call(me.scope || me, item);
  32270. },
  32271. getId: function() {
  32272. var id = this._id;
  32273. if (!id) {
  32274. id = this.getProperty();
  32275. if (!id) {
  32276. id = Ext.id(null, 'ext-filter-');
  32277. }
  32278. this._id = id;
  32279. }
  32280. return id;
  32281. },
  32282. getFilterFn: function() {
  32283. var me = this,
  32284. filterFn = me._filterFn,
  32285. operator;
  32286. if (!filterFn) {
  32287. operator = me.getOperator();
  32288. if (operator) {
  32289. filterFn = me.operatorFns[operator];
  32290. } else {
  32291. filterFn = me.createRegexFilter();
  32292. }
  32293. me._filterFn = filterFn;
  32294. me.generatedFilterFn = true;
  32295. }
  32296. return filterFn;
  32297. },
  32298. createRegexFilter: function() {
  32299. var me = this,
  32300. anyMatch = !!me.getAnyMatch(),
  32301. exact = !!me.getExactMatch(),
  32302. value = me.getValue(),
  32303. matcher = Ext.String.createRegex(value, !anyMatch,
  32304. !anyMatch && exact,
  32305. !me.getCaseSensitive());
  32306. return function(item) {
  32307. var val = me.getPropertyValue(item);
  32308. return matcher ? matcher.test(val) : (val == null);
  32309. };
  32310. },
  32311. getPropertyValue: function(item) {
  32312. var root = this._root,
  32313. value = (root == null) ? item : item[root];
  32314. return value[this._property];
  32315. },
  32316. getState: function() {
  32317. var config = this.getInitialConfig(),
  32318. result = {},
  32319. name;
  32320. for (name in config) {
  32321. if (config.hasOwnProperty(name)) {
  32322. result[name] = config[name];
  32323. }
  32324. }
  32325. delete result.root;
  32326. result.value = this.getValue();
  32327. return result;
  32328. },
  32329. getScope: function() {
  32330. return this.scope;
  32331. },
  32332. serialize: function() {
  32333. var result = this.getState(),
  32334. serializer = this.getSerializer(),
  32335. serialized;
  32336. delete result.id;
  32337. delete result.serializer;
  32338. if (serializer) {
  32339. serialized = serializer.call(this, result);
  32340. if (serialized) {
  32341. result = serialized;
  32342. }
  32343. }
  32344. return result;
  32345. },
  32346. updateDisabled: function() {
  32347. this.generation++;
  32348. },
  32349. updateOperator: function() {
  32350. this.onConfigMutation();
  32351. },
  32352. updateConvert: function() {
  32353. this.onConfigMutation();
  32354. },
  32355. updateProperty: function() {
  32356. this.onConfigMutation();
  32357. },
  32358. updateAnyMatch: function() {
  32359. this.onConfigMutation();
  32360. },
  32361. updateExactMatch: function() {
  32362. this.onConfigMutation();
  32363. },
  32364. updateCaseSensitive: function() {
  32365. this.onConfigMutation();
  32366. },
  32367. updateValue: function(value) {
  32368. this.onConfigMutation();
  32369. if (this.getDisableOnEmpty()) {
  32370. this.setDisabled(Ext.isEmpty(value));
  32371. }
  32372. },
  32373. updateFilterFn: function(filterFn) {
  32374. delete this.generatedFilterFn;
  32375. },
  32376. onConfigMutation: function() {
  32377. this.generation++;
  32378. if (this.generatedFilterFn) {
  32379. this._filterFn = null;
  32380. }
  32381. },
  32382. updateDisableOnEmpty: function(disableOnEmpty) {
  32383. if (disableOnEmpty) {
  32384. this.setDisabled(Ext.isEmpty(this.getValue()));
  32385. }
  32386. },
  32387. privates: {
  32388. getCandidateValue: function(candidate, v, preventCoerce) {
  32389. var me = this,
  32390. convert = me._convert,
  32391. result = me.getPropertyValue(candidate);
  32392. if (convert) {
  32393. result = convert.call(me.scope || me, result);
  32394. } else if (!preventCoerce) {
  32395. result = Ext.coerce(result, v);
  32396. }
  32397. return result;
  32398. }
  32399. }
  32400. }, function() {
  32401. var prototype = this.prototype,
  32402. operatorFns = (prototype.operatorFns = {
  32403. "<": function(candidate) {
  32404. var v = this._filterValue;
  32405. return this.getCandidateValue(candidate, v) < v;
  32406. },
  32407. "<=": function(candidate) {
  32408. var v = this._filterValue;
  32409. return this.getCandidateValue(candidate, v) <= v;
  32410. },
  32411. "=": function(candidate) {
  32412. var me = this,
  32413. v = me._filterValue;
  32414. candidate = me.getCandidateValue(candidate, v);
  32415. if (me.isDateValue && candidate instanceof Date) {
  32416. candidate = candidate.getTime();
  32417. v = me.dateValue;
  32418. }
  32419. return candidate == v;
  32420. },
  32421. "===": function(candidate) {
  32422. var me = this,
  32423. v = me._filterValue;
  32424. candidate = me.getCandidateValue(candidate, v, true);
  32425. if (me.isDateValue && candidate instanceof Date) {
  32426. candidate = candidate.getTime();
  32427. v = me.dateValue;
  32428. }
  32429. return candidate === v;
  32430. },
  32431. ">=": function(candidate) {
  32432. var v = this._filterValue;
  32433. return this.getCandidateValue(candidate, v) >= v;
  32434. },
  32435. ">": function(candidate) {
  32436. var v = this._filterValue;
  32437. return this.getCandidateValue(candidate, v) > v;
  32438. },
  32439. "!=": function(candidate) {
  32440. var me = this,
  32441. v = me._filterValue;
  32442. candidate = me.getCandidateValue(candidate, v);
  32443. if (me.isDateValue && candidate instanceof Date) {
  32444. candidate = candidate.getTime();
  32445. v = me.dateValue;
  32446. }
  32447. return candidate != v;
  32448. },
  32449. "!==": function(candidate) {
  32450. var me = this,
  32451. v = me._filterValue;
  32452. candidate = me.getCandidateValue(candidate, v, true);
  32453. if (me.isDateValue && candidate instanceof Date) {
  32454. candidate = candidate.getTime();
  32455. v = me.dateValue;
  32456. }
  32457. return candidate !== v;
  32458. },
  32459. "in": function(candidate) {
  32460. var v = this._filterValue;
  32461. return Ext.Array.contains(v, this.getCandidateValue(candidate, v));
  32462. },
  32463. notin: function(candidate) {
  32464. var v = this._filterValue;
  32465. return !Ext.Array.contains(v, this.getCandidateValue(candidate, v));
  32466. },
  32467. like: function(candidate) {
  32468. var v = this._filterValue;
  32469. return v && this.getCandidateValue(candidate, v).toLowerCase().indexOf(v.toLowerCase()) > -1;
  32470. },
  32471. "/=": function(candidate) {
  32472. var me = this,
  32473. v = me._filterValue;
  32474. candidate = me.getCandidateValue(candidate, v);
  32475. if (v !== me.lastRegExpSource) {
  32476. me.lastRegExpSource = v;
  32477. try {
  32478. me.regex = new RegExp(v, 'i');
  32479. } catch (e) {
  32480. me.regex = null;
  32481. }
  32482. }
  32483. return me.regex ? me.regex.test(candidate) : false;
  32484. }
  32485. });
  32486. operatorFns['=='] = operatorFns['='];
  32487. operatorFns.gt = operatorFns['>'];
  32488. operatorFns.ge = operatorFns['>='];
  32489. operatorFns.lt = operatorFns['<'];
  32490. operatorFns.le = operatorFns['<='];
  32491. operatorFns.eq = operatorFns['='];
  32492. operatorFns.ne = operatorFns['!='];
  32493. });
  32494. Ext.define('Ext.util.AbstractMixedCollection', {
  32495. mixins: {
  32496. observable: Ext.util.Observable
  32497. },
  32498. isMixedCollection: true,
  32499. generation: 0,
  32500. indexGeneration: 0,
  32501. constructor: function(allowFunctions, keyFn) {
  32502. var me = this;
  32503. if (arguments.length === 1 && Ext.isObject(allowFunctions)) {
  32504. me.initialConfig = allowFunctions;
  32505. Ext.apply(me, allowFunctions);
  32506. } else
  32507. {
  32508. me.allowFunctions = allowFunctions === true;
  32509. if (keyFn) {
  32510. me.getKey = keyFn;
  32511. }
  32512. me.initialConfig = {
  32513. allowFunctions: me.allowFunctions,
  32514. getKey: me.getKey
  32515. };
  32516. }
  32517. me.items = [];
  32518. me.map = {};
  32519. me.keys = [];
  32520. me.indexMap = {};
  32521. me.length = 0;
  32522. me.mixins.observable.constructor.call(me);
  32523. },
  32524. destroy: function() {
  32525. var me = this;
  32526. me.items = me.map = me.keys = me.indexMap = null;
  32527. me.callParent();
  32528. },
  32529. allowFunctions: false,
  32530. add: function(key, obj) {
  32531. var len = this.length,
  32532. out;
  32533. if (arguments.length === 1) {
  32534. out = this.insert(len, key);
  32535. } else {
  32536. out = this.insert(len, key, obj);
  32537. }
  32538. return out;
  32539. },
  32540. getKey: function(item) {
  32541. return item.id;
  32542. },
  32543. replace: function(key, o) {
  32544. var me = this,
  32545. old, index;
  32546. if (arguments.length == 1) {
  32547. o = arguments[0];
  32548. key = me.getKey(o);
  32549. }
  32550. old = me.map[key];
  32551. if (typeof key == 'undefined' || key === null || typeof old == 'undefined') {
  32552. return me.add(key, o);
  32553. }
  32554. me.generation++;
  32555. index = me.indexOfKey(key);
  32556. me.items[index] = o;
  32557. me.map[key] = o;
  32558. if (me.hasListeners.replace) {
  32559. me.fireEvent('replace', key, old, o);
  32560. }
  32561. return o;
  32562. },
  32563. reorder: function(mapping) {
  32564. var me = this,
  32565. items = me.items,
  32566. index = 0,
  32567. length = items.length,
  32568. order = [],
  32569. remaining = [],
  32570. oldIndex;
  32571. me.suspendEvents();
  32572. for (oldIndex in mapping) {
  32573. order[mapping[oldIndex]] = items[oldIndex];
  32574. }
  32575. for (index = 0; index < length; index++) {
  32576. if (mapping[index] == undefined) {
  32577. remaining.push(items[index]);
  32578. }
  32579. }
  32580. for (index = 0; index < length; index++) {
  32581. if (order[index] == undefined) {
  32582. order[index] = remaining.shift();
  32583. }
  32584. }
  32585. me.clear();
  32586. me.addAll(order);
  32587. me.resumeEvents();
  32588. },
  32589. updateKey: function(oldKey, newKey) {
  32590. var me = this,
  32591. map = me.map,
  32592. index = me.indexOfKey(oldKey),
  32593. indexMap = me.indexMap,
  32594. item;
  32595. if (index > -1) {
  32596. item = map[oldKey];
  32597. delete map[oldKey];
  32598. delete indexMap[oldKey];
  32599. map[newKey] = item;
  32600. indexMap[newKey] = index;
  32601. me.keys[index] = newKey;
  32602. me.indexGeneration = ++me.generation;
  32603. }
  32604. },
  32605. addAll: function(objs) {
  32606. var me = this,
  32607. key;
  32608. if (arguments.length > 1 || Ext.isArray(objs)) {
  32609. me.insert(me.length, arguments.length > 1 ? arguments : objs);
  32610. } else {
  32611. for (key in objs) {
  32612. if (objs.hasOwnProperty(key)) {
  32613. if (me.allowFunctions || typeof objs[key] != 'function') {
  32614. me.add(key, objs[key]);
  32615. }
  32616. }
  32617. }
  32618. }
  32619. },
  32620. each: function(fn, scope) {
  32621. var items = Ext.Array.push([], this.items),
  32622. i = 0,
  32623. len = items.length,
  32624. item;
  32625. for (; i < len; i++) {
  32626. item = items[i];
  32627. if (fn.call(scope || item, item, i, len) === false) {
  32628. break;
  32629. }
  32630. }
  32631. },
  32632. eachKey: function(fn, scope) {
  32633. var keys = this.keys,
  32634. items = this.items,
  32635. i = 0,
  32636. len = keys.length;
  32637. for (; i < len; i++) {
  32638. fn.call(scope || window, keys[i], items[i], i, len);
  32639. }
  32640. },
  32641. findBy: function(fn, scope) {
  32642. var keys = this.keys,
  32643. items = this.items,
  32644. i = 0,
  32645. len = items.length;
  32646. for (; i < len; i++) {
  32647. if (fn.call(scope || window, items[i], keys[i])) {
  32648. return items[i];
  32649. }
  32650. }
  32651. return null;
  32652. },
  32653. insert: function(index, key, obj) {
  32654. var out;
  32655. if (Ext.isIterable(key)) {
  32656. out = this.doInsert(index, key, obj);
  32657. } else {
  32658. if (arguments.length > 2) {
  32659. out = this.doInsert(index, [
  32660. key
  32661. ], [
  32662. obj
  32663. ]);
  32664. } else {
  32665. out = this.doInsert(index, [
  32666. key
  32667. ]);
  32668. }
  32669. out = out[0];
  32670. }
  32671. return out;
  32672. },
  32673. doInsert: function(index, keys, objects) {
  32674. var me = this,
  32675. itemKey, removeIndex, i,
  32676. len = keys.length,
  32677. deDupedLen = len,
  32678. fireAdd = me.hasListeners.add,
  32679. syncIndices,
  32680. newKeys = {},
  32681. passedDuplicates, oldKeys, oldObjects;
  32682. if (objects != null) {
  32683. me.useLinearSearch = true;
  32684. } else
  32685. {
  32686. objects = keys;
  32687. keys = new Array(len);
  32688. for (i = 0; i < len; i++) {
  32689. keys[i] = this.getKey(objects[i]);
  32690. }
  32691. }
  32692. me.suspendEvents();
  32693. for (i = 0; i < len; i++) {
  32694. itemKey = keys[i];
  32695. removeIndex = me.indexOfKey(itemKey);
  32696. if (removeIndex !== -1) {
  32697. if (removeIndex < index) {
  32698. index--;
  32699. }
  32700. me.removeAt(removeIndex);
  32701. }
  32702. if (itemKey != null) {
  32703. if (newKeys[itemKey] != null) {
  32704. passedDuplicates = true;
  32705. deDupedLen--;
  32706. }
  32707. newKeys[itemKey] = i;
  32708. }
  32709. }
  32710. me.resumeEvents();
  32711. if (passedDuplicates) {
  32712. oldKeys = keys;
  32713. oldObjects = objects;
  32714. keys = new Array(deDupedLen);
  32715. objects = new Array(deDupedLen);
  32716. i = 0;
  32717. for (itemKey in newKeys) {
  32718. keys[i] = oldKeys[newKeys[itemKey]];
  32719. objects[i] = oldObjects[newKeys[itemKey]];
  32720. i++;
  32721. }
  32722. len = deDupedLen;
  32723. }
  32724. syncIndices = index === me.length && me.indexGeneration === me.generation;
  32725. Ext.Array.insert(me.items, index, objects);
  32726. Ext.Array.insert(me.keys, index, keys);
  32727. me.length += len;
  32728. me.generation++;
  32729. if (syncIndices) {
  32730. me.indexGeneration = me.generation;
  32731. }
  32732. for (i = 0; i < len; i++ , index++) {
  32733. itemKey = keys[i];
  32734. if (itemKey != null) {
  32735. me.map[itemKey] = objects[i];
  32736. if (syncIndices) {
  32737. me.indexMap[itemKey] = index;
  32738. }
  32739. }
  32740. if (fireAdd) {
  32741. me.fireEvent('add', index, objects[i], itemKey);
  32742. }
  32743. }
  32744. return objects;
  32745. },
  32746. remove: function(o) {
  32747. var me = this,
  32748. removeKey, index;
  32749. if (!me.useLinearSearch && (removeKey = me.getKey(o))) {
  32750. index = me.indexOfKey(removeKey);
  32751. } else
  32752. {
  32753. index = Ext.Array.indexOf(me.items, o);
  32754. }
  32755. return (index === -1) ? false : me.removeAt(index);
  32756. },
  32757. removeAll: function(items) {
  32758. var me = this,
  32759. i;
  32760. if (items || me.hasListeners.remove) {
  32761. if (items) {
  32762. for (i = items.length - 1; i >= 0; --i) {
  32763. me.remove(items[i]);
  32764. }
  32765. } else {
  32766. while (me.length) {
  32767. me.removeAt(0);
  32768. }
  32769. }
  32770. } else {
  32771. me.length = me.items.length = me.keys.length = 0;
  32772. me.map = {};
  32773. me.indexMap = {};
  32774. me.generation++;
  32775. me.indexGeneration = me.generation;
  32776. }
  32777. },
  32778. removeAt: function(index) {
  32779. var me = this,
  32780. o, key;
  32781. if (index < me.length && index >= 0) {
  32782. me.length--;
  32783. o = me.items[index];
  32784. Ext.Array.erase(me.items, index, 1);
  32785. key = me.keys[index];
  32786. if (typeof key != 'undefined') {
  32787. delete me.map[key];
  32788. }
  32789. Ext.Array.erase(me.keys, index, 1);
  32790. if (me.hasListeners.remove) {
  32791. me.fireEvent('remove', o, key);
  32792. }
  32793. me.generation++;
  32794. return o;
  32795. }
  32796. return false;
  32797. },
  32798. removeRange: function(index, removeCount) {
  32799. var me = this,
  32800. o, key, i, limit, syncIndices, trimming;
  32801. if (index < me.length && index >= 0) {
  32802. if (!removeCount) {
  32803. removeCount = 1;
  32804. }
  32805. limit = Math.min(index + removeCount, me.length);
  32806. removeCount = limit - index;
  32807. trimming = limit === me.length;
  32808. syncIndices = trimming && me.indexGeneration === me.generation;
  32809. for (i = index; i < limit; i++) {
  32810. key = me.keys[i];
  32811. if (key != null) {
  32812. delete me.map[key];
  32813. if (syncIndices) {
  32814. delete me.indexMap[key];
  32815. }
  32816. }
  32817. }
  32818. o = me.items[i - 1];
  32819. me.length -= removeCount;
  32820. me.generation++;
  32821. if (syncIndices) {
  32822. me.indexGeneration = me.generation;
  32823. }
  32824. if (trimming) {
  32825. me.items.length = me.keys.length = me.length;
  32826. } else {
  32827. me.items.splice(index, removeCount);
  32828. me.keys.splice(index, removeCount);
  32829. }
  32830. return o;
  32831. }
  32832. return false;
  32833. },
  32834. removeAtKey: function(key) {
  32835. var me = this,
  32836. keys = me.keys,
  32837. i;
  32838. if (key == null) {
  32839. for (i = keys.length - 1; i >= 0; i--) {
  32840. if (keys[i] == null) {
  32841. me.removeAt(i);
  32842. }
  32843. }
  32844. } else
  32845. {
  32846. return me.removeAt(me.indexOfKey(key));
  32847. }
  32848. },
  32849. getCount: function() {
  32850. return this.length;
  32851. },
  32852. indexOf: function(o) {
  32853. var me = this,
  32854. key;
  32855. if (o != null) {
  32856. if (!me.useLinearSearch && (key = me.getKey(o))) {
  32857. return this.indexOfKey(key);
  32858. }
  32859. return Ext.Array.indexOf(me.items, o);
  32860. }
  32861. return -1;
  32862. },
  32863. indexOfKey: function(key) {
  32864. if (!this.map.hasOwnProperty(key)) {
  32865. return -1;
  32866. }
  32867. if (this.indexGeneration !== this.generation) {
  32868. this.rebuildIndexMap();
  32869. }
  32870. return this.indexMap[key];
  32871. },
  32872. rebuildIndexMap: function() {
  32873. var me = this,
  32874. indexMap = me.indexMap = {},
  32875. keys = me.keys,
  32876. len = keys.length,
  32877. i;
  32878. for (i = 0; i < len; i++) {
  32879. indexMap[keys[i]] = i;
  32880. }
  32881. me.indexGeneration = me.generation;
  32882. },
  32883. get: function(key) {
  32884. var me = this,
  32885. mk = me.map[key],
  32886. item = mk !== undefined ? mk : (typeof key == 'number') ? me.items[key] : undefined;
  32887. return typeof item != 'function' || me.allowFunctions ? item : null;
  32888. },
  32889. getAt: function(index) {
  32890. return this.items[index];
  32891. },
  32892. getByKey: function(key) {
  32893. return this.map[key];
  32894. },
  32895. contains: function(o) {
  32896. var me = this,
  32897. key;
  32898. if (o != null) {
  32899. if (!me.useLinearSearch && (key = me.getKey(o))) {
  32900. return this.map[key] != null;
  32901. }
  32902. return Ext.Array.indexOf(this.items, o) !== -1;
  32903. }
  32904. return false;
  32905. },
  32906. containsKey: function(key) {
  32907. return this.map.hasOwnProperty(key);
  32908. },
  32909. clear: function() {
  32910. var me = this;
  32911. if (me.generation) {
  32912. me.length = 0;
  32913. me.items = [];
  32914. me.keys = [];
  32915. me.map = {};
  32916. me.indexMap = {};
  32917. me.generation++;
  32918. me.indexGeneration = me.generation;
  32919. }
  32920. if (me.hasListeners.clear) {
  32921. me.fireEvent('clear');
  32922. }
  32923. },
  32924. first: function() {
  32925. return this.items[0];
  32926. },
  32927. last: function() {
  32928. return this.items[this.length - 1];
  32929. },
  32930. sum: function(property, root, start, end) {
  32931. var values = this.extractValues(property, root),
  32932. length = values.length,
  32933. sum = 0,
  32934. i;
  32935. start = start || 0;
  32936. end = (end || end === 0) ? end : length - 1;
  32937. for (i = start; i <= end; i++) {
  32938. sum += values[i];
  32939. }
  32940. return sum;
  32941. },
  32942. collect: function(property, root, allowNull) {
  32943. var values = this.extractValues(property, root),
  32944. length = values.length,
  32945. hits = {},
  32946. unique = [],
  32947. value, strValue, i;
  32948. for (i = 0; i < length; i++) {
  32949. value = values[i];
  32950. strValue = String(value);
  32951. if ((allowNull || !Ext.isEmpty(value)) && !hits[strValue]) {
  32952. hits[strValue] = true;
  32953. unique.push(value);
  32954. }
  32955. }
  32956. return unique;
  32957. },
  32958. extractValues: function(property, root) {
  32959. var values = this.items;
  32960. if (root) {
  32961. values = Ext.Array.pluck(values, root);
  32962. }
  32963. return Ext.Array.pluck(values, property);
  32964. },
  32965. hasRange: function(start, end) {
  32966. return (end < this.length);
  32967. },
  32968. getRange: function(start, end) {
  32969. var me = this,
  32970. items = me.items,
  32971. range = [],
  32972. len = items.length,
  32973. tmp, reverse;
  32974. if (len < 1) {
  32975. return range;
  32976. }
  32977. if (start > end) {
  32978. reverse = true;
  32979. tmp = start;
  32980. start = end;
  32981. end = tmp;
  32982. }
  32983. if (start < 0) {
  32984. start = 0;
  32985. }
  32986. if (end == null || end >= len) {
  32987. end = len - 1;
  32988. }
  32989. range = items.slice(start, end + 1);
  32990. if (reverse && range.length) {
  32991. range.reverse();
  32992. }
  32993. return range;
  32994. },
  32995. filter: function(property, value, anyMatch, caseSensitive) {
  32996. var filters = [];
  32997. if (Ext.isString(property)) {
  32998. filters.push(new Ext.util.Filter({
  32999. property: property,
  33000. value: value,
  33001. anyMatch: anyMatch,
  33002. caseSensitive: caseSensitive
  33003. }));
  33004. } else if (Ext.isArray(property) || property instanceof Ext.util.Filter) {
  33005. filters = filters.concat(property);
  33006. }
  33007. return this.filterBy(Ext.util.Filter.createFilterFn(filters));
  33008. },
  33009. filterBy: function(fn, scope) {
  33010. var me = this,
  33011. newMC = new me.self(me.initialConfig),
  33012. keys = me.keys,
  33013. items = me.items,
  33014. length = items.length,
  33015. i;
  33016. newMC.getKey = me.getKey;
  33017. for (i = 0; i < length; i++) {
  33018. if (fn.call(scope || me, items[i], keys[i])) {
  33019. newMC.add(keys[i], items[i]);
  33020. }
  33021. }
  33022. newMC.useLinearSearch = me.useLinearSearch;
  33023. return newMC;
  33024. },
  33025. findIndex: function(property, value, start, anyMatch, caseSensitive) {
  33026. if (Ext.isEmpty(value, false)) {
  33027. return -1;
  33028. }
  33029. value = this.createValueMatcher(value, anyMatch, caseSensitive);
  33030. return this.findIndexBy(function(o) {
  33031. return o && value.test(o[property]);
  33032. }, null, start);
  33033. },
  33034. findIndexBy: function(fn, scope, start) {
  33035. var me = this,
  33036. keys = me.keys,
  33037. items = me.items,
  33038. i = start || 0,
  33039. len = items.length;
  33040. for (; i < len; i++) {
  33041. if (fn.call(scope || me, items[i], keys[i])) {
  33042. return i;
  33043. }
  33044. }
  33045. return -1;
  33046. },
  33047. createValueMatcher: function(value, anyMatch, caseSensitive, exactMatch) {
  33048. if (!value.exec) {
  33049. var er = Ext.String.escapeRegex;
  33050. value = String(value);
  33051. if (anyMatch === true) {
  33052. value = er(value);
  33053. } else {
  33054. value = '^' + er(value);
  33055. if (exactMatch === true) {
  33056. value += '$';
  33057. }
  33058. }
  33059. value = new RegExp(value, caseSensitive ? '' : 'i');
  33060. }
  33061. return value;
  33062. },
  33063. clone: function() {
  33064. var me = this,
  33065. copy = new me.self(me.initialConfig);
  33066. copy.add(me.keys, me.items);
  33067. copy.useLinearSearch = me.useLinearSearch;
  33068. return copy;
  33069. }
  33070. });
  33071. Ext.define('Ext.util.Sorter', {
  33072. isSorter: true,
  33073. config: {
  33074. property: null,
  33075. sorterFn: null,
  33076. root: null,
  33077. transform: null,
  33078. direction: "ASC",
  33079. id: undefined
  33080. },
  33081. statics: {
  33082. createComparator: function(sorters, nextFn) {
  33083. nextFn = nextFn || 0;
  33084. return function(lhs, rhs) {
  33085. var items = sorters.isCollection ? sorters.items : sorters,
  33086. n = items.length,
  33087. comp, i;
  33088. for (i = 0; i < n; ++i) {
  33089. comp = items[i].sort(lhs, rhs);
  33090. if (comp) {
  33091. return comp;
  33092. }
  33093. }
  33094. return nextFn && nextFn(lhs, rhs);
  33095. };
  33096. }
  33097. },
  33098. multiplier: 1,
  33099. constructor: function(config) {
  33100. if (config && !this.isGrouper) {
  33101. if (!config.property === !config.sorterFn) {
  33102. Ext.raise("A Sorter requires either a property or a sorterFn.");
  33103. }
  33104. }
  33105. this.initConfig(config);
  33106. },
  33107. getId: function() {
  33108. var id = this._id;
  33109. if (!id) {
  33110. id = this.getProperty();
  33111. if (!id) {
  33112. id = Ext.id(null, 'ext-sorter-');
  33113. }
  33114. this._id = id;
  33115. }
  33116. return id;
  33117. },
  33118. sort: function(lhs, rhs) {
  33119. return this.multiplier * this.sortFn(lhs, rhs);
  33120. },
  33121. sortFn: function(item1, item2) {
  33122. var me = this,
  33123. transform = me._transform,
  33124. root = me._root,
  33125. property = me._property,
  33126. lhs, rhs;
  33127. if (root) {
  33128. item1 = item1[root];
  33129. item2 = item2[root];
  33130. }
  33131. lhs = item1[property];
  33132. rhs = item2[property];
  33133. if (transform) {
  33134. lhs = transform(lhs);
  33135. rhs = transform(rhs);
  33136. }
  33137. return (lhs > rhs) ? 1 : (lhs < rhs ? -1 : 0);
  33138. },
  33139. applyDirection: function(direction) {
  33140. return direction ? direction : 'ASC';
  33141. },
  33142. updateDirection: function(direction) {
  33143. this.multiplier = (direction.toUpperCase() === "DESC") ? -1 : 1;
  33144. },
  33145. updateProperty: function(property) {
  33146. if (property) {
  33147. delete this.sortFn;
  33148. }
  33149. },
  33150. updateSorterFn: function(sorterFn) {
  33151. this.sortFn = sorterFn;
  33152. },
  33153. toggle: function() {
  33154. this.setDirection(Ext.String.toggle(this.getDirection(), "ASC", "DESC"));
  33155. },
  33156. getState: function() {
  33157. var me = this,
  33158. result = {
  33159. root: me.getRoot(),
  33160. property: me.getProperty(),
  33161. direction: me.getDirection()
  33162. };
  33163. if (me._id) {
  33164. result.id = me._id;
  33165. }
  33166. return result;
  33167. },
  33168. serialize: function() {
  33169. return {
  33170. property: this.getProperty(),
  33171. direction: this.getDirection()
  33172. };
  33173. }
  33174. });
  33175. Ext.define("Ext.util.Sortable", {
  33176. isSortable: true,
  33177. $configPrefixed: false,
  33178. $configStrict: false,
  33179. config: {
  33180. sorters: null
  33181. },
  33182. defaultSortDirection: "ASC",
  33183. multiSortLimit: 3,
  33184. statics: {
  33185. createComparator: function(sorters) {
  33186. return sorters && sorters.length ? function(r1, r2) {
  33187. var result = sorters[0].sort(r1, r2),
  33188. length = sorters.length,
  33189. i = 1;
  33190. for (; !result && i < length; i++) {
  33191. result = sorters[i].sort.call(sorters[i], r1, r2);
  33192. }
  33193. return result;
  33194. } : function() {
  33195. return 0;
  33196. };
  33197. }
  33198. },
  33199. applySorters: function(sorters) {
  33200. var me = this,
  33201. sortersCollection = me.getSorters() || new Ext.util.MixedCollection(false, Ext.returnId);
  33202. if (sorters) {
  33203. sortersCollection.addAll(me.decodeSorters(sorters));
  33204. }
  33205. return sortersCollection;
  33206. },
  33207. sort: function(sorters, direction, insertionPosition, doSort) {
  33208. var me = this,
  33209. sorter, overFlow,
  33210. currentSorters = me.getSorters();
  33211. if (!currentSorters) {
  33212. me.setSorters(null);
  33213. currentSorters = me.getSorters();
  33214. }
  33215. if (Ext.isArray(sorters)) {
  33216. doSort = insertionPosition;
  33217. insertionPosition = direction;
  33218. } else if (Ext.isObject(sorters)) {
  33219. sorters = [
  33220. sorters
  33221. ];
  33222. doSort = insertionPosition;
  33223. insertionPosition = direction;
  33224. } else if (Ext.isString(sorters)) {
  33225. sorter = currentSorters.get(sorters);
  33226. if (!sorter) {
  33227. sorter = {
  33228. property: sorters,
  33229. direction: direction
  33230. };
  33231. } else if (direction == null) {
  33232. sorter.toggle();
  33233. } else {
  33234. sorter.setDirection(direction);
  33235. }
  33236. sorters = [
  33237. sorter
  33238. ];
  33239. }
  33240. if (sorters && sorters.length) {
  33241. sorters = me.decodeSorters(sorters);
  33242. switch (insertionPosition) {
  33243. case "multi":
  33244. currentSorters.insert(0, sorters[0]);
  33245. overFlow = currentSorters.getCount() - me.multiSortLimit;
  33246. if (overFlow > 0) {
  33247. currentSorters.removeRange(me.multiSortLimit, overFlow);
  33248. };
  33249. break;
  33250. case "prepend":
  33251. currentSorters.insert(0, sorters);
  33252. break;
  33253. case "append":
  33254. currentSorters.addAll(sorters);
  33255. break;
  33256. case undefined:
  33257. case null:
  33258. case "replace":
  33259. currentSorters.clear();
  33260. currentSorters.addAll(sorters);
  33261. break;
  33262. default:
  33263. Ext.raise('Sorter insertion point must be "multi", "prepend", "append" or "replace"');
  33264. }
  33265. }
  33266. if (doSort !== false) {
  33267. me.fireEvent('beforesort', me, sorters);
  33268. me.onBeforeSort(sorters);
  33269. if (me.getSorterCount()) {
  33270. me.doSort(me.generateComparator());
  33271. }
  33272. }
  33273. return sorters;
  33274. },
  33275. getSorterCount: function() {
  33276. return this.getSorters().items.length;
  33277. },
  33278. generateComparator: function() {
  33279. var sorters = this.getSorters().getRange();
  33280. return sorters.length ? this.createComparator(sorters) : this.emptyComparator;
  33281. },
  33282. emptyComparator: function() {
  33283. return 0;
  33284. },
  33285. onBeforeSort: Ext.emptyFn,
  33286. decodeSorters: function(sorters) {
  33287. if (!Ext.isArray(sorters)) {
  33288. if (sorters === undefined) {
  33289. sorters = [];
  33290. } else {
  33291. sorters = [
  33292. sorters
  33293. ];
  33294. }
  33295. }
  33296. var length = sorters.length,
  33297. Sorter = Ext.util.Sorter,
  33298. model = this.getModel ? this.getModel() : this.model,
  33299. field, config, i;
  33300. for (i = 0; i < length; i++) {
  33301. config = sorters[i];
  33302. if (!(config instanceof Sorter)) {
  33303. if (Ext.isString(config)) {
  33304. config = {
  33305. property: config
  33306. };
  33307. }
  33308. Ext.applyIf(config, {
  33309. root: this.sortRoot,
  33310. direction: "ASC"
  33311. });
  33312. if (config.fn) {
  33313. config.sorterFn = config.fn;
  33314. }
  33315. if (typeof config == 'function') {
  33316. config = {
  33317. sorterFn: config
  33318. };
  33319. }
  33320. if (model && !config.transform) {
  33321. field = model.getField(config.property);
  33322. config.transform = field && field.sortType !== Ext.identityFn ? field.sortType : undefined;
  33323. }
  33324. sorters[i] = new Ext.util.Sorter(config);
  33325. }
  33326. }
  33327. return sorters;
  33328. },
  33329. getFirstSorter: function() {
  33330. var sorters = this.getSorters().items,
  33331. len = sorters.length,
  33332. i = 0,
  33333. sorter;
  33334. for (; i < len; ++i) {
  33335. sorter = sorters[i];
  33336. if (!sorter.isGrouper) {
  33337. return sorter;
  33338. }
  33339. }
  33340. return null;
  33341. }
  33342. }, function() {
  33343. this.prototype.createComparator = this.createComparator;
  33344. });
  33345. Ext.define('Ext.util.MixedCollection', {
  33346. extend: Ext.util.AbstractMixedCollection,
  33347. mixins: {
  33348. sortable: Ext.util.Sortable
  33349. },
  33350. constructor: function() {
  33351. this.initConfig();
  33352. this.callParent(arguments);
  33353. },
  33354. doSort: function(sorterFn) {
  33355. this.sortBy(sorterFn);
  33356. },
  33357. _sort: function(property, dir, fn) {
  33358. var me = this,
  33359. i, len,
  33360. dsc = String(dir).toUpperCase() == 'DESC' ? -1 : 1,
  33361. c = [],
  33362. keys = me.keys,
  33363. items = me.items,
  33364. o;
  33365. fn = fn || function(a, b) {
  33366. return a - b;
  33367. };
  33368. for (i = 0 , len = items.length; i < len; i++) {
  33369. c[c.length] = {
  33370. key: keys[i],
  33371. value: items[i],
  33372. index: i
  33373. };
  33374. }
  33375. Ext.Array.sort(c, function(a, b) {
  33376. return fn(a[property], b[property]) * dsc || (
  33377. a.index < b.index ? -1 : 1);
  33378. });
  33379. for (i = 0 , len = c.length; i < len; i++) {
  33380. o = c[i];
  33381. items[i] = o.value;
  33382. keys[i] = o.key;
  33383. me.indexMap[o.key] = i;
  33384. }
  33385. me.generation++;
  33386. me.indexGeneration = me.generation;
  33387. me.fireEvent('sort', me);
  33388. },
  33389. sortBy: function(sorterFn) {
  33390. var me = this,
  33391. items = me.items,
  33392. item,
  33393. keys = me.keys,
  33394. key,
  33395. length = items.length,
  33396. i;
  33397. for (i = 0; i < length; i++) {
  33398. items[i].$extCollectionIndex = i;
  33399. }
  33400. Ext.Array.sort(items, function(a, b) {
  33401. return sorterFn(a, b) || (
  33402. a.$extCollectionIndex < b.$extCollectionIndex ? -1 : 1);
  33403. });
  33404. for (i = 0; i < length; i++) {
  33405. item = items[i];
  33406. key = me.getKey(item);
  33407. keys[i] = key;
  33408. me.indexMap[key] = i;
  33409. delete item.$extCollectionIndex;
  33410. }
  33411. me.generation++;
  33412. me.indexGeneration = me.generation;
  33413. me.fireEvent('sort', me, items, keys);
  33414. },
  33415. findInsertionIndex: function(newItem, sorterFn) {
  33416. var me = this,
  33417. items = me.items,
  33418. start = 0,
  33419. end = items.length - 1,
  33420. middle, comparison;
  33421. if (!sorterFn) {
  33422. sorterFn = me.generateComparator();
  33423. }
  33424. while (start <= end) {
  33425. middle = (start + end) >> 1;
  33426. comparison = sorterFn(newItem, items[middle]);
  33427. if (comparison >= 0) {
  33428. start = middle + 1;
  33429. } else if (comparison < 0) {
  33430. end = middle - 1;
  33431. }
  33432. }
  33433. return start;
  33434. },
  33435. reorder: function(mapping) {
  33436. this.callParent([
  33437. mapping
  33438. ]);
  33439. this.fireEvent('sort', this);
  33440. },
  33441. sortByKey: function(dir, fn) {
  33442. this._sort('key', dir, fn || function(a, b) {
  33443. var v1 = String(a).toUpperCase(),
  33444. v2 = String(b).toUpperCase();
  33445. return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);
  33446. });
  33447. }
  33448. });
  33449. Ext.define('Ext.util.CollectionKey', {
  33450. mixins: [
  33451. Ext.mixin.Identifiable
  33452. ],
  33453. isCollectionKey: true,
  33454. observerPriority: -200,
  33455. config: {
  33456. collection: null,
  33457. keyFn: null,
  33458. property: null,
  33459. rootProperty: null,
  33460. unique: true
  33461. },
  33462. generation: 0,
  33463. map: null,
  33464. mapRebuilds: 0,
  33465. constructor: function(config) {
  33466. this.initConfig(config);
  33467. if (!Ext.isFunction(this.getKey)) {
  33468. Ext.raise('CollectionKey requires a keyFn or property config');
  33469. }
  33470. },
  33471. get: function(key) {
  33472. var map = this.map || this.getMap();
  33473. return map[key] || null;
  33474. },
  33475. clear: function() {
  33476. this.map = null;
  33477. },
  33478. getRootProperty: function() {
  33479. var me = this,
  33480. root = this.callParent();
  33481. return root !== null ? root : me.getCollection().getRootProperty();
  33482. },
  33483. indexOf: function(key, startAt) {
  33484. var map = this.map || this.getMap(),
  33485. item = map[key],
  33486. collection = this.getCollection(),
  33487. length = collection.length,
  33488. i, index, items, n;
  33489. if (!item) {
  33490. return -1;
  33491. }
  33492. if (startAt === undefined) {
  33493. startAt = -1;
  33494. }
  33495. if (item instanceof Array) {
  33496. items = item;
  33497. index = length;
  33498. for (n = items.length; n-- > 0; ) {
  33499. i = collection.indexOf(items[n]);
  33500. if (i < index && i > startAt) {
  33501. index = i;
  33502. }
  33503. }
  33504. if (index === length) {
  33505. return -1;
  33506. }
  33507. } else {
  33508. index = collection.indexOf(item);
  33509. }
  33510. return (index > startAt) ? index : -1;
  33511. },
  33512. updateKey: function(item, oldKey) {
  33513. var me = this,
  33514. map = me.map,
  33515. bucket, index;
  33516. if (map) {
  33517. bucket = map[oldKey];
  33518. if (bucket instanceof Array) {
  33519. index = Ext.Array.indexOf(bucket, item);
  33520. if (index >= 0) {
  33521. if (bucket.length > 2) {
  33522. bucket.splice(index, 1);
  33523. } else {
  33524. map[oldKey] = bucket[1 - index];
  33525. }
  33526. }
  33527. }
  33528. else if (bucket) {
  33529. if (me.getUnique() && bucket !== item) {
  33530. Ext.raise('Incorrect oldKey "' + oldKey + '" for item with newKey "' + me.getKey(item) + '"');
  33531. }
  33532. delete map[oldKey];
  33533. }
  33534. me.add([
  33535. item
  33536. ]);
  33537. }
  33538. },
  33539. onCollectionAdd: function(collection, add) {
  33540. if (this.map) {
  33541. this.add(add.items);
  33542. }
  33543. },
  33544. onCollectionItemChange: function(collection, details) {
  33545. this.map = null;
  33546. },
  33547. onCollectionRefresh: function() {
  33548. this.map = null;
  33549. },
  33550. onCollectionRemove: function(collection, remove) {
  33551. var me = this,
  33552. map = me.map,
  33553. items = remove.items,
  33554. length = items.length,
  33555. i, item, key;
  33556. if (map) {
  33557. if (me.getUnique() && length < collection.length / 2) {
  33558. for (i = 0; i < length; ++i) {
  33559. key = me.getKey(item = items[i]);
  33560. delete map[key];
  33561. }
  33562. } else {
  33563. me.map = null;
  33564. }
  33565. }
  33566. },
  33567. add: function(items) {
  33568. var me = this,
  33569. map = me.map,
  33570. bucket, i, item, key, length, unique;
  33571. length = items.length;
  33572. unique = me.getUnique();
  33573. for (i = 0; i < length; ++i) {
  33574. key = me.getKey(item = items[i]);
  33575. if (unique || !(key in map)) {
  33576. map[key] = item;
  33577. } else {
  33578. if (!((bucket = map[key]) instanceof Array)) {
  33579. map[key] = bucket = [
  33580. bucket
  33581. ];
  33582. }
  33583. bucket.push(item);
  33584. }
  33585. }
  33586. },
  33587. applyKeyFn: function(keyFn) {
  33588. if (Ext.isString(keyFn)) {
  33589. this.getKey = function(item) {
  33590. return item[keyFn]();
  33591. };
  33592. } else {
  33593. this.getKey = keyFn;
  33594. }
  33595. },
  33596. updateProperty: function(property) {
  33597. var root = this.getRootProperty();
  33598. this.getKey = function(item) {
  33599. return (root ? item[root] : item)[property];
  33600. };
  33601. },
  33602. getMap: function() {
  33603. var me = this,
  33604. map = me.map;
  33605. if (!map) {
  33606. me.map = map = {};
  33607. me.keysByItemKey = {};
  33608. ++me.mapRebuilds;
  33609. me.add(me.getCollection().items);
  33610. }
  33611. return map;
  33612. },
  33613. updateCollection: function(collection, oldCollection) {
  33614. if (collection) {
  33615. collection.addObserver(this);
  33616. }
  33617. if (oldCollection) {
  33618. oldCollection.removeObserver(this);
  33619. }
  33620. },
  33621. clone: function() {
  33622. return new Ext.util.CollectionKey(this.getCurrentConfig());
  33623. },
  33624. destroy: function() {
  33625. this.clear();
  33626. this.getCollection().removeObserver(this);
  33627. this.destroyed = true;
  33628. }
  33629. });
  33630. Ext.define('Ext.util.Grouper', {
  33631. extend: Ext.util.Sorter,
  33632. isGrouper: true,
  33633. config: {
  33634. groupFn: null,
  33635. sortProperty: null
  33636. },
  33637. constructor: function(config) {
  33638. if (config) {
  33639. if (config.getGroupString) {
  33640. Ext.raise("Cannot set getGroupString - use groupFn instead");
  33641. }
  33642. }
  33643. this.callParent(arguments);
  33644. },
  33645. getGroupString: function(item) {
  33646. var group = this._groupFn(item);
  33647. return (group != null) ? String(group) : '';
  33648. },
  33649. sortFn: function(item1, item2) {
  33650. var me = this,
  33651. lhs = me._groupFn(item1),
  33652. rhs = me._groupFn(item2),
  33653. property = me._sortProperty,
  33654. root = me._root,
  33655. sorterFn = me._sorterFn,
  33656. transform = me._transform;
  33657. if (lhs === rhs) {
  33658. return 0;
  33659. }
  33660. if (property || sorterFn) {
  33661. if (sorterFn) {
  33662. return sorterFn.call(this, item1, item2);
  33663. }
  33664. if (root) {
  33665. item1 = item1[root];
  33666. item2 = item2[root];
  33667. }
  33668. lhs = item1[property];
  33669. rhs = item2[property];
  33670. if (transform) {
  33671. lhs = transform(lhs);
  33672. rhs = transform(rhs);
  33673. }
  33674. }
  33675. return (lhs > rhs) ? 1 : (lhs < rhs ? -1 : 0);
  33676. },
  33677. standardGroupFn: function(item) {
  33678. var root = this._root;
  33679. return (root ? item[root] : item)[this._property];
  33680. },
  33681. updateSorterFn: function() {},
  33682. updateProperty: function() {
  33683. if (!this.getGroupFn()) {
  33684. this.setGroupFn(this.standardGroupFn);
  33685. }
  33686. }
  33687. });
  33688. Ext.define('Ext.util.Collection', {
  33689. mixins: [
  33690. Ext.mixin.Observable
  33691. ],
  33692. isCollection: true,
  33693. config: {
  33694. autoFilter: true,
  33695. autoSort: true,
  33696. autoGroup: true,
  33697. decoder: null,
  33698. extraKeys: null,
  33699. filters: null,
  33700. grouper: null,
  33701. groups: null,
  33702. groupConfig: null,
  33703. rootProperty: null,
  33704. sorters: null,
  33705. multiSortLimit: 3,
  33706. defaultSortDirection: 'ASC',
  33707. source: null,
  33708. trackGroups: true
  33709. },
  33710. generation: 0,
  33711. indices: null,
  33712. indexRebuilds: 0,
  33713. updating: 0,
  33714. grouped: false,
  33715. sorted: false,
  33716. filtered: false,
  33717. $endUpdatePriority: 1001,
  33718. manageSorters: true,
  33719. constructor: function(config) {
  33720. var me = this;
  33721. me.callParent([
  33722. config
  33723. ]);
  33724. me.items = [];
  33725. me.map = {};
  33726. me.length = 0;
  33727. if (config && config.keyFn) {
  33728. me.getKey = config.keyFn;
  33729. }
  33730. me.mixins.observable.constructor.call(me, config);
  33731. },
  33732. destroy: function() {
  33733. var me = this,
  33734. filters = me._filters,
  33735. sorters = me._sorters,
  33736. groups = me._groups;
  33737. if (filters) {
  33738. filters.destroy();
  33739. me._filters = null;
  33740. }
  33741. if (sorters) {
  33742. me.grouped = me.sorted = false;
  33743. me.setSorters(null);
  33744. if (me.manageSorters) {
  33745. sorters.destroy();
  33746. }
  33747. }
  33748. if (groups) {
  33749. groups.destroy();
  33750. me._groups = null;
  33751. }
  33752. me.setSource(null);
  33753. me.observers = me.items = me.map = null;
  33754. me.callParent();
  33755. },
  33756. add: function(item) {
  33757. var me = this,
  33758. items = me.decodeItems(arguments, 0),
  33759. ret = items;
  33760. if (items.length) {
  33761. me.splice(me.length, 0, items);
  33762. ret = (items.length === 1) ? items[0] : items;
  33763. }
  33764. return ret;
  33765. },
  33766. replaceAll: function() {
  33767. var me = this,
  33768. ret, items;
  33769. items = me.decodeItems(arguments, 0);
  33770. ret = items;
  33771. if (items.length) {
  33772. me.splice(0, me.length, items);
  33773. ret = (items.length === 1) ? items[0] : items;
  33774. } else {
  33775. me.removeAll();
  33776. }
  33777. return ret;
  33778. },
  33779. aggregate: function(property, operation, begin, end, scope) {
  33780. var me = this,
  33781. args = Ext.Array.slice(arguments);
  33782. args.unshift(me.items);
  33783. return me.aggregateItems.apply(me, args);
  33784. },
  33785. aggregateByGroup: function(property, operation, scope) {
  33786. var groups = this.getGroups();
  33787. return this.aggregateGroups(groups, property, operation, scope);
  33788. },
  33789. aggregateItems: function(items, property, operation, begin, end, scope) {
  33790. var me = this,
  33791. range = Ext.Number.clipIndices(items.length, [
  33792. begin,
  33793. end
  33794. ]),
  33795. subsetRequested = (begin !== 0 && end !== items.length),
  33796. i, j, rangeLen, root, value, values, valueItems;
  33797. begin = range[0];
  33798. end = range[1];
  33799. if (!Ext.isFunction(operation)) {
  33800. operation = me._aggregators[operation];
  33801. return operation.call(me, items, begin, end, property, me.getRootProperty());
  33802. }
  33803. root = me.getRootProperty();
  33804. values = new Array(rangeLen);
  33805. valueItems = subsetRequested ? new Array(rangeLen) : items;
  33806. for (i = begin , j = 0; i < end; ++i , j++) {
  33807. if (subsetRequested) {
  33808. valueItems[j] = value = items[i];
  33809. }
  33810. values[j] = (root ? value[root] : value)[property];
  33811. }
  33812. return operation.call(scope || me, items, values, 0);
  33813. },
  33814. aggregateGroups: function(groups, property, operation, scope) {
  33815. var items = groups.items,
  33816. len = items.length,
  33817. callDirect = !Ext.isFunction(operation),
  33818. out = {},
  33819. i, group, result;
  33820. for (i = 0; i < len; ++i) {
  33821. group = items[i];
  33822. if (!callDirect) {
  33823. result = this.aggregateItems(group.items, property, operation, null, null, scope);
  33824. } else {
  33825. result = group[operation](property);
  33826. }
  33827. out[group.getGroupKey()] = result;
  33828. }
  33829. return out;
  33830. },
  33831. beginUpdate: function() {
  33832. if (!this.updating++) {
  33833. this.notify('beginupdate');
  33834. }
  33835. },
  33836. clear: function() {
  33837. var me = this,
  33838. generation = me.generation,
  33839. ret = generation ? me.items : [],
  33840. extraKeys, indexName;
  33841. if (generation) {
  33842. me.items.length = me.length = 0;
  33843. me.map = {};
  33844. me.indices = {};
  33845. me.generation++;
  33846. extraKeys = me.getExtraKeys();
  33847. if (extraKeys) {
  33848. for (indexName in extraKeys) {
  33849. extraKeys[indexName].clear();
  33850. }
  33851. }
  33852. }
  33853. return ret;
  33854. },
  33855. clone: function() {
  33856. var me = this,
  33857. copy = new me.self(me.initialConfig);
  33858. copy.add(me.items);
  33859. return copy;
  33860. },
  33861. collect: function(property, root, allowNull) {
  33862. var items = this.items,
  33863. length = items.length,
  33864. map = {},
  33865. ret = [],
  33866. i, strValue, value;
  33867. for (i = 0; i < length; ++i) {
  33868. value = items[i];
  33869. value = (root ? value[root] : value)[property];
  33870. strValue = String(value);
  33871. if ((allowNull || !Ext.isEmpty(value)) && !map[strValue]) {
  33872. map[strValue] = 1;
  33873. ret.push(value);
  33874. }
  33875. }
  33876. return ret;
  33877. },
  33878. contains: function(item) {
  33879. var ret = false,
  33880. key;
  33881. if (item != null) {
  33882. key = this.getKey(item);
  33883. ret = this.map[key] === item;
  33884. }
  33885. return ret;
  33886. },
  33887. containsAll: function(items) {
  33888. var all = Ext.isArray(items) ? items : arguments,
  33889. i;
  33890. for (i = all.length; i-- > 0; ) {
  33891. if (!this.contains(all[i])) {
  33892. return false;
  33893. }
  33894. }
  33895. return true;
  33896. },
  33897. containsKey: function(key) {
  33898. return key in this.map;
  33899. },
  33900. createFiltered: function(property, value, anyMatch, caseSensitive, exactMatch) {
  33901. var me = this,
  33902. ret = new me.self(me.initialConfig),
  33903. root = me.getRootProperty(),
  33904. items = me.items,
  33905. length, i, filters, fn, scope;
  33906. if (Ext.isFunction(property)) {
  33907. fn = property;
  33908. scope = value;
  33909. } else {
  33910. if (Ext.isString(property)) {
  33911. filters = [
  33912. new Ext.util.Filter({
  33913. property: property,
  33914. value: value,
  33915. root: root,
  33916. anyMatch: anyMatch,
  33917. caseSensitive: caseSensitive,
  33918. exactMatch: exactMatch
  33919. })
  33920. ];
  33921. } else if (property instanceof Ext.util.Filter) {
  33922. filters = [
  33923. property
  33924. ];
  33925. property.setRoot(root);
  33926. } else if (Ext.isArray(property)) {
  33927. filters = property.slice(0);
  33928. for (i = 0 , length = filters.length; i < length; ++i) {
  33929. filters[i].setRoot(root);
  33930. }
  33931. }
  33932. fn = Ext.util.Filter.createFilterFn(filters);
  33933. }
  33934. scope = scope || me;
  33935. for (i = 0 , length = items.length; i < length; i++) {
  33936. if (fn.call(scope, items[i])) {
  33937. ret.add(items[i]);
  33938. }
  33939. }
  33940. return ret;
  33941. },
  33942. filterBy: function(fn, scope) {
  33943. return this.createFiltered(fn, scope);
  33944. },
  33945. each: function(fn, scope) {
  33946. var items = this.items,
  33947. len = items.length,
  33948. i, ret;
  33949. if (len) {
  33950. scope = scope || this;
  33951. items = items.slice(0);
  33952. for (i = 0; i < len; i++) {
  33953. ret = fn.call(scope, items[i], i, len);
  33954. if (ret === false) {
  33955. break;
  33956. }
  33957. }
  33958. }
  33959. return ret;
  33960. },
  33961. eachKey: function(fn, scope) {
  33962. var me = this,
  33963. items = me.items,
  33964. len = items.length,
  33965. i, item, key, ret;
  33966. if (len) {
  33967. scope = scope || me;
  33968. items = items.slice(0);
  33969. for (i = 0; i < len; i++) {
  33970. key = me.getKey(item = items[i]);
  33971. ret = fn.call(scope, key, item, i, len);
  33972. if (ret === false) {
  33973. break;
  33974. }
  33975. }
  33976. }
  33977. return ret;
  33978. },
  33979. endUpdate: function() {
  33980. if (!--this.updating) {
  33981. this.notify('endupdate');
  33982. }
  33983. },
  33984. find: function(property, value, start, startsWith, endsWith, ignoreCase) {
  33985. if (Ext.isEmpty(value, false)) {
  33986. return null;
  33987. }
  33988. var regex = Ext.String.createRegex(value, startsWith, endsWith, ignoreCase),
  33989. root = this.getRootProperty();
  33990. return this.findBy(function(item) {
  33991. return item && regex.test((root ? item[root] : item)[property]);
  33992. }, null, start);
  33993. },
  33994. findBy: function(fn, scope, start) {
  33995. var me = this,
  33996. items = me.items,
  33997. len = items.length,
  33998. i, item, key;
  33999. scope = scope || me;
  34000. for (i = start || 0; i < len; i++) {
  34001. key = me.getKey(item = items[i]);
  34002. if (fn.call(scope, item, key)) {
  34003. return items[i];
  34004. }
  34005. }
  34006. return null;
  34007. },
  34008. findIndex: function(property, value, start, startsWith, endsWith, ignoreCase) {
  34009. var item = this.find(property, value, start, startsWith, endsWith, ignoreCase);
  34010. return item ? this.indexOf(item) : -1;
  34011. },
  34012. findIndexBy: function(fn, scope, start) {
  34013. var item = this.findBy(fn, scope, start);
  34014. return item ? this.indexOf(item) : -1;
  34015. },
  34016. first: function(grouped) {
  34017. var groups = grouped ? this.getGroups() : undefined;
  34018. return groups ? this.aggregateGroups(groups, null, 'first') : this.items[0];
  34019. },
  34020. last: function(grouped) {
  34021. var groups = grouped ? this.getGroups() : undefined;
  34022. return groups ? this.aggregateGroups(groups, null, 'last') : this.items[this.length - 1];
  34023. },
  34024. get: function(key) {
  34025. return this.map[key];
  34026. },
  34027. getAt: function(index) {
  34028. return this.items[index];
  34029. },
  34030. getByKey: function(key) {
  34031. return this.map[key];
  34032. },
  34033. getCount: function() {
  34034. return this.length;
  34035. },
  34036. getKey: function(item) {
  34037. var id = item.id;
  34038. return (id === 0 || id) ? id : ((id = item._id) === 0 || id) ? id : item.getId();
  34039. },
  34040. getRange: function(begin, end) {
  34041. var items = this.items,
  34042. length = items.length,
  34043. range;
  34044. if (begin > end) {
  34045. Ext.raise('Inverted range passed to Collection.getRange: [' + begin + ',' + end + ']');
  34046. }
  34047. if (!length) {
  34048. range = [];
  34049. } else {
  34050. range = Ext.Number.clipIndices(length, [
  34051. begin,
  34052. end
  34053. ]);
  34054. range = items.slice(range[0], range[1]);
  34055. }
  34056. return range;
  34057. },
  34058. getValues: function(property, root, start, end) {
  34059. var items = this.items,
  34060. range = Ext.Number.clipIndices(items.length, [
  34061. start,
  34062. end
  34063. ]),
  34064. ret = [],
  34065. i, value;
  34066. for (i = range[0] , end = range[1]; i < end; ++i) {
  34067. value = items[i];
  34068. value = (root ? value[root] : value)[property];
  34069. ret.push(value);
  34070. }
  34071. return ret;
  34072. },
  34073. indexOf: function(item) {
  34074. if (!item) {
  34075. return -1;
  34076. }
  34077. var key = this.getKey(item);
  34078. return this.indexOfKey(key);
  34079. },
  34080. indexOfKey: function(key) {
  34081. var me = this,
  34082. indices = me.indices;
  34083. if (key in me.map) {
  34084. if (!indices) {
  34085. indices = me.getIndices();
  34086. }
  34087. return indices[key];
  34088. }
  34089. return -1;
  34090. },
  34091. insert: function(index, item) {
  34092. var me = this,
  34093. items = me.decodeItems(arguments, 1),
  34094. ret = items;
  34095. if (items.length) {
  34096. me.splice(index, 0, items);
  34097. ret = (items.length === 1) ? items[0] : items;
  34098. }
  34099. return ret;
  34100. },
  34101. itemChanged: function(item, modified, oldKey, meta) {
  34102. var me = this,
  34103. keyChanged = oldKey !== undefined,
  34104. filtered = me.filtered && me.getAutoFilter(),
  34105. filterChanged = false,
  34106. itemMovement = 0,
  34107. items = me.items,
  34108. last = me.length - 1,
  34109. sorted = me.sorted && last > 0 && me.getAutoSort(),
  34110. source = me.getSource(),
  34111. toRemove = 0,
  34112. itemFiltered = false,
  34113. wasFiltered = false,
  34114. details, newKey, sortFn, toAdd, index, newIndex;
  34115. if (source && !source.updating) {
  34116. me.sourceUpdating = true;
  34117. source.itemChanged(item, modified, oldKey, meta);
  34118. me.sourceUpdating = false;
  34119. } else
  34120. {
  34121. newKey = me.getKey(item);
  34122. if (filtered) {
  34123. index = me.indexOfKey(keyChanged ? oldKey : newKey);
  34124. wasFiltered = (index < 0);
  34125. itemFiltered = me.isItemFiltered(item);
  34126. filterChanged = (wasFiltered !== itemFiltered);
  34127. }
  34128. if (filterChanged) {
  34129. if (itemFiltered) {
  34130. toRemove = [
  34131. item
  34132. ];
  34133. newIndex = -1;
  34134. } else {
  34135. toAdd = [
  34136. item
  34137. ];
  34138. newIndex = me.length;
  34139. }
  34140. }
  34141. else if (sorted && !itemFiltered) {
  34142. if (!filtered) {
  34143. index = me.indexOfKey(keyChanged ? oldKey : newKey);
  34144. }
  34145. sortFn = me.getSortFn();
  34146. if (index !== -1) {
  34147. if (index && sortFn(items[index - 1], items[index]) > 0) {
  34148. itemMovement = -1;
  34149. newIndex = Ext.Array.binarySearch(items, item, 0, index, sortFn);
  34150. } else if (index < last && sortFn(items[index], items[index + 1]) > 0) {
  34151. itemMovement = 1;
  34152. newIndex = Ext.Array.binarySearch(items, item, index + 1, sortFn);
  34153. }
  34154. if (itemMovement) {
  34155. toAdd = [
  34156. item
  34157. ];
  34158. }
  34159. }
  34160. }
  34161. details = {
  34162. item: item,
  34163. key: newKey,
  34164. index: newIndex,
  34165. filterChanged: filterChanged,
  34166. keyChanged: keyChanged,
  34167. indexChanged: !!itemMovement,
  34168. filtered: itemFiltered,
  34169. oldIndex: index,
  34170. newIndex: newIndex,
  34171. wasFiltered: wasFiltered,
  34172. meta: meta
  34173. };
  34174. if (keyChanged) {
  34175. details.oldKey = oldKey;
  34176. }
  34177. if (modified) {
  34178. details.modified = modified;
  34179. }
  34180. ++me.generation;
  34181. me.beginUpdate();
  34182. me.notify('beforeitemchange', [
  34183. details
  34184. ]);
  34185. if (keyChanged) {
  34186. me.updateKey(item, oldKey, details);
  34187. }
  34188. if (toAdd || toRemove) {
  34189. me.splice(newIndex, toRemove, toAdd);
  34190. }
  34191. if (itemMovement > 0) {
  34192. details.newIndex--;
  34193. } else if (itemMovement < 0) {
  34194. details.oldIndex++;
  34195. }
  34196. me.notify(itemFiltered ? 'filtereditemchange' : 'itemchange', [
  34197. details
  34198. ]);
  34199. me.endUpdate();
  34200. }
  34201. },
  34202. remove: function(item) {
  34203. var me = this,
  34204. items = me.decodeRemoveItems(arguments, 0),
  34205. length = me.length;
  34206. me.splice(0, items);
  34207. return length - me.length;
  34208. },
  34209. removeAll: function() {
  34210. var me = this,
  34211. length = me.length;
  34212. if (me.generation && length) {
  34213. me.splice(0, length);
  34214. }
  34215. return me;
  34216. },
  34217. removeAt: function(index, count) {
  34218. var me = this,
  34219. length = me.length,
  34220. Num = Ext.Number,
  34221. range = Num.clipIndices(length, [
  34222. index,
  34223. (count === undefined) ? 1 : count
  34224. ], Num.Clip.COUNT),
  34225. n = range[0],
  34226. removeCount = range[1] - n,
  34227. item = (removeCount === 1) && me.getAt(n),
  34228. removed;
  34229. me.splice(n, removeCount);
  34230. removed = me.length - length;
  34231. return (item && removed) ? item : removed;
  34232. },
  34233. removeByKey: function(key) {
  34234. var item = this.getByKey(key);
  34235. if (!item || !this.remove(item)) {
  34236. return false;
  34237. }
  34238. return item;
  34239. },
  34240. replace: function(item) {
  34241. var index = this.indexOf(item);
  34242. if (index === -1) {
  34243. this.add(item);
  34244. } else {
  34245. this.insert(index, item);
  34246. }
  34247. },
  34248. splice: function(index, toRemove, toAdd) {
  34249. var me = this,
  34250. autoSort = me.sorted && me.getAutoSort(),
  34251. map = me.map,
  34252. items = me.items,
  34253. length = me.length,
  34254. removeItems = (toRemove instanceof Array) ? me.decodeRemoveItems(toRemove) : null,
  34255. isRemoveCount = !removeItems,
  34256. Num = Ext.Number,
  34257. range = Num.clipIndices(length, [
  34258. index,
  34259. isRemoveCount ? toRemove : 0
  34260. ], Num.Clip.COUNT),
  34261. begin = range[0],
  34262. end = range[1],
  34263. removeCount = end - begin,
  34264. newItems = me.decodeItems(arguments, 2),
  34265. newCount = newItems ? newItems.length : 0,
  34266. addItems, newItemsMap, removeMap,
  34267. insertAt = begin,
  34268. indices = me.indices || ((newCount || removeItems) ? me.getIndices() : null),
  34269. adds = null,
  34270. removes = removeCount ? [
  34271. begin
  34272. ] : null,
  34273. newKeys = null,
  34274. source = me.getSource(),
  34275. chunk, chunkItems, chunks, i, item, itemIndex, k, key, keys, n, duplicates, sorters;
  34276. if (source && !source.updating) {
  34277. if (isRemoveCount) {
  34278. removeItems = [];
  34279. for (i = 0; i < removeCount; ++i) {
  34280. removeItems.push(items[begin + i]);
  34281. }
  34282. }
  34283. if (begin < length) {
  34284. i = source.indexOf(items[begin]);
  34285. } else {
  34286. i = source.length;
  34287. }
  34288. me.requestedIndex = index;
  34289. source.splice(i, removeItems, newItems);
  34290. delete me.requestedIndex;
  34291. return me;
  34292. }
  34293. if (newCount) {
  34294. addItems = newItems;
  34295. newKeys = [];
  34296. newItemsMap = {};
  34297. if (autoSort) {
  34298. sorters = me.getSorters();
  34299. if (newCount > 1) {
  34300. if (!addItems.$cloned) {
  34301. newItems = addItems = addItems.slice(0);
  34302. }
  34303. me.sortData(addItems);
  34304. }
  34305. }
  34306. for (i = 0; i < newCount; ++i) {
  34307. key = me.getKey(item = newItems[i]);
  34308. if ((k = newItemsMap[key]) !== undefined) {
  34309. (duplicates || (duplicates = {}))[k] = 1;
  34310. } else {
  34311. itemIndex = indices[key];
  34312. if (itemIndex < begin || end <= itemIndex) {
  34313. (removes || (removes = [])).push(itemIndex);
  34314. }
  34315. }
  34316. newItemsMap[key] = i;
  34317. newKeys.push(key);
  34318. }
  34319. if (duplicates) {
  34320. keys = newKeys;
  34321. addItems = [];
  34322. newKeys = [];
  34323. addItems.$cloned = true;
  34324. for (i = 0; i < newCount; ++i) {
  34325. if (!duplicates[i]) {
  34326. item = newItems[i];
  34327. addItems.push(item);
  34328. newKeys.push(keys[i]);
  34329. }
  34330. }
  34331. newCount = addItems.length;
  34332. }
  34333. adds = {
  34334. items: addItems,
  34335. keys: newKeys
  34336. };
  34337. }
  34338. for (i = removeItems ? removeItems.length : 0; i-- > 0; ) {
  34339. key = me.getKey(removeItems[i]);
  34340. if ((itemIndex = indices[key]) !== undefined) {
  34341. (removes || (removes = [])).push(itemIndex);
  34342. }
  34343. }
  34344. if (!adds && !removes) {
  34345. return me;
  34346. }
  34347. me.beginUpdate();
  34348. if (removes) {
  34349. chunk = null;
  34350. chunks = [];
  34351. removeMap = {};
  34352. if (removes.length > 1) {
  34353. removes.sort(Ext.Array.numericSortFn);
  34354. }
  34355. for (i = 0 , n = removes.length; i < n; ++i) {
  34356. key = me.getKey(item = items[itemIndex = removes[i]]);
  34357. if (!(key in map)) {
  34358. continue;
  34359. }
  34360. delete map[key];
  34361. if (!chunk || itemIndex > (chunk.at + chunkItems.length)) {
  34362. chunks.push(chunk = {
  34363. at: itemIndex,
  34364. items: (chunkItems = []),
  34365. keys: (keys = []),
  34366. map: removeMap,
  34367. next: chunk,
  34368. replacement: adds
  34369. });
  34370. if (adds) {
  34371. adds.replaced = chunk;
  34372. }
  34373. }
  34374. chunkItems.push(removeMap[key] = item);
  34375. keys.push(key);
  34376. if (itemIndex < insertAt - 1) {
  34377. --insertAt;
  34378. }
  34379. if (removeCount > 1 && itemIndex === begin) {
  34380. --removeCount;
  34381. removes[i--] = ++begin;
  34382. }
  34383. }
  34384. if (adds) {
  34385. adds.at = insertAt;
  34386. }
  34387. for (k = chunks.length; k-- > 0; ) {
  34388. chunk = chunks[k];
  34389. i = chunk.at;
  34390. n = chunk.items.length;
  34391. if (i + n < length) {
  34392. me.indices = indices = null;
  34393. }
  34394. me.length = length -= n;
  34395. items.splice(i, n);
  34396. if (indices) {
  34397. keys = chunk.keys;
  34398. for (i = 0; i < n; ++i) {
  34399. delete indices[keys[i]];
  34400. }
  34401. }
  34402. ++me.generation;
  34403. me.notify('remove', [
  34404. chunk
  34405. ]);
  34406. }
  34407. }
  34408. if (adds) {
  34409. if (autoSort && newCount > 1 && length) {
  34410. me.spliceMerge(addItems, newKeys);
  34411. } else {
  34412. if (autoSort) {
  34413. if (newCount > 1) {
  34414. insertAt = 0;
  34415. me.indices = indices = null;
  34416. } else {
  34417. insertAt = sorters.findInsertionIndex(adds.items[0], items, me.getSortFn(), index);
  34418. }
  34419. }
  34420. if (insertAt === length) {
  34421. end = insertAt;
  34422. for (i = addItems.length - 1; i >= 0; --i) {
  34423. items[end + i] = addItems[i];
  34424. }
  34425. indices = me.indices;
  34426. if (indices) {
  34427. for (i = 0; i < newCount; ++i) {
  34428. indices[newKeys[i]] = insertAt + i;
  34429. }
  34430. }
  34431. } else {
  34432. me.indices = null;
  34433. Ext.Array.insert(items, insertAt, addItems);
  34434. }
  34435. for (i = 0; i < newCount; ++i) {
  34436. map[newKeys[i]] = addItems[i];
  34437. }
  34438. me.length += newCount;
  34439. adds.at = insertAt;
  34440. adds.atItem = insertAt === 0 ? null : items[insertAt - 1];
  34441. ++me.generation;
  34442. me.notify('add', [
  34443. adds
  34444. ]);
  34445. }
  34446. }
  34447. me.endUpdate();
  34448. return me;
  34449. },
  34450. update: function(fn, scope) {
  34451. var me = this;
  34452. me.beginUpdate();
  34453. try {
  34454. return fn.call(scope || me, me);
  34455. } catch (e) {
  34456. Ext.log.error(this.$className + ': Unhandled Exception: ', e.description || e.message);
  34457. throw e;
  34458. } finally {
  34459. me.endUpdate();
  34460. }
  34461. },
  34462. updateKey: function(item, oldKey, details) {
  34463. var me = this,
  34464. map = me.map,
  34465. indices = me.indices,
  34466. source = me.getSource(),
  34467. newKey;
  34468. if (source && !source.updating) {
  34469. source.updateKey(item, oldKey);
  34470. } else if ((newKey = me.getKey(item)) !== oldKey) {
  34471. if (map[oldKey] === item && !(newKey in map)) {
  34472. delete map[oldKey];
  34473. me.updating++;
  34474. me.generation++;
  34475. map[newKey] = item;
  34476. if (indices) {
  34477. indices[newKey] = indices[oldKey];
  34478. delete indices[oldKey];
  34479. }
  34480. me.notify('updatekey', [
  34481. Ext.apply({
  34482. item: item,
  34483. newKey: newKey,
  34484. oldKey: oldKey
  34485. }, details)
  34486. ]);
  34487. me.updating--;
  34488. } else
  34489. {
  34490. if (newKey in map && map[newKey] !== item) {
  34491. Ext.raise('Duplicate newKey "' + newKey + '" for item with oldKey "' + oldKey + '"');
  34492. }
  34493. if (oldKey in map && map[oldKey] !== item) {
  34494. Ext.raise('Incorrect oldKey "' + oldKey + '" for item with newKey "' + newKey + '"');
  34495. }
  34496. }
  34497. }
  34498. },
  34499. findInsertIndex: function(item) {
  34500. var source = this.getSource(),
  34501. sourceItems = source.items,
  34502. i = source.indexOf(item) - 1,
  34503. sourceItem, index;
  34504. while (i > -1) {
  34505. sourceItem = sourceItems[i];
  34506. index = this.indexOf(sourceItem);
  34507. if (index > -1) {
  34508. return index + 1;
  34509. }
  34510. --i;
  34511. }
  34512. return 0;
  34513. },
  34514. onCollectionAdd: function(source, details) {
  34515. var me = this,
  34516. atItem = details.atItem,
  34517. items = details.items,
  34518. requestedIndex = me.requestedIndex,
  34519. filtered, index, copy, i, item, n;
  34520. if (!me.sorted) {
  34521. if (requestedIndex !== undefined) {
  34522. index = requestedIndex;
  34523. } else if (atItem) {
  34524. index = me.indexOf(atItem);
  34525. if (index === -1) {
  34526. index = me.findInsertIndex(items[0]);
  34527. } else {
  34528. ++index;
  34529. }
  34530. } else {
  34531. index = 0;
  34532. }
  34533. }
  34534. if (me.getAutoFilter() && me.filtered) {
  34535. for (i = 0 , n = items.length; i < n; ++i) {
  34536. item = items[i];
  34537. if (me.isItemFiltered(item)) {
  34538. if (!copy) {
  34539. copy = items.slice(0, i);
  34540. }
  34541. if (!filtered) {
  34542. filtered = [];
  34543. }
  34544. filtered.push(item);
  34545. } else if (copy) {
  34546. copy.push(item);
  34547. }
  34548. }
  34549. }
  34550. me.splice((index < 0) ? me.length : index, 0, copy || items);
  34551. if (filtered) {
  34552. me.notify('filteradd', [
  34553. filtered
  34554. ]);
  34555. }
  34556. },
  34557. onCollectionBeforeItemChange: function(source, details) {
  34558. this.onCollectionUpdateKey = null;
  34559. if (!this.sourceUpdating) {
  34560. this.notify('beforeitemchange', [
  34561. details
  34562. ]);
  34563. }
  34564. },
  34565. onCollectionBeginUpdate: function() {
  34566. this.beginUpdate();
  34567. },
  34568. onCollectionEndUpdate: function() {
  34569. this.endUpdate();
  34570. },
  34571. onCollectionItemChange: function(source, details) {
  34572. delete this.onCollectionUpdateKey;
  34573. this.itemChanged(details.item, details.modified, details.oldKey, details.meta);
  34574. },
  34575. onCollectionFilteredItemChange: function() {
  34576. delete this.onCollectionUpdateKey;
  34577. },
  34578. onCollectionRefresh: function(source) {
  34579. var me = this,
  34580. map = {},
  34581. indices = {},
  34582. items = me.items,
  34583. sourceItems = source.items,
  34584. filterFn = me.getFilterFn(),
  34585. i, item, key, length, newLength;
  34586. if (me.filtered && me.getAutoFilter()) {
  34587. for (i = 0 , newLength = 0 , length = sourceItems.length; i < length; i++) {
  34588. if (filterFn(sourceItems[i])) {
  34589. items[newLength++] = sourceItems[i];
  34590. }
  34591. }
  34592. items.length = newLength;
  34593. } else {
  34594. items.length = 0;
  34595. items.push.apply(items, sourceItems);
  34596. }
  34597. if (me.sorted) {
  34598. me.sortData(items);
  34599. }
  34600. me.length = length = items.length;
  34601. me.map = map;
  34602. me.indices = indices;
  34603. for (i = 0; i < length; ++i) {
  34604. key = me.getKey(item = items[i]);
  34605. map[key] = item;
  34606. indices[key] = i;
  34607. }
  34608. ++me.generation;
  34609. me.notify('refresh');
  34610. },
  34611. onCollectionRemove: function(source, details) {
  34612. this.splice(0, details.items);
  34613. },
  34614. onCollectionUpdateKey: function(source, details) {
  34615. this.updateKey(details.item, details.oldKey, details);
  34616. },
  34617. _aggregators: {
  34618. average: function(items, begin, end, property, root) {
  34619. var n = end - begin;
  34620. return n && this._aggregators.sum.call(this, items, begin, end, property, root) / n;
  34621. },
  34622. bounds: function(items, begin, end, property, root) {
  34623. for (var value, max, min,
  34624. i = begin; i < end; ++i) {
  34625. value = items[i];
  34626. value = (root ? value[root] : value)[property];
  34627. if (!(value < max)) {
  34628. max = value;
  34629. }
  34630. if (!(value > min)) {
  34631. min = value;
  34632. }
  34633. }
  34634. return [
  34635. min,
  34636. max
  34637. ];
  34638. },
  34639. count: function(items) {
  34640. return items.length;
  34641. },
  34642. extremes: function(items, begin, end, property, root) {
  34643. var most = null,
  34644. least = null,
  34645. i, item, max, min, value;
  34646. for (i = begin; i < end; ++i) {
  34647. item = items[i];
  34648. value = (root ? item[root] : item)[property];
  34649. if (!(value < max)) {
  34650. max = value;
  34651. most = item;
  34652. }
  34653. if (!(value > min)) {
  34654. min = value;
  34655. least = item;
  34656. }
  34657. }
  34658. return [
  34659. least,
  34660. most
  34661. ];
  34662. },
  34663. max: function(items, begin, end, property, root) {
  34664. var b = this._aggregators.bounds.call(this, items, begin, end, property, root);
  34665. return b[1];
  34666. },
  34667. maxItem: function(items, begin, end, property, root) {
  34668. var b = this._aggregators.extremes.call(this, items, begin, end, property, root);
  34669. return b[1];
  34670. },
  34671. min: function(items, begin, end, property, root) {
  34672. var b = this._aggregators.bounds.call(this, items, begin, end, property, root);
  34673. return b[0];
  34674. },
  34675. minItem: function(items, begin, end, property, root) {
  34676. var b = this._aggregators.extremes.call(this, items, begin, end, property, root);
  34677. return b[0];
  34678. },
  34679. sum: function(items, begin, end, property, root) {
  34680. for (var value,
  34681. sum = 0,
  34682. i = begin; i < end; ++i) {
  34683. value = items[i];
  34684. value = (root ? value[root] : value)[property];
  34685. sum += value;
  34686. }
  34687. return sum;
  34688. }
  34689. },
  34690. _eventToMethodMap: {
  34691. add: 'onCollectionAdd',
  34692. beforeitemchange: 'onCollectionBeforeItemChange',
  34693. beginupdate: 'onCollectionBeginUpdate',
  34694. endupdate: 'onCollectionEndUpdate',
  34695. itemchange: 'onCollectionItemChange',
  34696. filtereditemchange: 'onCollectionFilteredItemChange',
  34697. refresh: 'onCollectionRefresh',
  34698. remove: 'onCollectionRemove',
  34699. beforesort: 'beforeCollectionSort',
  34700. sort: 'onCollectionSort',
  34701. filter: 'onCollectionFilter',
  34702. filteradd: 'onCollectionFilterAdd',
  34703. updatekey: 'onCollectionUpdateKey'
  34704. },
  34705. addObserver: function(observer) {
  34706. var me = this,
  34707. observers = me.observers;
  34708. if (!observers) {
  34709. me.observers = observers = [];
  34710. }
  34711. if (Ext.Array.contains(observers, observer)) {
  34712. Ext.Error.raise('Observer already added');
  34713. }
  34714. if (me.notifying) {
  34715. me.observers = observers = observers.slice(0);
  34716. }
  34717. observers.push(observer);
  34718. if (observers.length > 1) {
  34719. Ext.Array.sort(observers, me.prioritySortFn);
  34720. }
  34721. },
  34722. prioritySortFn: function(o1, o2) {
  34723. var a = o1.observerPriority || 0,
  34724. b = o2.observerPriority || 0;
  34725. return a - b;
  34726. },
  34727. applyExtraKeys: function(extraKeys, oldExtraKeys) {
  34728. var me = this,
  34729. ret = oldExtraKeys || {},
  34730. config, name, value;
  34731. for (name in extraKeys) {
  34732. value = extraKeys[name];
  34733. if (!value.isCollectionKey) {
  34734. config = {
  34735. collection: me
  34736. };
  34737. if (Ext.isString(value)) {
  34738. config.property = value;
  34739. } else {
  34740. config = Ext.apply(config, value);
  34741. }
  34742. value = new Ext.util.CollectionKey(config);
  34743. } else {
  34744. value.setCollection(me);
  34745. }
  34746. ret[name] = me[name] = value;
  34747. value.name = name;
  34748. }
  34749. return ret;
  34750. },
  34751. applyGrouper: function(grouper) {
  34752. if (grouper) {
  34753. grouper = this.getSorters().decodeSorter(grouper, Ext.util.Grouper);
  34754. }
  34755. return grouper;
  34756. },
  34757. decodeItems: function(args, index) {
  34758. var me = this,
  34759. ret = (index === undefined) ? args : args[index],
  34760. cloned, decoder, i;
  34761. if (!ret || !ret.$cloned) {
  34762. cloned = args.length > index + 1 || !Ext.isIterable(ret);
  34763. if (cloned) {
  34764. ret = Ext.Array.slice(args, index);
  34765. if (ret.length === 1 && ret[0] === undefined) {
  34766. ret.length = 0;
  34767. }
  34768. }
  34769. decoder = me.getDecoder();
  34770. if (decoder) {
  34771. if (!cloned) {
  34772. ret = ret.slice(0);
  34773. cloned = true;
  34774. }
  34775. for (i = ret.length; i-- > 0; ) {
  34776. if ((ret[i] = decoder.call(me, ret[i])) === false) {
  34777. ret.splice(i, 1);
  34778. }
  34779. }
  34780. }
  34781. if (cloned) {
  34782. ret.$cloned = true;
  34783. }
  34784. }
  34785. return ret;
  34786. },
  34787. getIndices: function() {
  34788. var me = this,
  34789. indices = me.indices,
  34790. items = me.items,
  34791. n = items.length,
  34792. i, key;
  34793. if (!indices) {
  34794. me.indices = indices = {};
  34795. ++me.indexRebuilds;
  34796. for (i = 0; i < n; ++i) {
  34797. key = me.getKey(items[i]);
  34798. indices[key] = i;
  34799. }
  34800. }
  34801. return indices;
  34802. },
  34803. notify: function(eventName, args) {
  34804. var me = this,
  34805. observers = me.observers,
  34806. methodName = me._eventToMethodMap[eventName],
  34807. added = 0,
  34808. index, length, method, observer;
  34809. args = args || [];
  34810. if (observers && methodName) {
  34811. me.notifying = true;
  34812. for (index = 0 , length = observers.length; index < length; ++index) {
  34813. method = (observer = observers[index])[methodName];
  34814. if (method) {
  34815. if (!added++) {
  34816. args.unshift(me);
  34817. }
  34818. method.apply(observer, args);
  34819. }
  34820. }
  34821. me.notifying = false;
  34822. }
  34823. if (!me.hasListeners) {
  34824. return;
  34825. }
  34826. if (me.hasListeners[eventName]) {
  34827. if (!added) {
  34828. args.unshift(me);
  34829. }
  34830. me.fireEventArgs(eventName, args);
  34831. }
  34832. },
  34833. getFilterFn: function() {
  34834. return this.getFilters().getFilterFn();
  34835. },
  34836. getFilters: function(autoCreate) {
  34837. var ret = this._filters;
  34838. if (!ret && autoCreate !== false) {
  34839. ret = new Ext.util.FilterCollection();
  34840. this.setFilters(ret);
  34841. }
  34842. return ret;
  34843. },
  34844. isItemFiltered: function(item) {
  34845. return !this.getFilters().filterFn(item);
  34846. },
  34847. onFilterChange: function(filters) {
  34848. var me = this,
  34849. source = me.getSource(),
  34850. extraKeys, newKeys, key;
  34851. if (!source) {
  34852. extraKeys = me.getExtraKeys();
  34853. if (extraKeys) {
  34854. newKeys = {};
  34855. for (key in extraKeys) {
  34856. newKeys[key] = extraKeys[key].clone(me);
  34857. }
  34858. }
  34859. source = new Ext.util.Collection({
  34860. keyFn: me.getKey,
  34861. extraKeys: newKeys,
  34862. rootProperty: me.getRootProperty()
  34863. });
  34864. if (me.length) {
  34865. source.add(me.items);
  34866. }
  34867. me.setSource(source);
  34868. me.autoSource = source;
  34869. } else {
  34870. if (source.destroyed) {
  34871. return;
  34872. }
  34873. if (source.length || me.length) {
  34874. me.onCollectionRefresh(source);
  34875. }
  34876. }
  34877. me.notify('filter');
  34878. },
  34879. applyFilters: function(filters, collection) {
  34880. if (!filters || filters.isFilterCollection) {
  34881. return filters;
  34882. }
  34883. if (filters) {
  34884. if (!collection) {
  34885. collection = this.getFilters();
  34886. }
  34887. collection.splice(0, collection.length, filters);
  34888. }
  34889. return collection;
  34890. },
  34891. updateFilters: function(newFilters, oldFilters) {
  34892. var me = this;
  34893. if (oldFilters) {
  34894. oldFilters.un('endupdate', 'onEndUpdateFilters', me);
  34895. }
  34896. if (newFilters) {
  34897. newFilters.on({
  34898. endupdate: 'onEndUpdateFilters',
  34899. scope: me,
  34900. priority: me.$endUpdatePriority
  34901. });
  34902. newFilters.$filterable = me;
  34903. }
  34904. me.onEndUpdateFilters(newFilters);
  34905. },
  34906. onEndUpdateFilters: function(filters) {
  34907. var me = this,
  34908. was = me.filtered,
  34909. is = !!filters && (filters.getFilterCount() > 0);
  34910. if (was || is) {
  34911. me.filtered = is;
  34912. me.onFilterChange(filters);
  34913. }
  34914. },
  34915. getSortFn: function() {
  34916. return this._sortFn || this.createSortFn();
  34917. },
  34918. getSorters: function(autoCreate) {
  34919. var ret = this._sorters;
  34920. if (!ret && autoCreate !== false) {
  34921. ret = new Ext.util.SorterCollection();
  34922. this.setSorters(ret);
  34923. }
  34924. return ret;
  34925. },
  34926. onSortChange: function() {
  34927. if (this.sorted) {
  34928. this.sortItems();
  34929. }
  34930. },
  34931. sort: function(property, direction, mode) {
  34932. var sorters = this.getSorters();
  34933. sorters.addSort.apply(sorters, arguments);
  34934. return this;
  34935. },
  34936. sortData: function(data) {
  34937. Ext.Array.sort(data, this.getSortFn());
  34938. return data;
  34939. },
  34940. sortItems: function(sortFn) {
  34941. var me = this;
  34942. if (me.sorted) {
  34943. if (sortFn) {
  34944. Ext.raise('Collections with sorters cannot resorted');
  34945. }
  34946. sortFn = me.getSortFn();
  34947. }
  34948. me.indices = null;
  34949. me.notify('beforesort', [
  34950. me.getSorters(false)
  34951. ]);
  34952. if (me.length) {
  34953. Ext.Array.sort(me.items, sortFn);
  34954. }
  34955. me.notify('sort');
  34956. },
  34957. sortBy: function(sortFn) {
  34958. return this.sortItems(sortFn);
  34959. },
  34960. findInsertionIndex: function(item, items, comparatorFn, index) {
  34961. return Ext.Array.findInsertionIndex(item, items || this.items, comparatorFn || this.getSortFn(), index);
  34962. },
  34963. applySorters: function(sorters, collection) {
  34964. if (!sorters || sorters.isSorterCollection) {
  34965. return sorters;
  34966. }
  34967. if (sorters) {
  34968. if (!collection) {
  34969. collection = this.getSorters();
  34970. }
  34971. collection.splice(0, collection.length, sorters);
  34972. }
  34973. return collection;
  34974. },
  34975. createSortFn: function() {
  34976. var me = this,
  34977. grouper = me.getGrouper(),
  34978. sorters = me.getSorters(false),
  34979. sorterFn = sorters ? sorters.getSortFn() : null;
  34980. if (!grouper) {
  34981. return sorterFn;
  34982. }
  34983. return function(lhs, rhs) {
  34984. var ret = grouper.sort(lhs, rhs);
  34985. if (!ret && sorterFn) {
  34986. ret = sorterFn(lhs, rhs);
  34987. }
  34988. return ret;
  34989. };
  34990. },
  34991. updateGrouper: function(grouper) {
  34992. var me = this,
  34993. groups = me.getGroups(),
  34994. sorters = me.getSorters(),
  34995. populate;
  34996. me.onSorterChange();
  34997. me.grouped = !!grouper;
  34998. if (grouper) {
  34999. if (me.getTrackGroups()) {
  35000. if (!groups) {
  35001. groups = new Ext.util.GroupCollection({
  35002. itemRoot: me.getRootProperty(),
  35003. groupConfig: me.getGroupConfig()
  35004. });
  35005. groups.$groupable = me;
  35006. me.setGroups(groups);
  35007. }
  35008. groups.setGrouper(grouper);
  35009. populate = true;
  35010. }
  35011. } else {
  35012. if (groups) {
  35013. me.removeObserver(groups);
  35014. groups.destroy();
  35015. }
  35016. me.setGroups(null);
  35017. }
  35018. if (!sorters.updating) {
  35019. me.onEndUpdateSorters(sorters);
  35020. }
  35021. if (populate) {
  35022. groups.onCollectionRefresh(me);
  35023. }
  35024. },
  35025. updateSorters: function(newSorters, oldSorters) {
  35026. var me = this;
  35027. if (oldSorters && !oldSorters.destroyed) {
  35028. oldSorters.un('endupdate', 'onEndUpdateSorters', me);
  35029. }
  35030. if (newSorters) {
  35031. newSorters.on({
  35032. endupdate: 'onEndUpdateSorters',
  35033. scope: me,
  35034. priority: me.$endUpdatePriority
  35035. });
  35036. if (me.manageSorters) {
  35037. newSorters.$sortable = me;
  35038. }
  35039. }
  35040. me.onSorterChange();
  35041. me.onEndUpdateSorters(newSorters);
  35042. },
  35043. onSorterChange: function() {
  35044. this._sortFn = null;
  35045. },
  35046. onEndUpdateSorters: function(sorters) {
  35047. var me = this,
  35048. was = me.sorted,
  35049. is = (me.grouped && me.getAutoGroup()) || (sorters && sorters.length > 0);
  35050. if (was || is) {
  35051. me.sorted = !!is;
  35052. me.onSortChange(sorters);
  35053. }
  35054. },
  35055. removeObserver: function(observer) {
  35056. var observers = this.observers;
  35057. if (observers) {
  35058. Ext.Array.remove(observers, observer);
  35059. }
  35060. },
  35061. spliceMerge: function(newItems, newKeys) {
  35062. var me = this,
  35063. map = me.map,
  35064. newLength = newItems.length,
  35065. oldIndex = 0,
  35066. oldItems = me.items,
  35067. oldLength = oldItems.length,
  35068. adds = [],
  35069. count = 0,
  35070. items = [],
  35071. sortFn = me.getSortFn(),
  35072. addItems, end, i, newItem, oldItem, newIndex;
  35073. me.items = items;
  35074. for (newIndex = 0; newIndex < newLength; newIndex = end) {
  35075. newItem = newItems[newIndex];
  35076. for (; oldIndex < oldLength; ++oldIndex) {
  35077. if (sortFn(newItem, oldItem = oldItems[oldIndex]) < 0) {
  35078. break;
  35079. }
  35080. items.push(oldItem);
  35081. }
  35082. if (oldIndex === oldLength) {
  35083. adds[count++] = {
  35084. at: items.length,
  35085. itemAt: items[items.length - 1],
  35086. items: (addItems = [])
  35087. };
  35088. if (count > 1) {
  35089. adds[count - 2].next = adds[count - 1];
  35090. }
  35091. for (; newIndex < newLength; ++newIndex) {
  35092. addItems.push(newItem = newItems[newIndex]);
  35093. items.push(newItem);
  35094. }
  35095. break;
  35096. }
  35097. adds[count++] = {
  35098. at: items.length,
  35099. itemAt: items[items.length - 1],
  35100. items: (addItems = [
  35101. newItem
  35102. ])
  35103. };
  35104. if (count > 1) {
  35105. adds[count - 2].next = adds[count - 1];
  35106. }
  35107. items.push(newItem);
  35108. for (end = newIndex + 1; end < newLength; ++end) {
  35109. if (sortFn(newItem = newItems[end], oldItem) >= 0) {
  35110. break;
  35111. }
  35112. items.push(newItem);
  35113. addItems.push(newItem);
  35114. }
  35115. }
  35116. for (; oldIndex < oldLength; ++oldIndex) {
  35117. items.push(oldItems[oldIndex]);
  35118. }
  35119. for (i = 0; i < newLength; ++i) {
  35120. map[newKeys[i]] = newItems[i];
  35121. }
  35122. me.length = items.length;
  35123. ++me.generation;
  35124. me.indices = null;
  35125. for (i = 0; i < count; ++i) {
  35126. me.notify('add', [
  35127. adds[i]
  35128. ]);
  35129. }
  35130. },
  35131. getGroups: function() {
  35132. return this.callParent() || null;
  35133. },
  35134. updateAutoGroup: function(autoGroup) {
  35135. var groups = this.getGroups();
  35136. if (groups) {
  35137. groups.setAutoGroup(autoGroup);
  35138. }
  35139. this.onEndUpdateSorters(this._sorters);
  35140. },
  35141. updateGroups: function(newGroups, oldGroups) {
  35142. if (oldGroups) {
  35143. this.removeObserver(oldGroups);
  35144. }
  35145. if (newGroups) {
  35146. this.addObserver(newGroups);
  35147. }
  35148. },
  35149. updateSource: function(newSource, oldSource) {
  35150. var auto = this.autoSource;
  35151. if (oldSource) {
  35152. if (!oldSource.destroyed) {
  35153. oldSource.removeObserver(this);
  35154. }
  35155. if (oldSource === auto) {
  35156. auto.destroy();
  35157. this.autoSource = null;
  35158. }
  35159. }
  35160. if (newSource) {
  35161. newSource.addObserver(this);
  35162. if (newSource.length || this.length) {
  35163. this.onCollectionRefresh(newSource);
  35164. }
  35165. }
  35166. }
  35167. }, function() {
  35168. var prototype = this.prototype;
  35169. prototype.removeAtKey = prototype.removeByKey;
  35170. prototype.decodeRemoveItems = prototype.decodeItems;
  35171. Ext.Object.each(prototype._aggregators, function(name) {
  35172. prototype[name] = function(property, begin, end) {
  35173. return this.aggregate(property, name, begin, end);
  35174. };
  35175. prototype[name + 'ByGroup'] = function(property) {
  35176. return this.aggregateByGroup(property, name);
  35177. };
  35178. });
  35179. });
  35180. Ext.define('Ext.data.Range', {
  35181. isDataRange: true,
  35182. begin: 0,
  35183. buffer: 0,
  35184. end: 0,
  35185. length: 0,
  35186. store: null,
  35187. constructor: function(config) {
  35188. var me = this,
  35189. activeRanges, store;
  35190. Ext.apply(me, config);
  35191. store = me.store;
  35192. if (!(activeRanges = store.activeRanges)) {
  35193. store.activeRanges = activeRanges = [];
  35194. }
  35195. activeRanges.push(me);
  35196. me.refresh();
  35197. if ('begin' in config) {
  35198. me.begin = me.end = 0;
  35199. me.goto(config.begin, config.end);
  35200. }
  35201. },
  35202. destroy: function() {
  35203. var me = this,
  35204. store = me.store,
  35205. activeRanges = store && store.activeRanges;
  35206. Ext.destroy(me.storeListeners);
  35207. if (activeRanges) {
  35208. Ext.Array.remove(activeRanges, me);
  35209. }
  35210. me.callParent();
  35211. },
  35212. "goto": function(begin, end) {
  35213. var me = this,
  35214. buffer = me.buffer,
  35215. task = me.task;
  35216. me.begin = begin;
  35217. me.end = end;
  35218. me.length = end - begin;
  35219. if (buffer > 0) {
  35220. if (!task) {
  35221. me.task = task = new Ext.util.DelayedTask(me.doGoto, me);
  35222. }
  35223. task.delay(buffer);
  35224. } else {
  35225. me.doGoto();
  35226. }
  35227. },
  35228. privates: {
  35229. lastBegin: 0,
  35230. lastEnd: 0,
  35231. doGoto: Ext.privateFn,
  35232. refresh: function() {
  35233. this.records = this.store.getData().items;
  35234. }
  35235. }
  35236. });
  35237. Ext.define('Ext.util.ObjectTemplate', {
  35238. isObjectTemplate: true,
  35239. excludeProperties: {},
  35240. valueRe: /^[{][a-z\.]+[}]$/i,
  35241. statics: {
  35242. create: function(template, options) {
  35243. if (!Ext.isObject(template)) {
  35244. Ext.raise('The template is not an Object');
  35245. }
  35246. return template.isObjectTemplate ? template : new Ext.util.ObjectTemplate(template, options);
  35247. }
  35248. },
  35249. constructor: function(template, options) {
  35250. Ext.apply(this, options);
  35251. this.template = template;
  35252. },
  35253. apply: function(context) {
  35254. var me = this;
  35255. delete me.apply;
  35256. me.apply = me.compile(me.template);
  35257. return me.apply(context);
  35258. },
  35259. privates: {
  35260. compile: function(template) {
  35261. var me = this,
  35262. exclude = me.excludeProperties,
  35263. compiled, i, len, fn;
  35264. if (Ext.isString(template)) {
  35265. if (template.indexOf('{') < 0) {
  35266. fn = function() {
  35267. return template;
  35268. };
  35269. } else if (me.valueRe.test(template)) {
  35270. template = template.substring(1, template.length - 1).split('.');
  35271. fn = function(context) {
  35272. for (var v = context,
  35273. i = 0; v && i < template.length; ++i) {
  35274. v = v[template[i]];
  35275. }
  35276. return v;
  35277. };
  35278. } else {
  35279. template = new Ext.XTemplate(template);
  35280. fn = function(context) {
  35281. return template.apply(context);
  35282. };
  35283. }
  35284. } else if (!template || Ext.isPrimitive(template) || Ext.isFunction(template)) {
  35285. fn = function() {
  35286. return template;
  35287. };
  35288. } else if (template instanceof Array) {
  35289. compiled = [];
  35290. for (i = 0 , len = template.length; i < len; ++i) {
  35291. compiled[i] = me.compile(template[i]);
  35292. }
  35293. fn = function(context) {
  35294. var ret = [],
  35295. i;
  35296. for (i = 0; i < len; ++i) {
  35297. ret[i] = compiled[i](context);
  35298. }
  35299. return ret;
  35300. };
  35301. } else {
  35302. compiled = {};
  35303. for (i in template) {
  35304. if (!exclude[i]) {
  35305. compiled[i] = me.compile(template[i]);
  35306. }
  35307. }
  35308. fn = function(context) {
  35309. var ret = {},
  35310. i, v;
  35311. for (i in template) {
  35312. v = exclude[i] ? template[i] : compiled[i](context);
  35313. if (v !== undefined) {
  35314. ret[i] = v;
  35315. }
  35316. }
  35317. return ret;
  35318. };
  35319. }
  35320. return fn;
  35321. }
  35322. }
  35323. });
  35324. Ext.define('Ext.data.schema.Role', {
  35325. isRole: true,
  35326. left: true,
  35327. owner: false,
  35328. side: 'left',
  35329. isMany: false,
  35330. defaultReaderType: 'json',
  35331. _internalReadOptions: {
  35332. recordsOnly: true,
  35333. asRoot: true
  35334. },
  35335. constructor: function(association, config) {
  35336. var me = this,
  35337. extra = config.extra;
  35338. Ext.apply(me, config);
  35339. if (extra) {
  35340. extra = Ext.apply({}, extra);
  35341. delete extra.type;
  35342. Ext.apply(me, extra);
  35343. delete me.extra;
  35344. }
  35345. me.association = association;
  35346. if (association.owner === me.side) {
  35347. association.owner = me;
  35348. me.owner = true;
  35349. }
  35350. },
  35351. processUpdate: function() {
  35352. Ext.raise('Only the "many" for an association may be processed. "' + this.role + '" is not valid.');
  35353. },
  35354. processLoad: function(store, associatedEntity, records, session) {
  35355. return records;
  35356. },
  35357. checkMembership: Ext.emptyFn,
  35358. adoptAssociated: function(record, session) {
  35359. var other = this.getAssociatedItem(record);
  35360. if (other) {
  35361. session.adopt(other);
  35362. }
  35363. },
  35364. $roleFilterId: '$associationRoleFilter',
  35365. createAssociationStore: function(session, from, records, isComplete) {
  35366. var me = this,
  35367. association = me.association,
  35368. foreignKeyName = association.getFieldName(),
  35369. isMany = association.isManyToMany,
  35370. storeConfig = me.storeConfig,
  35371. id = from.getId(),
  35372. config = {
  35373. asynchronousLoad: false,
  35374. model: me.cls,
  35375. role: me,
  35376. session: session,
  35377. associatedEntity: from,
  35378. disableMetaChangeEvent: true,
  35379. pageSize: null,
  35380. remoteFilter: true,
  35381. trackRemoved: !session
  35382. },
  35383. store;
  35384. if (isMany) {
  35385. config.filters = [
  35386. {
  35387. id: me.$roleFilterId,
  35388. property: me.inverse.field,
  35389. value: id,
  35390. exactMatch: true
  35391. }
  35392. ];
  35393. } else if (foreignKeyName) {
  35394. config.filters = [
  35395. {
  35396. id: me.$roleFilterId,
  35397. property: foreignKeyName,
  35398. value: id,
  35399. exactMatch: true
  35400. }
  35401. ];
  35402. config.foreignKeyName = foreignKeyName;
  35403. }
  35404. if (storeConfig) {
  35405. Ext.apply(config, storeConfig);
  35406. }
  35407. store = Ext.Factory.store(config);
  35408. me.onStoreCreate(store, session, id);
  35409. if (!isMany || session) {
  35410. store.on({
  35411. scope: me,
  35412. add: 'onAddToMany',
  35413. remove: 'onRemoveFromMany',
  35414. clear: 'onRemoveFromMany'
  35415. });
  35416. }
  35417. if (records) {
  35418. store.loadData(records);
  35419. }
  35420. store.complete = !!isComplete;
  35421. return store;
  35422. },
  35423. onStoreCreate: Ext.emptyFn,
  35424. getAssociatedStore: function(inverseRecord, options, scope, records, allowInfer) {
  35425. var me = this,
  35426. storeName = me.getStoreName(),
  35427. store = inverseRecord[storeName],
  35428. hadStore = store,
  35429. session = inverseRecord.session,
  35430. load = options && options.reload,
  35431. source = inverseRecord.$source,
  35432. isComplete = false,
  35433. phantom = false,
  35434. hadSourceStore, args, i, len, raw, rec, sourceStore, hadRecords, isLoading;
  35435. if (!store) {
  35436. if (session) {
  35437. if (source) {
  35438. phantom = source.phantom;
  35439. }
  35440. if (!records && source) {
  35441. sourceStore = source[storeName];
  35442. if (sourceStore && !sourceStore.isLoading()) {
  35443. records = [];
  35444. raw = sourceStore.getData().items;
  35445. for (i = 0 , len = raw.length; i < len; ++i) {
  35446. rec = raw[i];
  35447. records.push(session.getRecord(rec.self, rec.id));
  35448. }
  35449. isComplete = !!sourceStore.complete;
  35450. hadSourceStore = true;
  35451. }
  35452. }
  35453. if (!hadSourceStore) {
  35454. hadRecords = !!records;
  35455. records = me.findRecords(session, inverseRecord, records, allowInfer);
  35456. if (!hadRecords && (!records || !records.length)) {
  35457. records = null;
  35458. }
  35459. isComplete = phantom || hadRecords;
  35460. }
  35461. } else {
  35462. isComplete = !!records;
  35463. }
  35464. store = me.createAssociationStore(session, inverseRecord, records, isComplete || inverseRecord.phantom);
  35465. store.$source = sourceStore;
  35466. if (!records && (me.autoLoad || options)) {
  35467. load = true;
  35468. }
  35469. inverseRecord[storeName] = store;
  35470. }
  35471. if (options) {
  35472. if (load || store.isLoading()) {
  35473. store.on('load', function(store, records, success, operation) {
  35474. args = [
  35475. store,
  35476. operation
  35477. ];
  35478. scope = scope || options.scope || inverseRecord;
  35479. if (success) {
  35480. Ext.callback(options.success, scope, args);
  35481. } else {
  35482. Ext.callback(options.failure, scope, args);
  35483. }
  35484. args.push(success);
  35485. Ext.callback(options, scope, args);
  35486. Ext.callback(options.callback, scope, args);
  35487. }, null, {
  35488. single: true
  35489. });
  35490. } else {
  35491. args = [
  35492. store,
  35493. null
  35494. ];
  35495. scope = scope || options.scope || inverseRecord;
  35496. Ext.callback(options.success, scope, args);
  35497. args.push(true);
  35498. Ext.callback(options, scope, args);
  35499. Ext.callback(options.callback, scope, args);
  35500. }
  35501. }
  35502. isLoading = store.isLoading();
  35503. if (load) {
  35504. if (!isLoading) {
  35505. store.load();
  35506. }
  35507. } else if (hadStore && records && !isLoading) {
  35508. store.loadData(records);
  35509. }
  35510. return store;
  35511. },
  35512. getAssociatedItem: function(rec) {
  35513. var key = this.isMany ? this.getStoreName() : this.getInstanceName();
  35514. return rec[key] || null;
  35515. },
  35516. onDrop: Ext.emptyFn,
  35517. onIdChanged: Ext.emptyFn,
  35518. getReaderRoot: function() {
  35519. var me = this;
  35520. return me.associationKey || (me.associationKey = me.association.schema.getNamer().readerRoot(me.role));
  35521. },
  35522. getReader: function() {
  35523. var me = this,
  35524. reader = me.reader,
  35525. Model = me.cls,
  35526. useSimpleAccessors = !me.associationKey,
  35527. root = this.getReaderRoot();
  35528. if (reader && !reader.isReader) {
  35529. if (Ext.isString(reader)) {
  35530. reader = {
  35531. type: reader
  35532. };
  35533. }
  35534. Ext.applyIf(reader, {
  35535. model: Model,
  35536. rootProperty: root,
  35537. useSimpleAccessors: useSimpleAccessors,
  35538. type: me.defaultReaderType
  35539. });
  35540. reader = me.reader = Ext.createByAlias('reader.' + reader.type, reader);
  35541. }
  35542. return reader;
  35543. },
  35544. getInstanceName: function() {
  35545. var me = this;
  35546. return me.instanceName || (me.instanceName = me.association.schema.getNamer().instanceName(me.role));
  35547. },
  35548. getOldInstanceName: function() {
  35549. return this.oldInstanceName || (this.oldInstanceName = '$old' + this.getInstanceName());
  35550. },
  35551. getStoreName: function() {
  35552. var me = this;
  35553. return me.storeName || (me.storeName = me.association.schema.getNamer().storeName(me.role));
  35554. },
  35555. constructReader: function(fromReader) {
  35556. var me = this,
  35557. reader = me.getReader(),
  35558. Model = me.cls,
  35559. useSimpleAccessors = !me.associationKey,
  35560. root = me.getReaderRoot(),
  35561. proxyReader, proxy;
  35562. if (!reader) {
  35563. proxy = Model.getProxy();
  35564. if (proxy) {
  35565. proxyReader = proxy.getReader();
  35566. reader = new proxyReader.self();
  35567. reader.copyFrom(proxyReader);
  35568. reader.setRootProperty(root);
  35569. } else {
  35570. reader = new fromReader.self({
  35571. model: Model,
  35572. useSimpleAccessors: useSimpleAccessors,
  35573. rootProperty: root
  35574. });
  35575. }
  35576. me.reader = reader;
  35577. }
  35578. return reader;
  35579. },
  35580. read: function(record, data, fromReader, readOptions) {
  35581. var reader = this.constructReader(fromReader),
  35582. root = reader.getRoot(data);
  35583. if (root) {
  35584. return reader.readRecords(root, readOptions, this._internalReadOptions);
  35585. }
  35586. },
  35587. getCallbackOptions: function(options, scope, defaultScope) {
  35588. if (typeof options === 'function') {
  35589. options = {
  35590. callback: options,
  35591. scope: scope || defaultScope
  35592. };
  35593. } else if (options) {
  35594. options = Ext.apply({}, options);
  35595. options.scope = scope || options.scope || defaultScope;
  35596. }
  35597. return options;
  35598. },
  35599. doGetFK: function(leftRecord, options, scope) {
  35600. var me = this,
  35601. cls = me.cls,
  35602. foreignKey = me.association.getFieldName(),
  35603. instanceName = me.getInstanceName(),
  35604. rightRecord = leftRecord[instanceName],
  35605. reload = options && options.reload,
  35606. done = rightRecord !== undefined && !reload,
  35607. session = leftRecord.session,
  35608. foreignKeyId, args;
  35609. if (!done) {
  35610. if (session) {
  35611. foreignKeyId = leftRecord.get(foreignKey);
  35612. if (foreignKeyId || foreignKeyId === 0) {
  35613. done = session.peekRecord(cls, foreignKeyId, true) && !reload;
  35614. rightRecord = session.getRecord(cls, foreignKeyId, false);
  35615. } else {
  35616. done = true;
  35617. leftRecord[instanceName] = rightRecord = null;
  35618. }
  35619. } else if (foreignKey) {
  35620. foreignKeyId = leftRecord.get(foreignKey);
  35621. if (!foreignKeyId && foreignKeyId !== 0) {
  35622. done = true;
  35623. leftRecord[instanceName] = rightRecord = null;
  35624. } else {
  35625. if (!rightRecord) {
  35626. rightRecord = cls.createWithId(foreignKeyId);
  35627. }
  35628. }
  35629. } else
  35630. {
  35631. done = true;
  35632. rightRecord = null;
  35633. }
  35634. } else if (rightRecord) {
  35635. done = !rightRecord.isLoading();
  35636. }
  35637. if (done) {
  35638. if (options) {
  35639. args = [
  35640. rightRecord,
  35641. null
  35642. ];
  35643. scope = scope || options.scope || leftRecord;
  35644. Ext.callback(options.success, scope, args);
  35645. args.push(true);
  35646. Ext.callback(options, scope, args);
  35647. Ext.callback(options.callback, scope, args);
  35648. }
  35649. } else {
  35650. leftRecord[instanceName] = rightRecord;
  35651. options = me.getCallbackOptions(options, scope, leftRecord);
  35652. rightRecord.load(options);
  35653. }
  35654. return rightRecord;
  35655. },
  35656. doSetFK: function(leftRecord, rightRecord, options, scope) {
  35657. var me = this,
  35658. foreignKey = me.association.getFieldName(),
  35659. instanceName = me.getInstanceName(),
  35660. current = leftRecord[instanceName],
  35661. inverse = me.inverse,
  35662. inverseSetter = inverse.setterName,
  35663. session = leftRecord.session,
  35664. modified, oldInstanceName;
  35665. if (rightRecord && rightRecord.isEntity) {
  35666. if (current !== rightRecord) {
  35667. oldInstanceName = me.getOldInstanceName();
  35668. leftRecord[oldInstanceName] = current;
  35669. leftRecord[instanceName] = rightRecord;
  35670. if (current && current.isEntity) {
  35671. current[inverse.getInstanceName()] = undefined;
  35672. }
  35673. if (foreignKey) {
  35674. leftRecord.set(foreignKey, rightRecord.getId());
  35675. }
  35676. delete leftRecord[oldInstanceName];
  35677. leftRecord.onAssociatedRecordSet(rightRecord, me);
  35678. if (inverseSetter) {
  35679. rightRecord[inverseSetter](leftRecord);
  35680. }
  35681. }
  35682. } else {
  35683. if (!foreignKey) {
  35684. Ext.raise('No foreignKey specified for "' + me.association.left.role + '" by ' + leftRecord.$className);
  35685. }
  35686. modified = (leftRecord.changingKey && !inverse.isMany) || leftRecord.set(foreignKey, rightRecord);
  35687. if (modified && current && current.isEntity && !current.isEqual(current.getId(), rightRecord)) {
  35688. leftRecord[instanceName] = undefined;
  35689. if (!inverse.isMany) {
  35690. current[inverse.getInstanceName()] = undefined;
  35691. }
  35692. }
  35693. }
  35694. if (options) {
  35695. if (Ext.isFunction(options)) {
  35696. options = {
  35697. callback: options,
  35698. scope: scope || leftRecord
  35699. };
  35700. }
  35701. return leftRecord.save(options);
  35702. }
  35703. }
  35704. });
  35705. Ext.define('Ext.data.schema.Association', {
  35706. isOneToOne: false,
  35707. isManyToOne: false,
  35708. isManyToMany: false,
  35709. owner: null,
  35710. field: null,
  35711. constructor: function(config) {
  35712. var me = this,
  35713. left, right;
  35714. Ext.apply(me, config);
  35715. me.left = left = new me.Left(me, me.left);
  35716. me.right = right = new me.Right(me, me.right);
  35717. left.inverse = right;
  35718. right.inverse = left;
  35719. },
  35720. hasField: function() {
  35721. return !!this.field;
  35722. },
  35723. getFieldName: function() {
  35724. var field = this.field;
  35725. return field ? field.name : '';
  35726. }
  35727. });
  35728. Ext.define('Ext.data.schema.OneToOne', {
  35729. extend: Ext.data.schema.Association,
  35730. isOneToOne: true,
  35731. isToOne: true,
  35732. kind: 'one-to-one',
  35733. Left: Ext.define(null, {
  35734. extend: 'Ext.data.schema.Role',
  35735. onDrop: function(rightRecord, session) {
  35736. var leftRecord = this.getAssociatedItem(rightRecord);
  35737. rightRecord[this.getInstanceName()] = null;
  35738. if (leftRecord) {
  35739. leftRecord[this.inverse.getInstanceName()] = null;
  35740. }
  35741. },
  35742. onIdChanged: function(rightRecord, oldId, newId) {
  35743. var leftRecord = this.getAssociatedItem(rightRecord),
  35744. fieldName = this.association.getFieldName();
  35745. if (!rightRecord.session && leftRecord && fieldName) {
  35746. leftRecord.set(fieldName, newId);
  35747. }
  35748. },
  35749. createGetter: function() {
  35750. var me = this;
  35751. return function() {
  35752. return me.doGet(this);
  35753. };
  35754. },
  35755. createSetter: function() {
  35756. var me = this;
  35757. return function(value) {
  35758. return me.doSet(this, value);
  35759. };
  35760. },
  35761. doGet: function(rightRecord) {
  35762. var instanceName = this.getInstanceName(),
  35763. ret = rightRecord[instanceName],
  35764. session = rightRecord.session;
  35765. if (!ret && session) {}
  35766. return ret || null;
  35767. },
  35768. doSet: function(rightRecord, leftRecord) {
  35769. var instanceName = this.getInstanceName(),
  35770. ret = rightRecord[instanceName],
  35771. inverseSetter = this.inverse.setterName;
  35772. if (ret !== leftRecord) {
  35773. rightRecord[instanceName] = leftRecord;
  35774. if (inverseSetter) {
  35775. leftRecord[inverseSetter](rightRecord);
  35776. }
  35777. rightRecord.onAssociatedRecordSet(leftRecord, this);
  35778. }
  35779. return ret;
  35780. },
  35781. read: function(rightRecord, node, fromReader, readOptions) {
  35782. var me = this,
  35783. leftRecords = me.callParent([
  35784. rightRecord,
  35785. node,
  35786. fromReader,
  35787. readOptions
  35788. ]),
  35789. leftRecord;
  35790. if (leftRecords) {
  35791. leftRecord = leftRecords[0];
  35792. if (leftRecord) {
  35793. leftRecord[me.inverse.getInstanceName()] = rightRecord;
  35794. rightRecord[me.getInstanceName()] = leftRecord;
  35795. delete rightRecord.data[me.role];
  35796. }
  35797. }
  35798. }
  35799. }),
  35800. Right: Ext.define(null, {
  35801. extend: 'Ext.data.schema.Role',
  35802. left: false,
  35803. side: 'right',
  35804. createGetter: function() {
  35805. var me = this;
  35806. return function(options, scope) {
  35807. return me.doGetFK(this, options, scope);
  35808. };
  35809. },
  35810. createSetter: function() {
  35811. var me = this;
  35812. return function(value, options, scope) {
  35813. return me.doSetFK(this, value, options, scope);
  35814. };
  35815. },
  35816. onDrop: function(leftRecord, session) {
  35817. var me = this,
  35818. field = me.association.field,
  35819. rightRecord = me.getAssociatedItem(leftRecord),
  35820. id;
  35821. if (me.inverse.owner) {
  35822. if (session && field) {
  35823. id = leftRecord.get(field.name);
  35824. if (id || id === 0) {
  35825. rightRecord = session.getEntry(me.cls, id).record;
  35826. if (rightRecord) {
  35827. rightRecord.drop();
  35828. }
  35829. }
  35830. } else {
  35831. if (rightRecord) {
  35832. rightRecord.drop();
  35833. }
  35834. }
  35835. }
  35836. if (field) {
  35837. leftRecord.set(field.name, null);
  35838. }
  35839. leftRecord[me.getInstanceName()] = null;
  35840. if (rightRecord) {
  35841. rightRecord[me.inverse.getInstanceName()] = null;
  35842. }
  35843. },
  35844. onValueChange: function(leftRecord, session, newValue) {
  35845. var me = this,
  35846. rightRecord = leftRecord[me.getOldInstanceName()] || me.getAssociatedItem(leftRecord),
  35847. hasNewValue = newValue || newValue === 0,
  35848. instanceName = me.getInstanceName(),
  35849. cls = me.cls;
  35850. leftRecord.changingKey = true;
  35851. me.doSetFK(leftRecord, newValue);
  35852. if (!hasNewValue) {
  35853. leftRecord[instanceName] = null;
  35854. } else if (session && cls) {
  35855. leftRecord[instanceName] = session.peekRecord(cls, newValue) || undefined;
  35856. }
  35857. if (me.inverse.owner && rightRecord) {
  35858. me.association.schema.queueKeyCheck(rightRecord, me);
  35859. }
  35860. leftRecord.changingKey = false;
  35861. },
  35862. checkKeyForDrop: function(rightRecord) {
  35863. var leftRecord = this.inverse.getAssociatedItem(rightRecord);
  35864. if (!leftRecord) {
  35865. rightRecord.drop();
  35866. }
  35867. },
  35868. read: function(leftRecord, node, fromReader, readOptions) {
  35869. var me = this,
  35870. rightRecords = me.callParent([
  35871. leftRecord,
  35872. node,
  35873. fromReader,
  35874. readOptions
  35875. ]),
  35876. rightRecord, field, fieldName, session, refs, id, oldId, setKey, data;
  35877. if (rightRecords) {
  35878. rightRecord = rightRecords[0];
  35879. field = me.association.field;
  35880. if (field) {
  35881. fieldName = field.name;
  35882. }
  35883. session = leftRecord.session;
  35884. data = leftRecord.data;
  35885. if (rightRecord) {
  35886. if (session) {
  35887. refs = session.getRefs(rightRecord, this.inverse, true);
  35888. setKey = (refs && refs[leftRecord.id]) || (data[fieldName] === undefined);
  35889. } else {
  35890. setKey = true;
  35891. }
  35892. if (setKey) {
  35893. if (field) {
  35894. oldId = data[fieldName];
  35895. id = rightRecord.id;
  35896. if (oldId !== id) {
  35897. data[fieldName] = id;
  35898. if (session) {
  35899. session.updateReference(leftRecord, field, id, oldId);
  35900. }
  35901. }
  35902. }
  35903. rightRecord[me.inverse.getInstanceName()] = leftRecord;
  35904. leftRecord[me.getInstanceName()] = rightRecord;
  35905. }
  35906. delete data[me.role];
  35907. }
  35908. }
  35909. }
  35910. })
  35911. });
  35912. Ext.define('Ext.data.schema.ManyToOne', {
  35913. extend: Ext.data.schema.Association,
  35914. isManyToOne: true,
  35915. isToOne: true,
  35916. kind: 'many-to-one',
  35917. Left: Ext.define(null, {
  35918. extend: 'Ext.data.schema.Role',
  35919. isMany: true,
  35920. onDrop: function(rightRecord, session) {
  35921. var me = this,
  35922. store = me.getAssociatedItem(rightRecord),
  35923. leftRecords, len, i, refs, id;
  35924. if (store) {
  35925. leftRecords = store.removeAll();
  35926. if (leftRecords && me.inverse.owner) {
  35927. for (i = 0 , len = leftRecords.length; i < len; ++i) {
  35928. leftRecords[i].drop();
  35929. }
  35930. }
  35931. store.destroy();
  35932. rightRecord[me.getStoreName()] = null;
  35933. } else if (session) {
  35934. leftRecords = session.getRefs(rightRecord, me);
  35935. if (leftRecords) {
  35936. for (id in leftRecords) {
  35937. leftRecords[id].drop();
  35938. }
  35939. }
  35940. }
  35941. },
  35942. onIdChanged: function(rightRecord, oldId, newId) {
  35943. var fieldName = this.association.getFieldName(),
  35944. store = this.getAssociatedItem(rightRecord),
  35945. leftRecords, i, len, filter;
  35946. if (store) {
  35947. filter = store.getFilters().get(this.$roleFilterId);
  35948. if (filter) {
  35949. filter.setValue(newId);
  35950. }
  35951. if (!rightRecord.session && fieldName) {
  35952. leftRecords = store.getDataSource().items;
  35953. for (i = 0 , len = leftRecords.length; i < len; ++i) {
  35954. leftRecords[i].set(fieldName, newId);
  35955. }
  35956. }
  35957. }
  35958. },
  35959. processUpdate: function(session, associationData) {
  35960. var me = this,
  35961. entityType = me.inverse.cls,
  35962. items = associationData.R,
  35963. id, rightRecord, store, leftRecords;
  35964. if (items) {
  35965. for (id in items) {
  35966. rightRecord = session.peekRecord(entityType, id);
  35967. if (rightRecord) {
  35968. leftRecords = session.getEntityList(me.cls, items[id]);
  35969. store = me.getAssociatedItem(rightRecord);
  35970. if (store) {
  35971. store.loadData(leftRecords);
  35972. store.complete = true;
  35973. } else {
  35974. rightRecord[me.getterName](null, null, leftRecords);
  35975. }
  35976. } else {
  35977. session.onInvalidAssociationEntity(entityType, id);
  35978. }
  35979. }
  35980. }
  35981. },
  35982. findRecords: function(session, rightRecord, leftRecords, allowInfer) {
  35983. var ret = leftRecords,
  35984. refs = session.getRefs(rightRecord, this, true),
  35985. field = this.association.field,
  35986. fieldName, leftRecord, id, i, len, seen;
  35987. if (field && (refs || allowInfer)) {
  35988. fieldName = field.name;
  35989. ret = [];
  35990. if (leftRecords) {
  35991. seen = {};
  35992. for (i = 0 , len = leftRecords.length; i < len; ++i) {
  35993. leftRecord = leftRecords[i];
  35994. id = leftRecord.id;
  35995. if (refs && refs[id]) {
  35996. ret.push(leftRecord);
  35997. } else if (allowInfer && leftRecord.data[fieldName] === undefined) {
  35998. ret.push(leftRecord);
  35999. leftRecord.data[fieldName] = rightRecord.id;
  36000. session.updateReference(leftRecord, field, rightRecord.id, undefined);
  36001. }
  36002. seen[id] = true;
  36003. }
  36004. }
  36005. if (refs) {
  36006. for (id in refs) {
  36007. if (!seen || !seen[id]) {
  36008. ret.push(refs[id]);
  36009. }
  36010. }
  36011. }
  36012. }
  36013. return ret;
  36014. },
  36015. processLoad: function(store, rightRecord, leftRecords, session) {
  36016. var ret = leftRecords;
  36017. if (session) {
  36018. ret = this.findRecords(session, rightRecord, leftRecords, true);
  36019. }
  36020. this.onLoadMany(rightRecord, ret, session);
  36021. return ret;
  36022. },
  36023. adoptAssociated: function(rightRecord, session) {
  36024. var store = this.getAssociatedItem(rightRecord),
  36025. leftRecords, i, len;
  36026. if (store) {
  36027. store.setSession(session);
  36028. leftRecords = store.getData().items;
  36029. for (i = 0 , len = leftRecords.length; i < len; ++i) {
  36030. session.adopt(leftRecords[i]);
  36031. }
  36032. }
  36033. },
  36034. createGetter: function() {
  36035. var me = this;
  36036. return function(options, scope, leftRecords) {
  36037. return me.getAssociatedStore(this, options, scope, leftRecords, true);
  36038. };
  36039. },
  36040. createSetter: null,
  36041. onAddToMany: function(store, leftRecords) {
  36042. var rightRecord = store.getAssociatedEntity();
  36043. if (this.association.field) {
  36044. this.syncFK(leftRecords, rightRecord, false);
  36045. } else {
  36046. this.setInstances(rightRecord, leftRecords);
  36047. }
  36048. },
  36049. onLoadMany: function(rightRecord, leftRecords, session) {
  36050. this.setInstances(rightRecord, leftRecords, session);
  36051. },
  36052. onRemoveFromMany: function(store, leftRecords) {
  36053. if (this.association.field) {
  36054. this.syncFK(leftRecords, store.getAssociatedEntity(), true);
  36055. } else {
  36056. this.setInstances(null, leftRecords);
  36057. }
  36058. },
  36059. read: function(rightRecord, node, fromReader, readOptions) {
  36060. var me = this,
  36061. instanceName = me.inverse.getInstanceName(),
  36062. leftRecords = me.callParent([
  36063. rightRecord,
  36064. node,
  36065. fromReader,
  36066. readOptions
  36067. ]),
  36068. store, len, i;
  36069. if (leftRecords) {
  36070. store = rightRecord[me.getterName](null, null, leftRecords);
  36071. delete rightRecord.data[me.role];
  36072. leftRecords = store.getData().items;
  36073. for (i = 0 , len = leftRecords.length; i < len; ++i) {
  36074. leftRecords[i][instanceName] = rightRecord;
  36075. }
  36076. }
  36077. },
  36078. setInstances: function(rightRecord, leftRecords, session) {
  36079. var instanceName = this.inverse.getInstanceName(),
  36080. id = rightRecord ? rightRecord.getId() : null,
  36081. field = this.association.field,
  36082. len = leftRecords.length,
  36083. i, leftRecord, oldId, data, name;
  36084. for (i = 0; i < len; ++i) {
  36085. leftRecord = leftRecords[i];
  36086. leftRecord[instanceName] = rightRecord;
  36087. if (field) {
  36088. name = field.name;
  36089. data = leftRecord.data;
  36090. oldId = data[name];
  36091. if (oldId !== id) {
  36092. data[name] = id;
  36093. if (session) {
  36094. session.updateReference(leftRecord, field, id, oldId);
  36095. }
  36096. }
  36097. }
  36098. }
  36099. },
  36100. syncFK: function(leftRecords, rightRecord, clearing) {
  36101. var foreignKeyName = this.association.getFieldName(),
  36102. inverse = this.inverse,
  36103. setter = inverse.setterName,
  36104. instanceName = inverse.getInstanceName(),
  36105. i = leftRecords.length,
  36106. id = rightRecord.getId(),
  36107. different, leftRecord, val;
  36108. while (i-- > 0) {
  36109. leftRecord = leftRecords[i];
  36110. different = !leftRecord.isEqual(id, leftRecord.get(foreignKeyName));
  36111. val = clearing ? null : rightRecord;
  36112. if (different !== clearing) {
  36113. leftRecord.changingKey = true;
  36114. leftRecord[setter](val);
  36115. leftRecord.changingKey = false;
  36116. } else {
  36117. leftRecord[instanceName] = val;
  36118. }
  36119. }
  36120. }
  36121. }),
  36122. Right: Ext.define(null, {
  36123. extend: 'Ext.data.schema.Role',
  36124. left: false,
  36125. side: 'right',
  36126. onDrop: function(leftRecord, session) {
  36127. var field = this.association.field;
  36128. if (field) {
  36129. leftRecord.set(field.name, null);
  36130. }
  36131. leftRecord[this.getInstanceName()] = null;
  36132. },
  36133. createGetter: function() {
  36134. var me = this;
  36135. return function(options, scope) {
  36136. return me.doGetFK(this, options, scope);
  36137. };
  36138. },
  36139. createSetter: function() {
  36140. var me = this;
  36141. return function(rightRecord, options, scope) {
  36142. return me.doSetFK(this, rightRecord, options, scope);
  36143. };
  36144. },
  36145. checkMembership: function(session, leftRecord) {
  36146. var field = this.association.field,
  36147. store;
  36148. if (field) {
  36149. store = this.getSessionStore(session, leftRecord.get(field.name));
  36150. if (store && !store.contains(leftRecord)) {
  36151. store.add(leftRecord);
  36152. }
  36153. }
  36154. },
  36155. onValueChange: function(leftRecord, session, newValue, oldValue) {
  36156. var me = this,
  36157. instanceName = me.getInstanceName(),
  36158. cls = me.cls,
  36159. hasNewValue, joined, store, i, associated, rightRecord;
  36160. if (!leftRecord.changingKey) {
  36161. hasNewValue = newValue || newValue === 0;
  36162. if (!hasNewValue) {
  36163. leftRecord[instanceName] = null;
  36164. }
  36165. if (session) {
  36166. store = me.getSessionStore(session, oldValue);
  36167. if (store) {
  36168. store.remove(leftRecord);
  36169. }
  36170. if (hasNewValue) {
  36171. store = me.getSessionStore(session, newValue);
  36172. if (store && !store.isLoading()) {
  36173. store.add(leftRecord);
  36174. }
  36175. if (cls) {
  36176. rightRecord = session.peekRecord(cls, newValue);
  36177. }
  36178. leftRecord[instanceName] = rightRecord || undefined;
  36179. }
  36180. } else {
  36181. joined = leftRecord.joined;
  36182. if (joined) {
  36183. for (i = joined.length - 1; i >= 0; i--) {
  36184. store = joined[i];
  36185. if (store.isStore) {
  36186. associated = store.getAssociatedEntity();
  36187. if (associated && associated.self === me.cls && associated.getId() === oldValue) {
  36188. store.remove(leftRecord);
  36189. }
  36190. }
  36191. }
  36192. }
  36193. }
  36194. }
  36195. if (me.owner && newValue === null) {
  36196. me.association.schema.queueKeyCheck(leftRecord, me);
  36197. }
  36198. },
  36199. checkKeyForDrop: function(leftRecord) {
  36200. var field = this.association.field;
  36201. if (leftRecord.get(field.name) === null) {
  36202. leftRecord.drop();
  36203. }
  36204. },
  36205. getSessionStore: function(session, value) {
  36206. var cls = this.cls,
  36207. rec;
  36208. if (cls) {
  36209. rec = session.peekRecord(cls, value);
  36210. if (rec) {
  36211. return this.inverse.getAssociatedItem(rec);
  36212. }
  36213. }
  36214. },
  36215. read: function(leftRecord, node, fromReader, readOptions) {
  36216. var rightRecords = this.callParent([
  36217. leftRecord,
  36218. node,
  36219. fromReader,
  36220. readOptions
  36221. ]),
  36222. rightRecord;
  36223. if (rightRecords) {
  36224. rightRecord = rightRecords[0];
  36225. if (rightRecord) {
  36226. leftRecord[this.getInstanceName()] = rightRecord;
  36227. delete leftRecord.data[this.role];
  36228. }
  36229. }
  36230. }
  36231. })
  36232. });
  36233. Ext.define('Ext.data.schema.ManyToMany', {
  36234. extend: Ext.data.schema.Association,
  36235. isManyToMany: true,
  36236. isToMany: true,
  36237. kind: 'many-to-many',
  36238. Left: Ext.define(null, {
  36239. extend: 'Ext.data.schema.Role',
  36240. isMany: true,
  36241. digitRe: /^\d+$/,
  36242. findRecords: function(session, rightRecord, leftRecords) {
  36243. var slice = session.getMatrixSlice(this.inverse, rightRecord.id),
  36244. members = slice.members,
  36245. ret = [],
  36246. cls = this.cls,
  36247. seen, i, len, id, member, leftRecord;
  36248. if (leftRecords) {
  36249. seen = {};
  36250. for (i = 0 , len = leftRecords.length; i < len; ++i) {
  36251. leftRecord = leftRecords[i];
  36252. id = leftRecord.id;
  36253. member = members[id];
  36254. if (!(member && member[2] === -1)) {
  36255. ret.push(leftRecord);
  36256. }
  36257. seen[id] = true;
  36258. }
  36259. }
  36260. for (id in members) {
  36261. member = members[id];
  36262. if (!seen || !seen[id] && (member && member[2] !== -1)) {
  36263. leftRecord = session.peekRecord(cls, id);
  36264. if (leftRecord) {
  36265. ret.push(leftRecord);
  36266. }
  36267. }
  36268. }
  36269. return ret;
  36270. },
  36271. onIdChanged: function(rightRecord, oldId, newId) {
  36272. var store = this.getAssociatedItem(rightRecord);
  36273. if (store) {
  36274. store.getFilters().get(this.$roleFilterId).setValue(newId);
  36275. }
  36276. },
  36277. processLoad: function(store, rightRecord, leftRecords, session) {
  36278. var ret = leftRecords;
  36279. if (session) {
  36280. ret = this.findRecords(session, rightRecord, leftRecords);
  36281. this.onAddToMany(store, ret, true);
  36282. }
  36283. return ret;
  36284. },
  36285. processUpdate: function(session, associationData) {
  36286. var me = this,
  36287. entityType = me.inverse.cls,
  36288. items = associationData.R,
  36289. id, rightRecord, store, leftRecords;
  36290. if (items) {
  36291. for (id in items) {
  36292. rightRecord = session.peekRecord(entityType, id);
  36293. if (rightRecord) {
  36294. leftRecords = session.getEntityList(me.cls, items[id]);
  36295. store = me.getAssociatedItem(rightRecord);
  36296. if (store) {
  36297. store.loadData(leftRecords);
  36298. store.complete = true;
  36299. } else {
  36300. rightRecord[me.getterName](null, null, leftRecords);
  36301. }
  36302. } else {
  36303. session.onInvalidAssociationEntity(entityType, id);
  36304. }
  36305. }
  36306. }
  36307. me.processMatrixBlock(session, associationData.C, 1);
  36308. me.processMatrixBlock(session, associationData.D, -1);
  36309. },
  36310. checkMembership: function(session, rightRecord) {
  36311. var matrix = session.getMatrix(this.association, true),
  36312. side, entityType, inverse, slice, slices, id, members, member, leftRecord, store;
  36313. if (!matrix) {
  36314. return;
  36315. }
  36316. side = this.left ? matrix.right : matrix.left;
  36317. entityType = side.inverse.role.cls;
  36318. inverse = this.inverse;
  36319. slices = side.slices;
  36320. if (slices) {
  36321. slice = slices[rightRecord.id];
  36322. if (slice) {
  36323. members = slice.members;
  36324. for (id in members) {
  36325. member = members[id];
  36326. if (member[2] !== -1) {
  36327. leftRecord = session.peekRecord(entityType, id);
  36328. if (leftRecord) {
  36329. store = inverse.getAssociatedItem(leftRecord);
  36330. if (store) {
  36331. store.matrixUpdate = 1;
  36332. store.add(rightRecord);
  36333. store.matrixUpdate = 0;
  36334. }
  36335. }
  36336. }
  36337. }
  36338. }
  36339. }
  36340. },
  36341. onStoreCreate: function(store, session, id) {
  36342. var me = this,
  36343. matrix;
  36344. if (session) {
  36345. matrix = session.getMatrixSlice(me.inverse, id);
  36346. matrix.attach(store);
  36347. matrix.notify = me.onMatrixUpdate;
  36348. matrix.scope = me;
  36349. }
  36350. },
  36351. processMatrixBlock: function(session, leftKeys, state) {
  36352. var inverse = this.inverse,
  36353. digitRe = this.digitRe,
  36354. slice, id;
  36355. if (leftKeys) {
  36356. for (id in leftKeys) {
  36357. if (digitRe.test(id)) {
  36358. id = parseInt(id, 10);
  36359. }
  36360. slice = session.getMatrixSlice(inverse, id);
  36361. slice.update(leftKeys[id], state);
  36362. }
  36363. }
  36364. },
  36365. createGetter: function() {
  36366. var me = this;
  36367. return function(options, scope, leftRecords) {
  36368. return me.getAssociatedStore(this, options, scope, leftRecords, false);
  36369. };
  36370. },
  36371. onAddToMany: function(store, leftRecords, load) {
  36372. if (!store.matrixUpdate) {
  36373. store.matrixUpdate = 1;
  36374. store.matrix.update(leftRecords, load === true ? 0 : 1);
  36375. store.matrixUpdate = 0;
  36376. }
  36377. },
  36378. onRemoveFromMany: function(store, records) {
  36379. if (!store.matrixUpdate) {
  36380. store.matrixUpdate = 1;
  36381. store.matrix.update(records, -1);
  36382. store.matrixUpdate = 0;
  36383. }
  36384. },
  36385. read: function(rightRecord, node, fromReader, readOptions) {
  36386. var me = this,
  36387. leftRecords = me.callParent([
  36388. rightRecord,
  36389. node,
  36390. fromReader,
  36391. readOptions
  36392. ]);
  36393. if (leftRecords) {
  36394. rightRecord[me.getterName](null, null, leftRecords);
  36395. delete rightRecord.data[me.role];
  36396. }
  36397. },
  36398. onMatrixUpdate: function(matrixSlice, id, state) {
  36399. var store = matrixSlice.store,
  36400. index, leftRecord, entry;
  36401. if (store && !store.loading && !store.matrixUpdate) {
  36402. store.matrixUpdate = 1;
  36403. index = store.indexOfId(id);
  36404. if (state < 0) {
  36405. if (index >= 0) {
  36406. store.remove([
  36407. index
  36408. ]);
  36409. }
  36410. } else if (index < 0) {
  36411. entry = store.getSession().getEntry(this.type, id);
  36412. leftRecord = entry && entry.record;
  36413. if (leftRecord) {
  36414. store.add(leftRecord);
  36415. }
  36416. }
  36417. store.matrixUpdate = 0;
  36418. }
  36419. },
  36420. adoptAssociated: function(record, session) {
  36421. var store = this.getAssociatedItem(record),
  36422. records, i, len;
  36423. if (store) {
  36424. store.setSession(session);
  36425. this.onStoreCreate(store, session, record.getId());
  36426. records = store.getData().items;
  36427. for (i = 0 , len = records.length; i < len; ++i) {
  36428. session.adopt(records[i]);
  36429. }
  36430. }
  36431. }
  36432. }, function() {
  36433. var Left = this;
  36434. Ext.ClassManager.onCreated(function() {
  36435. Ext.data.schema.ManyToMany.prototype.Right = Ext.define(null, {
  36436. extend: Left,
  36437. left: false,
  36438. side: 'right'
  36439. });
  36440. }, null, 'Ext.data.schema.ManyToMany');
  36441. })
  36442. });
  36443. Ext.define('Ext.util.Inflector', {
  36444. singleton: true,
  36445. plurals: [
  36446. [
  36447. (/(quiz)$/i),
  36448. "$1zes"
  36449. ],
  36450. [
  36451. (/^(ox)$/i),
  36452. "$1en"
  36453. ],
  36454. [
  36455. (/([m|l])ouse$/i),
  36456. "$1ice"
  36457. ],
  36458. [
  36459. (/(matr|vert|ind)ix|ex$/i),
  36460. "$1ices"
  36461. ],
  36462. [
  36463. (/(x|ch|ss|sh)$/i),
  36464. "$1es"
  36465. ],
  36466. [
  36467. (/([^aeiouy]|qu)y$/i),
  36468. "$1ies"
  36469. ],
  36470. [
  36471. (/(hive)$/i),
  36472. "$1s"
  36473. ],
  36474. [
  36475. (/(?:([^f])fe|([lr])f)$/i),
  36476. "$1$2ves"
  36477. ],
  36478. [
  36479. (/sis$/i),
  36480. "ses"
  36481. ],
  36482. [
  36483. (/([ti])um$/i),
  36484. "$1a"
  36485. ],
  36486. [
  36487. (/(buffal|tomat|potat)o$/i),
  36488. "$1oes"
  36489. ],
  36490. [
  36491. (/(bu)s$/i),
  36492. "$1ses"
  36493. ],
  36494. [
  36495. (/(alias|status|sex)$/i),
  36496. "$1es"
  36497. ],
  36498. [
  36499. (/(octop|vir)us$/i),
  36500. "$1i"
  36501. ],
  36502. [
  36503. (/(ax|test)is$/i),
  36504. "$1es"
  36505. ],
  36506. [
  36507. (/^(p)erson$/i),
  36508. "$1eople"
  36509. ],
  36510. [
  36511. (/^(m)an$/i),
  36512. "$1en"
  36513. ],
  36514. [
  36515. (/(.*)(child)(ren)?$/i),
  36516. "$1$2ren"
  36517. ],
  36518. [
  36519. (/s$/i),
  36520. "s"
  36521. ],
  36522. [
  36523. (/$/),
  36524. "s"
  36525. ]
  36526. ],
  36527. singulars: [
  36528. [
  36529. (/(address)$/i),
  36530. "$1"
  36531. ],
  36532. [
  36533. (/(quiz)zes$/i),
  36534. "$1"
  36535. ],
  36536. [
  36537. (/(matr)ices$/i),
  36538. "$1ix"
  36539. ],
  36540. [
  36541. (/(vert|ind)ices$/i),
  36542. "$1ex"
  36543. ],
  36544. [
  36545. (/^(ox)en/i),
  36546. "$1"
  36547. ],
  36548. [
  36549. (/(alias|status)es$/i),
  36550. "$1"
  36551. ],
  36552. [
  36553. (/(octop|vir)i$/i),
  36554. "$1us"
  36555. ],
  36556. [
  36557. (/(cris|ax|test)es$/i),
  36558. "$1is"
  36559. ],
  36560. [
  36561. (/(shoe)s$/i),
  36562. "$1"
  36563. ],
  36564. [
  36565. (/(o)es$/i),
  36566. "$1"
  36567. ],
  36568. [
  36569. (/(bus)es$/i),
  36570. "$1"
  36571. ],
  36572. [
  36573. (/([m|l])ice$/i),
  36574. "$1ouse"
  36575. ],
  36576. [
  36577. (/(x|ch|ss|sh)es$/i),
  36578. "$1"
  36579. ],
  36580. [
  36581. (/(m)ovies$/i),
  36582. "$1ovie"
  36583. ],
  36584. [
  36585. (/(s)eries$/i),
  36586. "$1eries"
  36587. ],
  36588. [
  36589. (/([^aeiouy]|qu)ies$/i),
  36590. "$1y"
  36591. ],
  36592. [
  36593. (/([lr])ves$/i),
  36594. "$1f"
  36595. ],
  36596. [
  36597. (/(tive)s$/i),
  36598. "$1"
  36599. ],
  36600. [
  36601. (/(hive)s$/i),
  36602. "$1"
  36603. ],
  36604. [
  36605. (/([^f])ves$/i),
  36606. "$1fe"
  36607. ],
  36608. [
  36609. (/(^analy)ses$/i),
  36610. "$1sis"
  36611. ],
  36612. [
  36613. (/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i),
  36614. "$1$2sis"
  36615. ],
  36616. [
  36617. (/([ti])a$/i),
  36618. "$1um"
  36619. ],
  36620. [
  36621. (/(n)ews$/i),
  36622. "$1ews"
  36623. ],
  36624. [
  36625. (/(p)eople$/i),
  36626. "$1erson"
  36627. ],
  36628. [
  36629. (/s$/i),
  36630. ""
  36631. ]
  36632. ],
  36633. uncountable: [
  36634. "sheep",
  36635. "fish",
  36636. "series",
  36637. "species",
  36638. "money",
  36639. "rice",
  36640. "information",
  36641. "equipment",
  36642. "grass",
  36643. "mud",
  36644. "offspring",
  36645. "deer",
  36646. "means"
  36647. ],
  36648. singular: function(matcher, replacer) {
  36649. this.singulars.unshift([
  36650. matcher,
  36651. replacer
  36652. ]);
  36653. },
  36654. plural: function(matcher, replacer) {
  36655. this.plurals.unshift([
  36656. matcher,
  36657. replacer
  36658. ]);
  36659. },
  36660. clearSingulars: function() {
  36661. this.singulars = [];
  36662. },
  36663. clearPlurals: function() {
  36664. this.plurals = [];
  36665. },
  36666. isTransnumeral: function(word) {
  36667. return Ext.Array.indexOf(this.uncountable, word) != -1;
  36668. },
  36669. pluralize: function(word) {
  36670. if (this.isTransnumeral(word)) {
  36671. return word;
  36672. }
  36673. var plurals = this.plurals,
  36674. length = plurals.length,
  36675. tuple, regex, i;
  36676. for (i = 0; i < length; i++) {
  36677. tuple = plurals[i];
  36678. regex = tuple[0];
  36679. if (regex == word || (regex.test && regex.test(word))) {
  36680. return word.replace(regex, tuple[1]);
  36681. }
  36682. }
  36683. return word;
  36684. },
  36685. singularize: function(word) {
  36686. if (this.isTransnumeral(word)) {
  36687. return word;
  36688. }
  36689. var singulars = this.singulars,
  36690. length = singulars.length,
  36691. tuple, regex, i;
  36692. for (i = 0; i < length; i++) {
  36693. tuple = singulars[i];
  36694. regex = tuple[0];
  36695. if (regex == word || (regex.test && regex.test(word))) {
  36696. return word.replace(regex, tuple[1]);
  36697. }
  36698. }
  36699. return word;
  36700. },
  36701. classify: function(word) {
  36702. return Ext.String.capitalize(this.singularize(word));
  36703. },
  36704. ordinalize: function(number) {
  36705. var parsed = parseInt(number, 10),
  36706. mod10 = parsed % 10,
  36707. mod100 = parsed % 100;
  36708. if (11 <= mod100 && mod100 <= 13) {
  36709. return number + "th";
  36710. } else {
  36711. switch (mod10) {
  36712. case 1:
  36713. return number + "st";
  36714. case 2:
  36715. return number + "nd";
  36716. case 3:
  36717. return number + "rd";
  36718. default:
  36719. return number + "th";
  36720. }
  36721. }
  36722. }
  36723. }, function() {
  36724. var irregulars = {
  36725. alumnus: 'alumni',
  36726. cactus: 'cacti',
  36727. focus: 'foci',
  36728. nucleus: 'nuclei',
  36729. radius: 'radii',
  36730. stimulus: 'stimuli',
  36731. ellipsis: 'ellipses',
  36732. paralysis: 'paralyses',
  36733. oasis: 'oases',
  36734. appendix: 'appendices',
  36735. index: 'indexes',
  36736. beau: 'beaux',
  36737. bureau: 'bureaux',
  36738. tableau: 'tableaux',
  36739. woman: 'women',
  36740. child: 'children',
  36741. man: 'men',
  36742. corpus: 'corpora',
  36743. criterion: 'criteria',
  36744. curriculum: 'curricula',
  36745. genus: 'genera',
  36746. memorandum: 'memoranda',
  36747. phenomenon: 'phenomena',
  36748. foot: 'feet',
  36749. goose: 'geese',
  36750. tooth: 'teeth',
  36751. antenna: 'antennae',
  36752. formula: 'formulae',
  36753. nebula: 'nebulae',
  36754. vertebra: 'vertebrae',
  36755. vita: 'vitae'
  36756. },
  36757. singular;
  36758. for (singular in irregulars) {
  36759. if (irregulars.hasOwnProperty(singular)) {
  36760. this.plural(singular, irregulars[singular]);
  36761. this.singular(irregulars[singular], singular);
  36762. }
  36763. }
  36764. });
  36765. Ext.define('Ext.data.schema.Namer', {
  36766. mixins: [
  36767. Ext.mixin.Factoryable
  36768. ],
  36769. alias: 'namer.default',
  36770. isNamer: true,
  36771. capitalize: function(name) {
  36772. return Ext.String.capitalize(name);
  36773. },
  36774. fieldRole: function(name) {
  36775. var match = name.match(this.endsWithIdRe, '');
  36776. if (match) {
  36777. name = name.substr(0, name.length - (match[1] || match[2]).length);
  36778. }
  36779. return this.apply('uncapitalize', name);
  36780. },
  36781. idField: function(name) {
  36782. return this.apply('uncapitalize,singularize', name) + 'Id';
  36783. },
  36784. instanceName: function(roleName) {
  36785. return this.apply('underscore', roleName);
  36786. },
  36787. multiRole: function(name) {
  36788. return this.apply('undotted,uncapitalize,pluralize', name);
  36789. },
  36790. pluralize: function(name) {
  36791. return Ext.util.Inflector.pluralize(name);
  36792. },
  36793. readerRoot: function(roleName) {
  36794. return this.apply('uncapitalize', roleName);
  36795. },
  36796. singularize: function(name) {
  36797. return Ext.util.Inflector.singularize(name);
  36798. },
  36799. storeName: function(roleName) {
  36800. return this.apply('underscore', roleName);
  36801. },
  36802. uncapitalize: function(name) {
  36803. return Ext.String.uncapitalize(name);
  36804. },
  36805. underscore: function(name) {
  36806. return '_' + name;
  36807. },
  36808. uniRole: function(name) {
  36809. return this.apply('undotted,uncapitalize,singularize', name);
  36810. },
  36811. undotted: function(name) {
  36812. if (name.indexOf('.') < 0) {
  36813. return name;
  36814. }
  36815. var parts = name.split('.'),
  36816. index = parts.length;
  36817. while (index-- > 1) {
  36818. parts[index] = this.apply('capitalize', parts[index]);
  36819. }
  36820. return parts.join('');
  36821. },
  36822. getterName: function(role) {
  36823. var name = role.role;
  36824. if (role && role.isMany) {
  36825. return name;
  36826. }
  36827. return 'get' + this.apply('capitalize', name);
  36828. },
  36829. inverseFieldRole: function(leftType, unique, rightRole, rightType) {
  36830. var me = this,
  36831. leftRole = me.apply(unique ? 'uniRole' : 'multiRole', leftType),
  36832. s1 = me.apply('pluralize', rightRole),
  36833. s2 = me.apply('undotted,pluralize', rightType);
  36834. if (s1.toLowerCase() !== s2.toLowerCase()) {
  36835. leftRole = rightRole + me.apply('capitalize', leftRole);
  36836. }
  36837. return leftRole;
  36838. },
  36839. manyToMany: function(relation, leftType, rightType) {
  36840. var me = this,
  36841. ret = me.apply('undotted,capitalize,singularize', leftType) + me.apply('undotted,capitalize,pluralize', rightType);
  36842. if (relation) {
  36843. ret = me.apply('capitalize', relation + ret);
  36844. }
  36845. return ret;
  36846. },
  36847. manyToOne: function(leftType, leftRole, rightType, rightRole) {
  36848. return this.apply('capitalize,singularize', rightType) + this.apply('capitalize', leftRole);
  36849. },
  36850. matrixRole: function(relation, entityType) {
  36851. var ret = this.apply(relation ? 'multiRole,capitalize' : 'multiRole', entityType);
  36852. return relation ? relation + ret : ret;
  36853. },
  36854. oneToOne: function(leftType, leftRole, rightType, rightRole) {
  36855. return this.apply('undotted,capitalize,singularize', rightType) + this.apply('capitalize', leftRole);
  36856. },
  36857. setterName: function(role) {
  36858. return 'set' + this.apply('capitalize', role.role);
  36859. },
  36860. endsWithIdRe: /(?:(_id)|[^A-Z](Id))$/,
  36861. cache: {},
  36862. apply: function(operation, name) {
  36863. var me = this,
  36864. cache = me.cache,
  36865. entry = cache[name] || (cache[name] = {}),
  36866. ret = entry[operation],
  36867. i, length, operations;
  36868. if (!ret) {
  36869. if (operation.indexOf(',') < 0) {
  36870. ret = me[operation](name);
  36871. } else {
  36872. length = (operations = operation.split(',')).length;
  36873. ret = name;
  36874. for (i = 0; i < length; ++i) {
  36875. ret = me.apply(operations[i], ret);
  36876. }
  36877. }
  36878. entry[operation] = ret;
  36879. }
  36880. return ret;
  36881. }
  36882. });
  36883. Ext.define('Ext.data.schema.Schema', {
  36884. mixins: [
  36885. Ext.mixin.Factoryable
  36886. ],
  36887. alias: 'schema.default',
  36888. aliasPrefix: 'schema.',
  36889. isSchema: true,
  36890. type: 'default',
  36891. statics: {
  36892. instances: {},
  36893. clearInstance: function(id) {
  36894. var schema = this.instances[id];
  36895. delete this.instances[id];
  36896. if (schema) {
  36897. schema.clear(true);
  36898. schema.destroy();
  36899. }
  36900. },
  36901. get: function(config) {
  36902. var Schema = this,
  36903. cache = Schema.instances,
  36904. id = 'default',
  36905. isString = config && Ext.isString(config),
  36906. instance, newConfig;
  36907. if (config) {
  36908. if (config.isSchema) {
  36909. return config;
  36910. }
  36911. id = isString ? config : (config.id || id);
  36912. }
  36913. if (!(instance = cache[id])) {
  36914. cache[id] = instance = Schema.create(config);
  36915. instance.id = id;
  36916. } else if (config && !isString) {
  36917. if (id !== 'default') {
  36918. Ext.raise('Only the default Schema instance can be reconfigured');
  36919. }
  36920. newConfig = Ext.merge({}, instance.config);
  36921. Ext.merge(newConfig, config);
  36922. instance.setConfig(newConfig);
  36923. instance.config = newConfig;
  36924. instance.setConfig = function() {
  36925. Ext.raise('The schema can only be reconfigured once');
  36926. };
  36927. }
  36928. return instance;
  36929. },
  36930. lookupEntity: function(entity) {
  36931. var ret = null,
  36932. instances = this.instances,
  36933. match, name, schema;
  36934. if (entity) {
  36935. if (entity.isEntity) {
  36936. ret = entity.self;
  36937. }
  36938. else if (Ext.isFunction(entity)) {
  36939. ret = entity;
  36940. } else if (Ext.isString(entity)) {
  36941. ret = Ext.ClassManager.get(entity);
  36942. if (ret && (!ret.prototype || !ret.prototype.isEntity)) {
  36943. ret = null;
  36944. }
  36945. if (!ret) {
  36946. for (name in instances) {
  36947. schema = instances[name];
  36948. match = schema.getEntity(entity);
  36949. if (match) {
  36950. if (ret) {
  36951. Ext.raise('Ambiguous entity name "' + entity + '". Defined by schema "' + ret.schema.type + '" and "' + name + '"');
  36952. }
  36953. ret = match;
  36954. }
  36955. }
  36956. }
  36957. if (!ret) {
  36958. Ext.raise('No such Entity "' + entity + '".');
  36959. }
  36960. }
  36961. }
  36962. return ret;
  36963. }
  36964. },
  36965. assocCount: 0,
  36966. entityCount: 0,
  36967. config: {
  36968. defaultIdentifier: null,
  36969. keyCheckDelay: 10,
  36970. namer: 'default',
  36971. namespace: null,
  36972. proxy: {
  36973. type: 'ajax',
  36974. url: '{prefix}/{entityName}'
  36975. },
  36976. urlPrefix: ''
  36977. },
  36978. onClassExtended: function(cls, data) {
  36979. var alias = data.alias;
  36980. if (alias && !data.type) {
  36981. if (!Ext.isString(alias)) {
  36982. alias = alias[0];
  36983. }
  36984. cls.prototype.type = alias.substring(this.prototype.aliasPrefix.length);
  36985. }
  36986. },
  36987. constructor: function(config) {
  36988. this.initConfig(config);
  36989. this.clear();
  36990. },
  36991. applyDefaultIdentifier: function(identifier) {
  36992. return identifier && Ext.Factory.dataIdentifier(identifier);
  36993. },
  36994. applyNamer: function(namer) {
  36995. var ret = Ext.data.schema.Namer.create(namer);
  36996. ret.schema = this;
  36997. return ret;
  36998. },
  36999. applyNamespace: function(namespace) {
  37000. if (namespace) {
  37001. var end = namespace.length - 1;
  37002. if (namespace.charAt(end) !== '.') {
  37003. namespace += '.';
  37004. }
  37005. }
  37006. return namespace;
  37007. },
  37008. applyProxy: function(proxy) {
  37009. return Ext.util.ObjectTemplate.create(proxy);
  37010. },
  37011. eachAssociation: function(fn, scope) {
  37012. var associations = this.associations,
  37013. name;
  37014. for (name in associations) {
  37015. if (associations.hasOwnProperty(name)) {
  37016. if (fn.call(scope, name, associations[name]) === false) {
  37017. break;
  37018. }
  37019. }
  37020. }
  37021. },
  37022. eachEntity: function(fn, scope) {
  37023. var entities = this.entities,
  37024. name;
  37025. for (name in entities) {
  37026. if (entities.hasOwnProperty(name)) {
  37027. if (fn.call(scope, name, entities[name].cls) === false) {
  37028. break;
  37029. }
  37030. }
  37031. }
  37032. },
  37033. getAssociation: function(name) {
  37034. var entry = this.associations[name];
  37035. return entry || null;
  37036. },
  37037. getEntity: function(name) {
  37038. var entry = this.entityClasses[name] || this.entities[name];
  37039. return (entry && entry.cls) || null;
  37040. },
  37041. getEntityName: function(cls) {
  37042. var ns = this.getNamespace(),
  37043. index, name;
  37044. if (typeof cls === 'string') {
  37045. name = cls;
  37046. } else {
  37047. name = cls.$className || null;
  37048. }
  37049. if (name) {
  37050. if (ns) {
  37051. index = ns.length;
  37052. if (name.substring(0, index) !== ns) {
  37053. return name;
  37054. }
  37055. }
  37056. if (index) {
  37057. name = name.substring(index);
  37058. }
  37059. }
  37060. return name;
  37061. },
  37062. hasAssociations: function(name) {
  37063. name = name.entityName || name;
  37064. return !!this.associationEntityMap[name];
  37065. },
  37066. hasEntity: function(entity) {
  37067. var name = this.getEntityName(entity);
  37068. return !!(this.entities[name] || this.entityClasses[name]);
  37069. },
  37070. addMatrix: function(entityType, matrixName, relation, left, right) {
  37071. var me = this,
  37072. namer = me.getNamer(),
  37073. associations = me.associations,
  37074. entities = me.entities,
  37075. leftType = left.type,
  37076. rightType = right.type,
  37077. leftField = left.field || namer.apply('idField', leftType),
  37078. rightField = right.field || namer.apply('idField', rightType),
  37079. leftRole = left.role || namer.matrixRole(relation, leftType),
  37080. rightRole = right.role || namer.matrixRole(relation, rightType),
  37081. matrix, leftEntry, rightEntry;
  37082. leftEntry = entities[leftType] || (entities[leftType] = {
  37083. cls: null,
  37084. name: leftType,
  37085. associations: {}
  37086. });
  37087. rightEntry = entities[rightType] || (entities[rightType] = {
  37088. cls: null,
  37089. name: rightType,
  37090. associations: {}
  37091. });
  37092. ++me.assocCount;
  37093. associations[matrixName] = matrix = new Ext.data.schema.ManyToMany({
  37094. name: matrixName,
  37095. schema: me,
  37096. definedBy: entityType,
  37097. left: {
  37098. cls: leftEntry.cls,
  37099. type: leftType,
  37100. role: leftRole,
  37101. field: leftField,
  37102. associationKey: left.associationKey
  37103. },
  37104. right: {
  37105. cls: rightEntry.cls,
  37106. type: rightType,
  37107. role: rightRole,
  37108. field: rightField,
  37109. associationKey: right.associationKey
  37110. }
  37111. });
  37112. leftEntry.associations[matrix.right.role] = matrix.right;
  37113. rightEntry.associations[matrix.left.role] = matrix.left;
  37114. if (leftEntry.cls) {
  37115. me.associationEntityMap[leftEntry.cls.entityName] = true;
  37116. }
  37117. if (rightEntry.cls) {
  37118. me.associationEntityMap[rightEntry.cls.entityName] = true;
  37119. }
  37120. me.decorateModel(matrix);
  37121. },
  37122. addReference: function(entityType, referenceField, descr, unique, dupeCheck) {
  37123. var me = this,
  37124. namer = me.getNamer(),
  37125. entities = me.entities,
  37126. associations = me.associations,
  37127. entityName = entityType.entityName,
  37128. association = descr.association,
  37129. child = descr.child,
  37130. parent = descr.parent,
  37131. rightRole = descr.role,
  37132. rightType = descr.type || parent || child,
  37133. leftVal = descr.inverse,
  37134. left = Ext.isString(leftVal) ? {
  37135. role: leftVal
  37136. } : leftVal,
  37137. leftRole = left && left.role,
  37138. entry, T;
  37139. if (!rightRole) {
  37140. if (!referenceField || descr.legacy) {
  37141. rightRole = namer.apply('uncapitalize', rightType);
  37142. } else {
  37143. rightRole = namer.apply('fieldRole', referenceField.name);
  37144. }
  37145. }
  37146. if (!leftRole) {
  37147. leftRole = namer.inverseFieldRole(entityName, unique, rightRole, rightType);
  37148. }
  37149. if (!association) {
  37150. if (unique) {
  37151. association = namer.oneToOne(entityType, leftRole, rightType, rightRole);
  37152. } else {
  37153. association = namer.manyToOne(entityType, leftRole, rightType, rightRole);
  37154. }
  37155. }
  37156. if (dupeCheck && association in associations) {
  37157. if (dupeCheck(associations[association], association, leftRole, rightRole) !== false) {
  37158. return;
  37159. }
  37160. }
  37161. if (association in associations) {
  37162. Ext.raise('Duplicate association: "' + association + '" declared by ' + entityName + (referenceField ? ('.' + referenceField.name) : '') + ' (collides with ' + associations[association].definedBy.entityName + ')');
  37163. }
  37164. if (referenceField && referenceField.definedBy === entities[rightType]) {
  37165. Ext.raise('ForeignKey reference should not be owned by the target model');
  37166. }
  37167. entry = entities[rightType] || (entities[rightType] = {
  37168. cls: null,
  37169. name: rightType,
  37170. associations: {}
  37171. });
  37172. T = unique ? Ext.data.schema.OneToOne : Ext.data.schema.ManyToOne;
  37173. association = new T({
  37174. name: association,
  37175. owner: child ? 'left' : (parent ? 'right' : null),
  37176. definedBy: entityType,
  37177. schema: me,
  37178. field: referenceField,
  37179. nullable: referenceField ? !!referenceField.allowBlank : true,
  37180. left: {
  37181. cls: entityType,
  37182. type: entityName,
  37183. role: leftRole,
  37184. extra: left
  37185. },
  37186. right: {
  37187. cls: entry.cls,
  37188. type: rightType,
  37189. role: rightRole,
  37190. extra: descr
  37191. },
  37192. meta: descr
  37193. });
  37194. entityType.associations[rightRole] = association.right;
  37195. entry.associations[leftRole] = association.left;
  37196. if (referenceField) {
  37197. referenceField.reference = association.right;
  37198. entityType.references.push(referenceField);
  37199. }
  37200. ++me.assocCount;
  37201. me.associationEntityMap[entityName] = true;
  37202. if (entry.cls) {
  37203. me.associationEntityMap[entry.cls.entityName] = true;
  37204. }
  37205. associations[association.name] = association;
  37206. if (association.right.cls) {
  37207. me.decorateModel(association);
  37208. }
  37209. },
  37210. privates: {
  37211. addEntity: function(entityType) {
  37212. var me = this,
  37213. entities = me.entities,
  37214. entityName = entityType.entityName,
  37215. entry = entities[entityName],
  37216. fields = entityType.fields,
  37217. associations, field, i, length, name;
  37218. if (!entry) {
  37219. entities[entityName] = entry = {
  37220. name: entityName,
  37221. associations: {}
  37222. };
  37223. }
  37224. else if (entry.cls) {
  37225. Ext.raise('Duplicate entity name "' + entityName + '": ' + entry.cls.$className + ' and ' + entityType.$className);
  37226. } else
  37227. {
  37228. associations = entry.associations;
  37229. for (name in associations) {
  37230. associations[name].inverse.cls = entityType;
  37231. me.associationEntityMap[entityName] = true;
  37232. me.decorateModel(associations[name].association);
  37233. }
  37234. }
  37235. entry.cls = entityType;
  37236. entityType.prototype.associations = entityType.associations = entry.associations;
  37237. me.entityClasses[entityType.$className] = entry;
  37238. ++me.entityCount;
  37239. for (i = 0 , length = fields.length; i < length; ++i) {
  37240. field = fields[i];
  37241. if (field.reference) {
  37242. me.addReferenceDescr(entityType, field);
  37243. }
  37244. }
  37245. },
  37246. addMatrices: function(entityType, matrices) {
  37247. var me = this,
  37248. i, length, matrixName;
  37249. if (Ext.isString(matrices)) {
  37250. me.addMatrixDescr(entityType, null, matrices);
  37251. } else if (matrices[0]) {
  37252. for (i = 0 , length = matrices.length; i < length; ++i) {
  37253. me.addMatrixDescr(entityType, null, matrices[i]);
  37254. }
  37255. } else {
  37256. for (matrixName in matrices) {
  37257. me.addMatrixDescr(entityType, matrixName, matrices[matrixName]);
  37258. }
  37259. }
  37260. },
  37261. addMatrixDescr: function(entityType, matrixName, matrixDef) {
  37262. var me = this,
  37263. entityName = entityType.entityName,
  37264. associations = me.associations,
  37265. namer = me.getNamer(),
  37266. left = matrixDef.left,
  37267. right = matrixDef.right,
  37268. last, relation;
  37269. if (Ext.isString(matrixDef)) {
  37270. if (matrixDef.charAt(0) === '#') {
  37271. left = {
  37272. type: entityName
  37273. };
  37274. right = {
  37275. type: matrixDef.substring(1)
  37276. };
  37277. }
  37278. else if (matrixDef.charAt(last = matrixDef.length - 1) === '#') {
  37279. left = {
  37280. type: matrixDef.substring(0, last)
  37281. };
  37282. right = {
  37283. type: entityName
  37284. };
  37285. }
  37286. else if (namer.apply('multiRole', entityName) < namer.apply('multiRole', matrixDef)) {
  37287. left = {
  37288. type: entityName
  37289. };
  37290. right = {
  37291. type: matrixDef
  37292. };
  37293. } else
  37294. {
  37295. left = {
  37296. type: matrixDef
  37297. };
  37298. right = {
  37299. type: entityName
  37300. };
  37301. }
  37302. } else
  37303. {
  37304. Ext.Assert.isString(matrixDef.type, 'No "type" for manyToMany in ' + entityName);
  37305. relation = matrixDef.relation;
  37306. if (left || (!right && namer.apply('multiRole', entityName) < namer.apply('multiRole', matrixDef.type))) {
  37307. if (!left || left === true) {
  37308. left = {
  37309. type: entityName
  37310. };
  37311. } else
  37312. {
  37313. left = Ext.apply({
  37314. type: entityName
  37315. }, left);
  37316. }
  37317. right = matrixDef;
  37318. } else
  37319. {
  37320. if (!right || right === true) {
  37321. right = {
  37322. type: entityName
  37323. };
  37324. } else
  37325. {
  37326. right = Ext.apply({
  37327. type: entityName
  37328. }, right);
  37329. }
  37330. left = matrixDef;
  37331. }
  37332. }
  37333. if (!matrixName) {
  37334. matrixName = namer.manyToMany(relation, left.type, right.type);
  37335. }
  37336. if (!(matrixName in associations)) {
  37337. me.addMatrix(entityType, matrixName, relation, left, right);
  37338. } else
  37339. {
  37340. var entry = associations[matrixName],
  37341. before = [
  37342. entry.kind,
  37343. entry.left.type,
  37344. entry.left.role,
  37345. entry.left.field,
  37346. entry.right.type,
  37347. entry.right.role,
  37348. entry.right.field
  37349. ].join('|');
  37350. delete associations[matrixName];
  37351. me.addMatrix(entityType, matrixName, relation, left, right);
  37352. var after = associations[matrixName];
  37353. associations[matrixName] = entry;
  37354. entry.left.cls.associations[entry.right.role] = entry.right;
  37355. entry.right.cls.associations[entry.left.role] = entry.left;
  37356. --me.assocCount;
  37357. after = [
  37358. after.kind,
  37359. after.left.type,
  37360. after.left.role,
  37361. after.left.field,
  37362. after.right.type,
  37363. after.right.role,
  37364. after.right.field
  37365. ].join('|');
  37366. if (before != after) {
  37367. Ext.log.warn(matrixName + '(' + entry.definedBy.entityName + '): ' + before);
  37368. Ext.log.warn(matrixName + '(' + entityName + '): ' + after);
  37369. Ext.raise('Conflicting association: "' + matrixName + '" declared by ' + entityName + ' was previously declared by ' + entry.definedBy.entityName);
  37370. }
  37371. }
  37372. },
  37373. addReferenceDescr: function(entityType, referenceField) {
  37374. var me = this,
  37375. descr = referenceField.$reference;
  37376. if (Ext.isString(descr)) {
  37377. descr = {
  37378. type: descr
  37379. };
  37380. } else {
  37381. descr = Ext.apply({}, descr);
  37382. }
  37383. me.addReference(entityType, referenceField, descr, referenceField.unique);
  37384. },
  37385. addBelongsTo: function(entityType, assoc) {
  37386. this.addKeylessSingle(entityType, assoc, false);
  37387. },
  37388. addHasOne: function(entityType, assoc) {
  37389. this.addKeylessSingle(entityType, assoc, true);
  37390. },
  37391. addKeylessSingle: function(entityType, assoc, unique) {
  37392. var foreignKey, referenceField;
  37393. assoc = Ext.apply({}, this.checkLegacyAssociation(entityType, assoc));
  37394. assoc.type = this.getEntityName(assoc.child || assoc.parent || assoc.type);
  37395. foreignKey = assoc.foreignKey || (assoc.type.toLowerCase() + '_id');
  37396. referenceField = entityType.getField(foreignKey);
  37397. assoc.fromSingle = true;
  37398. if (referenceField) {
  37399. referenceField.$reference = assoc;
  37400. referenceField.unique = true;
  37401. assoc.legacy = true;
  37402. Ext.log.warn('Using foreignKey is deprecated, use a keyed association. See Ext.data.field.Field.reference');
  37403. }
  37404. this.addReference(entityType, referenceField, assoc, unique);
  37405. },
  37406. addHasMany: function(entityType, assoc) {
  37407. var me = this,
  37408. entities = me.entities,
  37409. pending = me.pending,
  37410. cls, name, referenceField, target, foreignKey, inverseOptions, child, declaredInverse;
  37411. assoc = Ext.apply({}, this.checkLegacyAssociation(entityType, assoc));
  37412. assoc.type = this.getEntityName(assoc.child || assoc.parent || assoc.type);
  37413. name = assoc.type;
  37414. target = entities[name];
  37415. cls = target && target.cls;
  37416. if (cls) {
  37417. name = entityType.entityName;
  37418. foreignKey = assoc.foreignKey || (name.toLowerCase() + '_id');
  37419. delete assoc.foreignKey;
  37420. declaredInverse = Ext.apply({}, assoc.inverse);
  37421. delete assoc.inverse;
  37422. inverseOptions = Ext.apply({}, assoc);
  37423. delete inverseOptions.type;
  37424. assoc = Ext.apply({
  37425. type: name,
  37426. inverse: inverseOptions
  37427. }, declaredInverse);
  37428. child = inverseOptions.child;
  37429. if (child) {
  37430. delete inverseOptions.child;
  37431. assoc.parent = name;
  37432. }
  37433. referenceField = cls.getField(foreignKey);
  37434. if (referenceField) {
  37435. referenceField.$reference = assoc;
  37436. assoc.legacy = true;
  37437. Ext.log.warn('Using foreignKey is deprecated, use a keyed association. See Ext.data.field.Field.reference');
  37438. }
  37439. me.addReference(cls, referenceField, assoc, false,
  37440. function(association, name, leftRole, rightRole) {
  37441. var result = !!association.meta.fromSingle && cls === association.left.cls,
  37442. l, r;
  37443. if (result) {
  37444. l = cls.entityName;
  37445. r = entityType.entityName;
  37446. Ext.raise('hasMany ("' + r + '") and belongsTo ("' + l + '") should not be used in conjunction to declare a relationship. Use only one.');
  37447. }
  37448. return result;
  37449. });
  37450. } else
  37451. {
  37452. if (!pending[name]) {
  37453. pending[name] = [];
  37454. }
  37455. pending[name].push([
  37456. entityType,
  37457. assoc
  37458. ]);
  37459. }
  37460. },
  37461. checkLegacyAssociation: function(entityType, assoc) {
  37462. if (Ext.isString(assoc)) {
  37463. assoc = {
  37464. type: assoc
  37465. };
  37466. } else {
  37467. assoc = Ext.apply({}, assoc);
  37468. }
  37469. if (assoc.model) {
  37470. assoc.type = assoc.model;
  37471. delete assoc.model;
  37472. }
  37473. var name = assoc.associatedName || assoc.name;
  37474. if (name) {
  37475. delete assoc.associatedName;
  37476. delete assoc.name;
  37477. assoc.role = name;
  37478. }
  37479. return assoc;
  37480. },
  37481. afterKeylessAssociations: function(cls) {
  37482. var pending = this.pending,
  37483. name = cls.entityName,
  37484. mine = pending[name],
  37485. i, len;
  37486. if (mine) {
  37487. for (i = 0 , len = mine.length; i < len; ++i) {
  37488. this.addHasMany.apply(this, mine[i]);
  37489. }
  37490. delete pending[name];
  37491. }
  37492. },
  37493. clear: function(clearNamespace) {
  37494. var me = this,
  37495. timer = me.timer;
  37496. delete me.setConfig;
  37497. if (timer) {
  37498. window.clearTimeout(timer);
  37499. me.timer = null;
  37500. }
  37501. me.associations = {};
  37502. me.associationEntityMap = {};
  37503. me.entities = {};
  37504. me.entityClasses = {};
  37505. me.pending = {};
  37506. me.assocCount = me.entityCount = 0;
  37507. if (clearNamespace) {
  37508. me.setNamespace(null);
  37509. }
  37510. },
  37511. constructProxy: function(Model) {
  37512. var me = this,
  37513. data = Ext.Object.chain(Model),
  37514. proxy = me.getProxy();
  37515. data.schema = me;
  37516. data.prefix = me.getUrlPrefix();
  37517. return proxy.apply(data);
  37518. },
  37519. applyDecoration: function(role) {
  37520. var me = this,
  37521. cls = role.inverse.cls,
  37522. namer = me.getNamer(),
  37523. getterName, setterName, proto;
  37524. if (cls && !role.decorated) {
  37525. role.decorated = true;
  37526. proto = cls.prototype;
  37527. if (!(getterName = role.getterName)) {
  37528. role.getterName = getterName = namer.getterName(role);
  37529. }
  37530. proto[getterName] = role.createGetter();
  37531. if (role.createSetter) {
  37532. if (!(setterName = role.setterName)) {
  37533. role.setterName = setterName = namer.setterName(role);
  37534. }
  37535. proto[setterName] = role.createSetter();
  37536. }
  37537. }
  37538. },
  37539. decorateModel: function(association) {
  37540. this.applyDecoration(association.left);
  37541. this.applyDecoration(association.right);
  37542. },
  37543. processKeyChecks: function(processAll) {
  37544. var me = this,
  37545. keyCheckQueue = me.keyCheckQueue,
  37546. timer = me.timer,
  37547. len, i, item;
  37548. if (timer) {
  37549. window.clearTimeout(timer);
  37550. me.timer = null;
  37551. }
  37552. if (!keyCheckQueue) {
  37553. return;
  37554. }
  37555. do {
  37556. keyCheckQueue = me.keyCheckQueue;
  37557. me.keyCheckQueue = [];
  37558. for (i = 0 , len = keyCheckQueue.length; i < len; ++i) {
  37559. item = keyCheckQueue[i];
  37560. item.role.checkKeyForDrop(item.record);
  37561. }
  37562. } while (processAll && me.keyCheckQueue.length);
  37563. },
  37564. queueKeyCheck: function(record, role) {
  37565. var me = this,
  37566. keyCheckQueue = me.keyCheckQueue,
  37567. timer = me.timer;
  37568. if (!keyCheckQueue) {
  37569. me.keyCheckQueue = keyCheckQueue = [];
  37570. }
  37571. keyCheckQueue.push({
  37572. record: record,
  37573. role: role
  37574. });
  37575. if (!timer) {
  37576. me.timer = timer = Ext.defer(me.processKeyChecks, me.getKeyCheckDelay(), me);
  37577. }
  37578. },
  37579. rankEntities: function() {
  37580. var me = this,
  37581. entities = me.entities,
  37582. entityNames = Ext.Object.getKeys(entities),
  37583. length = entityNames.length,
  37584. entityType, i;
  37585. me.nextRank = 1;
  37586. entityNames.sort();
  37587. for (i = 0; i < length; ++i) {
  37588. entityType = entities[entityNames[i]].cls;
  37589. if (!entityType.rank) {
  37590. me.rankEntity(entityType);
  37591. }
  37592. }
  37593. me.topoStack = null;
  37594. },
  37595. rankEntity: function(entityType) {
  37596. var associations = entityType.associations,
  37597. associatedType, role, roleName;
  37598. var topoStack = this.topoStack || (this.topoStack = []),
  37599. entityName = entityType.entityName;
  37600. topoStack.push(entityName);
  37601. if (entityType.rank === 0) {
  37602. Ext.raise(entityName + " has circular foreign-key references: " + topoStack.join(" --> "));
  37603. }
  37604. entityType.rank = 0;
  37605. for (roleName in associations) {
  37606. role = associations[roleName];
  37607. if (!role.left && role.association.field) {
  37608. associatedType = role.cls;
  37609. if (!associatedType.rank) {
  37610. this.rankEntity(associatedType);
  37611. }
  37612. }
  37613. }
  37614. entityType.rank = this.nextRank++;
  37615. topoStack.pop();
  37616. }
  37617. }
  37618. });
  37619. Ext.define('Ext.data.AbstractStore', {
  37620. mixins: [
  37621. Ext.mixin.Observable,
  37622. Ext.mixin.Factoryable
  37623. ],
  37624. factoryConfig: {
  37625. defaultType: 'store',
  37626. type: 'store'
  37627. },
  37628. $configPrefixed: false,
  37629. $configStrict: false,
  37630. config: {
  37631. filters: null,
  37632. autoDestroy: undefined,
  37633. storeId: null,
  37634. statefulFilters: false,
  37635. sorters: null,
  37636. remoteSort: {
  37637. lazy: true,
  37638. $value: false
  37639. },
  37640. remoteFilter: {
  37641. lazy: true,
  37642. $value: false
  37643. },
  37644. groupField: undefined,
  37645. groupDir: 'ASC',
  37646. grouper: null,
  37647. pageSize: 25,
  37648. autoSort: null,
  37649. reloadOnClearSorters: false
  37650. },
  37651. currentPage: 1,
  37652. loading: false,
  37653. isStore: true,
  37654. updating: 0,
  37655. constructor: function(config) {
  37656. var me = this,
  37657. storeId;
  37658. me.callParent([
  37659. config
  37660. ]);
  37661. me.isInitializing = true;
  37662. me.mixins.observable.constructor.call(me, config);
  37663. me.isInitializing = false;
  37664. storeId = me.getStoreId();
  37665. if (!storeId && (config && config.id)) {
  37666. me.setStoreId(storeId = config.id);
  37667. }
  37668. if (storeId) {
  37669. Ext.data.StoreManager.register(me);
  37670. }
  37671. },
  37672. createActiveRange: function(config) {
  37673. var range = Ext.apply({
  37674. store: this
  37675. }, config);
  37676. return new Ext.data.Range(range);
  37677. },
  37678. syncActiveRanges: function() {
  37679. var activeRanges = this.activeRanges,
  37680. len = activeRanges && activeRanges.length,
  37681. i;
  37682. for (i = 0; i < len; i++) {
  37683. activeRanges[i].refresh();
  37684. }
  37685. },
  37686. getCount: function() {
  37687. var data = this.getData();
  37688. return data ? data.getCount() : 0;
  37689. },
  37690. rangeCached: function(start, end) {
  37691. return this.getData().getCount() >= Math.max(start, end);
  37692. },
  37693. find: function(property, value, startIndex, anyMatch, caseSensitive, exactMatch) {
  37694. var startsWith = !anyMatch,
  37695. endsWith = !!(startsWith && exactMatch);
  37696. return this.getData().findIndex(property, value, startIndex, startsWith, endsWith, !caseSensitive);
  37697. },
  37698. findRecord: function() {
  37699. var me = this,
  37700. index = me.find.apply(me, arguments);
  37701. return index !== -1 ? me.getAt(index) : null;
  37702. },
  37703. findExact: function(fieldName, value, startIndex) {
  37704. return this.getData().findIndexBy(function(rec) {
  37705. return rec.isEqual(rec.get(fieldName), value);
  37706. }, this, startIndex);
  37707. },
  37708. findBy: function(fn, scope, start) {
  37709. return this.getData().findIndexBy(fn, scope, start);
  37710. },
  37711. getAt: function(index) {
  37712. return this.getData().getAt(index) || null;
  37713. },
  37714. getRange: function(start, end, options) {
  37715. var result = this.getData().getRange(start, Ext.isNumber(end) ? end + 1 : end);
  37716. if (options && options.callback) {
  37717. options.callback.call(options.scope || this, result, start, end, options);
  37718. }
  37719. return result;
  37720. },
  37721. getFilters: function(autoCreate) {
  37722. var result = this.callParent();
  37723. if (!result && autoCreate !== false) {
  37724. this.setFilters([]);
  37725. result = this.callParent();
  37726. }
  37727. return result;
  37728. },
  37729. applyFilters: function(filters, filtersCollection) {
  37730. var created;
  37731. if (!filtersCollection) {
  37732. filtersCollection = this.createFiltersCollection();
  37733. created = true;
  37734. }
  37735. filtersCollection.add(filters);
  37736. if (created) {
  37737. this.onRemoteFilterSet(filtersCollection, this.getRemoteFilter());
  37738. }
  37739. return filtersCollection;
  37740. },
  37741. getSorters: function(autoCreate) {
  37742. var result = this.callParent();
  37743. if (!result && autoCreate !== false) {
  37744. this.setSorters([]);
  37745. result = this.callParent();
  37746. }
  37747. return result;
  37748. },
  37749. applySorters: function(sorters, sortersCollection) {
  37750. var created;
  37751. if (!sortersCollection) {
  37752. sortersCollection = this.createSortersCollection();
  37753. created = true;
  37754. }
  37755. sortersCollection.add(sorters);
  37756. if (created) {
  37757. this.onRemoteSortSet(sortersCollection, this.getRemoteSort());
  37758. }
  37759. return sortersCollection;
  37760. },
  37761. filter: function(filters, value, suppressEvent) {
  37762. if (Ext.isString(filters)) {
  37763. filters = {
  37764. property: filters,
  37765. value: value
  37766. };
  37767. }
  37768. this.suppressNextFilter = !!suppressEvent;
  37769. this.getFilters().add(filters);
  37770. this.suppressNextFilter = false;
  37771. },
  37772. removeFilter: function(toRemove, suppressEvent) {
  37773. var me = this,
  37774. filters = me.getFilters();
  37775. me.suppressNextFilter = !!suppressEvent;
  37776. if (toRemove instanceof Ext.util.Filter) {
  37777. filters.remove(toRemove);
  37778. } else {
  37779. filters.removeByKey(toRemove);
  37780. }
  37781. me.suppressNextFilter = false;
  37782. },
  37783. updateAutoSort: function(autoSort) {
  37784. this.getData().setAutoSort(autoSort);
  37785. },
  37786. updateRemoteSort: function(remoteSort) {
  37787. this.onRemoteSortSet(this.getSorters(false), remoteSort);
  37788. },
  37789. updateRemoteFilter: function(remoteFilter) {
  37790. this.onRemoteFilterSet(this.getFilters(false), remoteFilter);
  37791. },
  37792. addFilter: function(filters, suppressEvent) {
  37793. this.suppressNextFilter = !!suppressEvent;
  37794. this.getFilters().add(filters);
  37795. this.suppressNextFilter = false;
  37796. },
  37797. filterBy: function(fn, scope) {
  37798. this.getFilters().add({
  37799. filterFn: fn,
  37800. scope: scope || this
  37801. });
  37802. },
  37803. clearFilter: function(suppressEvent) {
  37804. var me = this,
  37805. filters = me.getFilters(false);
  37806. if (!filters || filters.getCount() === 0) {
  37807. return;
  37808. }
  37809. me.suppressNextFilter = !!suppressEvent;
  37810. filters.removeAll();
  37811. me.suppressNextFilter = false;
  37812. },
  37813. isFiltered: function() {
  37814. return this.getFilters().getCount() > 0;
  37815. },
  37816. isSorted: function() {
  37817. var sorters = this.getSorters(false);
  37818. return !!(sorters && sorters.length > 0) || this.isGrouped();
  37819. },
  37820. addFieldTransform: function(sorter) {
  37821. if (sorter.getTransform()) {
  37822. return;
  37823. }
  37824. var fieldName = sorter.getProperty(),
  37825. Model = this.getModel(),
  37826. field, sortType;
  37827. if (Model) {
  37828. field = Model.getField(fieldName);
  37829. sortType = field ? field.getSortType() : null;
  37830. }
  37831. if (sortType && sortType !== Ext.identityFn) {
  37832. sorter.setTransform(sortType);
  37833. }
  37834. },
  37835. beginUpdate: function() {
  37836. if (!this.updating++ && this.hasListeners.beginupdate) {
  37837. this.fireEvent('beginupdate');
  37838. }
  37839. },
  37840. endUpdate: function() {
  37841. if (this.updating && !--this.updating) {
  37842. if (this.hasListeners.endupdate) {
  37843. this.fireEvent('endupdate');
  37844. }
  37845. this.onEndUpdate();
  37846. }
  37847. },
  37848. getState: function() {
  37849. var me = this,
  37850. sorters = [],
  37851. filters = me.getFilters(),
  37852. grouper = me.getGrouper(),
  37853. filterState, hasState, result;
  37854. me.getSorters().each(function(s) {
  37855. sorters[sorters.length] = s.getState();
  37856. hasState = true;
  37857. });
  37858. if (me.statefulFilters && me.saveStatefulFilters) {
  37859. hasState = true;
  37860. filterState = [];
  37861. filters.each(function(f) {
  37862. filterState[filterState.length] = f.getState();
  37863. });
  37864. }
  37865. if (grouper) {
  37866. hasState = true;
  37867. }
  37868. if (hasState) {
  37869. result = {};
  37870. if (sorters.length) {
  37871. result.sorters = sorters;
  37872. }
  37873. if (filterState) {
  37874. result.filters = filterState;
  37875. }
  37876. if (grouper) {
  37877. result.grouper = grouper.getState();
  37878. }
  37879. }
  37880. return result;
  37881. },
  37882. applyState: function(state) {
  37883. var me = this,
  37884. stateSorters = state.sorters,
  37885. stateFilters = state.filters,
  37886. stateGrouper = state.grouper;
  37887. if (stateSorters) {
  37888. me.getSorters().replaceAll(stateSorters);
  37889. }
  37890. if (stateFilters) {
  37891. me.saveStatefulFilters = true;
  37892. me.getFilters().replaceAll(stateFilters);
  37893. }
  37894. if (stateGrouper) {
  37895. me.setGrouper(stateGrouper);
  37896. }
  37897. },
  37898. hasPendingLoad: Ext.emptyFn,
  37899. isLoaded: Ext.emptyFn,
  37900. isLoading: Ext.emptyFn,
  37901. destroy: function() {
  37902. var me = this;
  37903. if (me.hasListeners.beforedestroy) {
  37904. me.fireEvent('beforedestroy', me);
  37905. }
  37906. me.destroying = true;
  37907. if (me.getStoreId()) {
  37908. Ext.data.StoreManager.unregister(me);
  37909. }
  37910. me.doDestroy();
  37911. if (me.hasListeners.destroy) {
  37912. me.fireEvent('destroy', me);
  37913. }
  37914. me.destroying = false;
  37915. me.callParent();
  37916. },
  37917. doDestroy: Ext.emptyFn,
  37918. sort: function(field, direction, mode) {
  37919. var me = this;
  37920. if (arguments.length === 0) {
  37921. if (me.getRemoteSort()) {
  37922. me.load();
  37923. } else {
  37924. me.forceLocalSort();
  37925. }
  37926. } else {
  37927. me.getSorters().addSort(field, direction, mode);
  37928. }
  37929. },
  37930. onBeforeCollectionSort: function(store, sorters) {
  37931. if (sorters) {
  37932. this.fireEvent('beforesort', this, sorters.getRange());
  37933. }
  37934. },
  37935. onSorterEndUpdate: function() {
  37936. var me = this,
  37937. fireSort = true,
  37938. sorters = me.getSorters(false),
  37939. sorterCount;
  37940. if (me.settingGroups || !sorters) {
  37941. return;
  37942. }
  37943. sorters = sorters.getRange();
  37944. sorterCount = sorters.length;
  37945. if (me.getRemoteSort()) {
  37946. if (sorters.length || me.getReloadOnClearSorters()) {
  37947. fireSort = false;
  37948. me.load({
  37949. callback: function() {
  37950. me.fireEvent('sort', me, sorters);
  37951. }
  37952. });
  37953. }
  37954. } else if (sorterCount) {
  37955. me.fireEvent('datachanged', me);
  37956. me.fireEvent('refresh', me);
  37957. }
  37958. if (fireSort) {
  37959. me.fireEvent('sort', me, sorters);
  37960. }
  37961. },
  37962. onFilterEndUpdate: function() {
  37963. var me = this,
  37964. suppressNext = me.suppressNextFilter,
  37965. filters = me.getFilters(false);
  37966. if (!filters) {
  37967. return;
  37968. }
  37969. if (me.getRemoteFilter()) {
  37970. me.getFilters().each(function(filter) {
  37971. if (filter.getInitialConfig().filterFn) {
  37972. Ext.raise('Unable to use a filtering function in conjunction with remote filtering.');
  37973. }
  37974. });
  37975. me.currentPage = 1;
  37976. if (!suppressNext) {
  37977. me.load();
  37978. }
  37979. } else if (!suppressNext) {
  37980. me.fireEvent('datachanged', me);
  37981. me.fireEvent('refresh', me);
  37982. }
  37983. if (me.trackStateChanges) {
  37984. me.saveStatefulFilters = true;
  37985. }
  37986. me.fireEvent('filterchange', me, me.getFilters().getRange());
  37987. },
  37988. updateGroupField: function(field) {
  37989. if (field) {
  37990. this.setGrouper({
  37991. property: field,
  37992. direction: this.getGroupDir()
  37993. });
  37994. } else {
  37995. this.setGrouper(null);
  37996. }
  37997. },
  37998. getGrouper: function() {
  37999. return this.getData().getGrouper();
  38000. },
  38001. group: function(grouper, direction) {
  38002. var me = this,
  38003. sorters = me.getSorters(false),
  38004. change = grouper || (sorters && sorters.length),
  38005. data = me.getData();
  38006. if (grouper && typeof grouper === 'string') {
  38007. grouper = {
  38008. property: grouper,
  38009. direction: direction || me.getGroupDir()
  38010. };
  38011. }
  38012. me.settingGroups = true;
  38013. if (grouper === data.getGrouper()) {
  38014. data.updateGrouper(grouper);
  38015. } else {
  38016. data.setGrouper(grouper);
  38017. }
  38018. delete me.settingGroups;
  38019. if (change) {
  38020. if (me.getRemoteSort()) {
  38021. if (!me.isInitializing) {
  38022. me.load({
  38023. scope: me,
  38024. callback: me.fireGroupChange
  38025. });
  38026. }
  38027. } else {
  38028. me.fireEvent('datachanged', me);
  38029. me.fireEvent('refresh', me);
  38030. me.fireGroupChange();
  38031. }
  38032. } else
  38033. {
  38034. me.fireGroupChange();
  38035. }
  38036. },
  38037. fireGroupChange: function() {
  38038. if (!this.destroyed) {
  38039. this.fireEvent('groupchange', this, this.getGrouper());
  38040. }
  38041. },
  38042. clearGrouping: function() {
  38043. this.group(null);
  38044. },
  38045. getGroupField: function() {
  38046. var grouper = this.getGrouper(),
  38047. group = '';
  38048. if (grouper) {
  38049. group = grouper.getProperty();
  38050. }
  38051. return group;
  38052. },
  38053. isGrouped: function() {
  38054. return !!this.getGrouper();
  38055. },
  38056. applyGrouper: function(grouper) {
  38057. this.group(grouper);
  38058. return this.getData().getGrouper();
  38059. },
  38060. getGroups: function() {
  38061. return this.getData().getGroups();
  38062. },
  38063. onEndUpdate: Ext.emptyFn,
  38064. privates: {
  38065. _metaProperties: {
  38066. count: 'getCount',
  38067. first: 'first',
  38068. last: 'last',
  38069. loading: 'hasPendingLoad',
  38070. totalCount: 'getTotalCount'
  38071. },
  38072. interpret: function(name) {
  38073. var me = this,
  38074. accessor = me._metaProperties[name];
  38075. return accessor && me[accessor]();
  38076. },
  38077. loadsSynchronously: Ext.privateFn,
  38078. onRemoteFilterSet: function(filters, remoteFilter) {
  38079. if (filters) {
  38080. filters[remoteFilter ? 'on' : 'un']('endupdate', 'onFilterEndUpdate', this);
  38081. }
  38082. },
  38083. onRemoteSortSet: function(sorters, remoteSort) {
  38084. var me = this,
  38085. data;
  38086. if (sorters) {
  38087. sorters[remoteSort ? 'on' : 'un']('endupdate', 'onSorterEndUpdate', me);
  38088. data = me.getData();
  38089. if (data) {
  38090. data[remoteSort ? 'un' : 'on']('beforesort', 'onBeforeCollectionSort', me);
  38091. }
  38092. }
  38093. }
  38094. },
  38095. deprecated: {
  38096. 5: {
  38097. methods: {
  38098. destroyStore: function() {
  38099. this.destroy();
  38100. }
  38101. }
  38102. }
  38103. }
  38104. });
  38105. Ext.define('Ext.data.Error', {
  38106. isError: true,
  38107. $configPrefixed: false,
  38108. config: {
  38109. field: null,
  38110. message: ''
  38111. },
  38112. constructor: function(config) {
  38113. this.initConfig(config);
  38114. this.msg = this.message;
  38115. }
  38116. });
  38117. Ext.define('Ext.data.ErrorCollection', {
  38118. extend: Ext.util.MixedCollection,
  38119. alternateClassName: 'Ext.data.Errors',
  38120. init: function(record) {
  38121. var me = this,
  38122. fields = record.fields,
  38123. data = record.data,
  38124. before, field, item, i, len, msg, val, name;
  38125. for (i = 0 , len = fields.length; i < len; ++i) {
  38126. field = fields[i];
  38127. name = field.name;
  38128. val = data[name];
  38129. if (field.validate && !field.validate.$nullFn) {
  38130. before = me.length;
  38131. msg = field.validate(val, null, me, record);
  38132. if (before === me.length && msg !== true) {
  38133. me.add(name, msg);
  38134. }
  38135. }
  38136. }
  38137. return me;
  38138. },
  38139. add: function(key, value) {
  38140. var me = this,
  38141. defaultMessage = Ext.data.field.Field.defaultInvalidMessage,
  38142. obj = key,
  38143. current;
  38144. if (Ext.isString(key)) {
  38145. obj = new Ext.data.Error({
  38146. field: key,
  38147. message: value || defaultMessage
  38148. });
  38149. } else {
  38150. if (!(obj.isError)) {
  38151. obj = new Ext.data.Error({
  38152. field: obj.field || obj.name,
  38153. message: obj.error || obj.message || obj.msg || defaultMessage
  38154. });
  38155. }
  38156. key = obj.field;
  38157. }
  38158. current = me.get(key);
  38159. if (current) {
  38160. if (Ext.isArray(current)) {
  38161. current.push(obj);
  38162. return current;
  38163. }
  38164. me.removeAtKey(key);
  38165. obj = [
  38166. current,
  38167. obj
  38168. ];
  38169. obj.field = key;
  38170. obj = [
  38171. obj
  38172. ];
  38173. }
  38174. return me.callParent([
  38175. obj
  38176. ]);
  38177. },
  38178. getKey: function(item) {
  38179. return item.field;
  38180. },
  38181. isValid: function() {
  38182. return this.length === 0;
  38183. },
  38184. getByField: function(fieldName) {
  38185. var values = this.get(fieldName);
  38186. if (values && !Ext.isArray(values)) {
  38187. values = [
  38188. values
  38189. ];
  38190. }
  38191. return values || [];
  38192. }
  38193. });
  38194. Ext.define('Ext.data.operation.Operation', {
  38195. alternateClassName: 'Ext.data.Operation',
  38196. isOperation: true,
  38197. config: {
  38198. synchronous: false,
  38199. url: '',
  38200. params: undefined,
  38201. callback: undefined,
  38202. scope: undefined,
  38203. resultSet: null,
  38204. response: null,
  38205. request: null,
  38206. records: null,
  38207. id: undefined,
  38208. proxy: null,
  38209. batch: null,
  38210. recordCreator: null,
  38211. internalCallback: null,
  38212. internalScope: null
  38213. },
  38214. order: 0,
  38215. foreignKeyDirection: 1,
  38216. started: false,
  38217. running: false,
  38218. complete: false,
  38219. success: undefined,
  38220. exception: false,
  38221. error: undefined,
  38222. idPrefix: 'ext-operation-',
  38223. constructor: function(config) {
  38224. var scope = config && config.scope;
  38225. this.initConfig(config);
  38226. if (config) {
  38227. config.scope = scope;
  38228. }
  38229. if (scope) {
  38230. this.setScope(scope);
  38231. this.initialConfig.scope = scope;
  38232. }
  38233. this._internalId = Ext.id(this, this.idPrefix);
  38234. },
  38235. getAction: function() {
  38236. return this.action;
  38237. },
  38238. execute: function() {
  38239. var me = this,
  38240. request;
  38241. delete me.error;
  38242. delete me.success;
  38243. me.complete = me.exception = false;
  38244. me.setStarted();
  38245. me.request = request = me.doExecute();
  38246. if (request) {
  38247. request.setOperation(me);
  38248. }
  38249. return request;
  38250. },
  38251. doExecute: Ext.emptyFn,
  38252. abort: function() {
  38253. var me = this,
  38254. request = me.request,
  38255. proxy;
  38256. me.aborted = true;
  38257. if (me.running && request) {
  38258. proxy = me.getProxy();
  38259. if (proxy && !proxy.destroyed) {
  38260. proxy.abort(request);
  38261. }
  38262. me.request = null;
  38263. }
  38264. me.running = false;
  38265. },
  38266. process: function(resultSet, request, response, autoComplete) {
  38267. var me = this;
  38268. autoComplete = autoComplete !== false;
  38269. me.setResponse(response);
  38270. me.setResultSet(resultSet);
  38271. if (resultSet.getSuccess()) {
  38272. me.doProcess(resultSet, request, response);
  38273. me.setSuccessful(autoComplete);
  38274. } else if (autoComplete) {
  38275. me.setException(resultSet.getMessage());
  38276. }
  38277. },
  38278. _commitSetOptions: {
  38279. convert: true,
  38280. commit: true
  38281. },
  38282. doProcess: function(resultSet, request, response) {
  38283. var me = this,
  38284. commitSetOptions = me._commitSetOptions,
  38285. clientRecords = me.getRecords(),
  38286. clientLen = clientRecords.length,
  38287. clientIdProperty = clientRecords[0].clientIdProperty,
  38288. serverRecords = resultSet.getRecords(),
  38289. serverLen = serverRecords ? serverRecords.length : 0,
  38290. clientMap, serverRecord, clientRecord, i;
  38291. if (serverLen && clientIdProperty) {
  38292. clientMap = Ext.Array.toValueMap(clientRecords, 'id');
  38293. for (i = 0; i < serverLen; ++i) {
  38294. serverRecord = serverRecords[i];
  38295. clientRecord = clientMap[serverRecord[clientIdProperty]];
  38296. if (clientRecord) {
  38297. delete clientMap[clientRecord.id];
  38298. delete serverRecord[clientIdProperty];
  38299. clientRecord.set(serverRecord, commitSetOptions);
  38300. } else
  38301. {
  38302. Ext.log.warn('Ignoring server record: ' + Ext.encode(serverRecord));
  38303. }
  38304. }
  38305. for (i in clientMap) {
  38306. clientMap[i].commit();
  38307. }
  38308. } else {
  38309. for (i = 0; i < clientLen; ++i) {
  38310. clientRecord = clientRecords[i];
  38311. if (serverLen === 0 || !(serverRecord = serverRecords[i])) {
  38312. clientRecord.commit();
  38313. } else {
  38314. clientRecord.set(serverRecord, commitSetOptions);
  38315. }
  38316. }
  38317. }
  38318. },
  38319. setStarted: function() {
  38320. this.started = this.running = true;
  38321. },
  38322. setCompleted: function() {
  38323. var me = this,
  38324. proxy;
  38325. me.complete = true;
  38326. me.running = false;
  38327. if (!me.destroying) {
  38328. me.triggerCallbacks();
  38329. }
  38330. if (me.destroyed) {
  38331. return;
  38332. }
  38333. proxy = me.getProxy();
  38334. if (proxy && !proxy.destroyed) {
  38335. proxy.completeOperation(me);
  38336. }
  38337. },
  38338. setSuccessful: function(complete) {
  38339. this.success = true;
  38340. if (complete) {
  38341. this.setCompleted();
  38342. }
  38343. },
  38344. setException: function(error) {
  38345. var me = this;
  38346. me.exception = true;
  38347. me.success = me.running = false;
  38348. me.error = error;
  38349. me.setCompleted();
  38350. },
  38351. triggerCallbacks: function() {
  38352. var me = this,
  38353. callback = me.getInternalCallback();
  38354. if (callback) {
  38355. callback.call(me.getInternalScope() || me, me);
  38356. if (me.destroyed) {
  38357. return;
  38358. }
  38359. me.setInternalCallback(null);
  38360. me.setInternalScope(null);
  38361. }
  38362. if (callback = me.getCallback()) {
  38363. callback.call(me.getScope() || me, me.getRecords(), me, me.wasSuccessful());
  38364. if (me.destroyed) {
  38365. return;
  38366. }
  38367. me.setCallback(null);
  38368. me.setScope(null);
  38369. }
  38370. },
  38371. hasException: function() {
  38372. return this.exception;
  38373. },
  38374. getError: function() {
  38375. return this.error;
  38376. },
  38377. getRecords: function() {
  38378. var resultSet;
  38379. return this._records || ((resultSet = this.getResultSet()) ? resultSet.getRecords() : null);
  38380. },
  38381. isStarted: function() {
  38382. return this.started;
  38383. },
  38384. isRunning: function() {
  38385. return this.running;
  38386. },
  38387. isComplete: function() {
  38388. return this.complete;
  38389. },
  38390. wasSuccessful: function() {
  38391. return this.isComplete() && this.success === true;
  38392. },
  38393. allowWrite: function() {
  38394. return true;
  38395. },
  38396. destroy: function() {
  38397. var me = this;
  38398. me.destroying = true;
  38399. if (me.running) {
  38400. me.abort();
  38401. }
  38402. me._params = me._callback = me._scope = me._resultSet = me._response = null;
  38403. me.request = me._request = me._records = me._proxy = me._batch = null;
  38404. me._recordCreator = me._internalCallback = me._internalScope = null;
  38405. me.callParent();
  38406. }
  38407. });
  38408. Ext.define('Ext.data.operation.Create', {
  38409. extend: Ext.data.operation.Operation,
  38410. alias: 'data.operation.create',
  38411. action: 'create',
  38412. isCreateOperation: true,
  38413. order: 10,
  38414. config: {
  38415. recordCreator: Ext.identityFn
  38416. },
  38417. doExecute: function() {
  38418. return this.getProxy().create(this);
  38419. }
  38420. });
  38421. Ext.define('Ext.data.operation.Destroy', {
  38422. extend: Ext.data.operation.Operation,
  38423. alias: 'data.operation.destroy',
  38424. action: 'destroy',
  38425. isDestroyOperation: true,
  38426. order: 30,
  38427. foreignKeyDirection: -1,
  38428. doProcess: function()
  38429. {
  38430. var clientRecords = this.getRecords(),
  38431. clientLen = clientRecords.length,
  38432. i;
  38433. for (i = 0; i < clientLen; ++i) {
  38434. clientRecords[i].setErased();
  38435. }
  38436. },
  38437. doExecute: function() {
  38438. return this.getProxy().erase(this);
  38439. },
  38440. getRecordData: function(record, operation) {
  38441. var data = {},
  38442. idField = record.idField,
  38443. nameProperty = this.getNameProperty() || 'name';
  38444. data[idField[nameProperty]] = record.id;
  38445. return data;
  38446. }
  38447. });
  38448. Ext.define('Ext.data.operation.Read', {
  38449. extend: Ext.data.operation.Operation,
  38450. alias: 'data.operation.read',
  38451. action: 'read',
  38452. isReadOperation: true,
  38453. config: {
  38454. filters: undefined,
  38455. sorters: undefined,
  38456. grouper: undefined,
  38457. start: undefined,
  38458. limit: undefined,
  38459. page: undefined,
  38460. addRecords: false
  38461. },
  38462. doExecute: function() {
  38463. return this.getProxy().read(this);
  38464. },
  38465. doProcess: Ext.emptyFn,
  38466. allowWrite: function() {
  38467. return false;
  38468. }
  38469. });
  38470. Ext.define('Ext.data.operation.Update', {
  38471. extend: Ext.data.operation.Operation,
  38472. alias: 'data.operation.update',
  38473. action: 'update',
  38474. isUpdateOperation: true,
  38475. order: 20,
  38476. config: {
  38477. recordCreator: Ext.identityFn
  38478. },
  38479. doExecute: function() {
  38480. return this.getProxy().update(this);
  38481. }
  38482. });
  38483. Ext.define('Ext.data.SortTypes', function() {
  38484. var me;
  38485. return {
  38486. singleton: true,
  38487. constructor: function() {
  38488. me = this;
  38489. },
  38490. none: Ext.identityFn,
  38491. stripCommasRe: /,/g,
  38492. stripTagsRE: /<\/?[^>]+>/gi,
  38493. asText: function(s) {
  38494. return (s != null) ? String(s).replace(me.stripTagsRE, '') : '\x00';
  38495. },
  38496. asUCText: function(s) {
  38497. return (s != null) ? String(s).toUpperCase().replace(me.stripTagsRE, '') : '\x00';
  38498. },
  38499. asUCString: function(s) {
  38500. return (s != null) ? String(s).toUpperCase() : '\x00';
  38501. },
  38502. asDate: function(s) {
  38503. if (!s) {
  38504. return 0;
  38505. }
  38506. if (Ext.isDate(s)) {
  38507. return s.getTime();
  38508. }
  38509. return Date.parse(String(s));
  38510. },
  38511. asFloat: function(s) {
  38512. var val = parseFloat(String(s).replace(me.stripCommasRe, ''));
  38513. return isNaN(val) ? 0 : val;
  38514. },
  38515. asInt: function(s) {
  38516. var val = parseInt(String(s).replace(me.stripCommasRe, ''), 10);
  38517. return isNaN(val) ? 0 : val;
  38518. }
  38519. };
  38520. });
  38521. Ext.define('Ext.data.validator.Validator', {
  38522. mixins: [
  38523. Ext.mixin.Factoryable
  38524. ],
  38525. alias: 'data.validator.base',
  38526. isValidator: true,
  38527. factoryConfig: {
  38528. cacheable: true
  38529. },
  38530. type: 'base',
  38531. constructor: function(config) {
  38532. if (typeof config === 'function') {
  38533. this.fnOnly = true;
  38534. this.validate = config;
  38535. } else {
  38536. this.initConfig(config);
  38537. }
  38538. },
  38539. validate: function() {
  38540. return true;
  38541. },
  38542. clone: function() {
  38543. var me = this;
  38544. if (me.fnOnly) {
  38545. return new Ext.data.validator.Validator(me.validate);
  38546. }
  38547. return new me.self(me.getCurrentConfig());
  38548. }
  38549. }, function(Validator) {
  38550. Ext.Factory.validator = Ext.Factory.dataValidator;
  38551. });
  38552. Ext.define('Ext.data.field.Field', {
  38553. mixins: [
  38554. Ext.mixin.Factoryable
  38555. ],
  38556. alternateClassName: 'Ext.data.Field',
  38557. alias: 'data.field.auto',
  38558. aliasPrefix: 'data.field.',
  38559. type: 'auto',
  38560. factoryConfig: {
  38561. defaultProperty: 'name'
  38562. },
  38563. isDataField: true,
  38564. isField: true,
  38565. allowBlank: true,
  38566. allowNull: false,
  38567. critical: false,
  38568. defaultInvalidMessage: 'This field is invalid',
  38569. defaultValue: undefined,
  38570. definedBy: null,
  38571. depends: null,
  38572. dependents: null,
  38573. mapping: null,
  38574. name: null,
  38575. ordinal: undefined,
  38576. persist: null,
  38577. reference: null,
  38578. summary: null,
  38579. summaryField: '',
  38580. unique: false,
  38581. rank: null,
  38582. stripRe: /[\$,%]/g,
  38583. calculated: false,
  38584. evil: false,
  38585. identifier: false,
  38586. onClassExtended: function(cls, data) {
  38587. var sortType = data.sortType,
  38588. proto = cls.prototype,
  38589. superValidators = proto.validators,
  38590. validators = data.validators;
  38591. if (sortType && Ext.isString(sortType)) {
  38592. proto.sortType = Ext.data.SortTypes[sortType];
  38593. }
  38594. if (validators) {
  38595. if (!Ext.isArray(validators)) {
  38596. validators = [
  38597. validators
  38598. ];
  38599. }
  38600. delete data.validators;
  38601. if (superValidators) {
  38602. validators = superValidators.concat(validators);
  38603. }
  38604. proto.validators = validators;
  38605. }
  38606. },
  38607. argumentNamesRe: /^function\s*\(\s*([^,\)\s]+)/,
  38608. calculateRe: /[^\.a-z0-9_]([a-z_][a-z_0-9]*)\.([a-z_][a-z_0-9]*)/gi,
  38609. constructor: function(config) {
  38610. var me = this,
  38611. calculateRe = me.calculateRe,
  38612. calculate, calculated, defaultValue, sortType, depends, map, match, dataProp, str, fld, validators;
  38613. if (config) {
  38614. if (Ext.isString(config)) {
  38615. me.name = config;
  38616. } else {
  38617. validators = config.validators;
  38618. if (validators) {
  38619. delete config.validators;
  38620. me.instanceValidators = validators;
  38621. }
  38622. Ext.apply(me, config);
  38623. }
  38624. }
  38625. if (!me.allowNull) {
  38626. me.allowNull = !!me.reference;
  38627. }
  38628. calculate = me.calculate;
  38629. depends = me.depends;
  38630. if (calculate) {
  38631. me.convert = me.doCalculate;
  38632. if (!depends) {
  38633. if (!(depends = calculate.$depends)) {
  38634. map = {};
  38635. str = Ext.Function.toCode(calculate);
  38636. calculate.$depends = depends = [];
  38637. match = me.argumentNamesRe.exec(str);
  38638. dataProp = match ? match[1] : 'data';
  38639. while ((match = calculateRe.exec(str))) {
  38640. if (dataProp === match[1] && !map[fld = match[2]]) {
  38641. map[fld] = 1;
  38642. depends.push(fld);
  38643. }
  38644. }
  38645. }
  38646. me.depends = depends;
  38647. }
  38648. }
  38649. defaultValue = me.defaultValue;
  38650. if (me.convert) {
  38651. me.calculated = calculated = me.convert.length > 1;
  38652. me.evil = calculated && !depends;
  38653. }
  38654. if (me.persist === null) {
  38655. me.persist = !calculate;
  38656. }
  38657. sortType = me.sortType;
  38658. if (!me.sortType) {
  38659. me.sortType = Ext.data.SortTypes.none;
  38660. } else if (Ext.isString(sortType)) {
  38661. me.sortType = Ext.data.SortTypes[sortType];
  38662. }
  38663. if (depends && typeof depends === 'string') {
  38664. me.depends = [
  38665. depends
  38666. ];
  38667. }
  38668. me.cloneDefaultValue = defaultValue !== undefined && (Ext.isDate(defaultValue) || Ext.isArray(defaultValue) || Ext.isObject(defaultValue));
  38669. },
  38670. setModelValidators: function(modelValidators) {
  38671. this._validators = null;
  38672. this.modelValidators = modelValidators;
  38673. },
  38674. constructValidators: function(validators) {
  38675. if (validators) {
  38676. if (!(validators instanceof Array)) {
  38677. validators = [
  38678. validators
  38679. ];
  38680. }
  38681. var length = validators.length,
  38682. all = this._validators,
  38683. i, item, validator, presence;
  38684. for (i = 0; i < length; ++i) {
  38685. item = validators[i];
  38686. if (item.fn) {
  38687. item = item.fn;
  38688. }
  38689. validator = Ext.Factory.dataValidator(item);
  38690. if (!validator.isPresence) {
  38691. all.push(validator);
  38692. } else {
  38693. presence = validator;
  38694. }
  38695. }
  38696. if (presence) {
  38697. this.presence = [
  38698. presence
  38699. ];
  38700. }
  38701. }
  38702. },
  38703. collate: function(value1, value2) {
  38704. var me = this,
  38705. lhs = value1,
  38706. rhs = value2;
  38707. if (me.sortType) {
  38708. lhs = me.sortType(lhs);
  38709. rhs = me.sortType(rhs);
  38710. }
  38711. return (lhs === rhs) ? 0 : ((lhs < rhs) ? -1 : 1);
  38712. },
  38713. compare: function(value1, value2) {
  38714. return (value1 === value2) ? 0 : ((value1 < value2) ? -1 : 1);
  38715. },
  38716. isEqual: function(value1, value2) {
  38717. return this.compare(value1, value2) === 0;
  38718. },
  38719. convert: null,
  38720. serialize: null,
  38721. validate: function(value, separator, errors, record) {
  38722. var me = this,
  38723. validators = me.getValidators(),
  38724. result, presence;
  38725. presence = this.presence;
  38726. if (presence && (value == null || value === '')) {
  38727. result = me.validateGroup(presence, value, separator, errors, record);
  38728. if (result !== true) {
  38729. return result;
  38730. }
  38731. }
  38732. return me.validateGroup(validators, value, separator, errors, record);
  38733. },
  38734. validateGroup: function(validators, value, separator, errors, record) {
  38735. var ret = '',
  38736. validator, length, i, result;
  38737. for (i = 0 , length = validators.length; i < length; ++i) {
  38738. validator = validators[i];
  38739. result = validator.validate(value, record);
  38740. if (result !== true) {
  38741. result = result || this.defaultInvalidMessage;
  38742. if (errors) {
  38743. if (errors.isMixedCollection) {
  38744. errors.add(this.name, result);
  38745. } else if (errors.isCollection) {
  38746. errors.add(result);
  38747. } else {
  38748. errors.push(result);
  38749. }
  38750. ret = ret || result;
  38751. } else if (separator) {
  38752. if (ret) {
  38753. ret += separator;
  38754. }
  38755. ret += result;
  38756. } else {
  38757. ret = result;
  38758. break;
  38759. }
  38760. }
  38761. }
  38762. return ret || true;
  38763. },
  38764. doCalculate: function(v, rec) {
  38765. return rec ? this.calculate(rec.data) : v;
  38766. },
  38767. getName: function() {
  38768. return this.name;
  38769. },
  38770. getAllowBlank: function() {
  38771. return this.allowBlank;
  38772. },
  38773. getAllowNull: function() {
  38774. return this.allowNull;
  38775. },
  38776. getConvert: function() {
  38777. return this.convert;
  38778. },
  38779. getDefaultValue: function() {
  38780. return this.defaultValue;
  38781. },
  38782. getDepends: function() {
  38783. return this.depends;
  38784. },
  38785. getMapping: function() {
  38786. return this.mapping;
  38787. },
  38788. hasMapping: function() {
  38789. var map = this.mapping;
  38790. return !!(map || map === 0);
  38791. },
  38792. getPersist: function() {
  38793. return this.persist;
  38794. },
  38795. getSortType: function() {
  38796. return this.sortType;
  38797. },
  38798. getSummary: function() {
  38799. var me = this,
  38800. doneSummary = me.doneSummary,
  38801. summary = me.summary;
  38802. if (!doneSummary) {
  38803. me.doneSummary = true;
  38804. if (summary) {
  38805. me.summary = summary = Ext.Factory.dataSummary(summary);
  38806. }
  38807. }
  38808. return summary || null;
  38809. },
  38810. getType: function() {
  38811. return 'auto';
  38812. },
  38813. privates: {
  38814. getValidators: function() {
  38815. var me = this,
  38816. validators = me._validators;
  38817. if (!validators) {
  38818. me._validators = validators = [];
  38819. me.constructValidators(me.validators);
  38820. me.constructValidators(me.modelValidators);
  38821. me.constructValidators(me.instanceValidators);
  38822. }
  38823. return validators;
  38824. }
  38825. },
  38826. deprecated: {
  38827. 5.1: {
  38828. methods: {
  38829. getSortDir: function() {
  38830. return this.sortDir;
  38831. }
  38832. }
  38833. }
  38834. }
  38835. });
  38836. Ext.define('Ext.data.field.Boolean', {
  38837. extend: Ext.data.field.Field,
  38838. alias: [
  38839. 'data.field.bool',
  38840. 'data.field.boolean'
  38841. ],
  38842. isBooleanField: true,
  38843. trueRe: /^\s*(?:true|yes|on|1)\s*$/i,
  38844. convert: function(v) {
  38845. if (typeof v === 'boolean') {
  38846. return v;
  38847. }
  38848. if (this.allowNull && (v === undefined || v === null || v === '')) {
  38849. return null;
  38850. }
  38851. return this.trueRe.test(String(v));
  38852. },
  38853. getType: function() {
  38854. return 'bool';
  38855. }
  38856. });
  38857. Ext.define('Ext.data.field.Date', {
  38858. extend: Ext.data.field.Field,
  38859. alias: 'data.field.date',
  38860. sortType: 'asDate',
  38861. isDateField: true,
  38862. dateFormat: null,
  38863. dateReadFormat: null,
  38864. dateWriteFormat: null,
  38865. compare: function(lhs, rhs) {
  38866. var lhsIsDate = lhs instanceof Date,
  38867. rhsIsDate = rhs instanceof Date,
  38868. result;
  38869. if (rhsIsDate && lhsIsDate) {
  38870. result = lhs.getTime() - rhs.getTime();
  38871. if (result === 0) {
  38872. result = 0;
  38873. } else {
  38874. result = result < 0 ? -1 : 1;
  38875. }
  38876. } else if (lhsIsDate === rhsIsDate) {
  38877. result = 0;
  38878. } else {
  38879. result = lhsIsDate ? 1 : -1;
  38880. }
  38881. return result;
  38882. },
  38883. convert: function(v) {
  38884. if (!v) {
  38885. return null;
  38886. }
  38887. if (v instanceof Date) {
  38888. return v;
  38889. }
  38890. var dateFormat = this.dateReadFormat || this.dateFormat,
  38891. parsed;
  38892. if (dateFormat) {
  38893. return Ext.Date.parse(v, dateFormat, this.useStrict);
  38894. }
  38895. parsed = Date.parse(v);
  38896. return parsed ? new Date(parsed) : null;
  38897. },
  38898. serialize: function(value) {
  38899. var result = null,
  38900. format;
  38901. if (Ext.isDate(value)) {
  38902. format = this.getDateWriteFormat();
  38903. result = format ? Ext.Date.format(value, format) : value;
  38904. }
  38905. return result;
  38906. },
  38907. getDateFormat: function() {
  38908. return this.dateFormat;
  38909. },
  38910. getDateReadFormat: function() {
  38911. return this.dateReadFormat;
  38912. },
  38913. getDateWriteFormat: function() {
  38914. var me = this;
  38915. if (me.hasOwnProperty('dateWriteFormat')) {
  38916. return me.dateWriteFormat;
  38917. }
  38918. if (me.hasOwnProperty('dateFormat')) {
  38919. return me.dateFormat;
  38920. }
  38921. return me.dateWriteFormat || me.dateFormat || 'timestamp';
  38922. },
  38923. getType: function() {
  38924. return 'date';
  38925. }
  38926. });
  38927. Ext.define('Ext.data.field.Integer', {
  38928. extend: Ext.data.field.Field,
  38929. alias: [
  38930. 'data.field.int',
  38931. 'data.field.integer'
  38932. ],
  38933. isNumeric: true,
  38934. isIntegerField: true,
  38935. numericType: 'int',
  38936. convert: function(v) {
  38937. if (typeof v === 'number') {
  38938. return this.getNumber(v);
  38939. }
  38940. var empty = v == null || v === '',
  38941. allowNull = this.allowNull,
  38942. out;
  38943. if (empty) {
  38944. out = allowNull ? null : 0;
  38945. } else {
  38946. out = this.parse(v);
  38947. if (allowNull && isNaN(out)) {
  38948. out = null;
  38949. }
  38950. }
  38951. return out;
  38952. },
  38953. getNumber: function(v) {
  38954. return parseInt(v, 10);
  38955. },
  38956. getType: function() {
  38957. return this.numericType;
  38958. },
  38959. parse: function(v) {
  38960. return parseInt(String(v).replace(this.stripRe, ''), 10);
  38961. },
  38962. sortType: function(s) {
  38963. if (s == null) {
  38964. s = Infinity;
  38965. }
  38966. return s;
  38967. }
  38968. });
  38969. Ext.define('Ext.data.field.Number', {
  38970. extend: Ext.data.field.Integer,
  38971. alias: [
  38972. 'data.field.float',
  38973. 'data.field.number'
  38974. ],
  38975. isIntegerField: false,
  38976. isNumberField: true,
  38977. numericType: 'float',
  38978. getNumber: Ext.identityFn,
  38979. parse: function(v) {
  38980. return parseFloat(String(v).replace(this.stripRe, ''));
  38981. }
  38982. });
  38983. Ext.define('Ext.data.field.String', {
  38984. extend: Ext.data.field.Field,
  38985. alias: 'data.field.string',
  38986. sortType: 'asUCString',
  38987. isStringField: true,
  38988. convert: function(v) {
  38989. var defaultValue = this.allowNull ? null : '';
  38990. return (v === undefined || v === null) ? defaultValue : String(v);
  38991. },
  38992. getType: function() {
  38993. return 'string';
  38994. }
  38995. });
  38996. Ext.define('Ext.data.identifier.Generator', {
  38997. 'abstract': true,
  38998. mixins: [
  38999. Ext.mixin.Factoryable
  39000. ],
  39001. alias: 'data.identifier.default',
  39002. factoryConfig: {
  39003. defaultType: 'sequential'
  39004. },
  39005. isGenerator: true,
  39006. config: {
  39007. id: null
  39008. },
  39009. constructor: function(config) {
  39010. var me = this,
  39011. id;
  39012. me.initConfig(config);
  39013. id = me.getId();
  39014. if (id) {
  39015. Ext.data.identifier.Generator.all[id] = me;
  39016. }
  39017. },
  39018. privates: {
  39019. clone: function(config) {
  39020. var cfg = this.getInitialConfig();
  39021. cfg = config ? Ext.apply({}, config, cfg) : cfg;
  39022. return new this.self(cfg);
  39023. },
  39024. statics: {
  39025. all: {}
  39026. }
  39027. }
  39028. }, function() {
  39029. var Generator = this,
  39030. Factory = Ext.Factory,
  39031. factory = Factory.dataIdentifier;
  39032. Factory.dataIdentifier = function(config) {
  39033. var id = Ext.isString(config) ? config : (config && config.id),
  39034. existing = id && Generator.all[id];
  39035. return existing || factory(config);
  39036. };
  39037. });
  39038. Ext.define('Ext.data.identifier.Sequential', {
  39039. extend: Ext.data.identifier.Generator,
  39040. alias: 'data.identifier.sequential',
  39041. config: {
  39042. increment: 1,
  39043. prefix: null,
  39044. seed: 1
  39045. },
  39046. generate: function() {
  39047. var me = this,
  39048. seed = me._seed,
  39049. prefix = me._prefix;
  39050. me._seed += me._increment;
  39051. return (prefix !== null) ? prefix + seed : seed;
  39052. }
  39053. });
  39054. Ext.define('Ext.data.Model', {
  39055. alternateClassName: 'Ext.data.Record',
  39056. isEntity: true,
  39057. isModel: true,
  39058. validIdRe: null,
  39059. erasing: false,
  39060. loadOperation: null,
  39061. loadCount: 0,
  39062. observableType: 'record',
  39063. crudState: 'R',
  39064. crudStateWas: null,
  39065. constructor: function(data, session) {
  39066. var me = this,
  39067. cls = me.self,
  39068. identifier = cls.identifier,
  39069. Model = Ext.data.Model,
  39070. modelIdentifier = Model.identifier,
  39071. idProperty = me.idField.name,
  39072. array, id, initializeFn, internalId, len, i, fields;
  39073. me.data = me.data = data || (data = {});
  39074. me.internalId = internalId = modelIdentifier.generate();
  39075. var dataId = data[idProperty];
  39076. if (session && !session.isSession) {
  39077. Ext.raise('Bad Model constructor argument 2 - "session" is not a Session');
  39078. }
  39079. if ((array = data) instanceof Array) {
  39080. me.data = data = {};
  39081. fields = me.getFields();
  39082. len = Math.min(fields.length, array.length);
  39083. for (i = 0; i < len; ++i) {
  39084. data[fields[i].name] = array[i];
  39085. }
  39086. }
  39087. if (!(initializeFn = cls.initializeFn)) {
  39088. cls.initializeFn = initializeFn = Model.makeInitializeFn(cls);
  39089. }
  39090. if (!initializeFn.$nullFn) {
  39091. cls.initializeFn(me);
  39092. }
  39093. if (!me.isSummaryModel) {
  39094. if (!(me.id = id = data[idProperty]) && id !== 0) {
  39095. if (dataId) {
  39096. Ext.raise('The model ID configured in data ("' + dataId + '") has been rejected by the ' + me.fieldsMap[idProperty].type + ' field converter for the ' + idProperty + ' field');
  39097. }
  39098. if (session) {
  39099. identifier = session.getIdentifier(cls);
  39100. id = identifier.generate();
  39101. } else if (modelIdentifier === identifier) {
  39102. id = internalId;
  39103. } else {
  39104. id = identifier.generate();
  39105. }
  39106. data[idProperty] = me.id = id;
  39107. me.phantom = true;
  39108. me.crudState = 'C';
  39109. }
  39110. if (session) {
  39111. session.add(me);
  39112. }
  39113. if (me.phantom) {
  39114. me.crudStateWas = 'C';
  39115. }
  39116. }
  39117. if (me.init && Ext.isFunction(me.init)) {
  39118. me.init();
  39119. }
  39120. },
  39121. editing: false,
  39122. dirty: false,
  39123. session: null,
  39124. dropped: false,
  39125. erased: false,
  39126. clientIdProperty: null,
  39127. evented: false,
  39128. phantom: false,
  39129. idProperty: 'id',
  39130. manyToMany: null,
  39131. identifier: null,
  39132. previousValues: undefined,
  39133. proxy: undefined,
  39134. schema: 'default',
  39135. summary: null,
  39136. versionProperty: null,
  39137. generation: 1,
  39138. validationSeparator: null,
  39139. convertOnSet: true,
  39140. beginEdit: function() {
  39141. var me = this,
  39142. modified = me.modified,
  39143. previousValues = me.previousValues;
  39144. if (!me.editing) {
  39145. me.editing = true;
  39146. me.editMemento = {
  39147. dirty: me.dirty,
  39148. data: Ext.apply({}, me.data),
  39149. generation: me.generation,
  39150. modified: modified && Ext.apply({}, modified),
  39151. previousValues: previousValues && Ext.apply({}, previousValues)
  39152. };
  39153. }
  39154. },
  39155. calculateSummary: function(records) {
  39156. var fields = this.getFields(),
  39157. len = fields.length,
  39158. recLen = records.length,
  39159. i, result, summary, prop, name, field;
  39160. for (i = 0; i < len; ++i) {
  39161. field = fields[i];
  39162. summary = field.getSummary();
  39163. if (summary) {
  39164. result = result || {};
  39165. name = field.name;
  39166. prop = field.summaryField || name;
  39167. result[name] = summary.calculate(records, prop, 'data', 0, recLen);
  39168. }
  39169. }
  39170. if (result) {
  39171. this.set(result, this._commitOptions);
  39172. }
  39173. },
  39174. cancelEdit: function() {
  39175. var me = this,
  39176. editMemento = me.editMemento,
  39177. validation = me.validation;
  39178. if (editMemento) {
  39179. me.editing = false;
  39180. Ext.apply(me, editMemento);
  39181. me.editMemento = null;
  39182. if (validation && validation.syncGeneration !== me.generation) {
  39183. validation.syncGeneration = 0;
  39184. }
  39185. }
  39186. },
  39187. endEdit: function(silent, modifiedFieldNames) {
  39188. var me = this,
  39189. editMemento = me.editMemento;
  39190. if (editMemento) {
  39191. me.editing = false;
  39192. me.editMemento = null;
  39193. me.previousValues = editMemento.previousValues;
  39194. if (!silent) {
  39195. if (!modifiedFieldNames) {
  39196. modifiedFieldNames = me.getModifiedFieldNames(editMemento.data);
  39197. }
  39198. if (me.dirty || (modifiedFieldNames && modifiedFieldNames.length)) {
  39199. me.callJoined('afterEdit', [
  39200. modifiedFieldNames
  39201. ]);
  39202. }
  39203. }
  39204. }
  39205. },
  39206. getField: function(name) {
  39207. return this.self.getField(name);
  39208. },
  39209. getFields: function() {
  39210. return this.self.getFields();
  39211. },
  39212. getFieldsMap: function() {
  39213. return this.fieldsMap;
  39214. },
  39215. getIdProperty: function() {
  39216. return this.idProperty;
  39217. },
  39218. getId: function() {
  39219. return this.id;
  39220. },
  39221. getObservableId: function() {
  39222. return this.internalId;
  39223. },
  39224. setId: function(id, options) {
  39225. this.set(this.idProperty, id, options);
  39226. },
  39227. getPrevious: function(fieldName) {
  39228. var previousValues = this.previousValues;
  39229. return previousValues && previousValues[fieldName];
  39230. },
  39231. isModified: function(fieldName) {
  39232. var modified = this.modified;
  39233. return !!(modified && modified.hasOwnProperty(fieldName));
  39234. },
  39235. getModified: function(fieldName) {
  39236. var out;
  39237. if (this.isModified(fieldName)) {
  39238. out = this.modified[fieldName];
  39239. }
  39240. return out;
  39241. },
  39242. get: function(fieldName) {
  39243. return this.data[fieldName];
  39244. },
  39245. _singleProp: {},
  39246. _rejectOptions: {
  39247. convert: false,
  39248. silent: true
  39249. },
  39250. set: function(fieldName, newValue, options) {
  39251. var me = this,
  39252. cls = me.self,
  39253. data = me.data,
  39254. modified = me.modified,
  39255. prevVals = me.previousValues,
  39256. session = me.session,
  39257. single = Ext.isString(fieldName),
  39258. opt = (single ? options : newValue),
  39259. convertOnSet = opt ? opt.convert !== false : me.convertOnSet,
  39260. fieldsMap = me.fieldsMap,
  39261. silent = opt && opt.silent,
  39262. commit = opt && opt.commit,
  39263. updateRefs = !(opt && opt.refs === false) && session,
  39264. dirty = !(opt && opt.dirty === false && !commit),
  39265. modifiedFieldNames = null,
  39266. dirtyRank = 0,
  39267. associations = me.associations,
  39268. currentValue, field, idChanged, key, name, oldId, comparator, dep, dependents, i, numFields, newId, rankedFields, reference, value, values, roleName;
  39269. if (single) {
  39270. values = me._singleProp;
  39271. values[fieldName] = newValue;
  39272. } else {
  39273. values = fieldName;
  39274. }
  39275. if (!(rankedFields = cls.rankedFields)) {
  39276. rankedFields = cls.rankFields();
  39277. }
  39278. numFields = rankedFields.length;
  39279. do {
  39280. for (name in values) {
  39281. value = values[name];
  39282. currentValue = data[name];
  39283. comparator = me;
  39284. field = fieldsMap[name];
  39285. if (field) {
  39286. if (convertOnSet && field.convert) {
  39287. value = field.convert(value, me);
  39288. }
  39289. comparator = field;
  39290. reference = field.reference;
  39291. } else {
  39292. reference = null;
  39293. }
  39294. if (comparator.isEqual(currentValue, value)) {
  39295. continue;
  39296. }
  39297. data[name] = value;
  39298. (modifiedFieldNames || (modifiedFieldNames = [])).push(name);
  39299. (prevVals || (me.previousValues = prevVals = {}))[name] = currentValue;
  39300. if (reference && reference.cls) {
  39301. if (updateRefs) {
  39302. session.updateReference(me, field, value, currentValue);
  39303. }
  39304. reference.onValueChange(me, session, value, currentValue);
  39305. }
  39306. i = (dependents = field && field.dependents) && dependents.length;
  39307. while (i-- > 0) {
  39308. (dep = dependents[i]).dirty = true;
  39309. dirtyRank = dirtyRank ? Math.min(dirtyRank, dep.rank) : dep.rank;
  39310. }
  39311. if (!field || field.persist) {
  39312. if (modified && modified.hasOwnProperty(name)) {
  39313. if (!dirty || comparator.isEqual(modified[name], value)) {
  39314. delete modified[name];
  39315. me.dirty = -1;
  39316. }
  39317. } else if (dirty) {
  39318. if (!modified) {
  39319. me.modified = modified = {};
  39320. }
  39321. me.dirty = true;
  39322. modified[name] = currentValue;
  39323. }
  39324. }
  39325. if (name === me.idField.name) {
  39326. idChanged = true;
  39327. oldId = currentValue;
  39328. newId = value;
  39329. }
  39330. }
  39331. if (!dirtyRank) {
  39332. break;
  39333. }
  39334. field = rankedFields[dirtyRank - 1];
  39335. field.dirty = false;
  39336. if (single) {
  39337. delete values[fieldName];
  39338. } else {
  39339. values = me._singleProp;
  39340. single = true;
  39341. }
  39342. fieldName = field.name;
  39343. values[fieldName] = data[fieldName];
  39344. convertOnSet = true;
  39345. for (; dirtyRank < numFields; ++dirtyRank) {
  39346. if (rankedFields[dirtyRank].dirty) {
  39347. break;
  39348. }
  39349. }
  39350. if (dirtyRank < numFields) {
  39351. ++dirtyRank;
  39352. } else {
  39353. dirtyRank = 0;
  39354. }
  39355. } while (
  39356. 1);
  39357. if (me.dirty < 0) {
  39358. me.dirty = false;
  39359. for (key in modified) {
  39360. if (modified.hasOwnProperty(key)) {
  39361. me.dirty = true;
  39362. break;
  39363. }
  39364. }
  39365. }
  39366. if (single) {
  39367. delete values[fieldName];
  39368. }
  39369. ++me.generation;
  39370. if (idChanged) {
  39371. me.id = newId;
  39372. me.onIdChanged(newId, oldId);
  39373. me.callJoined('onIdChanged', [
  39374. oldId,
  39375. newId
  39376. ]);
  39377. if (associations) {
  39378. for (roleName in associations) {
  39379. associations[roleName].onIdChanged(me, oldId, newId);
  39380. }
  39381. }
  39382. }
  39383. if (commit) {
  39384. me.commit(silent, modifiedFieldNames);
  39385. } else if (!silent && !me.editing && modifiedFieldNames) {
  39386. me.callJoined('afterEdit', [
  39387. modifiedFieldNames
  39388. ]);
  39389. }
  39390. return modifiedFieldNames;
  39391. },
  39392. reject: function(silent) {
  39393. var me = this,
  39394. modified = me.modified;
  39395. if (me.erased) {
  39396. Ext.raise('Cannot reject once a record has been erased.');
  39397. }
  39398. if (modified) {
  39399. me.set(modified, me._rejectOptions);
  39400. }
  39401. me.dropped = false;
  39402. me.clearState();
  39403. if (!silent) {
  39404. me.callJoined('afterReject');
  39405. }
  39406. },
  39407. commit: function(silent, modifiedFieldNames) {
  39408. var me = this,
  39409. versionProperty = me.versionProperty,
  39410. data = me.data,
  39411. erased;
  39412. me.clearState();
  39413. if (versionProperty && !me.phantom && !isNaN(data[versionProperty])) {
  39414. ++data[versionProperty];
  39415. }
  39416. me.phantom = false;
  39417. if (me.dropped) {
  39418. me.erased = erased = true;
  39419. }
  39420. if (!silent) {
  39421. if (erased) {
  39422. me.callJoined('afterErase');
  39423. } else {
  39424. me.callJoined('afterCommit', [
  39425. modifiedFieldNames
  39426. ]);
  39427. }
  39428. }
  39429. },
  39430. clearState: function() {
  39431. var me = this;
  39432. me.dirty = me.editing = false;
  39433. me.editMemento = me.modified = null;
  39434. },
  39435. drop: function(cascade) {
  39436. var me = this,
  39437. associations = me.associations,
  39438. session = me.session,
  39439. roleName;
  39440. if (me.erased || me.dropped) {
  39441. return;
  39442. }
  39443. me.dropped = true;
  39444. if (associations && cascade !== false) {
  39445. for (roleName in associations) {
  39446. associations[roleName].onDrop(me, session);
  39447. }
  39448. }
  39449. me.callJoined('afterDrop');
  39450. if (me.phantom) {
  39451. me.setErased();
  39452. }
  39453. },
  39454. join: function(owner) {
  39455. var me = this,
  39456. joined = me.joined;
  39457. if (!joined) {
  39458. joined = me.joined = [
  39459. owner
  39460. ];
  39461. } else if (!joined.length) {
  39462. joined[0] = owner;
  39463. } else {
  39464. Ext.Array.include(joined, owner);
  39465. }
  39466. if (owner.isStore && !me.store) {
  39467. me.store = owner;
  39468. }
  39469. },
  39470. unjoin: function(owner) {
  39471. var me = this,
  39472. joined = me.joined,
  39473. len = joined && joined.length,
  39474. store = me.store,
  39475. i;
  39476. if (owner === me.session) {
  39477. me.session = null;
  39478. } else {
  39479. if (len === 1 && joined[0] === owner) {
  39480. joined.length = 0;
  39481. } else if (len) {
  39482. Ext.Array.remove(joined, owner);
  39483. }
  39484. if (store === owner) {
  39485. store = null;
  39486. if (joined) {
  39487. for (i = 0 , len = joined.length; i < len; ++i) {
  39488. owner = joined[i];
  39489. if (owner.isStore) {
  39490. store = owner;
  39491. break;
  39492. }
  39493. }
  39494. }
  39495. me.store = store;
  39496. }
  39497. }
  39498. },
  39499. clone: function(session) {
  39500. var me = this,
  39501. modified = me.modified,
  39502. ret = me.copy(me.id, session);
  39503. if (modified) {
  39504. ret.modified = Ext.apply({}, modified);
  39505. }
  39506. ret.dirty = me.dirty;
  39507. ret.dropped = me.dropped;
  39508. ret.phantom = me.phantom;
  39509. return ret;
  39510. },
  39511. copy: function(newId, session) {
  39512. var me = this,
  39513. data = Ext.apply({}, me.data),
  39514. idProperty = me.idProperty,
  39515. T = me.self;
  39516. if (newId || newId === 0) {
  39517. data[idProperty] = newId;
  39518. } else if (newId === null) {
  39519. delete data[idProperty];
  39520. }
  39521. return new T(data, session);
  39522. },
  39523. getProxy: function() {
  39524. return this.self.getProxy();
  39525. },
  39526. getValidation: function(refresh) {
  39527. var me = this,
  39528. ret = me.validation;
  39529. if (!ret) {
  39530. me.validation = ret = new Ext.data.Validation();
  39531. ret.attach(me);
  39532. }
  39533. if (refresh === true || (refresh !== false && ret.syncGeneration !== me.generation)) {
  39534. ret.refresh(refresh);
  39535. }
  39536. return ret;
  39537. },
  39538. validate: function() {
  39539. return new Ext.data.ErrorCollection().init(this);
  39540. },
  39541. isValid: function() {
  39542. return this.getValidation().isValid();
  39543. },
  39544. toUrl: function() {
  39545. var pieces = this.$className.split('.'),
  39546. name = pieces[pieces.length - 1].toLowerCase();
  39547. return name + '/' + this.getId();
  39548. },
  39549. erase: function(options) {
  39550. var me = this;
  39551. me.erasing = true;
  39552. me.drop();
  39553. me.erasing = false;
  39554. return me.save(options);
  39555. },
  39556. setErased: function() {
  39557. this.erased = true;
  39558. this.callJoined('afterErase');
  39559. },
  39560. getChanges: function() {
  39561. return this.getData(this._getChangesOptions);
  39562. },
  39563. getCriticalFields: function() {
  39564. var cls = this.self,
  39565. ret = cls.criticalFields;
  39566. if (!ret) {
  39567. cls.rankFields();
  39568. ret = cls.criticalFields;
  39569. }
  39570. return ret;
  39571. },
  39572. getAssociatedData: function(result, options) {
  39573. var me = this,
  39574. associations = me.associations,
  39575. deep, i, item, items, itemData, length, record, role, roleName, opts, clear, associated;
  39576. result = result || {};
  39577. me.$gathering = 1;
  39578. if (options) {
  39579. options = Ext.apply({}, options);
  39580. }
  39581. for (roleName in associations) {
  39582. role = associations[roleName];
  39583. item = role.getAssociatedItem(me);
  39584. if (!item || item.$gathering) {
  39585. continue;
  39586. }
  39587. if (item.isStore) {
  39588. item.$gathering = 1;
  39589. items = item.getData().items;
  39590. length = items.length;
  39591. itemData = [];
  39592. for (i = 0; i < length; ++i) {
  39593. record = items[i];
  39594. deep = !record.$gathering;
  39595. record.$gathering = 1;
  39596. if (options) {
  39597. associated = options.associated;
  39598. if (associated === undefined) {
  39599. options.associated = deep;
  39600. clear = true;
  39601. } else if (!deep) {
  39602. options.associated = false;
  39603. clear = true;
  39604. }
  39605. opts = options;
  39606. } else {
  39607. opts = deep ? me._getAssociatedOptions : me._getNotAssociatedOptions;
  39608. }
  39609. itemData.push(record.getData(opts));
  39610. if (clear) {
  39611. options.associated = associated;
  39612. clear = false;
  39613. }
  39614. delete record.$gathering;
  39615. }
  39616. delete item.$gathering;
  39617. } else {
  39618. opts = options || me._getAssociatedOptions;
  39619. if (options && options.associated === undefined) {
  39620. opts.associated = true;
  39621. }
  39622. itemData = item.getData(opts);
  39623. }
  39624. result[roleName] = itemData;
  39625. }
  39626. delete me.$gathering;
  39627. return result;
  39628. },
  39629. getData: function(options) {
  39630. var me = this,
  39631. ret = {},
  39632. opts = (options === true) ? me._getAssociatedOptions : (options || ret),
  39633. data = me.data,
  39634. associated = opts.associated,
  39635. changes = opts.changes,
  39636. critical = changes && opts.critical,
  39637. content = changes ? me.modified : data,
  39638. fieldsMap = me.fieldsMap,
  39639. persist = opts.persist,
  39640. serialize = opts.serialize,
  39641. criticalFields, field, n, name, value;
  39642. if (content) {
  39643. for (name in content) {
  39644. value = data[name];
  39645. field = fieldsMap[name];
  39646. if (field) {
  39647. if (persist && !field.persist) {
  39648. continue;
  39649. }
  39650. if (serialize && field.serialize) {
  39651. value = field.serialize(value, me);
  39652. }
  39653. }
  39654. ret[name] = value;
  39655. }
  39656. }
  39657. if (critical) {
  39658. criticalFields = me.self.criticalFields || me.getCriticalFields();
  39659. for (n = criticalFields.length; n-- > 0; ) {
  39660. name = (field = criticalFields[n]).name;
  39661. if (!(name in ret)) {
  39662. value = data[name];
  39663. if (serialize && field.serialize) {
  39664. value = field.serialize(value, me);
  39665. }
  39666. ret[name] = value;
  39667. }
  39668. }
  39669. }
  39670. if (associated) {
  39671. if (typeof associated === 'object') {
  39672. me.getNestedData(opts, ret);
  39673. } else {
  39674. me.getAssociatedData(ret, opts);
  39675. }
  39676. }
  39677. return ret;
  39678. },
  39679. getNestedData: function(options, result) {
  39680. var me = this,
  39681. associations = me.associations,
  39682. graph = options.associated,
  39683. i, item, items, itemData, length, record, role, roleName, opts;
  39684. result = result || {};
  39685. for (roleName in graph) {
  39686. role = associations[roleName];
  39687. opts = graph[roleName];
  39688. if (opts === true) {
  39689. delete options.associated;
  39690. } else {
  39691. options.associated = opts;
  39692. }
  39693. item = role.getAssociatedItem(me);
  39694. if (item.isStore) {
  39695. items = item.getData().items;
  39696. length = items.length;
  39697. itemData = [];
  39698. for (i = 0; i < length; ++i) {
  39699. record = items[i];
  39700. itemData.push(record.getData(options));
  39701. }
  39702. } else {
  39703. itemData = item.getData(options);
  39704. }
  39705. result[roleName] = itemData;
  39706. }
  39707. options.associated = graph;
  39708. return result;
  39709. },
  39710. getTransientFields: function() {
  39711. var cls = this.self,
  39712. ret = cls.transientFields;
  39713. if (!ret) {
  39714. cls.rankFields();
  39715. ret = cls.transientFields;
  39716. }
  39717. return ret;
  39718. },
  39719. isLoading: function() {
  39720. return !!this.loadOperation;
  39721. },
  39722. abort: function() {
  39723. var operation = this.loadOperation;
  39724. if (operation) {
  39725. operation.abort();
  39726. }
  39727. },
  39728. load: function(options) {
  39729. options = Ext.apply({}, options);
  39730. var me = this,
  39731. scope = options.scope || me,
  39732. proxy = me.getProxy(),
  39733. callback = options.callback,
  39734. operation = me.loadOperation,
  39735. id = me.getId(),
  39736. extras;
  39737. if (operation) {
  39738. extras = operation.extraCalls;
  39739. if (!extras) {
  39740. extras = operation.extraCalls = [];
  39741. }
  39742. extras.push(options);
  39743. return operation;
  39744. }
  39745. var doIdCheck = true;
  39746. if (me.phantom) {
  39747. doIdCheck = false;
  39748. }
  39749. options.id = id;
  39750. options.recordCreator = function(data, type, readOptions) {
  39751. var session = me.session;
  39752. if (readOptions) {
  39753. readOptions.recordCreator = session ? session.recordCreator : null;
  39754. }
  39755. me.set(data, me._commitOptions);
  39756. if (doIdCheck && me.getId() !== id) {
  39757. Ext.raise('Invalid record id returned for ' + id + '@' + me.entityName);
  39758. }
  39759. return me;
  39760. };
  39761. options.internalCallback = function(operation) {
  39762. var success = operation.wasSuccessful() && operation.getRecords().length > 0,
  39763. op = me.loadOperation,
  39764. extras = op.extraCalls,
  39765. successFailArgs = [
  39766. me,
  39767. operation
  39768. ],
  39769. callbackArgs = [
  39770. me,
  39771. operation,
  39772. success
  39773. ],
  39774. i, len;
  39775. me.loadOperation = null;
  39776. ++me.loadCount;
  39777. if (success) {
  39778. Ext.callback(options.success, scope, successFailArgs);
  39779. } else {
  39780. Ext.callback(options.failure, scope, successFailArgs);
  39781. }
  39782. Ext.callback(callback, scope, callbackArgs);
  39783. if (extras) {
  39784. for (i = 0 , len = extras.length; i < len; ++i) {
  39785. options = extras[i];
  39786. if (success) {
  39787. Ext.callback(options.success, scope, successFailArgs);
  39788. } else {
  39789. Ext.callback(options.failure, scope, successFailArgs);
  39790. }
  39791. Ext.callback(options.callback, scope, callbackArgs);
  39792. }
  39793. }
  39794. me.callJoined('afterLoad');
  39795. };
  39796. delete options.callback;
  39797. me.loadOperation = operation = proxy.createOperation('read', options);
  39798. operation.execute();
  39799. return operation;
  39800. },
  39801. mergeData: function(data) {
  39802. if (!this.dirty) {
  39803. this.set(data, this._commitOptions);
  39804. }
  39805. },
  39806. save: function(options) {
  39807. options = Ext.apply({}, options);
  39808. var me = this,
  39809. phantom = me.phantom,
  39810. dropped = me.dropped,
  39811. action = dropped ? 'destroy' : (phantom ? 'create' : 'update'),
  39812. scope = options.scope || me,
  39813. callback = options.callback,
  39814. proxy = me.getProxy(),
  39815. operation;
  39816. options.records = [
  39817. me
  39818. ];
  39819. options.internalCallback = function(operation) {
  39820. var args = [
  39821. me,
  39822. operation
  39823. ],
  39824. success = operation.wasSuccessful();
  39825. if (success) {
  39826. Ext.callback(options.success, scope, args);
  39827. } else {
  39828. Ext.callback(options.failure, scope, args);
  39829. }
  39830. args.push(success);
  39831. Ext.callback(callback, scope, args);
  39832. };
  39833. delete options.callback;
  39834. operation = proxy.createOperation(action, options);
  39835. if (dropped && phantom) {
  39836. operation.setResultSet(Ext.data.reader.Reader.prototype.nullResultSet);
  39837. me.setErased();
  39838. operation.setSuccessful(true);
  39839. } else {
  39840. operation.execute();
  39841. }
  39842. return operation;
  39843. },
  39844. statics: {
  39845. defaultProxy: 'memory'
  39846. },
  39847. inheritableStatics: {
  39848. _associatedReadOptions: {
  39849. recordsOnly: true,
  39850. asRoot: true
  39851. },
  39852. loadData: function(data, session) {
  39853. var rec;
  39854. if (data) {
  39855. rec = this.getProxy().getReader().readRecords([
  39856. data
  39857. ], session ? {
  39858. recordCreator: session.recordCreator
  39859. } : undefined, this._associatedReadOptions)[0];
  39860. } else {
  39861. rec = new this(data, session);
  39862. }
  39863. return rec;
  39864. },
  39865. getSummaryModel: function() {
  39866. var me = this,
  39867. proto = me.prototype,
  39868. summaryModel = me.summaryModel;
  39869. if (!summaryModel) {
  39870. summaryModel = Ext.define(null, {
  39871. extend: me,
  39872. fields: proto.summaryFields || [],
  39873. isSummaryModel: true
  39874. });
  39875. summaryModel.isSummaryModel = true;
  39876. me.summaryModel = proto.summaryModel = summaryModel;
  39877. }
  39878. return summaryModel || null;
  39879. },
  39880. addFields: function(newFields) {
  39881. this.replaceFields(newFields);
  39882. },
  39883. replaceFields: function(newFields, removeFields) {
  39884. var me = this,
  39885. proto = me.prototype,
  39886. Field = Ext.data.field.Field,
  39887. fields = me.fields,
  39888. fieldsMap = me.fieldsMap,
  39889. ordinals = me.fieldOrdinals,
  39890. field, i, idField, len, name, ordinal, cleared;
  39891. if (removeFields === true) {
  39892. fields.length = 0;
  39893. me.fieldsMap = fieldsMap = {};
  39894. me.fieldOrdinals = ordinals = {};
  39895. cleared = true;
  39896. } else if (removeFields) {
  39897. for (i = removeFields.length; i-- > 0; ) {
  39898. name = removeFields[i];
  39899. if (name in ordinals) {
  39900. delete ordinals[name];
  39901. delete fieldsMap[name];
  39902. }
  39903. }
  39904. for (i = 0 , len = fields.length; i < len; ++i) {
  39905. name = (field = fields[i]).name;
  39906. if (name in ordinals) {
  39907. ordinals[name] = i;
  39908. } else {
  39909. fields.splice(i, 1);
  39910. --i;
  39911. --len;
  39912. }
  39913. }
  39914. }
  39915. for (i = 0 , len = newFields ? newFields.length : 0; i < len; i++) {
  39916. name = (field = newFields[i]).name;
  39917. if (!(name in ordinals)) {
  39918. ordinals[name] = ordinal = fields.length;
  39919. fields.push(field = Field.create(field));
  39920. fieldsMap[name] = field;
  39921. field.ordinal = ordinal;
  39922. field.definedBy = field.owner = this;
  39923. }
  39924. }
  39925. if (!cleared) {
  39926. for (i = 0 , len = fields.length; i < len; ++i) {
  39927. fields[i].rank = null;
  39928. }
  39929. }
  39930. me.idField = proto.idField = idField = fieldsMap[proto.idProperty];
  39931. if (idField) {
  39932. idField.allowNull = idField.critical = idField.identifier = true;
  39933. idField.defaultValue = null;
  39934. }
  39935. me.initializeFn = me.rankedFields = me.transientFields = me.criticalFields = null;
  39936. },
  39937. removeFields: function(removeFields) {
  39938. this.replaceFields(null, removeFields);
  39939. },
  39940. getIdFromData: function(data) {
  39941. var T = this,
  39942. idField = T.idField,
  39943. id = idField.calculated ? (new T(data)).id : data[idField.name];
  39944. return id;
  39945. },
  39946. createWithId: function(id, data, session) {
  39947. var d = data,
  39948. T = this;
  39949. if (id || id === 0) {
  39950. d = {};
  39951. if (data) {
  39952. Ext.apply(d, data);
  39953. }
  39954. d[T.idField.name] = id;
  39955. }
  39956. return new T(d, session);
  39957. },
  39958. getFields: function() {
  39959. return this.fields;
  39960. },
  39961. getFieldsMap: function() {
  39962. return this.fieldsMap;
  39963. },
  39964. getField: function(name) {
  39965. return this.fieldsMap[name] || null;
  39966. },
  39967. getProxy: function() {
  39968. var me = this,
  39969. proxy = me.proxy,
  39970. defaultProxy = me.defaultProxy,
  39971. defaults;
  39972. if (!proxy) {
  39973. proxy = me.proxyConfig;
  39974. if (!proxy && defaultProxy) {
  39975. proxy = defaultProxy;
  39976. }
  39977. if (!proxy || !proxy.isProxy) {
  39978. if (typeof proxy === 'string') {
  39979. proxy = {
  39980. type: proxy
  39981. };
  39982. }
  39983. defaults = Ext.merge(me.schema.constructProxy(me), proxy);
  39984. if (proxy && proxy.type) {
  39985. proxy = proxy.schema === false ? proxy : defaults;
  39986. } else {
  39987. proxy = defaults;
  39988. }
  39989. }
  39990. proxy = me.setProxy(proxy);
  39991. }
  39992. return proxy;
  39993. },
  39994. setProxy: function(proxy) {
  39995. var me = this,
  39996. model;
  39997. if (proxy) {
  39998. if (!proxy.isProxy) {
  39999. proxy = Ext.Factory.proxy(proxy);
  40000. } else {
  40001. model = proxy.getModel();
  40002. if (model && model !== me) {
  40003. proxy = proxy.clone();
  40004. }
  40005. }
  40006. proxy.setModel(me);
  40007. }
  40008. return (me.prototype.proxy = me.proxy = proxy);
  40009. },
  40010. load: function(id, options, session) {
  40011. var data = {},
  40012. rec;
  40013. if (session) {
  40014. rec = session.peekRecord(this, id);
  40015. }
  40016. if (!rec) {
  40017. data[this.prototype.idProperty] = id;
  40018. rec = new this(data, session);
  40019. }
  40020. rec.load(options);
  40021. return rec;
  40022. }
  40023. },
  40024. deprecated: {
  40025. 5: {
  40026. methods: {
  40027. hasId: null,
  40028. markDirty: null,
  40029. setDirty: null,
  40030. eachStore: function(callback, scope) {
  40031. var me = this,
  40032. stores = me.stores,
  40033. len = stores.length,
  40034. i;
  40035. for (i = 0; i < len; ++i) {
  40036. callback.call(scope, stores[i]);
  40037. }
  40038. },
  40039. join: function(item) {
  40040. var me = this,
  40041. stores = me.stores,
  40042. joined = me.joined;
  40043. if (!joined) {
  40044. joined = me.joined = [
  40045. item
  40046. ];
  40047. } else {
  40048. joined.push(item);
  40049. }
  40050. if (item.isStore) {
  40051. me.store = me.store || item;
  40052. if (!stores) {
  40053. stores = me.stores = [];
  40054. }
  40055. stores.push(item);
  40056. }
  40057. },
  40058. unjoin: function(item) {
  40059. var me = this,
  40060. stores = me.stores,
  40061. joined = me.joined;
  40062. if (joined.length === 1) {
  40063. joined.length = 0;
  40064. } else {
  40065. Ext.Array.remove(joined, item);
  40066. }
  40067. if (item.isStore) {
  40068. Ext.Array.remove(stores, item);
  40069. me.store = stores[0] || null;
  40070. }
  40071. }
  40072. },
  40073. properties: {
  40074. persistenceProperty: null
  40075. },
  40076. inheritableStatics: {
  40077. methods: {
  40078. setFields: null
  40079. }
  40080. }
  40081. }
  40082. },
  40083. privates: {
  40084. _commitOptions: {
  40085. commit: true
  40086. },
  40087. _getChangesOptions: {
  40088. changes: true
  40089. },
  40090. _getAssociatedOptions: {
  40091. associated: true
  40092. },
  40093. _getNotAssociatedOptions: {
  40094. associated: false
  40095. },
  40096. _metaProperties: {
  40097. dirty: 'isDirty',
  40098. phantom: 'isPhantom',
  40099. valid: 'isValid'
  40100. },
  40101. copyFrom: function(sourceRecord) {
  40102. var me = this,
  40103. fields = me.fields,
  40104. fieldCount = fields.length,
  40105. modifiedFieldNames = [],
  40106. field,
  40107. i = 0,
  40108. myData, sourceData,
  40109. idProperty = me.idProperty,
  40110. name, value;
  40111. if (sourceRecord) {
  40112. myData = me.data;
  40113. sourceData = sourceRecord.data;
  40114. for (; i < fieldCount; i++) {
  40115. field = fields[i];
  40116. name = field.name;
  40117. if (name !== idProperty) {
  40118. value = sourceData[name];
  40119. if (value !== undefined && !me.isEqual(myData[name], value)) {
  40120. myData[name] = value;
  40121. modifiedFieldNames.push(name);
  40122. }
  40123. }
  40124. }
  40125. if (me.phantom && !sourceRecord.phantom) {
  40126. me.beginEdit();
  40127. me.setId(sourceRecord.getId());
  40128. me.endEdit(true);
  40129. me.commit(true);
  40130. }
  40131. }
  40132. return modifiedFieldNames;
  40133. },
  40134. callJoined: function(funcName, args) {
  40135. var me = this,
  40136. joined = me.joined,
  40137. session = me.session,
  40138. state = me.dropped ? 'D' : (me.phantom ? 'C' : (me.dirty ? 'U' : 'R')),
  40139. i, len, fn, item;
  40140. me.crudState = state;
  40141. if (joined || session) {
  40142. if (args) {
  40143. args.unshift(me);
  40144. } else {
  40145. args = [
  40146. me
  40147. ];
  40148. }
  40149. fn = session && session[funcName];
  40150. if (fn) {
  40151. fn.apply(session, args);
  40152. }
  40153. if (joined) {
  40154. for (i = 0 , len = joined.length; i < len; ++i) {
  40155. item = joined[i];
  40156. if (item && (fn = item[funcName])) {
  40157. fn.apply(item, args);
  40158. }
  40159. }
  40160. }
  40161. }
  40162. me.crudStateWas = state;
  40163. },
  40164. hasPendingLoad: function() {
  40165. return this.isLoading();
  40166. },
  40167. interpret: function(name) {
  40168. var me = this,
  40169. accessor = me._metaProperties[name];
  40170. if (!accessor) {
  40171. accessor = me.associations;
  40172. accessor = accessor && accessor[name] && accessor[name].getterName;
  40173. }
  40174. if (accessor) {
  40175. return me[accessor]();
  40176. }
  40177. return me.data[name];
  40178. },
  40179. isDirty: function() {
  40180. return this.dirty;
  40181. },
  40182. isPhantom: function() {
  40183. return this.phantom;
  40184. },
  40185. onAssociatedRecordSet: function(record, role) {
  40186. this.callJoined('afterAssociatedRecordSet', [
  40187. record,
  40188. role
  40189. ]);
  40190. },
  40191. onIdChanged: Ext.privateFn,
  40192. setSession: function(session) {
  40193. if (session) {
  40194. if (this.session) {
  40195. Ext.raise('This model already belongs to a session.');
  40196. }
  40197. if (!this.id) {
  40198. Ext.raise('The model must have an id to participate in a session.');
  40199. }
  40200. }
  40201. this.session = session;
  40202. if (session) {
  40203. session.add(this);
  40204. }
  40205. },
  40206. getModifiedFieldNames: function(old) {
  40207. var me = this,
  40208. data = me.data,
  40209. modified = [],
  40210. oldData = old || me.editMemento.data,
  40211. key;
  40212. for (key in data) {
  40213. if (data.hasOwnProperty(key)) {
  40214. if (!me.isEqual(data[key], oldData[key], key)) {
  40215. modified.push(key);
  40216. }
  40217. }
  40218. }
  40219. return modified;
  40220. },
  40221. isEqual: function(lhs, rhs, field) {
  40222. var f;
  40223. if (field) {
  40224. f = field.isField ? field : this.fieldsMap[field];
  40225. if (f) {
  40226. return f.isEqual(lhs, rhs);
  40227. }
  40228. }
  40229. if (lhs instanceof Date && rhs instanceof Date) {
  40230. return lhs.getTime() === rhs.getTime();
  40231. }
  40232. return lhs === rhs;
  40233. },
  40234. statics: {
  40235. EDIT: 'edit',
  40236. REJECT: 'reject',
  40237. COMMIT: 'commit',
  40238. rankFields: function() {
  40239. var cls = this,
  40240. prototype = cls.prototype,
  40241. fields = cls.fields,
  40242. length = fields.length,
  40243. rankedFields = [],
  40244. criticalFields = [],
  40245. transientFields = [],
  40246. evilFields, field, i;
  40247. cls.rankedFields = prototype.rankedFields = rankedFields;
  40248. cls.criticalFields = prototype.criticalFields = criticalFields;
  40249. cls.transientFields = prototype.transientFields = transientFields;
  40250. for (i = 0; i < length; ++i) {
  40251. field = fields[i];
  40252. if (field.critical) {
  40253. criticalFields.push(field);
  40254. }
  40255. if (!field.persist) {
  40256. transientFields.push(field);
  40257. }
  40258. if (field.evil) {
  40259. (evilFields || (evilFields = [])).push(field);
  40260. } else if (!field.depends) {
  40261. rankedFields.push(field);
  40262. field.rank = rankedFields.length;
  40263. }
  40264. }
  40265. for (i = 0; i < length; ++i) {
  40266. if (!(field = fields[i]).rank && !field.evil) {
  40267. cls.topoAdd(field);
  40268. }
  40269. }
  40270. if (evilFields) {
  40271. for (i = 0 , length = evilFields.length; i < length; ++i) {
  40272. rankedFields.push(field = evilFields[i]);
  40273. field.rank = rankedFields.length;
  40274. }
  40275. }
  40276. cls.topoStack = null;
  40277. return rankedFields;
  40278. },
  40279. topoAdd: function(field) {
  40280. var cls = this,
  40281. dep = field.depends,
  40282. dependsLength = dep ? dep.length : 0,
  40283. rankedFields = cls.rankedFields,
  40284. i, targetField;
  40285. var topoStack = cls.topoStack || (cls.topoStack = []);
  40286. topoStack.push(field.name);
  40287. if (field.rank === 0) {
  40288. Ext.raise(cls.$className + " has circular field dependencies: " + topoStack.join(" --> "));
  40289. }
  40290. if (topoStack.length && field.evil) {
  40291. Ext.raise(cls.$className + ": Field " + topoStack[topoStack.length - 1] + " cannot depend on depends-less field " + field.name);
  40292. }
  40293. field.rank = 0;
  40294. for (i = 0; i < dependsLength; ++i) {
  40295. targetField = cls.fieldsMap[dep[i]];
  40296. if (!targetField) {
  40297. Ext.raise(cls.$className + ": Field " + field.name + " depends on undefined field " + dep[i]);
  40298. }
  40299. (targetField.dependents || (targetField.dependents = [])).push(field);
  40300. if (!targetField.rank) {
  40301. cls.topoAdd(targetField);
  40302. }
  40303. }
  40304. rankedFields.push(field);
  40305. field.rank = rankedFields.length;
  40306. topoStack.pop();
  40307. },
  40308. initFields: function(data, cls, proto) {
  40309. var Field = Ext.data.field.Field,
  40310. fieldDefs = data.fields,
  40311. fields = [],
  40312. fieldOrdinals = {},
  40313. fieldsMap = {},
  40314. references = [],
  40315. superFields = proto.fields,
  40316. versionProperty = data.versionProperty || proto.versionProperty,
  40317. idProperty = cls.idProperty,
  40318. idField, field, i, length, name, ordinal, reference, superIdField, superIdFieldName, superIdDeclared, idDeclared;
  40319. cls.fields = proto.fields = fields;
  40320. cls.fieldOrdinals = proto.fieldOrdinals = fieldOrdinals;
  40321. cls.fieldsMap = proto.fieldsMap = fieldsMap;
  40322. cls.references = proto.references = references;
  40323. if (superFields) {
  40324. for (i = 0 , length = superFields.length; i < length; ++i) {
  40325. fields[i] = field = Ext.Object.chain(superFields[i]);
  40326. field.dependents = null;
  40327. field.owner = cls;
  40328. fieldOrdinals[name = field.name] = i;
  40329. fieldsMap[name] = field;
  40330. field.rank = null;
  40331. if (field.generated) {
  40332. superIdField = field;
  40333. superIdFieldName = field.name;
  40334. }
  40335. }
  40336. }
  40337. delete data.fields;
  40338. if (fieldDefs) {
  40339. for (i = 0 , length = fieldDefs.length; i < length; ++i) {
  40340. field = fieldDefs[i];
  40341. reference = field.reference;
  40342. if (reference && typeof reference !== 'string') {
  40343. reference = Ext.merge({}, reference);
  40344. }
  40345. field.$reference = reference;
  40346. field = Field.create(fieldDefs[i]);
  40347. name = field.name;
  40348. ordinal = fieldOrdinals[name];
  40349. if (ordinal === undefined) {
  40350. fieldOrdinals[name] = ordinal = fields.length;
  40351. }
  40352. fieldsMap[name] = field;
  40353. fields[ordinal] = field;
  40354. field.definedBy = field.owner = cls;
  40355. field.ordinal = ordinal;
  40356. if (name === idProperty) {
  40357. idDeclared = field;
  40358. }
  40359. if (name === superIdFieldName) {
  40360. superIdDeclared = true;
  40361. }
  40362. }
  40363. }
  40364. idField = fieldsMap[idProperty];
  40365. if (!idField) {
  40366. if (superIdField && superIdField.generated) {
  40367. ordinal = superIdField.ordinal;
  40368. } else {
  40369. ordinal = fields.length;
  40370. }
  40371. delete fieldsMap[superIdFieldName];
  40372. delete fieldOrdinals[superIdFieldName];
  40373. idField = new Field(idProperty);
  40374. fields[ordinal] = idField;
  40375. fieldOrdinals[idProperty] = ordinal;
  40376. fieldsMap[idProperty] = idField;
  40377. idField.definedBy = cls;
  40378. idField.ordinal = ordinal;
  40379. idField.generated = true;
  40380. } else if (idDeclared && !superIdDeclared && superIdField && superIdField.generated) {
  40381. Ext.Array.remove(fields, superIdField);
  40382. delete fieldsMap[superIdFieldName];
  40383. delete fieldOrdinals[superIdFieldName];
  40384. fieldsMap[idProperty] = idDeclared;
  40385. for (i = 0 , length = fields.length; i < length; ++i) {
  40386. field = fields[i];
  40387. fields.ordinal = i;
  40388. fieldOrdinals[field.name] = i;
  40389. }
  40390. }
  40391. idField.allowNull = idField.critical = idField.identifier = true;
  40392. idField.defaultValue = null;
  40393. cls.idField = proto.idField = idField;
  40394. if (versionProperty) {
  40395. field = fieldsMap[versionProperty];
  40396. if (!field) {
  40397. ordinal = fields.length;
  40398. field = new Field({
  40399. name: versionProperty,
  40400. type: 'int'
  40401. });
  40402. fields[ordinal] = field;
  40403. fieldOrdinals[versionProperty] = ordinal;
  40404. fieldsMap[versionProperty] = field;
  40405. field.definedBy = cls;
  40406. field.ordinal = ordinal;
  40407. field.generated = true;
  40408. }
  40409. field.defaultValue = 1;
  40410. field.critical = true;
  40411. }
  40412. },
  40413. initSummaries: function(data, cls, proto) {
  40414. var summaryDefs = data.summary,
  40415. superSummaries = proto.summaryFields,
  40416. summaries, summaryMap, name, summary, len, i, index, field;
  40417. if (superSummaries) {
  40418. summaries = [];
  40419. summaryMap = {};
  40420. for (i = 0 , len = superSummaries.length; i < len; ++i) {
  40421. summary = superSummaries[i];
  40422. summaries.push(summary);
  40423. summaries[summary.name] = i;
  40424. }
  40425. }
  40426. if (summaryDefs) {
  40427. delete data.summary;
  40428. summaries = summaries || [];
  40429. summaryMap = summaryMap || {};
  40430. for (name in summaryDefs) {
  40431. summary = summaryDefs[name];
  40432. if (typeof summary === 'function') {
  40433. summary = {
  40434. summary: summary
  40435. };
  40436. }
  40437. index = summaryMap[name];
  40438. summary = Ext.apply({
  40439. name: name
  40440. }, summary);
  40441. field = summary.field;
  40442. if (field) {
  40443. delete summary.field;
  40444. summary.summaryField = field;
  40445. }
  40446. if (index === undefined) {
  40447. index = summaries.length;
  40448. summaryMap[name] = summary;
  40449. }
  40450. summaries[index] = summary;
  40451. }
  40452. }
  40453. if (summaries) {
  40454. for (i = 0 , len = summaries.length; i < len; ++i) {
  40455. if (summaries[i].name in proto.fieldsMap) {
  40456. Ext.raise('Cannot redefine field, use the summary property on the field.');
  40457. }
  40458. }
  40459. proto.summaryFields = summaries;
  40460. }
  40461. },
  40462. initValidators: function(data, cls, proto) {
  40463. var superValidators = proto.validators,
  40464. validators, field, copy, validatorDefs, i, length, fieldValidator, name, validator, item;
  40465. if (superValidators) {
  40466. validators = {};
  40467. for (field in superValidators) {
  40468. validators[field] = Ext.Array.clone(superValidators[field]);
  40469. }
  40470. }
  40471. validatorDefs = data.validators || data.validations;
  40472. if (data.validations) {
  40473. delete data.validations;
  40474. Ext.log.warn((cls.$className || 'Ext.data.Model') + ': validations has been deprecated. Please use validators instead.');
  40475. }
  40476. if (validatorDefs) {
  40477. delete data.validators;
  40478. validators = validators || {};
  40479. if (Ext.isArray(validatorDefs)) {
  40480. copy = {};
  40481. for (i = 0 , length = validatorDefs.length; i < length; ++i) {
  40482. item = validatorDefs[i];
  40483. name = item.field;
  40484. if (!copy[name]) {
  40485. copy[name] = [];
  40486. }
  40487. item = item.fn || item;
  40488. copy[name].push(item);
  40489. }
  40490. validatorDefs = copy;
  40491. }
  40492. for (name in validatorDefs) {
  40493. fieldValidator = validatorDefs[name];
  40494. if (!Ext.isArray(fieldValidator)) {
  40495. fieldValidator = [
  40496. fieldValidator
  40497. ];
  40498. }
  40499. validator = validators[name];
  40500. if (validator) {
  40501. Ext.Array.push(validator, fieldValidator);
  40502. } else {
  40503. validators[name] = fieldValidator;
  40504. }
  40505. }
  40506. }
  40507. if (validators) {
  40508. for (name in validators) {
  40509. field = cls.getField(name);
  40510. if (field) {
  40511. field.setModelValidators(validators[name]);
  40512. }
  40513. }
  40514. }
  40515. cls.validators = proto.validators = validators;
  40516. },
  40517. initAssociations: function(schema, data, cls) {
  40518. var associations = data.associations,
  40519. belongsTo = data.belongsTo,
  40520. hasMany = data.hasMany,
  40521. hasOne = data.hasOne,
  40522. matrices = data.manyToMany,
  40523. i, length, assoc, o;
  40524. delete data.associations;
  40525. delete data.belongsTo;
  40526. delete data.hasMany;
  40527. delete data.hasOne;
  40528. delete data.manyToMany;
  40529. if (matrices) {
  40530. schema.addMatrices(cls, matrices);
  40531. }
  40532. if (associations) {
  40533. associations = Ext.isArray(associations) ? associations : [
  40534. associations
  40535. ];
  40536. for (i = 0 , length = associations.length; i < length; ++i) {
  40537. assoc = associations[i];
  40538. o = Ext.apply({}, assoc);
  40539. delete o.type;
  40540. switch (assoc.type) {
  40541. case 'belongsTo':
  40542. schema.addBelongsTo(cls, o);
  40543. break;
  40544. case 'hasMany':
  40545. schema.addHasMany(cls, o);
  40546. break;
  40547. case 'hasOne':
  40548. schema.addHasOne(cls, o);
  40549. break;
  40550. default:
  40551. Ext.raise('Invalid association type: "' + assoc.type + '"');
  40552. }
  40553. }
  40554. }
  40555. if (belongsTo) {
  40556. belongsTo = Ext.isArray(belongsTo) ? belongsTo : [
  40557. belongsTo
  40558. ];
  40559. for (i = 0 , length = belongsTo.length; i < length; ++i) {
  40560. schema.addBelongsTo(cls, belongsTo[i]);
  40561. }
  40562. }
  40563. if (hasMany) {
  40564. hasMany = Ext.isArray(hasMany) ? hasMany : [
  40565. hasMany
  40566. ];
  40567. for (i = 0 , length = hasMany.length; i < length; ++i) {
  40568. schema.addHasMany(cls, hasMany[i]);
  40569. }
  40570. }
  40571. if (hasOne) {
  40572. hasOne = Ext.isArray(hasOne) ? hasOne : [
  40573. hasOne
  40574. ];
  40575. for (i = 0 , length = hasOne.length; i < length; ++i) {
  40576. schema.addHasOne(cls, hasOne[i]);
  40577. }
  40578. }
  40579. schema.afterKeylessAssociations(cls);
  40580. },
  40581. initIdentifier: function(data, cls, proto) {
  40582. var identifier = data.identifier || data.idgen,
  40583. superIdent = proto.identifier || cls.schema._defaultIdentifier,
  40584. generatorPrefix;
  40585. if (data.idgen) {
  40586. Ext.log.warn('Ext.data.Model: idgen has been deprecated. Please use identifier instead.');
  40587. }
  40588. if (identifier) {
  40589. delete data.identifier;
  40590. delete data.idgen;
  40591. identifier = Ext.Factory.dataIdentifier(identifier);
  40592. } else if (superIdent) {
  40593. if (superIdent.clone && !superIdent.getId()) {
  40594. identifier = superIdent.clone();
  40595. } else if (superIdent.isGenerator) {
  40596. identifier = superIdent;
  40597. } else {
  40598. identifier = Ext.Factory.dataIdentifier(superIdent);
  40599. }
  40600. }
  40601. cls.identifier = proto.identifier = identifier;
  40602. if (!identifier) {
  40603. generatorPrefix = cls.entityName;
  40604. if (!generatorPrefix) {
  40605. generatorPrefix = Ext.id(null, 'extModel');
  40606. }
  40607. cls.identifier = Ext.Factory.dataIdentifier({
  40608. type: 'sequential',
  40609. prefix: generatorPrefix + '-'
  40610. });
  40611. }
  40612. },
  40613. findValidator: function(validators, name, cfg) {
  40614. var type = cfg.type || cfg,
  40615. field = validators[name],
  40616. len, i, item;
  40617. if (field) {
  40618. for (i = 0 , len = field.length; i < len; ++i) {
  40619. item = field[i];
  40620. if (item.type === type) {
  40621. return item;
  40622. }
  40623. }
  40624. }
  40625. return null;
  40626. },
  40627. makeInitializeFn: function(cls) {
  40628. var code = [
  40629. 'var '
  40630. ],
  40631. body = [
  40632. '\nreturn function (e) {\n var data = e.data, v;\n'
  40633. ],
  40634. work = 0,
  40635. bc, ec,
  40636. convert, expr, factory, field, fields, fs, hasDefValue, i, length;
  40637. if (!(fields = cls.rankedFields)) {
  40638. fields = cls.rankFields();
  40639. }
  40640. for (i = 0 , length = fields.length; i < length; ++i) {
  40641. field = fields[i];
  40642. fs = 'f' + i;
  40643. convert = field.convert;
  40644. if (i) {
  40645. code.push(', \n ');
  40646. }
  40647. code.push(fs, ' = $fields[' + i + ']');
  40648. code.push(' /* ', field.name, ' */');
  40649. if ((hasDefValue = (field.defaultValue !== undefined)) || convert) {
  40650. expr = 'data["' + field.name + '"]';
  40651. ++work;
  40652. bc = ec = '';
  40653. if (field.cloneDefaultValue) {
  40654. bc = 'Ext.clone(';
  40655. ec = ')';
  40656. }
  40657. body.push('\n');
  40658. if (convert && hasDefValue) {
  40659. 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;');
  40660. } else if (convert) {
  40661. body.push(' v = ', fs, '.convert(', expr, ',e);\n' + ' if (v !== undefined) {\n' + ' ', expr, ' = v;\n' + ' }\n');
  40662. } else if (hasDefValue) {
  40663. body.push(' if (', expr, ' === undefined) {\n' + ' ', expr, ' = ', bc, fs, '.defaultValue', ec, ';\n' + ' }\n');
  40664. }
  40665. }
  40666. }
  40667. if (!work) {
  40668. return Ext.emptyFn;
  40669. }
  40670. code.push(';\n');
  40671. code.push.apply(code, body);
  40672. code.push('}');
  40673. code = code.join('');
  40674. factory = new Function('$fields', 'Ext', code);
  40675. return factory(fields, Ext);
  40676. }
  40677. }
  40678. }
  40679. },
  40680. function() {
  40681. var Model = this,
  40682. proto = Model.prototype,
  40683. Schema = Ext.data.schema.Schema,
  40684. defaultSchema;
  40685. Model.proxyConfig = proto.proxy;
  40686. delete proto.proxy;
  40687. Model.fields = [];
  40688. Model.fieldsMap = proto.fieldsMap = {};
  40689. Model.schema = proto.schema = Schema.get(proto.schema);
  40690. proto.idField = new Ext.data.field.Field(proto.idProperty);
  40691. Model.identifier = new Ext.data.identifier.Sequential();
  40692. Model.onExtended(function(cls, data) {
  40693. var proto = cls.prototype,
  40694. schemaName = data.schema,
  40695. superCls = proto.superclass.self,
  40696. schema, entityName, proxy;
  40697. cls.idProperty = data.idProperty || proto.idProperty;
  40698. if (schemaName) {
  40699. delete data.schema;
  40700. schema = Schema.get(schemaName);
  40701. } else if (!(schema = proto.schema)) {
  40702. schema = defaultSchema || (defaultSchema = Schema.get('default'));
  40703. }
  40704. cls.rankFields = Model.rankFields;
  40705. cls.topoAdd = Model.topoAdd;
  40706. proto.schema = cls.schema = schema;
  40707. if (!(entityName = data.entityName)) {
  40708. proto.entityName = entityName = schema.getEntityName(cls);
  40709. if (!entityName) {
  40710. if (data.associations) {
  40711. Ext.raise('Anonymous entities cannot specify "associations"');
  40712. }
  40713. if (data.belongsTo) {
  40714. Ext.raise('Anonymous entities cannot specify "belongsTo"');
  40715. }
  40716. if (data.hasMany) {
  40717. Ext.raise('Anonymous entities cannot specify "hasMany"');
  40718. }
  40719. if (data.hasOne) {
  40720. Ext.raise('Anonymous entities cannot specify "hasOne"');
  40721. }
  40722. if (data.matrices) {
  40723. Ext.raise('Anonymous entities cannot specify "manyToMany"');
  40724. }
  40725. }
  40726. }
  40727. cls.entityName = entityName;
  40728. cls.fieldExtractors = {};
  40729. Model.initIdentifier(data, cls, proto);
  40730. Model.initFields(data, cls, proto);
  40731. Model.initValidators(data, cls, proto);
  40732. if (!data.isSummaryModel) {
  40733. Model.initSummaries(data, cls, proto);
  40734. }
  40735. cls.fields.items = cls.fields;
  40736. if (entityName) {
  40737. schema.addEntity(cls);
  40738. Model.initAssociations(schema, data, cls);
  40739. }
  40740. proxy = data.proxy;
  40741. if (proxy) {
  40742. delete data.proxy;
  40743. } else if (superCls !== Model) {
  40744. proxy = superCls.proxyConfig || superCls.proxy;
  40745. }
  40746. cls.proxyConfig = proxy;
  40747. });
  40748. });
  40749. Ext.define('Ext.data.ResultSet', {
  40750. isResultSet: true,
  40751. $configPrefixed: false,
  40752. config: {
  40753. loaded: true,
  40754. count: null,
  40755. total: null,
  40756. remoteTotal: null,
  40757. success: false,
  40758. records: null,
  40759. message: null,
  40760. metadata: null,
  40761. groupData: null,
  40762. summaryData: null
  40763. },
  40764. constructor: function(config) {
  40765. this.initConfig(config);
  40766. },
  40767. getCount: function() {
  40768. var count = this.callParent(),
  40769. records;
  40770. if (!count) {
  40771. records = this.getRecords();
  40772. if (records) {
  40773. count = records.length;
  40774. }
  40775. }
  40776. return count;
  40777. }
  40778. });
  40779. Ext.define('Ext.data.reader.Reader', {
  40780. alternateClassName: [
  40781. 'Ext.data.Reader',
  40782. 'Ext.data.DataReader'
  40783. ],
  40784. mixins: [
  40785. Ext.mixin.Observable,
  40786. Ext.mixin.Factoryable
  40787. ],
  40788. alias: 'reader.base',
  40789. factoryConfig: {
  40790. defaultType: null
  40791. },
  40792. config: {
  40793. groupRootProperty: '',
  40794. implicitIncludes: true,
  40795. keepRawData: null,
  40796. messageProperty: '',
  40797. model: null,
  40798. proxy: null,
  40799. readRecordsOnFailure: true,
  40800. rootProperty: '',
  40801. successProperty: 'success',
  40802. summaryRootProperty: '',
  40803. totalProperty: 'total',
  40804. transform: null,
  40805. typeProperty: ''
  40806. },
  40807. isReader: true,
  40808. constructor: function(config) {
  40809. if (config && config.hasOwnProperty('root')) {
  40810. config = Ext.apply({}, config);
  40811. config.rootProperty = config.root;
  40812. delete config.root;
  40813. Ext.log.error('Ext.data.reader.Reader: Using the deprecated "root" configuration. Use "rootProperty" instead.');
  40814. }
  40815. var me = this;
  40816. me.duringInit = 1;
  40817. me.mixins.observable.constructor.call(me, config);
  40818. --me.duringInit;
  40819. me.buildExtractors();
  40820. },
  40821. forceBuildExtractors: function() {
  40822. if (!this.duringInit) {
  40823. this.buildExtractors(true);
  40824. }
  40825. },
  40826. updateGroupRootProperty: function() {
  40827. this.forceBuildExtractors();
  40828. },
  40829. updateMessageProperty: function() {
  40830. this.forceBuildExtractors();
  40831. },
  40832. applyModel: function(model) {
  40833. return Ext.data.schema.Schema.lookupEntity(model);
  40834. },
  40835. updateSuccessProperty: function() {
  40836. this.forceBuildExtractors();
  40837. },
  40838. updateTotalProperty: function() {
  40839. this.forceBuildExtractors();
  40840. },
  40841. applyTransform: function(transform) {
  40842. if (transform) {
  40843. if (Ext.isFunction(transform)) {
  40844. transform = {
  40845. fn: transform
  40846. };
  40847. } else if (transform.charAt) {
  40848. transform = {
  40849. fn: this[transform]
  40850. };
  40851. }
  40852. return transform.fn.bind(transform.scope || this);
  40853. }
  40854. return transform;
  40855. },
  40856. read: function(response, readOptions) {
  40857. var data, result, responseText;
  40858. if (response) {
  40859. responseText = response.responseText;
  40860. if (response.responseType || responseText) {
  40861. result = this.getResponseData(response);
  40862. if (result && result.__$isError) {
  40863. return new Ext.data.ResultSet({
  40864. total: 0,
  40865. count: 0,
  40866. records: [],
  40867. success: false,
  40868. message: result.msg
  40869. });
  40870. } else {
  40871. data = this.readRecords(result, readOptions);
  40872. }
  40873. } else if (responseText !== '') {
  40874. data = this.readRecords(response, readOptions);
  40875. }
  40876. }
  40877. return data || this.nullResultSet;
  40878. },
  40879. getNullResultSet: function() {
  40880. return this.nullResultSet;
  40881. },
  40882. createReadError: function(msg) {
  40883. return {
  40884. __$isError: true,
  40885. msg: msg
  40886. };
  40887. },
  40888. readRecords: function(data, readOptions, internalReadOptions) {
  40889. var me = this,
  40890. recordsOnly = internalReadOptions && internalReadOptions.recordsOnly,
  40891. asRoot = internalReadOptions && internalReadOptions.asRoot,
  40892. groupData = null,
  40893. summaryData = null,
  40894. success, recordCount, records, root, remoteTotal, total, value, message, transform, meta, summaryOptions;
  40895. meta = me.getMeta ? me.getMeta(data) : data.metaData;
  40896. if (meta) {
  40897. me.onMetaChange(meta);
  40898. }
  40899. transform = me.getTransform();
  40900. if (transform) {
  40901. data = transform(data);
  40902. }
  40903. me.buildExtractors();
  40904. if (me.getKeepRawData()) {
  40905. me.rawData = data;
  40906. }
  40907. if (me.hasListeners.rawdata) {
  40908. me.fireEventArgs('rawdata', [
  40909. data
  40910. ]);
  40911. }
  40912. data = me.getData(data);
  40913. success = true;
  40914. recordCount = 0;
  40915. records = [];
  40916. if (me.getSuccessProperty()) {
  40917. value = me.getSuccess(data);
  40918. if (value === false || value === 'false') {
  40919. success = false;
  40920. }
  40921. }
  40922. if (me.getMessageProperty()) {
  40923. message = me.getMessage(data);
  40924. }
  40925. if (success || me.getReadRecordsOnFailure()) {
  40926. root = (asRoot || Ext.isArray(data)) ? data : me.getRoot(data);
  40927. if (root) {
  40928. total = root.length;
  40929. }
  40930. if (me.getTotalProperty()) {
  40931. value = parseInt(me.getTotal(data), 10);
  40932. if (!isNaN(value)) {
  40933. remoteTotal = total = value;
  40934. }
  40935. }
  40936. if (root) {
  40937. records = me.extractData(root, readOptions);
  40938. recordCount = records.length;
  40939. }
  40940. if (me.getGroupRootProperty()) {
  40941. root = me.getGroupRoot(data);
  40942. if (root) {
  40943. summaryOptions = {
  40944. includes: false,
  40945. model: me.getModel().getSummaryModel()
  40946. };
  40947. groupData = me.extractData(root, summaryOptions) || null;
  40948. }
  40949. }
  40950. if (me.getSummaryRootProperty()) {
  40951. root = me.getSummaryRoot(data);
  40952. if (root) {
  40953. summaryOptions = summaryOptions || {
  40954. includes: false,
  40955. model: me.getModel().getSummaryModel()
  40956. };
  40957. summaryData = me.extractData(root, summaryOptions) || null;
  40958. if (summaryData) {
  40959. summaryData = summaryData[0];
  40960. }
  40961. }
  40962. }
  40963. }
  40964. return recordsOnly ? records : new Ext.data.ResultSet({
  40965. total: total || recordCount,
  40966. remoteTotal: remoteTotal,
  40967. metadata: meta,
  40968. count: recordCount,
  40969. records: records,
  40970. success: success,
  40971. message: message,
  40972. groupData: groupData,
  40973. summaryData: summaryData
  40974. });
  40975. },
  40976. extractData: function(root, readOptions) {
  40977. var me = this,
  40978. entityType = readOptions && readOptions.model ? Ext.data.schema.Schema.lookupEntity(readOptions.model) : me.getModel(),
  40979. schema = entityType.schema,
  40980. includes = readOptions && 'includes' in readOptions ? readOptions.includes : schema.hasAssociations(entityType) && me.getImplicitIncludes(),
  40981. fieldExtractorInfo = me.getFieldExtractorInfo(entityType),
  40982. length = root.length,
  40983. records = new Array(length),
  40984. typeProperty = me.getTypeProperty(),
  40985. reader, node, nodeType, record, i;
  40986. if (!length && Ext.isObject(root)) {
  40987. root = [
  40988. root
  40989. ];
  40990. length = 1;
  40991. }
  40992. for (i = 0; i < length; i++) {
  40993. record = root[i];
  40994. if (!record.isModel) {
  40995. node = record;
  40996. if (typeProperty && (nodeType = me.getChildType(schema, node, typeProperty))) {
  40997. reader = nodeType.getProxy().getReader();
  40998. record = reader.extractRecord(node, readOptions, nodeType, schema.hasAssociations(nodeType) && reader.getImplicitIncludes(), reader.getFieldExtractorInfo(nodeType));
  40999. } else {
  41000. record = me.extractRecord(node, readOptions, entityType, includes, fieldExtractorInfo);
  41001. }
  41002. if (record.isModel && record.isNode) {
  41003. record.raw = node;
  41004. }
  41005. }
  41006. if (record.onLoad) {
  41007. record.onLoad();
  41008. }
  41009. records[i] = record;
  41010. }
  41011. return records;
  41012. },
  41013. getChildType: function(schema, rawNode, typeProperty) {
  41014. var namespace;
  41015. switch (typeof typeProperty) {
  41016. case 'string':
  41017. return schema.getEntity(rawNode[typeProperty]);
  41018. case 'object':
  41019. namespace = typeProperty.namespace;
  41020. return schema.getEntity((namespace ? namespace + '.' : '') + rawNode[typeProperty.name]);
  41021. case 'function':
  41022. return schema.getEntity(typeProperty(rawNode));
  41023. }
  41024. },
  41025. extractRecordData: function(node, readOptions) {
  41026. var entityType = readOptions && readOptions.model ? Ext.data.schema.Schema.lookupEntity(readOptions.model) : this.getModel(),
  41027. fieldExtractorInfo = this.getFieldExtractorInfo(entityType);
  41028. return this.extractRecord(node, readOptions, entityType, false, fieldExtractorInfo);
  41029. },
  41030. extractRecord: function(node, readOptions, entityType, includes, fieldExtractorInfo) {
  41031. var me = this,
  41032. creatorFn = (readOptions && readOptions.recordCreator) || me.defaultRecordCreator,
  41033. modelData, record;
  41034. modelData = me.extractModelData(node, fieldExtractorInfo);
  41035. record = creatorFn.call(me, modelData, entityType || me.getModel(), readOptions);
  41036. if (includes && record.isModel) {
  41037. me.readAssociated(record, node, readOptions);
  41038. }
  41039. return record;
  41040. },
  41041. getFieldExtractorInfo: function(entityType) {
  41042. var extractors = entityType.fieldExtractors,
  41043. type, extractor;
  41044. if (!extractors) {
  41045. return;
  41046. }
  41047. type = this.$className;
  41048. extractor = extractors[type];
  41049. if (extractor === undefined) {
  41050. extractors[type] = extractor = this.buildFieldExtractors(entityType);
  41051. }
  41052. return extractor;
  41053. },
  41054. buildFieldExtractors: function(entityType) {
  41055. var fields = entityType.getFields(),
  41056. len = fields.length,
  41057. buffer = [],
  41058. extractors = [],
  41059. out = null,
  41060. cnt = 0,
  41061. field, name, i, extractor;
  41062. for (i = 0; i < len; ++i) {
  41063. field = fields[i];
  41064. extractor = this.createFieldAccessor(field);
  41065. if (extractor) {
  41066. name = field.name;
  41067. buffer.push('val = extractors[' + cnt + '](raw, self); if (val !== undefined) { data[\'' + name + '\'] = val; }');
  41068. extractors.push(extractor);
  41069. ++cnt;
  41070. }
  41071. }
  41072. if (buffer.length) {
  41073. out = {
  41074. extractors: extractors,
  41075. fn: new Function('raw', 'data', 'extractors', 'self', 'var val;' + buffer.join('\n'))
  41076. };
  41077. }
  41078. return out;
  41079. },
  41080. defaultRecordCreator: function(data, Model) {
  41081. return new Model(data);
  41082. },
  41083. defaultRecordCreatorFromServer: function(data, Model) {
  41084. var record = new Model(data);
  41085. record.phantom = false;
  41086. return record;
  41087. },
  41088. getModelData: function(raw) {
  41089. return {};
  41090. },
  41091. extractModelData: function(raw, fieldExtractorInfo) {
  41092. var data = this.getModelData(raw),
  41093. fn;
  41094. if (fieldExtractorInfo) {
  41095. fn = fieldExtractorInfo.fn;
  41096. fn(raw, data, fieldExtractorInfo.extractors, this);
  41097. }
  41098. return data;
  41099. },
  41100. readAssociated: function(record, data, readOptions) {
  41101. var roles = record.associations,
  41102. key, role;
  41103. for (key in roles) {
  41104. if (roles.hasOwnProperty(key)) {
  41105. role = roles[key];
  41106. if (role.cls) {
  41107. role.read(record, data, this, readOptions);
  41108. }
  41109. }
  41110. }
  41111. },
  41112. getData: Ext.identityFn,
  41113. getRoot: Ext.identityFn,
  41114. getResponseData: function(response) {
  41115. Ext.raise("getResponseData must be implemented in the Ext.data.reader.Reader subclass");
  41116. },
  41117. onMetaChange: function(meta) {
  41118. var me = this,
  41119. fields = meta.fields,
  41120. model, newModel, clientIdProperty, proxy;
  41121. me.metaData = meta;
  41122. if (meta.root) {
  41123. me.setRootProperty(meta.root);
  41124. }
  41125. if (meta.totalProperty) {
  41126. me.setTotalProperty(meta.totalProperty);
  41127. }
  41128. if (meta.successProperty) {
  41129. me.setSuccessProperty(meta.successProperty);
  41130. }
  41131. if (meta.messageProperty) {
  41132. me.setMessageProperty(meta.messageProperty);
  41133. }
  41134. clientIdProperty = meta.clientIdProperty;
  41135. if (fields) {
  41136. newModel = Ext.define(null, {
  41137. extend: 'Ext.data.Model',
  41138. fields: fields,
  41139. clientIdProperty: clientIdProperty
  41140. });
  41141. me.setModel(newModel);
  41142. proxy = me.getProxy();
  41143. if (proxy) {
  41144. proxy.setModel(newModel);
  41145. }
  41146. } else if (clientIdProperty) {
  41147. model = me.getModel();
  41148. if (model) {
  41149. model.self.prototype.clientIdProperty = clientIdProperty;
  41150. }
  41151. }
  41152. },
  41153. buildExtractors: function(force) {
  41154. var me = this,
  41155. totalProp, successProp, messageProp;
  41156. if (force || !me.hasExtractors) {
  41157. totalProp = me.getTotalProperty();
  41158. successProp = me.getSuccessProperty();
  41159. messageProp = me.getMessageProperty();
  41160. if (totalProp) {
  41161. me.getTotal = me.getAccessor(totalProp);
  41162. }
  41163. if (successProp) {
  41164. me.getSuccess = me.getAccessor(successProp);
  41165. }
  41166. if (messageProp) {
  41167. me.getMessage = me.getAccessor(messageProp);
  41168. }
  41169. me.hasExtractors = true;
  41170. return true;
  41171. }
  41172. },
  41173. getAccessor: function(prop) {
  41174. var me = this,
  41175. cache = me.extractorCache,
  41176. ret, key;
  41177. if (typeof prop === 'string') {
  41178. key = me.getAccessorKey(prop);
  41179. if (key) {
  41180. ret = cache.get(key);
  41181. }
  41182. if (!ret) {
  41183. ret = me.createAccessor(prop);
  41184. if (key) {
  41185. cache.add(key, ret);
  41186. }
  41187. }
  41188. } else {
  41189. ret = me.createAccessor(prop);
  41190. }
  41191. return ret;
  41192. },
  41193. getAccessorKey: function(prop) {
  41194. var className = this.$className;
  41195. return className ? className + prop : '';
  41196. },
  41197. createAccessor: Ext.emptyFn,
  41198. createFieldAccessor: Ext.emptyFn,
  41199. destroy: function() {
  41200. var me = this;
  41201. me.model = me.getTotal = me.getSuccess = me.getMessage = me.rawData = null;
  41202. me.onMetaChange = null;
  41203. me.transform = null;
  41204. me.callParent();
  41205. },
  41206. privates: {
  41207. copyFrom: function(reader) {
  41208. var me = this;
  41209. reader.buildExtractors();
  41210. me.getTotal = reader.getTotal;
  41211. me.getSuccess = reader.getSuccess;
  41212. me.getMessage = reader.getMessage;
  41213. ++me.duringInit;
  41214. me.setConfig(reader.getConfig());
  41215. --me.duringInit;
  41216. me.hasExtractors = true;
  41217. },
  41218. getGroupRoot: Ext.privateFn,
  41219. getSummaryRoot: Ext.privateFn
  41220. }
  41221. }, function(Cls) {
  41222. var proto = Cls.prototype;
  41223. Ext.apply(proto, {
  41224. nullResultSet: new Ext.data.ResultSet({
  41225. total: 0,
  41226. count: 0,
  41227. records: [],
  41228. success: true,
  41229. message: ''
  41230. })
  41231. });
  41232. proto.extractorCache = new Ext.util.LruCache();
  41233. });
  41234. Ext.define('Ext.data.writer.Writer', {
  41235. mixins: [
  41236. Ext.mixin.Factoryable
  41237. ],
  41238. alias: 'writer.base',
  41239. factoryConfig: {
  41240. defaultType: null
  41241. },
  41242. alternateClassName: [
  41243. 'Ext.data.DataWriter',
  41244. 'Ext.data.Writer'
  41245. ],
  41246. config: {
  41247. clientIdProperty: null,
  41248. allDataOptions: {
  41249. persist: true
  41250. },
  41251. partialDataOptions: {
  41252. changes: true,
  41253. critical: true
  41254. },
  41255. writeAllFields: false,
  41256. dateFormat: null,
  41257. nameProperty: 'name',
  41258. writeRecordId: true,
  41259. transform: null
  41260. },
  41261. isWriter: true,
  41262. constructor: function(config) {
  41263. this.initConfig(config);
  41264. },
  41265. applyTransform: function(transform) {
  41266. if (transform) {
  41267. if (Ext.isFunction(transform)) {
  41268. transform = {
  41269. fn: transform
  41270. };
  41271. }
  41272. return transform.fn.bind(transform.scope || this);
  41273. }
  41274. return transform;
  41275. },
  41276. write: function(request) {
  41277. var operation = request.getOperation(),
  41278. records = operation.getRecords() || [],
  41279. len = records.length,
  41280. data = [],
  41281. i;
  41282. for (i = 0; i < len; i++) {
  41283. data.push(this.getRecordData(records[i], operation));
  41284. }
  41285. return this.writeRecords(request, data);
  41286. },
  41287. writeRecords: Ext.emptyFn,
  41288. getRecordData: function(record, operation) {
  41289. var me = this,
  41290. nameProperty = me.getNameProperty(),
  41291. mapping = nameProperty !== 'name',
  41292. idField = record.self.idField,
  41293. key = idField[nameProperty] || idField.name,
  41294. value = record.id,
  41295. writeAll = me.getWriteAllFields(),
  41296. ret, dateFormat, phantom, options, clientIdProperty, fieldsMap, data, field;
  41297. if (idField.serialize) {
  41298. value = idField.serialize(value);
  41299. }
  41300. if (!writeAll && operation && operation.isDestroyOperation) {
  41301. ret = {};
  41302. ret[key] = value;
  41303. } else {
  41304. dateFormat = me.getDateFormat();
  41305. phantom = record.phantom;
  41306. options = (phantom || writeAll) ? me.getAllDataOptions() : me.getPartialDataOptions();
  41307. clientIdProperty = phantom && me.getClientIdProperty();
  41308. fieldsMap = record.getFieldsMap();
  41309. options.serialize = false;
  41310. data = record.getData(options);
  41311. ret = mapping ? {} : data;
  41312. if (clientIdProperty) {
  41313. ret[clientIdProperty] = value;
  41314. delete data[key];
  41315. }
  41316. else if (!me.getWriteRecordId()) {
  41317. delete data[key];
  41318. }
  41319. for (key in data) {
  41320. value = data[key];
  41321. if (!(field = fieldsMap[key])) {
  41322. if (mapping) {
  41323. ret[key] = value;
  41324. }
  41325. } else {
  41326. if (field.isDateField && dateFormat && Ext.isDate(value)) {
  41327. value = Ext.Date.format(value, dateFormat);
  41328. } else if (field.serialize) {
  41329. value = field.serialize(value, record);
  41330. }
  41331. if (mapping) {
  41332. key = field[nameProperty] || key;
  41333. }
  41334. ret[key] = value;
  41335. }
  41336. }
  41337. }
  41338. return ret;
  41339. }
  41340. });
  41341. Ext.define('Ext.data.proxy.Proxy', {
  41342. mixins: [
  41343. Ext.mixin.Factoryable,
  41344. Ext.mixin.Observable
  41345. ],
  41346. $configPrefixed: false,
  41347. alias: 'proxy.proxy',
  41348. alternateClassName: [
  41349. 'Ext.data.DataProxy',
  41350. 'Ext.data.Proxy'
  41351. ],
  41352. config: {
  41353. batchOrder: 'create,update,destroy',
  41354. batchActions: true,
  41355. model: undefined,
  41356. reader: {
  41357. type: 'json'
  41358. },
  41359. writer: {
  41360. type: 'json'
  41361. }
  41362. },
  41363. isProxy: true,
  41364. isSynchronous: false,
  41365. constructor: function(config) {
  41366. this.mixins.observable.constructor.call(this, config);
  41367. this.pendingOperations = {};
  41368. },
  41369. applyModel: function(model) {
  41370. return Ext.data.schema.Schema.lookupEntity(model);
  41371. },
  41372. updateModel: function(model) {
  41373. if (model) {
  41374. var reader = this.getReader();
  41375. if (reader && !reader.getModel()) {
  41376. reader.setModel(model);
  41377. }
  41378. }
  41379. },
  41380. applyReader: function(reader) {
  41381. if (this.isSynchronous) {
  41382. reader = reader || {};
  41383. reader.keepRawData = true;
  41384. }
  41385. return Ext.Factory.reader(reader);
  41386. },
  41387. updateReader: function(reader) {
  41388. if (reader) {
  41389. var me = this,
  41390. model = me.getModel();
  41391. if (!model) {
  41392. model = reader.getModel();
  41393. if (model) {
  41394. me.setModel(model);
  41395. }
  41396. } else {
  41397. reader.setModel(model);
  41398. }
  41399. if (reader.responseType != null) {
  41400. me.responseType = reader.responseType;
  41401. }
  41402. }
  41403. },
  41404. applyWriter: function(writer) {
  41405. var reader = this.getReader();
  41406. writer = Ext.Factory.writer(writer);
  41407. if (writer.getRecord && !writer.getRecord() && reader && reader.getRecord) {
  41408. reader = reader.getRecord();
  41409. if (reader) {
  41410. writer.setRecord(reader);
  41411. }
  41412. }
  41413. return writer;
  41414. },
  41415. abort: Ext.emptyFn,
  41416. onMetaChange: function(meta) {
  41417. this.fireEvent('metachange', this, meta);
  41418. },
  41419. create: Ext.emptyFn,
  41420. read: Ext.emptyFn,
  41421. update: Ext.emptyFn,
  41422. erase: Ext.emptyFn,
  41423. batch: function(options, listeners) {
  41424. var me = this,
  41425. useBatch = me.getBatchActions(),
  41426. batch, records, actions, aLen, action, a, r, rLen, record;
  41427. if (options.operations === undefined) {
  41428. options = {
  41429. operations: options,
  41430. listeners: listeners
  41431. };
  41432. }
  41433. if (options.batch) {
  41434. if (Ext.isDefined(options.batch.runOperation)) {
  41435. batch = Ext.applyIf(options.batch, {
  41436. proxy: me,
  41437. listeners: {}
  41438. });
  41439. }
  41440. } else {
  41441. options.batch = {
  41442. proxy: me,
  41443. listeners: options.listeners || {}
  41444. };
  41445. }
  41446. if (!batch) {
  41447. batch = new Ext.data.Batch(options.batch);
  41448. }
  41449. batch.on('complete', Ext.bind(me.onBatchComplete, me, [
  41450. options
  41451. ], 0), null, {
  41452. single: true,
  41453. priority: 1000
  41454. });
  41455. batch.$destroyOwner = options.$destroyOwner;
  41456. actions = me.getBatchOrder().split(',');
  41457. aLen = actions.length;
  41458. for (a = 0; a < aLen; a++) {
  41459. action = actions[a];
  41460. records = options.operations[action];
  41461. if (records) {
  41462. if (useBatch) {
  41463. batch.add(me.createOperation(action, {
  41464. records: records,
  41465. params: options.params
  41466. }));
  41467. } else {
  41468. rLen = records.length;
  41469. for (r = 0; r < rLen; r++) {
  41470. record = records[r];
  41471. batch.add(me.createOperation(action, {
  41472. records: [
  41473. record
  41474. ],
  41475. params: options.params
  41476. }));
  41477. }
  41478. }
  41479. }
  41480. }
  41481. batch.start();
  41482. return batch;
  41483. },
  41484. onBatchComplete: function(batchOptions, batch) {
  41485. var scope = batchOptions.scope || this;
  41486. if (batch.hasException()) {
  41487. if (Ext.isFunction(batchOptions.failure)) {
  41488. Ext.callback(batchOptions.failure, scope, [
  41489. batch,
  41490. batchOptions
  41491. ]);
  41492. }
  41493. } else if (Ext.isFunction(batchOptions.success)) {
  41494. Ext.callback(batchOptions.success, scope, [
  41495. batch,
  41496. batchOptions
  41497. ]);
  41498. }
  41499. if (Ext.isFunction(batchOptions.callback)) {
  41500. Ext.callback(batchOptions.callback, scope, [
  41501. batch,
  41502. batchOptions
  41503. ]);
  41504. }
  41505. if (!batch.$destroyOwner) {
  41506. batch.destroy();
  41507. }
  41508. },
  41509. createOperation: function(action, config) {
  41510. var operation = Ext.createByAlias('data.operation.' + action, config);
  41511. operation.setProxy(this);
  41512. this.pendingOperations[operation._internalId] = operation;
  41513. return operation;
  41514. },
  41515. completeOperation: function(operation) {
  41516. delete this.pendingOperations[operation._internalId];
  41517. },
  41518. clone: function() {
  41519. return new this.self(this.getInitialConfig());
  41520. },
  41521. destroy: function() {
  41522. var ops = this.pendingOperations,
  41523. opId, op;
  41524. for (opId in ops) {
  41525. op = ops[opId];
  41526. if (op && op.isRunning()) {
  41527. op.abort();
  41528. }
  41529. op.destroy();
  41530. }
  41531. this.pendingOperations = null;
  41532. this.callParent();
  41533. }
  41534. });
  41535. Ext.define('Ext.data.proxy.Client', {
  41536. extend: Ext.data.proxy.Proxy,
  41537. alternateClassName: 'Ext.data.ClientProxy',
  41538. isSynchronous: true,
  41539. clear: function() {
  41540. 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.");
  41541. }
  41542. });
  41543. Ext.define('Ext.data.proxy.Memory', {
  41544. extend: Ext.data.proxy.Client,
  41545. alias: 'proxy.memory',
  41546. alternateClassName: 'Ext.data.MemoryProxy',
  41547. isMemoryProxy: true,
  41548. config: {
  41549. enablePaging: null,
  41550. data: {
  41551. $value: null,
  41552. merge: function(newValue, currentValue, target, mixinClass) {
  41553. return newValue ? Ext.clone(newValue) : newValue;
  41554. }
  41555. },
  41556. clearOnRead: null
  41557. },
  41558. finishOperation: function(operation) {
  41559. var recs = operation.getRecords(),
  41560. len = recs.length,
  41561. i;
  41562. for (i = 0; i < len; i++) {
  41563. recs[i].dropped = !!operation.isDestroyOperation;
  41564. recs[i].commit();
  41565. }
  41566. operation.setSuccessful(true);
  41567. },
  41568. create: function(operation) {
  41569. this.finishOperation(operation);
  41570. },
  41571. update: function(operation) {
  41572. this.finishOperation(operation);
  41573. },
  41574. erase: function(operation) {
  41575. this.finishOperation(operation);
  41576. },
  41577. read: function(operation) {
  41578. var me = this,
  41579. reader = me.getReader(),
  41580. resultSet = reader.read(me.getData(), {
  41581. recordCreator: reader.defaultRecordCreatorFromServer
  41582. }),
  41583. records = resultSet.getRecords(),
  41584. sorters = operation.getSorters(),
  41585. grouper = operation.getGrouper(),
  41586. filters = operation.getFilters(),
  41587. start = operation.getStart(),
  41588. limit = operation.getLimit(),
  41589. meta;
  41590. if (operation.process(resultSet, null, null, false) !== false) {
  41591. if (operation.success && me.getClearOnRead()) {
  41592. this.setData(null);
  41593. }
  41594. if (filters && filters.length) {
  41595. resultSet.setRecords(records = Ext.Array.filter(records, Ext.util.Filter.createFilterFn(filters)));
  41596. resultSet.setTotal(records.length);
  41597. }
  41598. if (grouper) {
  41599. sorters = sorters ? sorters.concat(grouper) : sorters;
  41600. }
  41601. if (sorters && sorters.length) {
  41602. resultSet.setRecords(records = Ext.Array.sort(records, Ext.util.Sortable.createComparator(sorters)));
  41603. }
  41604. if (me.getEnablePaging() && start !== undefined && limit !== undefined) {
  41605. if (start >= resultSet.getTotal()) {
  41606. resultSet.setConfig({
  41607. success: false,
  41608. records: [],
  41609. total: 0
  41610. });
  41611. } else
  41612. {
  41613. resultSet.setRecords(Ext.Array.slice(records, start, start + limit));
  41614. }
  41615. }
  41616. operation.setCompleted();
  41617. if (meta = resultSet.getMetadata()) {
  41618. me.onMetaChange(meta);
  41619. }
  41620. }
  41621. },
  41622. clear: Ext.emptyFn
  41623. });
  41624. Ext.define('Ext.data.ProxyStore', {
  41625. extend: Ext.data.AbstractStore,
  41626. config: {
  41627. model: undefined,
  41628. fields: null,
  41629. proxy: undefined,
  41630. autoLoad: undefined,
  41631. autoSync: false,
  41632. batchUpdateMode: 'operation',
  41633. sortOnLoad: true,
  41634. trackRemoved: true,
  41635. asynchronousLoad: undefined
  41636. },
  41637. onClassExtended: function(cls, data, hooks) {
  41638. var model = data.model,
  41639. onBeforeClassCreated;
  41640. if (typeof model === 'string') {
  41641. onBeforeClassCreated = hooks.onBeforeCreated;
  41642. hooks.onBeforeCreated = function() {
  41643. var me = this,
  41644. args = arguments;
  41645. Ext.require(model, function() {
  41646. onBeforeClassCreated.apply(me, args);
  41647. });
  41648. };
  41649. }
  41650. },
  41651. implicitModel: 'Ext.data.Model',
  41652. autoSyncSuspended: 0,
  41653. removed: null,
  41654. constructor: function(config) {
  41655. var me = this;
  41656. var configModel = me.model;
  41657. me.callParent(arguments);
  41658. if (me.getAsynchronousLoad() === false) {
  41659. me.flushLoad();
  41660. }
  41661. if (!me.getModel() && me.useModelWarning !== false && me.getStoreId() !== 'ext-empty-store') {
  41662. var logMsg = [
  41663. Ext.getClassName(me) || 'Store',
  41664. ' created with no model.'
  41665. ];
  41666. if (typeof configModel === 'string') {
  41667. logMsg.push(" The name '", configModel, "'", ' does not correspond to a valid model.');
  41668. }
  41669. Ext.log.warn(logMsg.join(''));
  41670. }
  41671. },
  41672. doDestroy: function() {
  41673. var me = this,
  41674. proxy = me.getProxy();
  41675. me.clearLoadTask();
  41676. Ext.destroy(me.getData());
  41677. me.data = null;
  41678. me.setProxy(null);
  41679. if (proxy.autoCreated) {
  41680. proxy.destroy();
  41681. }
  41682. me.setModel(null);
  41683. me.callParent();
  41684. },
  41685. applyAsynchronousLoad: function(asynchronousLoad) {
  41686. if (asynchronousLoad == null) {
  41687. asynchronousLoad = !this.loadsSynchronously();
  41688. }
  41689. return asynchronousLoad;
  41690. },
  41691. updateAutoLoad: function(autoLoad) {
  41692. this.getData();
  41693. if (autoLoad) {
  41694. this.load(Ext.isObject(autoLoad) ? autoLoad : undefined);
  41695. }
  41696. },
  41697. getTotalCount: function() {
  41698. return this.totalCount || 0;
  41699. },
  41700. applyFields: function(fields) {
  41701. if (fields) {
  41702. this.createImplicitModel(fields);
  41703. }
  41704. },
  41705. applyModel: function(model) {
  41706. if (model) {
  41707. model = Ext.data.schema.Schema.lookupEntity(model);
  41708. } else if (!this.destroying) {
  41709. this.getFields();
  41710. model = this.getModel() || this.createImplicitModel();
  41711. }
  41712. return model;
  41713. },
  41714. applyProxy: function(proxy) {
  41715. var model = this.getModel();
  41716. if (proxy !== null) {
  41717. if (proxy) {
  41718. if (proxy.isProxy) {
  41719. proxy.setModel(model);
  41720. } else {
  41721. if (Ext.isString(proxy)) {
  41722. proxy = {
  41723. type: proxy,
  41724. model: model
  41725. };
  41726. } else if (!proxy.model) {
  41727. proxy = Ext.apply({
  41728. model: model
  41729. }, proxy);
  41730. }
  41731. proxy = Ext.createByAlias('proxy.' + proxy.type, proxy);
  41732. proxy.autoCreated = true;
  41733. }
  41734. } else if (model) {
  41735. proxy = model.getProxy();
  41736. this.useModelProxy = true;
  41737. }
  41738. if (!proxy) {
  41739. proxy = Ext.createByAlias('proxy.memory');
  41740. proxy.autoCreated = true;
  41741. }
  41742. }
  41743. return proxy;
  41744. },
  41745. applyState: function(state) {
  41746. var me = this;
  41747. me.callParent([
  41748. state
  41749. ]);
  41750. if (me.getAutoLoad() || me.isLoaded()) {
  41751. me.load();
  41752. }
  41753. },
  41754. updateProxy: function(proxy, oldProxy) {
  41755. this.proxyListeners = Ext.destroy(this.proxyListeners);
  41756. },
  41757. updateTrackRemoved: function(track) {
  41758. this.cleanRemoved();
  41759. this.removed = track ? [] : null;
  41760. },
  41761. onMetaChange: function(proxy, meta) {
  41762. this.fireEvent('metachange', this, meta);
  41763. },
  41764. create: function(data, options) {
  41765. var me = this,
  41766. Model = me.getModel(),
  41767. instance = new Model(data),
  41768. operation;
  41769. options = Ext.apply({}, options);
  41770. if (!options.records) {
  41771. options.records = [
  41772. instance
  41773. ];
  41774. }
  41775. options.internalScope = me;
  41776. options.internalCallback = me.onProxyWrite;
  41777. operation = me.createOperation('create', options);
  41778. return operation.execute();
  41779. },
  41780. read: function() {
  41781. return this.load.apply(this, arguments);
  41782. },
  41783. update: function(options) {
  41784. var me = this,
  41785. operation;
  41786. options = Ext.apply({}, options);
  41787. if (!options.records) {
  41788. options.records = me.getUpdatedRecords();
  41789. }
  41790. options.internalScope = me;
  41791. options.internalCallback = me.onProxyWrite;
  41792. operation = me.createOperation('update', options);
  41793. return operation.execute();
  41794. },
  41795. onProxyWrite: function(operation) {
  41796. var me = this,
  41797. success = operation.wasSuccessful(),
  41798. records = operation.getRecords();
  41799. switch (operation.getAction()) {
  41800. case 'create':
  41801. me.onCreateRecords(records, operation, success);
  41802. break;
  41803. case 'update':
  41804. me.onUpdateRecords(records, operation, success);
  41805. break;
  41806. case 'destroy':
  41807. me.onDestroyRecords(records, operation, success);
  41808. break;
  41809. }
  41810. if (success) {
  41811. me.fireEvent('write', me, operation);
  41812. me.fireEvent('datachanged', me);
  41813. }
  41814. },
  41815. onCreateRecords: Ext.emptyFn,
  41816. onUpdateRecords: Ext.emptyFn,
  41817. onDestroyRecords: function(records, operation, success) {
  41818. if (success) {
  41819. this.cleanRemoved();
  41820. }
  41821. },
  41822. erase: function(options) {
  41823. var me = this,
  41824. operation;
  41825. options = Ext.apply({}, options);
  41826. if (!options.records) {
  41827. options.records = me.getRemovedRecords();
  41828. }
  41829. options.internalScope = me;
  41830. options.internalCallback = me.onProxyWrite;
  41831. operation = me.createOperation('destroy', options);
  41832. return operation.execute();
  41833. },
  41834. onBatchOperationComplete: function(batch, operation) {
  41835. return this.onProxyWrite(operation);
  41836. },
  41837. onBatchComplete: function(batch, operation) {
  41838. var me = this,
  41839. operations = batch.operations,
  41840. length = operations.length,
  41841. i;
  41842. if (me.batchUpdateMode !== 'operation') {
  41843. me.suspendEvents();
  41844. for (i = 0; i < length; i++) {
  41845. me.onProxyWrite(operations[i]);
  41846. }
  41847. me.resumeEvents();
  41848. }
  41849. me.isSyncing = false;
  41850. if (batch.$destroyOwner === me) {
  41851. batch.destroy();
  41852. }
  41853. me.fireEvent('datachanged', me);
  41854. },
  41855. onBatchException: function(batch, operation) {},
  41856. filterNew: function(item) {
  41857. return item.phantom && item.isValid();
  41858. },
  41859. getNewRecords: function() {
  41860. return [];
  41861. },
  41862. getUpdatedRecords: function() {
  41863. return [];
  41864. },
  41865. getModifiedRecords: function() {
  41866. return [].concat(this.getNewRecords(), this.getUpdatedRecords());
  41867. },
  41868. filterUpdated: function(item) {
  41869. return item.dirty && !item.phantom && item.isValid();
  41870. },
  41871. getRemovedRecords: function() {
  41872. var removed = this.getRawRemovedRecords();
  41873. return removed ? Ext.Array.clone(removed) : [];
  41874. },
  41875. sync: function(options) {
  41876. var me = this,
  41877. operations = {},
  41878. toCreate = me.getNewRecords(),
  41879. toUpdate = me.getUpdatedRecords(),
  41880. toDestroy = me.getRemovedRecords(),
  41881. needsSync = false;
  41882. if (me.isSyncing) {
  41883. Ext.log.warn('Sync called while a sync operation is in progress. Consider configuring autoSync as false.');
  41884. }
  41885. me.needsSync = false;
  41886. if (toCreate.length > 0) {
  41887. operations.create = toCreate;
  41888. needsSync = true;
  41889. }
  41890. if (toUpdate.length > 0) {
  41891. operations.update = toUpdate;
  41892. needsSync = true;
  41893. }
  41894. if (toDestroy.length > 0) {
  41895. operations.destroy = toDestroy;
  41896. needsSync = true;
  41897. }
  41898. if (needsSync && me.fireEvent('beforesync', operations) !== false) {
  41899. me.isSyncing = true;
  41900. options = options || {};
  41901. me.proxy.batch(Ext.apply(options, {
  41902. operations: operations,
  41903. listeners: me.getBatchListeners(),
  41904. $destroyOwner: me
  41905. }));
  41906. }
  41907. return me;
  41908. },
  41909. getBatchListeners: function() {
  41910. var me = this,
  41911. listeners = {
  41912. scope: me,
  41913. exception: me.onBatchException,
  41914. complete: me.onBatchComplete
  41915. };
  41916. if (me.batchUpdateMode === 'operation') {
  41917. listeners.operationcomplete = me.onBatchOperationComplete;
  41918. }
  41919. return listeners;
  41920. },
  41921. save: function() {
  41922. return this.sync.apply(this, arguments);
  41923. },
  41924. load: function(options) {
  41925. var me = this;
  41926. if (typeof options === 'function') {
  41927. options = {
  41928. callback: options
  41929. };
  41930. } else {
  41931. options = options ? Ext.Object.chain(options) : {};
  41932. }
  41933. me.pendingLoadOptions = options;
  41934. if (me.getAsynchronousLoad()) {
  41935. if (!me.loadTimer) {
  41936. me.loadTimer = Ext.asap(me.flushLoad, me);
  41937. }
  41938. } else
  41939. {
  41940. me.flushLoad();
  41941. }
  41942. return me;
  41943. },
  41944. flushLoad: function() {
  41945. var me = this,
  41946. options = me.pendingLoadOptions,
  41947. operation;
  41948. if (me.destroying || me.destroyed) {
  41949. return;
  41950. }
  41951. me.clearLoadTask();
  41952. if (!options) {
  41953. return;
  41954. }
  41955. me.setLoadOptions(options);
  41956. if (me.getRemoteSort() && options.sorters) {
  41957. me.fireEvent('beforesort', me, options.sorters);
  41958. }
  41959. operation = Ext.apply({
  41960. internalScope: me,
  41961. internalCallback: me.onProxyLoad,
  41962. scope: me
  41963. }, options);
  41964. me.lastOptions = operation;
  41965. operation = me.createOperation('read', operation);
  41966. if (me.fireEvent('beforeload', me, operation) !== false) {
  41967. me.onBeforeLoad(operation);
  41968. me.loading = true;
  41969. if (me.hasListeners.beginload) {
  41970. me.fireEvent('beginload', me, operation);
  41971. }
  41972. operation.execute();
  41973. }
  41974. },
  41975. reload: function(options) {
  41976. return this.load(Ext.apply({}, options, this.lastOptions));
  41977. },
  41978. onEndUpdate: function() {
  41979. var me = this;
  41980. if (me.needsSync && me.autoSync && !me.autoSyncSuspended) {
  41981. me.sync();
  41982. }
  41983. },
  41984. afterReject: function(record) {
  41985. var me = this;
  41986. if (me.contains(record)) {
  41987. me.onUpdate(record, Ext.data.Model.REJECT, null);
  41988. me.fireEvent('update', me, record, Ext.data.Model.REJECT, null);
  41989. me.fireEvent('datachanged', me);
  41990. }
  41991. },
  41992. afterCommit: function(record, modifiedFieldNames) {
  41993. var me = this;
  41994. if (!modifiedFieldNames) {
  41995. modifiedFieldNames = null;
  41996. }
  41997. if (me.contains(record)) {
  41998. me.onUpdate(record, Ext.data.Model.COMMIT, modifiedFieldNames);
  41999. me.fireEvent('update', me, record, Ext.data.Model.COMMIT, modifiedFieldNames);
  42000. me.fireEvent('datachanged', me);
  42001. }
  42002. },
  42003. afterErase: function(record) {
  42004. this.onErase(record);
  42005. },
  42006. onErase: Ext.emptyFn,
  42007. onUpdate: Ext.emptyFn,
  42008. hasPendingLoad: function() {
  42009. return !!this.pendingLoadOptions || this.isLoading();
  42010. },
  42011. isLoading: function() {
  42012. return !!this.loading;
  42013. },
  42014. isLoaded: function() {
  42015. return this.loadCount > 0;
  42016. },
  42017. suspendAutoSync: function() {
  42018. ++this.autoSyncSuspended;
  42019. },
  42020. resumeAutoSync: function(syncNow) {
  42021. var me = this;
  42022. if (!me.autoSyncSuspended) {
  42023. Ext.log.warn('Mismatched call to resumeAutoSync - auto synchronization is currently not suspended.');
  42024. }
  42025. if (me.autoSyncSuspended && !--me.autoSyncSuspended) {
  42026. if (syncNow) {
  42027. me.sync();
  42028. }
  42029. }
  42030. },
  42031. removeAll: Ext.emptyFn,
  42032. clearData: Ext.emptyFn,
  42033. privates: {
  42034. getRawRemovedRecords: function() {
  42035. return this.removed;
  42036. },
  42037. onExtraParamsChanged: function() {},
  42038. clearLoadTask: function() {
  42039. this.pendingLoadOptions = this.loadTimer = Ext.unasap(this.loadTimer);
  42040. },
  42041. cleanRemoved: function() {
  42042. var removed = this.getRawRemovedRecords(),
  42043. len, i;
  42044. if (removed) {
  42045. for (i = 0 , len = removed.length; i < len; ++i) {
  42046. removed[i].unjoin(this);
  42047. }
  42048. removed.length = 0;
  42049. }
  42050. },
  42051. createOperation: function(type, options) {
  42052. var me = this,
  42053. proxy = me.getProxy(),
  42054. listeners;
  42055. if (!me.proxyListeners) {
  42056. listeners = {
  42057. scope: me,
  42058. destroyable: true,
  42059. beginprocessresponse: me.beginUpdate,
  42060. endprocessresponse: me.endUpdate
  42061. };
  42062. if (!me.disableMetaChangeEvent) {
  42063. listeners.metachange = me.onMetaChange;
  42064. }
  42065. me.proxyListeners = proxy.on(listeners);
  42066. }
  42067. return proxy.createOperation(type, options);
  42068. },
  42069. createImplicitModel: function(fields) {
  42070. var me = this,
  42071. modelCfg = {
  42072. extend: me.implicitModel,
  42073. statics: {
  42074. defaultProxy: 'memory'
  42075. }
  42076. },
  42077. proxy, model;
  42078. if (fields) {
  42079. modelCfg.fields = fields;
  42080. }
  42081. model = Ext.define(null, modelCfg);
  42082. me.setModel(model);
  42083. proxy = me.getProxy();
  42084. if (proxy) {
  42085. model.setProxy(proxy);
  42086. } else {
  42087. me.setProxy(model.getProxy());
  42088. }
  42089. },
  42090. loadsSynchronously: function() {
  42091. return this.getProxy().isSynchronous;
  42092. },
  42093. onBeforeLoad: Ext.privateFn,
  42094. removeFromRemoved: function(record) {
  42095. var removed = this.getRawRemovedRecords();
  42096. if (removed) {
  42097. Ext.Array.remove(removed, record);
  42098. record.unjoin(this);
  42099. }
  42100. },
  42101. setLoadOptions: function(options) {
  42102. var me = this,
  42103. filters, sorters;
  42104. if (me.getRemoteFilter()) {
  42105. filters = me.getFilters(false);
  42106. if (filters && filters.getCount()) {
  42107. options.filters = filters.getRange();
  42108. }
  42109. }
  42110. if (me.getRemoteSort()) {
  42111. sorters = me.getSorters(false);
  42112. if (sorters && sorters.getCount()) {
  42113. options.sorters = sorters.getRange();
  42114. }
  42115. }
  42116. }
  42117. }
  42118. });
  42119. Ext.define('Ext.util.Group', {
  42120. extend: Ext.util.Collection,
  42121. config: {
  42122. groupKey: null
  42123. },
  42124. $endUpdatePriority: 2001,
  42125. manageSorters: false
  42126. });
  42127. Ext.define('Ext.data.Group', {
  42128. extend: Ext.util.Group,
  42129. store: null,
  42130. getSummaryRecord: function() {
  42131. var me = this,
  42132. summaryRecord = me.summaryRecord,
  42133. store = me.store,
  42134. generation = store.getData().generation,
  42135. M, T;
  42136. if (!summaryRecord) {
  42137. M = store.getModel();
  42138. T = M.getSummaryModel();
  42139. me.summaryRecord = summaryRecord = new T();
  42140. }
  42141. if (!summaryRecord.isRemote && summaryRecord.summaryGeneration !== generation) {
  42142. summaryRecord.calculateSummary(me.items);
  42143. summaryRecord.summaryGeneration = generation;
  42144. }
  42145. return summaryRecord;
  42146. }
  42147. });
  42148. Ext.define('Ext.data.LocalStore', {
  42149. extend: Ext.Mixin,
  42150. mixinConfig: {
  42151. id: 'localstore'
  42152. },
  42153. config: {
  42154. extraKeys: null
  42155. },
  42156. applyExtraKeys: function(extraKeys) {
  42157. var indexName,
  42158. data = this.getData();
  42159. data.setExtraKeys(extraKeys);
  42160. extraKeys = data.getExtraKeys();
  42161. for (indexName in extraKeys) {
  42162. this[indexName] = extraKeys[indexName];
  42163. }
  42164. },
  42165. add: function(record) {
  42166. return this.insert(this.getCount(), arguments.length === 1 ? record : arguments);
  42167. },
  42168. constructDataCollection: function() {
  42169. var result = new Ext.util.Collection({
  42170. rootProperty: 'data',
  42171. groupConfig: {
  42172. xclass: 'Ext.data.Group',
  42173. store: this
  42174. }
  42175. });
  42176. result.addObserver(this);
  42177. return result;
  42178. },
  42179. createModel: function(record) {
  42180. var session = this.getSession(),
  42181. Model;
  42182. if (!record.isModel) {
  42183. Model = this.getModel();
  42184. record = new Model(record, session);
  42185. }
  42186. return record;
  42187. },
  42188. createFiltersCollection: function() {
  42189. return this.getData().getFilters();
  42190. },
  42191. createSortersCollection: function() {
  42192. var sorters = this.getData().getSorters();
  42193. sorters.setSorterConfigure(this.addFieldTransform, this);
  42194. return sorters;
  42195. },
  42196. getSummaryRecord: function() {
  42197. var me = this,
  42198. summaryRecord = me.summaryRecord,
  42199. data = me.getData(),
  42200. generation = data.generation,
  42201. T;
  42202. if (!summaryRecord) {
  42203. T = me.getModel().getSummaryModel();
  42204. me.summaryRecord = summaryRecord = new T();
  42205. }
  42206. if (!summaryRecord.isRemote && summaryRecord.summaryGeneration !== generation) {
  42207. summaryRecord.calculateSummary(data.items);
  42208. summaryRecord.summaryGeneration = generation;
  42209. }
  42210. return summaryRecord;
  42211. },
  42212. onCollectionBeginUpdate: function() {
  42213. this.beginUpdate();
  42214. },
  42215. onCollectionEndUpdate: function() {
  42216. this.endUpdate();
  42217. },
  42218. onCollectionSort: function() {
  42219. this.onSorterEndUpdate();
  42220. },
  42221. onCollectionFilter: function() {
  42222. this.onFilterEndUpdate();
  42223. },
  42224. notifySorterChange: function() {
  42225. this.getData().onSorterChange();
  42226. },
  42227. forceLocalSort: function() {
  42228. var sorters = this.getSorters();
  42229. sorters.beginUpdate();
  42230. sorters.endUpdate();
  42231. },
  42232. contains: function(record) {
  42233. return this.indexOf(record) > -1;
  42234. },
  42235. each: function(fn, scope, includeOptions) {
  42236. var data = this.getData(),
  42237. bypassFilters = includeOptions,
  42238. len, record, i;
  42239. if (typeof includeOptions === 'object') {
  42240. bypassFilters = includeOptions.filtered;
  42241. }
  42242. if (bypassFilters && data.filtered) {
  42243. data = data.getSource();
  42244. }
  42245. data = data.items.slice(0);
  42246. len = data.length;
  42247. for (i = 0; i < len; ++i) {
  42248. record = data[i];
  42249. if (fn.call(scope || record, record, i, len) === false) {
  42250. break;
  42251. }
  42252. }
  42253. },
  42254. collect: function(property, includeOptions, filtered) {
  42255. var me = this,
  42256. allowNull = includeOptions,
  42257. data = me.getData();
  42258. if (typeof includeOptions === 'object') {
  42259. filtered = includeOptions.filtered;
  42260. allowNull = includeOptions.allowNull;
  42261. }
  42262. if (filtered && data.filtered) {
  42263. data = data.getSource();
  42264. }
  42265. return data.collect(property, 'data', allowNull);
  42266. },
  42267. getById: function(id) {
  42268. var data = this.getData();
  42269. if (data.filtered) {
  42270. data = data.getSource();
  42271. }
  42272. return data.get(id) || null;
  42273. },
  42274. getByInternalId: function(internalId) {
  42275. var data = this.getData(),
  42276. keyCfg;
  42277. if (data.filtered) {
  42278. if (!data.$hasExtraKeys) {
  42279. keyCfg = this.makeInternalKeyCfg();
  42280. data.setExtraKeys(keyCfg);
  42281. data.$hasExtraKeys = true;
  42282. }
  42283. data = data.getSource();
  42284. }
  42285. if (!data.$hasExtraKeys) {
  42286. data.setExtraKeys(keyCfg || this.makeInternalKeyCfg());
  42287. data.$hasExtraKeys = true;
  42288. }
  42289. return data.byInternalId.get(internalId) || null;
  42290. },
  42291. getDataSource: function() {
  42292. var data = this.getData();
  42293. return data.getSource() || data;
  42294. },
  42295. indexOf: function(record) {
  42296. return this.getData().indexOf(record);
  42297. },
  42298. indexOfId: function(id) {
  42299. return this.indexOf(this.getById(id));
  42300. },
  42301. insert: function(index, records) {
  42302. var me = this,
  42303. len, i;
  42304. if (records) {
  42305. if (!Ext.isIterable(records)) {
  42306. records = [
  42307. records
  42308. ];
  42309. } else {
  42310. records = Ext.Array.clone(records);
  42311. }
  42312. len = records.length;
  42313. }
  42314. if (!len) {
  42315. return [];
  42316. }
  42317. for (i = 0; i < len; ++i) {
  42318. records[i] = me.createModel(records[i]);
  42319. }
  42320. me.getData().insert(index, records);
  42321. return records;
  42322. },
  42323. queryBy: function(fn, scope) {
  42324. var data = this.getData();
  42325. return (data.getSource() || data).createFiltered(fn, scope);
  42326. },
  42327. query: function(property, value, anyMatch, caseSensitive, exactMatch) {
  42328. var data = this.getData();
  42329. return (data.getSource() || data).createFiltered(property, value, anyMatch, caseSensitive, exactMatch);
  42330. },
  42331. first: function(grouped) {
  42332. return this.getData().first(grouped) || null;
  42333. },
  42334. last: function(grouped) {
  42335. return this.getData().last(grouped) || null;
  42336. },
  42337. sum: function(field, grouped) {
  42338. var data = this.getData();
  42339. return (grouped && this.isGrouped()) ? data.sumByGroup(field) : data.sum(field);
  42340. },
  42341. count: function(grouped) {
  42342. var data = this.getData();
  42343. return (grouped && this.isGrouped()) ? data.countByGroup() : data.count();
  42344. },
  42345. min: function(field, grouped) {
  42346. var data = this.getData();
  42347. return (grouped && this.isGrouped()) ? data.minByGroup(field) : data.min(field);
  42348. },
  42349. max: function(field, grouped) {
  42350. var data = this.getData();
  42351. return (grouped && this.isGrouped()) ? data.maxByGroup(field) : data.max(field);
  42352. },
  42353. average: function(field, grouped) {
  42354. var data = this.getData();
  42355. return (grouped && this.isGrouped()) ? data.averageByGroup(field) : data.average(field);
  42356. },
  42357. aggregate: function(fn, scope, grouped, field) {
  42358. var me = this,
  42359. groups, len, out, group, i;
  42360. if (grouped && me.isGrouped()) {
  42361. groups = me.getGroups().items;
  42362. len = groups.length;
  42363. out = {};
  42364. for (i = 0; i < len; ++i) {
  42365. group = groups[i];
  42366. out[group.getGroupKey()] = me.getAggregate(fn, scope || me, group.items, field);
  42367. }
  42368. return out;
  42369. } else {
  42370. return me.getAggregate(fn, scope, me.getData().items, field);
  42371. }
  42372. },
  42373. getAggregate: function(fn, scope, records, field) {
  42374. var values = [],
  42375. len = records.length,
  42376. i;
  42377. for (i = 0; i < len; ++i) {
  42378. values[i] = records[i].get(field);
  42379. }
  42380. return fn.call(scope || this, records, values);
  42381. },
  42382. addObserver: function(observer) {
  42383. var observers = this.observers;
  42384. if (!observers) {
  42385. this.observers = observers = new Ext.util.Collection();
  42386. }
  42387. observers.add(observer);
  42388. },
  42389. removeObserver: function(observer) {
  42390. var observers = this.observers;
  42391. if (observers) {
  42392. observers.remove(observer);
  42393. }
  42394. },
  42395. callObservers: function(action, args) {
  42396. var observers = this.observers,
  42397. len, items, i, methodName, item;
  42398. if (observers) {
  42399. items = observers.items;
  42400. if (args) {
  42401. args.unshift(this);
  42402. } else {
  42403. args = [
  42404. this
  42405. ];
  42406. }
  42407. for (i = 0 , len = items.length; i < len; ++i) {
  42408. item = items[i];
  42409. methodName = 'onSource' + action;
  42410. if (item[methodName]) {
  42411. item[methodName].apply(item, args);
  42412. }
  42413. }
  42414. }
  42415. },
  42416. queryRecordsBy: function(fn, scope) {
  42417. var data = this.getData(),
  42418. matches = [],
  42419. len, i, record;
  42420. data = (data.getSource() || data).items;
  42421. scope = scope || this;
  42422. for (i = 0 , len = data.length; i < len; ++i) {
  42423. record = data[i];
  42424. if (fn.call(scope, record) === true) {
  42425. matches.push(record);
  42426. }
  42427. }
  42428. return matches;
  42429. },
  42430. queryRecords: function(field, value) {
  42431. var data = this.getData(),
  42432. matches = [],
  42433. len, i, record;
  42434. data = (data.getSource() || data).items;
  42435. for (i = 0 , len = data.length; i < len; ++i) {
  42436. record = data[i];
  42437. if (record.get(field) === value) {
  42438. matches.push(record);
  42439. }
  42440. }
  42441. return matches;
  42442. },
  42443. privates: {
  42444. isLast: function(record) {
  42445. return record === this.last();
  42446. },
  42447. makeInternalKeyCfg: function() {
  42448. return {
  42449. byInternalId: {
  42450. property: 'internalId',
  42451. rootProperty: ''
  42452. }
  42453. };
  42454. }
  42455. }
  42456. });
  42457. Ext.define('Ext.data.proxy.Server', {
  42458. extend: Ext.data.proxy.Proxy,
  42459. alias: 'proxy.server',
  42460. alternateClassName: 'Ext.data.ServerProxy',
  42461. isRemote: true,
  42462. config: {
  42463. url: '',
  42464. pageParam: 'page',
  42465. startParam: 'start',
  42466. limitParam: 'limit',
  42467. groupParam: 'group',
  42468. groupDirectionParam: 'groupDir',
  42469. sortParam: 'sort',
  42470. filterParam: 'filter',
  42471. directionParam: 'dir',
  42472. idParam: 'id',
  42473. simpleSortMode: false,
  42474. simpleGroupMode: false,
  42475. noCache: true,
  42476. cacheString: "_dc",
  42477. timeout: 30000,
  42478. api: {
  42479. create: undefined,
  42480. read: undefined,
  42481. update: undefined,
  42482. destroy: undefined
  42483. },
  42484. extraParams: {}
  42485. },
  42486. primitiveRe: /string|number|boolean/,
  42487. create: function() {
  42488. return this.doRequest.apply(this, arguments);
  42489. },
  42490. read: function() {
  42491. return this.doRequest.apply(this, arguments);
  42492. },
  42493. update: function() {
  42494. return this.doRequest.apply(this, arguments);
  42495. },
  42496. erase: function() {
  42497. return this.doRequest.apply(this, arguments);
  42498. },
  42499. setExtraParam: function(name, value) {
  42500. var extraParams = this.getExtraParams();
  42501. extraParams[name] = value;
  42502. this.fireEvent('extraparamschanged', extraParams);
  42503. },
  42504. updateExtraParams: function(newExtraParams, oldExtraParams) {
  42505. this.fireEvent('extraparamschanged', newExtraParams);
  42506. },
  42507. buildRequest: function(operation) {
  42508. var me = this,
  42509. initialParams = Ext.apply({}, operation.getParams()),
  42510. params = Ext.applyIf(initialParams, me.getExtraParams() || {}),
  42511. request, operationId, idParam;
  42512. Ext.applyIf(params, me.getParams(operation));
  42513. operationId = operation.getId();
  42514. idParam = me.getIdParam();
  42515. if (operationId !== undefined && params[idParam] === undefined) {
  42516. params[idParam] = operationId;
  42517. }
  42518. request = new Ext.data.Request({
  42519. params: params,
  42520. action: operation.getAction(),
  42521. records: operation.getRecords(),
  42522. url: operation.getUrl(),
  42523. operation: operation,
  42524. proxy: me
  42525. });
  42526. request.setUrl(me.buildUrl(request));
  42527. operation.setRequest(request);
  42528. return request;
  42529. },
  42530. processResponse: function(success, operation, request, response) {
  42531. var me = this,
  42532. exception, reader, resultSet, meta, destroyOp;
  42533. if (me.destroying || me.destroyed) {
  42534. return;
  42535. }
  42536. me.fireEvent('beginprocessresponse', me, response, operation);
  42537. if (success === true) {
  42538. reader = me.getReader();
  42539. if (response.status === 204) {
  42540. resultSet = reader.getNullResultSet();
  42541. } else {
  42542. resultSet = reader.read(me.extractResponseData(response), {
  42543. recordCreator: operation.getRecordCreator() || reader.defaultRecordCreatorFromServer
  42544. });
  42545. }
  42546. if (!operation.$destroyOwner) {
  42547. operation.$destroyOwner = me;
  42548. destroyOp = true;
  42549. }
  42550. operation.process(resultSet, request, response);
  42551. exception = !operation.wasSuccessful();
  42552. } else {
  42553. me.setException(operation, response);
  42554. exception = true;
  42555. }
  42556. if (me.destroyed) {
  42557. if (!operation.destroyed && destroyOp && operation.$destroyOwner === me) {
  42558. operation.destroy();
  42559. }
  42560. return;
  42561. }
  42562. if (exception) {
  42563. me.fireEvent('exception', me, response, operation);
  42564. } else
  42565. {
  42566. meta = resultSet.getMetadata();
  42567. if (meta) {
  42568. me.onMetaChange(meta);
  42569. }
  42570. }
  42571. if (me.destroyed) {
  42572. if (!operation.destroyed && destroyOp && operation.$destroyOwner === me) {
  42573. operation.destroy();
  42574. }
  42575. return;
  42576. }
  42577. me.afterRequest(request, success);
  42578. me.fireEvent('endprocessresponse', me, response, operation);
  42579. if (!operation.destroyed && destroyOp && operation.$destroyOwner === me) {
  42580. operation.destroy();
  42581. }
  42582. },
  42583. setException: function(operation, response) {
  42584. operation.setException({
  42585. status: response.status,
  42586. statusText: response.statusText,
  42587. response: response
  42588. });
  42589. },
  42590. extractResponseData: Ext.identityFn,
  42591. applyEncoding: function(value) {
  42592. return Ext.encode(value);
  42593. },
  42594. encodeSorters: function(sorters, preventArray) {
  42595. var out = [],
  42596. length = sorters.length,
  42597. i;
  42598. for (i = 0; i < length; i++) {
  42599. out[i] = sorters[i].serialize();
  42600. }
  42601. return this.applyEncoding(preventArray ? out[0] : out);
  42602. },
  42603. encodeFilters: function(filters) {
  42604. var out = [],
  42605. length = filters.length,
  42606. needsEncoding, i, filter, encodedFilter;
  42607. for (i = 0; i < length; i++) {
  42608. filter = filters[i];
  42609. filter.getFilterFn();
  42610. if (filter.generatedFilterFn) {
  42611. encodedFilter = filter.serialize();
  42612. needsEncoding |= !this.primitiveRe.test(typeof encodedFilter);
  42613. out.push(encodedFilter);
  42614. }
  42615. }
  42616. return needsEncoding ? this.applyEncoding(out) : out;
  42617. },
  42618. getParams: function(operation) {
  42619. if (!operation.isReadOperation) {
  42620. return {};
  42621. }
  42622. var me = this,
  42623. params = {},
  42624. grouper = operation.getGrouper(),
  42625. sorters = operation.getSorters(),
  42626. filters = operation.getFilters(),
  42627. page = operation.getPage(),
  42628. start = operation.getStart(),
  42629. limit = operation.getLimit(),
  42630. simpleSortMode = me.getSimpleSortMode(),
  42631. simpleGroupMode = me.getSimpleGroupMode(),
  42632. pageParam = me.getPageParam(),
  42633. startParam = me.getStartParam(),
  42634. limitParam = me.getLimitParam(),
  42635. groupParam = me.getGroupParam(),
  42636. groupDirectionParam = me.getGroupDirectionParam(),
  42637. sortParam = me.getSortParam(),
  42638. filterParam = me.getFilterParam(),
  42639. directionParam = me.getDirectionParam(),
  42640. hasGroups, index;
  42641. if (pageParam && page) {
  42642. params[pageParam] = page;
  42643. }
  42644. if (startParam && (start || start === 0)) {
  42645. params[startParam] = start;
  42646. }
  42647. if (limitParam && limit) {
  42648. params[limitParam] = limit;
  42649. }
  42650. hasGroups = groupParam && grouper;
  42651. if (hasGroups) {
  42652. if (simpleGroupMode) {
  42653. params[groupParam] = grouper.getProperty();
  42654. if (groupDirectionParam === groupParam) {
  42655. params[groupParam] += ' ' + grouper.getDirection();
  42656. } else {
  42657. params[groupDirectionParam] = grouper.getDirection();
  42658. }
  42659. } else {
  42660. params[groupParam] = me.encodeSorters([
  42661. grouper
  42662. ], true);
  42663. }
  42664. }
  42665. if (sortParam && sorters && sorters.length > 0) {
  42666. if (simpleSortMode) {
  42667. for (index = (sorters.length > 1 && hasGroups) ? 1 : 0; index < sorters.length; index++) {
  42668. if (directionParam === sortParam) {
  42669. params[sortParam] = Ext.Array.push(params[sortParam] || [], sorters[index].getProperty() + ' ' + sorters[index].getDirection());
  42670. } else {
  42671. params[sortParam] = Ext.Array.push(params[sortParam] || [], sorters[index].getProperty());
  42672. params[directionParam] = Ext.Array.push(params[directionParam] || [], sorters[index].getDirection());
  42673. }
  42674. }
  42675. } else {
  42676. params[sortParam] = me.encodeSorters(sorters);
  42677. }
  42678. }
  42679. if (filterParam && filters && filters.length > 0) {
  42680. params[filterParam] = me.encodeFilters(filters);
  42681. }
  42682. return params;
  42683. },
  42684. buildUrl: function(request) {
  42685. var me = this,
  42686. url = me.getUrl(request);
  42687. if (!url) {
  42688. Ext.raise("You are using a ServerProxy but have not supplied it with a url.");
  42689. }
  42690. if (me.getNoCache()) {
  42691. url = Ext.urlAppend(url, Ext.String.format("{0}={1}", me.getCacheString(), Ext.Date.now()));
  42692. }
  42693. return url;
  42694. },
  42695. getUrl: function(request) {
  42696. var url;
  42697. if (request) {
  42698. url = request.getUrl() || this.getApi()[request.getAction()];
  42699. }
  42700. return url ? url : this.callParent();
  42701. },
  42702. doRequest: function(operation, callback, scope) {
  42703. Ext.raise("The doRequest function has not been implemented on your Ext.data.proxy.Server subclass. See src/data/ServerProxy.js for details");
  42704. },
  42705. afterRequest: Ext.emptyFn,
  42706. destroy: function() {
  42707. var me = this;
  42708. me.destroying = true;
  42709. me.reader = me.writer = Ext.destroy(me.reader, me.writer);
  42710. me.callParent();
  42711. me.destroying = false;
  42712. me.destroyed = true;
  42713. }
  42714. });
  42715. Ext.define('Ext.data.proxy.Ajax', {
  42716. extend: Ext.data.proxy.Server,
  42717. alias: 'proxy.ajax',
  42718. alternateClassName: [
  42719. 'Ext.data.HttpProxy',
  42720. 'Ext.data.AjaxProxy'
  42721. ],
  42722. isAjaxProxy: true,
  42723. defaultActionMethods: {
  42724. create: 'POST',
  42725. read: 'GET',
  42726. update: 'POST',
  42727. destroy: 'POST'
  42728. },
  42729. config: {
  42730. binary: false,
  42731. headers: undefined,
  42732. paramsAsJson: false,
  42733. withCredentials: false,
  42734. useDefaultXhrHeader: true,
  42735. username: null,
  42736. password: null,
  42737. actionMethods: {
  42738. create: 'POST',
  42739. read: 'GET',
  42740. update: 'POST',
  42741. destroy: 'POST'
  42742. }
  42743. },
  42744. doRequest: function(operation) {
  42745. var me = this,
  42746. writer = me.getWriter(),
  42747. request = me.buildRequest(operation),
  42748. method = me.getMethod(request),
  42749. jsonData, params;
  42750. if (writer && operation.allowWrite()) {
  42751. request = writer.write(request);
  42752. }
  42753. request.setConfig({
  42754. binary: me.getBinary(),
  42755. headers: me.getHeaders(),
  42756. timeout: me.getTimeout(),
  42757. scope: me,
  42758. callback: me.createRequestCallback(request, operation),
  42759. method: method,
  42760. useDefaultXhrHeader: me.getUseDefaultXhrHeader(),
  42761. disableCaching: false
  42762. });
  42763. if (me.responseType != null && Ext.supports.XHR2) {
  42764. request.setResponseType(me.responseType);
  42765. }
  42766. if (method.toUpperCase() !== 'GET' && me.getParamsAsJson()) {
  42767. params = request.getParams();
  42768. if (params) {
  42769. jsonData = request.getJsonData();
  42770. if (jsonData) {
  42771. jsonData = Ext.Object.merge({}, jsonData, params);
  42772. } else {
  42773. jsonData = params;
  42774. }
  42775. request.setJsonData(jsonData);
  42776. request.setParams(undefined);
  42777. }
  42778. }
  42779. if (me.getWithCredentials()) {
  42780. request.setWithCredentials(true);
  42781. request.setUsername(me.getUsername());
  42782. request.setPassword(me.getPassword());
  42783. }
  42784. return me.sendRequest(request);
  42785. },
  42786. sendRequest: function(request) {
  42787. request.setRawRequest(Ext.Ajax.request(request.getCurrentConfig()));
  42788. this.lastRequest = request;
  42789. return request;
  42790. },
  42791. abort: function(request) {
  42792. request = request || this.lastRequest;
  42793. if (request) {
  42794. Ext.Ajax.abort(request.getRawRequest());
  42795. }
  42796. },
  42797. getMethod: function(request) {
  42798. var actions = this.getActionMethods(),
  42799. action = request.getAction(),
  42800. method;
  42801. if (actions) {
  42802. method = actions[action];
  42803. }
  42804. return method || this.defaultActionMethods[action];
  42805. },
  42806. createRequestCallback: function(request, operation) {
  42807. return function(options, success, response) {
  42808. var me = this;
  42809. if (request === me.lastRequest) {
  42810. me.lastRequest = null;
  42811. }
  42812. if (!me.destroying && !me.destroyed) {
  42813. me.processResponse(success, operation, request, response);
  42814. }
  42815. };
  42816. },
  42817. destroy: function() {
  42818. this.lastRequest = null;
  42819. this.callParent();
  42820. }
  42821. });
  42822. Ext.define('Ext.data.reader.Json', {
  42823. extend: Ext.data.reader.Reader,
  42824. alternateClassName: 'Ext.data.JsonReader',
  42825. alias: 'reader.json',
  42826. config: {
  42827. record: null,
  42828. metaProperty: 'metaData',
  42829. useSimpleAccessors: false,
  42830. preserveRawData: false
  42831. },
  42832. responseType: 'json',
  42833. updateRootProperty: function() {
  42834. this.forceBuildExtractors();
  42835. },
  42836. updateMetaProperty: function() {
  42837. this.forceBuildExtractors();
  42838. },
  42839. getResponseData: function(response) {
  42840. var error;
  42841. if (typeof response.responseJson === 'object') {
  42842. return response.responseJson;
  42843. }
  42844. try {
  42845. return Ext.decode(response.responseText);
  42846. } catch (ex) {
  42847. error = this.createReadError(ex.message);
  42848. Ext.Logger.warn('Unable to parse the JSON returned by the server');
  42849. this.fireEvent('exception', this, response, error);
  42850. return error;
  42851. }
  42852. },
  42853. buildExtractors: function(force) {
  42854. var me = this,
  42855. emptyFn = Ext.emptyFn,
  42856. prop;
  42857. if (me.callParent([
  42858. force
  42859. ])) {
  42860. me.getRoot = me.setupExtractor(me.getRootProperty(), Ext.identityFn);
  42861. me.getGroupRoot = me.setupExtractor(me.getGroupRootProperty(), emptyFn);
  42862. me.getSummaryRoot = me.setupExtractor(me.getSummaryRootProperty(), emptyFn);
  42863. me.getMeta = me.setupExtractor(me.getMetaProperty(), emptyFn);
  42864. }
  42865. },
  42866. extractData: function(root, readOptions) {
  42867. var recordName = this.getRecord(),
  42868. data = [],
  42869. length, i;
  42870. if (recordName) {
  42871. length = root.length;
  42872. if (!length && Ext.isObject(root)) {
  42873. length = 1;
  42874. root = [
  42875. root
  42876. ];
  42877. }
  42878. for (i = 0; i < length; i++) {
  42879. data[i] = root[i][recordName];
  42880. }
  42881. } else {
  42882. data = root;
  42883. }
  42884. return this.callParent([
  42885. data,
  42886. readOptions
  42887. ]);
  42888. },
  42889. getModelData: function(raw) {
  42890. return this.getPreserveRawData() ? Ext.apply({}, raw) : raw;
  42891. },
  42892. createAccessor: (function() {
  42893. var re = /[\[\.]/;
  42894. return function(expr) {
  42895. var simple = this.getUseSimpleAccessors(),
  42896. operatorIndex, result, current, parts, part, inExpr, isDot, isLeft, isRight, special, c, i, bracketed, len;
  42897. if (!(expr || expr === 0)) {
  42898. return;
  42899. }
  42900. if (typeof expr === 'function') {
  42901. return expr;
  42902. }
  42903. if (!simple) {
  42904. operatorIndex = String(expr).search(re);
  42905. }
  42906. if (simple === true || operatorIndex < 0) {
  42907. result = function(raw) {
  42908. return raw == null ? null : raw[expr];
  42909. };
  42910. } else {
  42911. current = 'raw';
  42912. parts = [];
  42913. part = '';
  42914. inExpr = 0;
  42915. len = expr.length;
  42916. for (i = 0; i <= len; ++i) {
  42917. c = expr[i];
  42918. isDot = c === '.';
  42919. isLeft = c === '[';
  42920. isRight = c === ']';
  42921. special = isDot || isLeft || isRight || !c;
  42922. if (!special || inExpr > 1 || (inExpr && !isRight)) {
  42923. part += c;
  42924. } else if (special) {
  42925. bracketed = false;
  42926. if (isLeft) {
  42927. ++inExpr;
  42928. } else if (isRight) {
  42929. --inExpr;
  42930. bracketed = true;
  42931. }
  42932. if (part) {
  42933. if (bracketed) {
  42934. part = '[' + part + ']';
  42935. } else {
  42936. part = '.' + part;
  42937. }
  42938. current += part;
  42939. parts.push('' + current);
  42940. part = '';
  42941. }
  42942. }
  42943. }
  42944. result = parts.join(' && ');
  42945. result = Ext.functionFactory('raw', 'return ' + result);
  42946. }
  42947. return result;
  42948. };
  42949. }()),
  42950. createFieldAccessor: function(field) {
  42951. var me = this,
  42952. mapping = field.mapping,
  42953. hasMap = mapping || mapping === 0,
  42954. map = hasMap ? mapping : field.name;
  42955. if (hasMap) {
  42956. if (typeof map === 'function') {
  42957. return function(raw, self) {
  42958. return field.mapping(raw, self);
  42959. };
  42960. } else {
  42961. return me.createAccessor(map);
  42962. }
  42963. }
  42964. },
  42965. getAccessorKey: function(prop) {
  42966. var simple = this.getUseSimpleAccessors() ? 'simple' : '';
  42967. return this.callParent([
  42968. simple + prop
  42969. ]);
  42970. },
  42971. privates: {
  42972. copyFrom: function(reader) {
  42973. this.callParent([
  42974. reader
  42975. ]);
  42976. this.getRoot = reader.getRoot;
  42977. },
  42978. setupExtractor: function(prop, defaultFn) {
  42979. return prop ? this.getAccessor(prop) : defaultFn;
  42980. }
  42981. }
  42982. });
  42983. Ext.define('Ext.data.writer.Json', {
  42984. extend: Ext.data.writer.Writer,
  42985. alternateClassName: 'Ext.data.JsonWriter',
  42986. alias: 'writer.json',
  42987. config: {
  42988. rootProperty: undefined,
  42989. encode: false,
  42990. allowSingle: true,
  42991. expandData: false
  42992. },
  42993. constructor: function(config) {
  42994. if (config && config.hasOwnProperty('root')) {
  42995. config = Ext.apply({}, config);
  42996. config.rootProperty = config.root;
  42997. delete config.root;
  42998. Ext.log.warn('Ext.data.writer.Json: Using the deprecated "root" configuration. Use "rootProperty" instead.');
  42999. }
  43000. this.callParent([
  43001. config
  43002. ]);
  43003. },
  43004. getExpandedData: function(data) {
  43005. var dataLength = data.length,
  43006. i = 0,
  43007. item, prop, nameParts, j, tempObj,
  43008. toObject = function(name, value) {
  43009. var o = {};
  43010. o[name] = value;
  43011. return o;
  43012. };
  43013. for (; i < dataLength; i++) {
  43014. item = data[i];
  43015. for (prop in item) {
  43016. if (item.hasOwnProperty(prop)) {
  43017. nameParts = prop.split('.');
  43018. j = nameParts.length - 1;
  43019. if (j > 0) {
  43020. tempObj = item[prop];
  43021. for (; j > 0; j--) {
  43022. tempObj = toObject(nameParts[j], tempObj);
  43023. }
  43024. item[nameParts[0]] = item[nameParts[0]] || {};
  43025. Ext.Object.merge(item[nameParts[0]], tempObj);
  43026. delete item[prop];
  43027. }
  43028. }
  43029. }
  43030. }
  43031. return data;
  43032. },
  43033. writeRecords: function(request, data) {
  43034. var me = this,
  43035. root = me.getRootProperty(),
  43036. json, single, transform;
  43037. if (me.getExpandData()) {
  43038. data = me.getExpandedData(data);
  43039. }
  43040. if (me.getAllowSingle() && data.length === 1) {
  43041. data = data[0];
  43042. single = true;
  43043. }
  43044. transform = this.getTransform();
  43045. if (transform) {
  43046. data = transform(data, request);
  43047. }
  43048. if (me.getEncode()) {
  43049. if (root) {
  43050. request.setParam(root, Ext.encode(data));
  43051. } else {
  43052. Ext.raise('Must specify a root when using encode');
  43053. }
  43054. }
  43055. else if (single || (data && data.length)) {
  43056. json = request.getJsonData() || {};
  43057. if (root) {
  43058. json[root] = data;
  43059. } else {
  43060. json = data;
  43061. }
  43062. request.setJsonData(json);
  43063. }
  43064. return request;
  43065. }
  43066. });
  43067. Ext.define('Ext.util.SorterCollection', {
  43068. extend: Ext.util.Collection,
  43069. isSorterCollection: true,
  43070. $sortable: null,
  43071. sortFn: null,
  43072. config: {
  43073. sorterOptionsFn: null,
  43074. sorterOptionsScope: null
  43075. },
  43076. constructor: function(config) {
  43077. var me = this;
  43078. me.sortFn = Ext.util.Sorter.createComparator(me);
  43079. me.callParent([
  43080. config
  43081. ]);
  43082. me.setDecoder(me.decodeSorter);
  43083. },
  43084. addSort: function(property, direction, mode) {
  43085. var me = this,
  43086. count, index, limit, options, primary, sorter, sorters;
  43087. if (!property) {
  43088. me.beginUpdate();
  43089. me.endUpdate();
  43090. } else {
  43091. options = me.getOptions();
  43092. if (property instanceof Array) {
  43093. sorters = property;
  43094. mode = direction;
  43095. direction = null;
  43096. } else if (Ext.isString(property)) {
  43097. if (!(sorter = me.get(property))) {
  43098. sorters = [
  43099. {
  43100. property: property,
  43101. direction: direction || options.getDefaultSortDirection()
  43102. }
  43103. ];
  43104. } else {
  43105. sorters = [
  43106. sorter
  43107. ];
  43108. }
  43109. } else if (Ext.isFunction(property)) {
  43110. sorters = [
  43111. {
  43112. sorterFn: property,
  43113. direction: direction || options.getDefaultSortDirection()
  43114. }
  43115. ];
  43116. } else {
  43117. if (!Ext.isObject(property)) {
  43118. Ext.raise('Invalid sort descriptor: ' + property);
  43119. }
  43120. sorters = [
  43121. property
  43122. ];
  43123. mode = direction;
  43124. direction = null;
  43125. }
  43126. if (mode && !me._sortModes[mode]) {
  43127. Ext.raise('Sort mode should be "multi", "append", "prepend" or "replace", not "' + mode + '"');
  43128. }
  43129. mode = me._sortModes[mode || 'replace'];
  43130. primary = me.getAt(0);
  43131. count = me.length;
  43132. index = mode.append ? count : 0;
  43133. me.beginUpdate();
  43134. me.splice(index, mode.replace ? count : 0, sorters);
  43135. if (mode.multi) {
  43136. count = me.length;
  43137. limit = options.getMultiSortLimit();
  43138. if (count > limit) {
  43139. me.removeAt(limit, count);
  43140. }
  43141. }
  43142. if (sorter && direction) {
  43143. sorter.setDirection(direction);
  43144. } else if (index === 0 && primary && primary === me.getAt(0)) {
  43145. primary.toggle();
  43146. }
  43147. me.endUpdate();
  43148. }
  43149. },
  43150. clear: function() {
  43151. this.beginUpdate();
  43152. this.callParent();
  43153. this.endUpdate(this.items);
  43154. },
  43155. getSortFn: function() {
  43156. return this.sortFn;
  43157. },
  43158. getByProperty: function(prop) {
  43159. var items = this.items,
  43160. len = items.length,
  43161. i, item;
  43162. for (i = 0; i < len; ++i) {
  43163. item = items[i];
  43164. if (item.getProperty() === prop) {
  43165. return item;
  43166. }
  43167. }
  43168. return null;
  43169. },
  43170. _sortModes: {
  43171. append: {
  43172. append: 1
  43173. },
  43174. multi: {
  43175. multi: 1
  43176. },
  43177. prepend: {
  43178. prepend: 1
  43179. },
  43180. replace: {
  43181. replace: 1
  43182. }
  43183. },
  43184. decodeSorter: function(sorter, xclass) {
  43185. var me = this,
  43186. options = me.getOptions(),
  43187. root = options.getRootProperty(),
  43188. sorterOptionsFn = me.getSorterOptionsFn(),
  43189. currentSorter, sorterConfig, type;
  43190. if (sorter.isSorter) {
  43191. if (!sorter.getRoot()) {
  43192. sorter.setRoot(root);
  43193. }
  43194. } else {
  43195. sorterConfig = {
  43196. direction: options.getDefaultSortDirection(),
  43197. root: root
  43198. };
  43199. type = typeof sorter;
  43200. if (type === 'string') {
  43201. currentSorter = me.get(sorter);
  43202. if (currentSorter) {
  43203. return currentSorter;
  43204. }
  43205. sorterConfig.property = sorter;
  43206. }
  43207. else if (type === 'function') {
  43208. sorterConfig.sorterFn = sorter;
  43209. } else
  43210. {
  43211. if (!Ext.isObject(sorter)) {
  43212. Ext.raise('Invalid sorter specified: ' + sorter);
  43213. }
  43214. sorterConfig = Ext.apply(sorterConfig, sorter);
  43215. if (sorterConfig.fn) {
  43216. sorterConfig.sorterFn = sorterConfig.fn;
  43217. delete sorterConfig.fn;
  43218. }
  43219. }
  43220. sorter = Ext.create(xclass || Ext.util.Sorter, sorterConfig);
  43221. }
  43222. if (sorterOptionsFn) {
  43223. sorterOptionsFn.call(me.getSorterOptionsScope() || me, sorter);
  43224. }
  43225. return sorter;
  43226. },
  43227. setSorterConfigure: function(fn, scope) {
  43228. this.setSorterOptionsFn(fn);
  43229. this.setSorterOptionsScope(scope);
  43230. },
  43231. decodeRemoveItems: function(args, index) {
  43232. var me = this,
  43233. ret = (index === undefined) ? args : args[index];
  43234. if (!ret || !ret.$cloned) {
  43235. if (args.length > index + 1 || !Ext.isIterable(ret)) {
  43236. ret = Ext.Array.slice(args, index);
  43237. }
  43238. var currentSorters = me.items,
  43239. ln = ret.length,
  43240. remove = [],
  43241. i, item, n, sorter, type;
  43242. for (i = 0; i < ln; i++) {
  43243. sorter = ret[i];
  43244. if (sorter && sorter.isSorter) {
  43245. remove.push(sorter);
  43246. } else {
  43247. type = typeof sorter;
  43248. if (type === 'string') {
  43249. sorter = me.get(sorter);
  43250. if (sorter) {
  43251. remove.push(sorter);
  43252. }
  43253. } else if (type === 'function') {
  43254. for (n = currentSorters.length; n-- > 0; ) {
  43255. item = currentSorters[n];
  43256. if (item.getSorterFn() === sorter) {
  43257. remove.push(item);
  43258. }
  43259. }
  43260. } else
  43261. {
  43262. Ext.raise('Invalid sorter specification: ' + sorter);
  43263. }
  43264. }
  43265. }
  43266. ret = remove;
  43267. ret.$cloned = true;
  43268. }
  43269. return ret;
  43270. },
  43271. getOptions: function() {
  43272. return this.$sortable || this;
  43273. }
  43274. });
  43275. Ext.define('Ext.util.FilterCollection', {
  43276. extend: Ext.util.Collection,
  43277. isFilterCollection: true,
  43278. $filterable: null,
  43279. filterFn: null,
  43280. constructor: function(config) {
  43281. var me = this;
  43282. me.filterFn = Ext.util.Filter.createFilterFn(me);
  43283. me.callParent([
  43284. config
  43285. ]);
  43286. me.setDecoder(me.decodeFilter);
  43287. },
  43288. filterData: function(data) {
  43289. return this.filtered ? Ext.Array.filter(data, this.filterFn) : data;
  43290. },
  43291. getFilterFn: function() {
  43292. return this.filterFn;
  43293. },
  43294. isItemFiltered: function(item) {
  43295. return !this.filterFn(item);
  43296. },
  43297. getFilterCount: function() {
  43298. var filters = this.items,
  43299. len = filters.length,
  43300. i;
  43301. for (i = len - 1; i >= 0; i--) {
  43302. if (filters[i].getDisabled()) {
  43303. len--;
  43304. }
  43305. }
  43306. return len;
  43307. },
  43308. decodeFilter: function(filter) {
  43309. var options = this.getOptions(),
  43310. filterRoot = options.getRootProperty(),
  43311. filterConfig;
  43312. if (filter.isFilter) {
  43313. if (!filter.getRoot()) {
  43314. filter.setRoot(filterRoot);
  43315. }
  43316. } else {
  43317. filterConfig = {
  43318. root: filterRoot
  43319. };
  43320. if (Ext.isFunction(filter)) {
  43321. filterConfig.filterFn = filter;
  43322. } else
  43323. {
  43324. if (!Ext.isObject(filter)) {
  43325. Ext.raise('Invalid filter specified: ' + filter);
  43326. }
  43327. filterConfig = Ext.apply(filterConfig, filter);
  43328. if (filterConfig.fn) {
  43329. filterConfig.filterFn = filterConfig.fn;
  43330. delete filterConfig.fn;
  43331. }
  43332. if (Ext.util.Filter.isInvalid(filterConfig)) {
  43333. return false;
  43334. }
  43335. }
  43336. filter = new Ext.util.Filter(filterConfig);
  43337. }
  43338. return filter;
  43339. },
  43340. decodeRemoveItems: function(args, index) {
  43341. var me = this,
  43342. ret = (index === undefined) ? args : args[index];
  43343. if (!ret.$cloned) {
  43344. if (args.length > index + 1 || !Ext.isIterable(ret)) {
  43345. ret = Ext.Array.slice(args, index);
  43346. }
  43347. var currentFilters = me.items,
  43348. ln = ret.length,
  43349. remove = [],
  43350. filter, i, isFunction, isProp, isString, item, match, n, type;
  43351. for (i = 0; i < ln; i++) {
  43352. filter = ret[i];
  43353. if (filter && filter.isFilter) {
  43354. remove.push(filter);
  43355. } else {
  43356. type = typeof filter;
  43357. isFunction = type === 'function';
  43358. isProp = filter.property !== undefined && filter.value !== undefined;
  43359. isString = type === 'string';
  43360. if (!isFunction && !isProp && !isString) {
  43361. Ext.raise('Invalid filter specification: ' + filter);
  43362. }
  43363. for (n = currentFilters.length; n-- > 0; ) {
  43364. item = currentFilters[n];
  43365. match = false;
  43366. if (isString) {
  43367. match = item.getProperty() === filter;
  43368. } else if (isFunction) {
  43369. match = item.getFilterFn() === filter;
  43370. } else if (isProp) {
  43371. match = item.getProperty() === filter.property && item.getValue() === filter.value;
  43372. }
  43373. if (match) {
  43374. remove.push(item);
  43375. }
  43376. }
  43377. }
  43378. }
  43379. ret = remove;
  43380. ret.$cloned = true;
  43381. }
  43382. return ret;
  43383. },
  43384. getOptions: function() {
  43385. return this.$filterable || this;
  43386. }
  43387. });
  43388. Ext.define('Ext.util.GroupCollection', {
  43389. extend: Ext.util.Collection,
  43390. isGroupCollection: true,
  43391. config: {
  43392. grouper: null,
  43393. groupConfig: null,
  43394. itemRoot: null
  43395. },
  43396. observerPriority: -100,
  43397. emptyGroupRetainTime: 300000,
  43398. constructor: function(config) {
  43399. this.emptyGroups = {};
  43400. this.callParent([
  43401. config
  43402. ]);
  43403. this.on('remove', 'onGroupRemove', this);
  43404. },
  43405. getItemGroup: function(item) {
  43406. var key = this.getGrouper().getGroupString(item);
  43407. return this.get(key);
  43408. },
  43409. onCollectionAdd: function(source, details) {
  43410. if (!this.isConfiguring) {
  43411. this.addItemsToGroups(source, details.items, details.at);
  43412. }
  43413. },
  43414. onCollectionBeforeItemChange: function(source, details) {
  43415. this.changeDetails = details;
  43416. },
  43417. onCollectionBeginUpdate: function() {
  43418. this.beginUpdate();
  43419. },
  43420. onCollectionEndUpdate: function() {
  43421. this.endUpdate();
  43422. },
  43423. onCollectionItemChange: function(source, details) {
  43424. if (!details.indexChanged) {
  43425. this.syncItemGrouping(source, details);
  43426. }
  43427. this.changeDetails = null;
  43428. },
  43429. onCollectionRefresh: function(source) {
  43430. if (source.generation) {
  43431. var me = this,
  43432. itemGroupKeys = me.itemGroupKeys = {},
  43433. groupData = me.createEntries(source, source.items),
  43434. entries = groupData.entries,
  43435. groupKey, i, len, entry, j;
  43436. for (i = 0 , len = entries.length; i < len; ++i) {
  43437. entry = entries[i];
  43438. entry.group.splice(0, 1.0E99, entry.items);
  43439. for (j = 0; j < entry.items.length; j++) {
  43440. itemGroupKeys[source.getKey(entry.items[j])] = entry.group;
  43441. }
  43442. }
  43443. entries = null;
  43444. for (groupKey in me.map) {
  43445. if (!(groupKey in groupData.groups)) {
  43446. (entries || (entries = [])).push(me.map[groupKey]);
  43447. }
  43448. }
  43449. if (entries) {
  43450. me.remove(entries);
  43451. }
  43452. me.sortItems();
  43453. }
  43454. },
  43455. onCollectionRemove: function(source, details) {
  43456. var me = this,
  43457. changeDetails = me.changeDetails,
  43458. itemGroupKeys = me.itemGroupKeys || (me.itemGroupKeys = {}),
  43459. entries, entry, group, i, n, j, removeGroups, item;
  43460. if (source.getCount()) {
  43461. if (changeDetails) {
  43462. item = changeDetails.item || changeDetails.items[0];
  43463. entries = me.createEntries(source, [
  43464. item
  43465. ]).entries;
  43466. entries[0].group = itemGroupKeys['oldKey' in details ? details.oldKey : source.getKey(item)];
  43467. } else {
  43468. entries = me.createEntries(source, details.items).entries;
  43469. }
  43470. for (i = 0 , n = entries.length; i < n; ++i) {
  43471. group = (entry = entries[i]).group;
  43472. if (group) {
  43473. group.remove(entry.items);
  43474. }
  43475. for (j = 0; j < entry.items.length; j++) {
  43476. delete itemGroupKeys[source.getKey(entry.items[j])];
  43477. }
  43478. if (group && !group.length) {
  43479. (removeGroups || (removeGroups = [])).push(group);
  43480. }
  43481. }
  43482. } else
  43483. {
  43484. me.itemGroupKeys = {};
  43485. removeGroups = me.items;
  43486. for (i = 0 , n = removeGroups.length; i < n; ++i) {
  43487. removeGroups[i].clear();
  43488. }
  43489. }
  43490. if (removeGroups) {
  43491. me.remove(removeGroups);
  43492. }
  43493. },
  43494. onCollectionSort: function(source) {
  43495. var me = this,
  43496. sorters = source.getSorters(false),
  43497. items, length, i, group;
  43498. if (sorters) {
  43499. items = me.items;
  43500. length = me.length;
  43501. for (i = 0; i < length; ++i) {
  43502. group = items[i];
  43503. if (group.getSorters() !== sorters) {
  43504. group.setSorters(sorters);
  43505. }
  43506. }
  43507. }
  43508. },
  43509. onCollectionUpdateKey: function(source, details) {
  43510. if (!details.indexChanged) {
  43511. details.oldIndex = source.indexOf(details.item);
  43512. this.syncItemGrouping(source, details);
  43513. }
  43514. },
  43515. addItemsToGroups: function(source, items, at, oldIndex) {
  43516. var me = this,
  43517. itemGroupKeys = me.itemGroupKeys || (me.itemGroupKeys = {}),
  43518. entries = me.createEntries(source, items).entries,
  43519. index = -1,
  43520. sourceStartIndex, entry, i, len, j, group, firstIndex, item;
  43521. for (i = 0 , len = entries.length; i < len; ++i) {
  43522. entry = entries[i];
  43523. group = entry.group;
  43524. if (oldIndex || oldIndex === 0) {
  43525. item = items[0];
  43526. if (group.getCount() > 0 && source.getSorters().getCount() === 0) {
  43527. firstIndex = source.indexOf(group.items[0]);
  43528. if (oldIndex < firstIndex) {
  43529. index = 0;
  43530. } else {
  43531. index = oldIndex - firstIndex;
  43532. }
  43533. }
  43534. if (index === -1) {
  43535. group.add(item);
  43536. } else {
  43537. group.insert(index, item);
  43538. }
  43539. } else {
  43540. if (me.length > 1 && at) {
  43541. sourceStartIndex = source.indexOf(entries[0].group.getAt(0));
  43542. at = Math.max(at - sourceStartIndex, 0);
  43543. }
  43544. entry.group.insert(at != null ? at : group.items.length, entry.items);
  43545. for (j = 0; j < entry.items.length; j++) {
  43546. itemGroupKeys[source.getKey(entry.items[j])] = entry.group;
  43547. }
  43548. }
  43549. }
  43550. me.sortItems();
  43551. },
  43552. createEntries: function(source, items) {
  43553. var me = this,
  43554. groups = {},
  43555. entries = [],
  43556. grouper = me.getGrouper(),
  43557. entry, group, groupKey, i, item, len;
  43558. for (i = 0 , len = items.length; i < len; ++i) {
  43559. groupKey = grouper.getGroupString(item = items[i]);
  43560. if (!(entry = groups[groupKey])) {
  43561. group = me.getGroup(source, groupKey);
  43562. entries.push(groups[groupKey] = entry = {
  43563. group: group,
  43564. items: []
  43565. });
  43566. }
  43567. entry.items.push(item);
  43568. }
  43569. return {
  43570. groups: groups,
  43571. entries: entries
  43572. };
  43573. },
  43574. syncItemGrouping: function(source, details) {
  43575. var me = this,
  43576. itemGroupKeys = me.itemGroupKeys || (me.itemGroupKeys = {}),
  43577. item = details.item,
  43578. oldKey, itemKey, oldGroup, group;
  43579. itemKey = source.getKey(item);
  43580. oldKey = 'oldKey' in details ? details.oldKey : itemKey;
  43581. oldGroup = itemGroupKeys[oldKey];
  43582. group = me.getGroup(source, me.getGrouper().getGroupString(item));
  43583. details.group = group;
  43584. details.oldGroup = oldGroup;
  43585. if (!(details.groupChanged = group !== oldGroup)) {
  43586. oldGroup.itemChanged(item, details.modified, details.oldKey, details);
  43587. } else {
  43588. if (oldGroup) {
  43589. oldGroup.updateKey(item, oldKey, itemKey);
  43590. oldGroup.remove(item);
  43591. if (!oldGroup.length) {
  43592. me.remove(oldGroup);
  43593. }
  43594. }
  43595. me.addItemsToGroups(source, [
  43596. item
  43597. ], null, details.oldIndex);
  43598. }
  43599. delete itemGroupKeys[oldKey];
  43600. itemGroupKeys[itemKey] = group;
  43601. },
  43602. getGroup: function(source, key) {
  43603. var me = this,
  43604. group = me.get(key),
  43605. autoSort = me.getAutoSort();
  43606. if (group) {
  43607. group.setSorters(source.getSorters());
  43608. } else {
  43609. group = me.emptyGroups[key] || Ext.create(Ext.apply({
  43610. xclass: 'Ext.util.Group',
  43611. groupKey: key,
  43612. rootProperty: me.getItemRoot(),
  43613. sorters: source.getSorters()
  43614. }, me.getGroupConfig()));
  43615. group.ejectTime = null;
  43616. me.setAutoSort(false);
  43617. me.add(group);
  43618. me.setAutoSort(autoSort);
  43619. }
  43620. return group;
  43621. },
  43622. getKey: function(item) {
  43623. return item.getGroupKey();
  43624. },
  43625. createSortFn: function() {
  43626. var me = this,
  43627. grouper = me.getGrouper(),
  43628. sorterFn = me.getSorters().getSortFn();
  43629. if (!grouper) {
  43630. return sorterFn;
  43631. }
  43632. return function(lhs, rhs) {
  43633. return grouper.sort(lhs.items[0], rhs.items[0]) || sorterFn(lhs, rhs);
  43634. };
  43635. },
  43636. updateGrouper: function(grouper) {
  43637. var me = this;
  43638. me.grouped = !!(grouper && me.$groupable.getAutoGroup());
  43639. me.onSorterChange();
  43640. me.onEndUpdateSorters(me.getSorters());
  43641. },
  43642. destroy: function() {
  43643. var me = this;
  43644. me.$groupable = null;
  43645. me.destroyGroups(me.items);
  43646. Ext.undefer(me.checkRemoveQueueTimer);
  43647. me.callParent();
  43648. },
  43649. privates: {
  43650. destroyGroups: function(groups) {
  43651. var len = groups.length,
  43652. i;
  43653. for (i = 0; i < len; ++i) {
  43654. groups[i].destroy();
  43655. }
  43656. },
  43657. onGroupRemove: function(collection, info) {
  43658. var me = this,
  43659. groups = info.items,
  43660. emptyGroups = me.emptyGroups,
  43661. len, group, i;
  43662. groups = Ext.Array.from(groups);
  43663. for (i = 0 , len = groups.length; i < len; i++) {
  43664. group = groups[i];
  43665. group.setSorters(null);
  43666. emptyGroups[group.getGroupKey()] = group;
  43667. group.ejectTime = Ext.now();
  43668. }
  43669. me.checkRemoveQueue();
  43670. },
  43671. checkRemoveQueue: function() {
  43672. var me = this,
  43673. emptyGroups = me.emptyGroups,
  43674. groupKey, group, reschedule;
  43675. for (groupKey in emptyGroups) {
  43676. group = emptyGroups[groupKey];
  43677. if (!group.getCount() && Ext.now() - group.ejectTime > me.emptyGroupRetainTime) {
  43678. Ext.destroy(group);
  43679. delete emptyGroups[groupKey];
  43680. } else {
  43681. reschedule = true;
  43682. }
  43683. }
  43684. if (reschedule) {
  43685. Ext.undefer(me.checkRemoveQueueTimer);
  43686. me.checkRemoveQueueTimer = Ext.defer(me.checkRemoveQueue, me.emptyGroupRetainTime, me);
  43687. }
  43688. }
  43689. }
  43690. });
  43691. Ext.define('Ext.data.Store', {
  43692. extend: Ext.data.ProxyStore,
  43693. alias: 'store.store',
  43694. mixins: [
  43695. Ext.data.LocalStore
  43696. ],
  43697. config: {
  43698. data: undefined,
  43699. clearRemovedOnLoad: true,
  43700. clearOnPageLoad: true,
  43701. associatedEntity: null,
  43702. role: null,
  43703. session: null
  43704. },
  43705. addRecordsOptions: {
  43706. addRecords: true
  43707. },
  43708. loadCount: 0,
  43709. complete: false,
  43710. moveMapCount: 0,
  43711. constructor: function(config) {
  43712. var me = this,
  43713. data;
  43714. if (config) {
  43715. if (config.buffered) {
  43716. if (this.self !== Ext.data.Store) {
  43717. Ext.raise('buffered config not supported on derived Store classes. ' + 'Please derive from Ext.data.BufferedStore.');
  43718. }
  43719. return new Ext.data['BufferedStore'](config);
  43720. }
  43721. if (config.remoteGroup) {
  43722. Ext.log.warn('Ext.data.Store: remoteGroup has been removed. Use remoteSort instead.');
  43723. }
  43724. }
  43725. me.callParent([
  43726. config
  43727. ]);
  43728. data = me.inlineData;
  43729. if (data) {
  43730. delete me.inlineData;
  43731. me.loadInlineData(data);
  43732. }
  43733. },
  43734. applyData: function(data, dataCollection) {
  43735. var me = this;
  43736. me.getFields();
  43737. me.getModel();
  43738. if (data && data.isCollection) {
  43739. dataCollection = data;
  43740. } else {
  43741. if (!dataCollection) {
  43742. dataCollection = me.constructDataCollection();
  43743. }
  43744. if (data) {
  43745. if (me.isInitializing) {
  43746. me.inlineData = data;
  43747. } else {
  43748. me.loadData(data);
  43749. }
  43750. }
  43751. }
  43752. return dataCollection;
  43753. },
  43754. loadInlineData: function(data) {
  43755. var me = this,
  43756. proxy = me.getProxy();
  43757. if (proxy && proxy.isMemoryProxy) {
  43758. proxy.setData(data);
  43759. me.suspendEvents();
  43760. me.read();
  43761. me.resumeEvents();
  43762. } else {
  43763. me.removeAll(true);
  43764. me.suspendEvents();
  43765. me.loadData(data);
  43766. me.resumeEvents();
  43767. }
  43768. },
  43769. onCollectionAdd: function(collection, info) {
  43770. this.loadCount = this.loadCount || 1;
  43771. this.onCollectionAddItems(collection, info.items, info);
  43772. },
  43773. onCollectionFilterAdd: function(collection, items) {
  43774. this.onCollectionAddItems(collection, items);
  43775. },
  43776. onCollectionAddItems: function(collection, records, info) {
  43777. var me = this,
  43778. len = records.length,
  43779. lastChunk = info ? !info.next : false,
  43780. removed = me.removed,
  43781. ignoreAdd = me.ignoreCollectionAdd,
  43782. session = me.getSession(),
  43783. replaced = info && info.replaced,
  43784. i, sync, record, replacedItems;
  43785. if (me.activeRanges) {
  43786. me.syncActiveRanges();
  43787. }
  43788. for (i = 0; i < len; ++i) {
  43789. record = records[i];
  43790. if (session) {
  43791. session.adopt(record);
  43792. }
  43793. if (!ignoreAdd) {
  43794. record.join(me);
  43795. if (removed && removed.length) {
  43796. Ext.Array.remove(removed, record);
  43797. }
  43798. sync = sync || record.phantom || record.dirty;
  43799. }
  43800. }
  43801. if (ignoreAdd) {
  43802. return;
  43803. }
  43804. if (replaced) {
  43805. replacedItems = [];
  43806. do {
  43807. Ext.Array.push(replacedItems, replaced.items);
  43808. replaced = replaced.next;
  43809. } while (replaced);
  43810. me.setMoving(replacedItems, true);
  43811. }
  43812. if (info) {
  43813. if (info.replaced) {
  43814. if (lastChunk) {
  43815. me.fireEvent('datachanged', me);
  43816. me.fireEvent('refresh', me);
  43817. }
  43818. } else {
  43819. me.fireEvent('add', me, records, info.at);
  43820. if (lastChunk) {
  43821. me.fireEvent('datachanged', me);
  43822. }
  43823. }
  43824. }
  43825. if (replacedItems) {
  43826. me.setMoving(replacedItems, false);
  43827. }
  43828. me.needsSync = me.needsSync || sync;
  43829. },
  43830. onCollectionBeforeItemChange: function(collection, info) {
  43831. var record = info.item,
  43832. modifiedFieldNames = info.modified || null,
  43833. type = info.meta;
  43834. this.fireEvent('beforeupdate', this, record, type, modifiedFieldNames, info);
  43835. },
  43836. onCollectionFilteredItemChange: function() {
  43837. this.onCollectionItemChange.apply(this, arguments);
  43838. },
  43839. onCollectionItemChange: function(collection, info) {
  43840. var me = this,
  43841. record = info.item,
  43842. modifiedFieldNames = info.modified || null,
  43843. type = info.meta;
  43844. if (me.fireChangeEvent(record)) {
  43845. me.onUpdate(record, type, modifiedFieldNames, info);
  43846. me.fireEvent('update', me, record, type, modifiedFieldNames, info);
  43847. me.fireEvent('datachanged', me);
  43848. }
  43849. },
  43850. afterChange: function(record, modifiedFieldNames, type) {
  43851. this.getData().itemChanged(record, modifiedFieldNames || null, undefined, type);
  43852. },
  43853. afterCommit: function(record, modifiedFieldNames) {
  43854. this.afterChange(record, modifiedFieldNames, Ext.data.Model.COMMIT);
  43855. },
  43856. afterEdit: function(record, modifiedFieldNames) {
  43857. this.needsSync = this.needsSync || record.dirty;
  43858. this.afterChange(record, modifiedFieldNames, Ext.data.Model.EDIT);
  43859. },
  43860. afterReject: function(record) {
  43861. this.afterChange(record, null, Ext.data.Model.REJECT);
  43862. },
  43863. afterDrop: function(record) {
  43864. this.getData().remove(record);
  43865. },
  43866. afterErase: function(record) {
  43867. this.removeFromRemoved(record);
  43868. },
  43869. addSorted: function(record) {
  43870. var me = this,
  43871. remote = me.getRemoteSort(),
  43872. data = me.getData(),
  43873. index;
  43874. if (remote) {
  43875. data.setSorters(me.getSorters());
  43876. }
  43877. index = data.findInsertionIndex(record);
  43878. if (remote) {
  43879. data.setSorters(null);
  43880. }
  43881. return me.insert(index, record);
  43882. },
  43883. remove: function(records, isMove, silent) {
  43884. var me = this,
  43885. data = me.getDataSource(),
  43886. len, i, toRemove, record;
  43887. if (records) {
  43888. if (records.isModel) {
  43889. if (data.indexOf(records) > -1) {
  43890. toRemove = [
  43891. records
  43892. ];
  43893. len = 1;
  43894. } else {
  43895. len = 0;
  43896. }
  43897. } else {
  43898. toRemove = [];
  43899. for (i = 0 , len = records.length; i < len; ++i) {
  43900. record = records[i];
  43901. if (record && record.isEntity) {
  43902. if (!data.contains(record)) {
  43903. continue;
  43904. }
  43905. } else if (!(record = data.getAt(record))) {
  43906. continue;
  43907. }
  43908. toRemove.push(record);
  43909. }
  43910. len = toRemove.length;
  43911. }
  43912. }
  43913. if (!len) {
  43914. return [];
  43915. }
  43916. me.removeIsMove = isMove === true;
  43917. me.removeIsSilent = silent;
  43918. data.remove(toRemove);
  43919. me.removeIsSilent = false;
  43920. return toRemove;
  43921. },
  43922. onCollectionRemove: function(collection, info) {
  43923. var me = this,
  43924. removed = me.removed,
  43925. records = info.items,
  43926. len = records.length,
  43927. index = info.at,
  43928. replacement = info.replacement,
  43929. isMove = me.removeIsMove || (replacement && Ext.Array.equals(records, replacement.items)),
  43930. silent = me.removeIsSilent,
  43931. lastChunk = !info.next,
  43932. data = me.getDataSource(),
  43933. i, record;
  43934. if (me.ignoreCollectionRemove) {
  43935. return;
  43936. }
  43937. if (replacement) {
  43938. me.setMoving(replacement.items, true);
  43939. }
  43940. for (i = len - 1; i >= 0; i--) {
  43941. record = records[i];
  43942. if (!data.contains(record)) {
  43943. if (removed && !isMove && !record.phantom && !record.erasing) {
  43944. record.removedFrom = index + i;
  43945. removed.push(record);
  43946. me.needsSync = true;
  43947. } else {
  43948. record.unjoin(me);
  43949. }
  43950. }
  43951. }
  43952. if (!silent) {
  43953. if (!replacement || !replacement.items.length) {
  43954. me.fireEvent('remove', me, records, index, isMove);
  43955. if (lastChunk) {
  43956. me.fireEvent('datachanged', me);
  43957. }
  43958. }
  43959. }
  43960. if (replacement) {
  43961. me.setMoving(replacement.items, false);
  43962. }
  43963. },
  43964. onFilterEndUpdate: function() {
  43965. var me = this;
  43966. if (me.destroying || me.destroyed) {
  43967. return;
  43968. }
  43969. if (me.activeRanges) {
  43970. me.syncActiveRanges();
  43971. }
  43972. me.callParent(arguments);
  43973. me.callObservers('Filter');
  43974. },
  43975. removeAt: function(index, count) {
  43976. var data = this.getData();
  43977. index = Math.max(index, 0);
  43978. if (index < data.length) {
  43979. if (arguments.length === 1) {
  43980. count = 1;
  43981. } else if (!count) {
  43982. return;
  43983. }
  43984. data.removeAt(index, count);
  43985. }
  43986. },
  43987. removeAll: function(silent) {
  43988. var me = this,
  43989. data = me.getData(),
  43990. records = data.getRange();
  43991. if (data.length) {
  43992. me.removeIsSilent = true;
  43993. me.callObservers('BeforeRemoveAll');
  43994. data.removeAll();
  43995. me.removeIsSilent = false;
  43996. if (!silent) {
  43997. me.fireEvent('clear', me, records);
  43998. me.fireEvent('datachanged', me);
  43999. }
  44000. me.callObservers('AfterRemoveAll', [
  44001. !!silent
  44002. ]);
  44003. }
  44004. return records;
  44005. },
  44006. setRecords: function(records) {
  44007. var count = this.getCount();
  44008. ++this.loadCount;
  44009. if (count) {
  44010. this.getData().splice(0, count, records);
  44011. } else {
  44012. this.add(records);
  44013. }
  44014. },
  44015. splice: function(index, toRemove, toAdd) {
  44016. return this.getData().splice(index, toRemove, toAdd);
  44017. },
  44018. onProxyLoad: function(operation) {
  44019. var me = this,
  44020. resultSet = operation.getResultSet(),
  44021. records = operation.getRecords(),
  44022. successful = operation.wasSuccessful();
  44023. if (me.destroyed) {
  44024. return;
  44025. }
  44026. if (resultSet) {
  44027. me.totalCount = resultSet.getTotal();
  44028. }
  44029. if (successful) {
  44030. records = me.processAssociation(records);
  44031. me.loadRecords(records, operation.getAddRecords() ? {
  44032. addRecords: true
  44033. } : undefined);
  44034. me.attachSummaryRecord(resultSet);
  44035. } else {
  44036. me.loading = false;
  44037. }
  44038. if (me.hasListeners.load) {
  44039. me.fireEvent('load', me, records, successful, operation);
  44040. }
  44041. me.callObservers('AfterLoad', [
  44042. records,
  44043. successful,
  44044. operation
  44045. ]);
  44046. },
  44047. onProxyWrite: function(operation) {
  44048. if (operation.wasSuccessful()) {
  44049. this.attachSummaryRecord(operation.getResultSet());
  44050. }
  44051. this.callParent([
  44052. operation
  44053. ]);
  44054. },
  44055. filterDataSource: function(fn) {
  44056. var source = this.getDataSource(),
  44057. items = source.items,
  44058. len = items.length,
  44059. ret = [],
  44060. i;
  44061. for (i = 0; i < len; i++) {
  44062. if (fn.call(source, items[i])) {
  44063. ret.push(items[i]);
  44064. }
  44065. }
  44066. return ret;
  44067. },
  44068. getNewRecords: function() {
  44069. return this.filterDataSource(this.filterNew);
  44070. },
  44071. getRejectRecords: function() {
  44072. return this.filterDataSource(this.filterRejects);
  44073. },
  44074. getUpdatedRecords: function() {
  44075. return this.filterDataSource(this.filterUpdated);
  44076. },
  44077. loadData: function(data, append) {
  44078. var me = this,
  44079. length = data.length,
  44080. newData = [],
  44081. i;
  44082. for (i = 0; i < length; i++) {
  44083. newData.push(me.createModel(data[i]));
  44084. }
  44085. newData = me.processAssociation(newData);
  44086. me.loadRecords(newData, append ? me.addRecordsOptions : undefined);
  44087. },
  44088. loadRawData: function(data, append) {
  44089. var me = this,
  44090. session = me.getSession(),
  44091. result = me.getProxy().getReader().read(data, session ? {
  44092. recordCreator: session.recordCreator
  44093. } : undefined),
  44094. records = result.getRecords(),
  44095. success = result.getSuccess();
  44096. if (success) {
  44097. me.totalCount = result.getTotal();
  44098. me.loadRecords(records, append ? me.addRecordsOptions : undefined);
  44099. }
  44100. return success;
  44101. },
  44102. loadRecords: function(records, options) {
  44103. var me = this,
  44104. length = records.length,
  44105. data = me.getData(),
  44106. addRecords, i, skipSort;
  44107. if (options) {
  44108. addRecords = options.addRecords;
  44109. }
  44110. if (!me.getRemoteSort() && !me.getSortOnLoad()) {
  44111. skipSort = true;
  44112. data.setAutoSort(false);
  44113. }
  44114. if (!addRecords) {
  44115. me.clearData(true);
  44116. }
  44117. me.loading = false;
  44118. me.ignoreCollectionAdd = true;
  44119. me.callObservers('BeforePopulate');
  44120. data.add(records);
  44121. me.ignoreCollectionAdd = false;
  44122. if (skipSort) {
  44123. data.setAutoSort(true);
  44124. }
  44125. for (i = 0; i < length; i++) {
  44126. records[i].join(me);
  44127. }
  44128. if (!me.isEmptyStore) {
  44129. ++me.loadCount;
  44130. me.complete = true;
  44131. }
  44132. if (me.hasListeners.datachanged) {
  44133. me.fireEvent('datachanged', me);
  44134. }
  44135. if (me.hasListeners.refresh) {
  44136. me.fireEvent('refresh', me);
  44137. }
  44138. me.callObservers('AfterPopulate');
  44139. },
  44140. loadPage: function(page, options) {
  44141. var me = this,
  44142. size = me.getPageSize();
  44143. me.currentPage = page;
  44144. options = Ext.apply({
  44145. page: page,
  44146. start: (page - 1) * size,
  44147. limit: size,
  44148. addRecords: !me.getClearOnPageLoad()
  44149. }, options);
  44150. me.read(options);
  44151. },
  44152. nextPage: function(options) {
  44153. this.loadPage(this.currentPage + 1, options);
  44154. },
  44155. previousPage: function(options) {
  44156. this.loadPage(this.currentPage - 1, options);
  44157. },
  44158. clearData: function(isLoad) {
  44159. var me = this,
  44160. removed = me.removed,
  44161. data = me.getDataSource(),
  44162. clearRemovedOnLoad = me.getClearRemovedOnLoad(),
  44163. needsUnjoinCheck = removed && isLoad && !clearRemovedOnLoad,
  44164. records, record, i, len;
  44165. if (data) {
  44166. records = data.items;
  44167. for (i = 0 , len = records.length; i < len; ++i) {
  44168. record = records[i];
  44169. if (needsUnjoinCheck && Ext.Array.contains(removed, record)) {
  44170. continue;
  44171. }
  44172. record.unjoin(me);
  44173. }
  44174. me.ignoreCollectionRemove = true;
  44175. me.callObservers('BeforeClear');
  44176. data.removeAll();
  44177. me.ignoreCollectionRemove = false;
  44178. me.callObservers('AfterClear');
  44179. }
  44180. if (removed && (!isLoad || clearRemovedOnLoad)) {
  44181. removed.length = 0;
  44182. }
  44183. },
  44184. onIdChanged: function(rec, oldId, newId) {
  44185. this.getData().updateKey(rec, oldId);
  44186. this.fireEvent('idchanged', this, rec, oldId, newId);
  44187. },
  44188. commitChanges: function() {
  44189. var me = this,
  44190. recs = me.getModifiedRecords(),
  44191. len = recs.length,
  44192. i = 0;
  44193. Ext.suspendLayouts();
  44194. me.beginUpdate();
  44195. for (; i < len; i++) {
  44196. recs[i].commit();
  44197. }
  44198. me.cleanRemoved();
  44199. me.endUpdate();
  44200. Ext.resumeLayouts(true);
  44201. me.fireEvent('commit', me);
  44202. },
  44203. filterNewOnly: function(item) {
  44204. return item.phantom === true;
  44205. },
  44206. filterRejects: function(item) {
  44207. return item.phantom || item.dirty;
  44208. },
  44209. rejectChanges: function() {
  44210. var me = this,
  44211. recs = me.getRejectRecords(),
  44212. len = recs.length,
  44213. i, rec, toRemove, sorted, data, currentAutoSort;
  44214. Ext.suspendLayouts();
  44215. me.beginUpdate();
  44216. for (i = 0; i < len; i++) {
  44217. rec = recs[i];
  44218. if (rec.phantom) {
  44219. toRemove = toRemove || [];
  44220. toRemove.push(rec);
  44221. } else {
  44222. rec.reject();
  44223. }
  44224. }
  44225. if (toRemove) {
  44226. me.remove(toRemove);
  44227. for (i = 0 , len = toRemove.length; i < len; ++i) {
  44228. toRemove[i].reject();
  44229. }
  44230. }
  44231. recs = me.getRawRemovedRecords();
  44232. if (recs) {
  44233. len = recs.length;
  44234. sorted = !me.getRemoteSort() && me.isSorted();
  44235. if (sorted) {
  44236. data = me.getData();
  44237. currentAutoSort = data.getAutoSort();
  44238. data.setAutoSort(false);
  44239. }
  44240. for (i = len - 1; i >= 0; i--) {
  44241. rec = recs[i];
  44242. rec.reject();
  44243. if (!sorted) {
  44244. me.insert(rec.removedFrom || 0, rec);
  44245. }
  44246. }
  44247. if (sorted) {
  44248. data.setAutoSort(currentAutoSort);
  44249. me.add(recs);
  44250. }
  44251. recs.length = 0;
  44252. }
  44253. me.endUpdate();
  44254. Ext.resumeLayouts(true);
  44255. me.fireEvent('reject', me);
  44256. },
  44257. doDestroy: function() {
  44258. var me = this,
  44259. task = me.loadTask,
  44260. data = me.getData(),
  44261. source = data.getSource();
  44262. me.clearData();
  44263. me.setSession(null);
  44264. me.observers = null;
  44265. if (task) {
  44266. task.cancel();
  44267. me.loadTask = null;
  44268. }
  44269. if (source) {
  44270. source.destroy();
  44271. }
  44272. me.callParent();
  44273. },
  44274. privates: {
  44275. commitOptions: {
  44276. commit: true
  44277. },
  44278. attachSummaryRecord: function(resultSet) {
  44279. if (!resultSet) {
  44280. return;
  44281. }
  44282. var me = this,
  44283. summary = resultSet.getSummaryData(),
  44284. grouper = me.getGrouper(),
  44285. current = me.summaryRecord,
  44286. commitOptions = me.commitOptions,
  44287. groups, len, i, rec, group;
  44288. if (summary) {
  44289. if (current) {
  44290. current.set(summary.data, commitOptions);
  44291. } else {
  44292. me.summaryRecord = summary;
  44293. summary.isRemote = true;
  44294. }
  44295. }
  44296. if (grouper) {
  44297. summary = resultSet.getGroupData();
  44298. if (summary) {
  44299. groups = me.getGroups();
  44300. for (i = 0 , len = summary.length; i < len; ++i) {
  44301. rec = summary[i];
  44302. group = groups.getItemGroup(rec);
  44303. if (group) {
  44304. current = group.summaryRecord;
  44305. if (current) {
  44306. current.set(rec.data, commitOptions);
  44307. } else {
  44308. group.summaryRecord = rec;
  44309. rec.isRemote = true;
  44310. }
  44311. }
  44312. }
  44313. }
  44314. }
  44315. },
  44316. fetch: function(options) {
  44317. options = Ext.apply({}, options);
  44318. this.setLoadOptions(options);
  44319. var operation = this.createOperation('read', options);
  44320. operation.execute();
  44321. },
  44322. fireChangeEvent: function(record) {
  44323. return this.getDataSource().contains(record);
  44324. },
  44325. onBeforeLoad: function(operation) {
  44326. this.callObservers('BeforeLoad', [
  44327. operation
  44328. ]);
  44329. },
  44330. onRemoteFilterSet: function(filters, remoteFilter) {
  44331. if (filters) {
  44332. this.getData().setFilters(remoteFilter ? null : filters);
  44333. }
  44334. this.callParent([
  44335. filters,
  44336. remoteFilter
  44337. ]);
  44338. },
  44339. onRemoteSortSet: function(sorters, remoteSort) {
  44340. var data = this.getData();
  44341. if (sorters) {
  44342. data.setSorters(remoteSort ? null : sorters);
  44343. }
  44344. data.setAutoGroup(!remoteSort);
  44345. this.callParent([
  44346. sorters,
  44347. remoteSort
  44348. ]);
  44349. },
  44350. isMoving: function(records, getMap) {
  44351. var map = this.moveMap,
  44352. moving = 0,
  44353. len, i;
  44354. if (map) {
  44355. if (records) {
  44356. if (Ext.isArray(records)) {
  44357. for (i = 0 , len = records.length; i < len; ++i) {
  44358. moving += map[records[i].id] ? 1 : 0;
  44359. }
  44360. } else if (map[records.id]) {
  44361. ++moving;
  44362. }
  44363. } else {
  44364. moving = getMap ? map : this.moveMapCount;
  44365. }
  44366. }
  44367. return moving;
  44368. },
  44369. setLoadOptions: function(options) {
  44370. var me = this,
  44371. pageSize = me.getPageSize(),
  44372. session, grouper;
  44373. if (me.getRemoteSort() && !options.grouper) {
  44374. grouper = me.getGrouper();
  44375. if (grouper) {
  44376. options.grouper = grouper;
  44377. }
  44378. }
  44379. if (pageSize || 'start' in options || 'limit' in options || 'page' in options) {
  44380. options.page = options.page != null ? options.page : me.currentPage;
  44381. options.start = (options.start !== undefined) ? options.start : (options.page - 1) * pageSize;
  44382. options.limit = options.limit != null ? options.limit : pageSize;
  44383. me.currentPage = options.page;
  44384. }
  44385. options.addRecords = options.addRecords || false;
  44386. if (!options.recordCreator) {
  44387. session = me.getSession();
  44388. if (session) {
  44389. options.recordCreator = session.recordCreator;
  44390. }
  44391. }
  44392. me.callParent([
  44393. options
  44394. ]);
  44395. },
  44396. setMoving: function(records, isMoving) {
  44397. var me = this,
  44398. map = me.moveMap || (me.moveMap = {}),
  44399. len = records.length,
  44400. i, id;
  44401. for (i = 0; i < len; ++i) {
  44402. id = records[i].id;
  44403. if (isMoving) {
  44404. if (map[id]) {
  44405. ++map[id];
  44406. } else {
  44407. map[id] = 1;
  44408. ++me.moveMapCount;
  44409. }
  44410. } else {
  44411. if (--map[id] === 0) {
  44412. delete map[id];
  44413. --me.moveMapCount;
  44414. }
  44415. }
  44416. }
  44417. if (me.moveMapCount === 0) {
  44418. me.moveMap = null;
  44419. }
  44420. },
  44421. processAssociation: function(records) {
  44422. var me = this,
  44423. associatedEntity = me.getAssociatedEntity();
  44424. if (associatedEntity) {
  44425. records = me.getRole().processLoad(me, associatedEntity, records, me.getSession());
  44426. }
  44427. return records;
  44428. }
  44429. }
  44430. });
  44431. Ext.define('Ext.data.reader.Array', {
  44432. extend: Ext.data.reader.Json,
  44433. alternateClassName: 'Ext.data.ArrayReader',
  44434. alias: 'reader.array',
  44435. config: {
  44436. totalProperty: undefined,
  44437. successProperty: undefined
  44438. },
  44439. createFieldAccessor: function(field) {
  44440. var oldMap = field.mapping,
  44441. index = field.hasMapping() ? oldMap : field.ordinal,
  44442. result;
  44443. field.mapping = index;
  44444. result = this.callParent(arguments);
  44445. field.mapping = oldMap;
  44446. return result;
  44447. },
  44448. getModelData: function(raw) {
  44449. return {};
  44450. }
  44451. });
  44452. Ext.define('Ext.data.ArrayStore', {
  44453. extend: Ext.data.Store,
  44454. alias: 'store.array',
  44455. alternateClassName: [
  44456. 'Ext.data.SimpleStore'
  44457. ],
  44458. config: {
  44459. proxy: {
  44460. type: 'memory',
  44461. reader: 'array'
  44462. }
  44463. },
  44464. loadData: function(data, append) {
  44465. if (this.expandData) {
  44466. var r = [],
  44467. i = 0,
  44468. ln = data.length;
  44469. for (; i < ln; i++) {
  44470. r[r.length] = [
  44471. data[i]
  44472. ];
  44473. }
  44474. data = r;
  44475. }
  44476. this.callParent([
  44477. data,
  44478. append
  44479. ]);
  44480. }
  44481. });
  44482. Ext.define('Ext.data.StoreManager', {
  44483. extend: Ext.util.MixedCollection,
  44484. alternateClassName: [
  44485. 'Ext.StoreMgr',
  44486. 'Ext.data.StoreMgr',
  44487. 'Ext.StoreManager'
  44488. ],
  44489. singleton: true,
  44490. register: function() {
  44491. for (var i = 0,
  44492. s; (s = arguments[i]); i++) {
  44493. this.add(s);
  44494. }
  44495. },
  44496. unregister: function() {
  44497. for (var i = 0,
  44498. s; (s = arguments[i]); i++) {
  44499. this.remove(this.lookup(s));
  44500. }
  44501. },
  44502. lookup: function(store, defaultType) {
  44503. if (Ext.isArray(store)) {
  44504. var first = store[0],
  44505. data = store,
  44506. arrays, fields, i, len;
  44507. if (Ext.isObject(first)) {
  44508. store = {
  44509. data: data
  44510. };
  44511. } else {
  44512. arrays = Ext.isArray(first);
  44513. fields = [
  44514. 'field1'
  44515. ];
  44516. if (arrays) {
  44517. for (i = 2 , len = first.length; i <= len; ++i) {
  44518. fields.push('field' + i);
  44519. }
  44520. } else {
  44521. data = [];
  44522. for (i = 0 , len = store.length; i < len; ++i) {
  44523. data.push([
  44524. store[i]
  44525. ]);
  44526. }
  44527. }
  44528. return new Ext.data.ArrayStore({
  44529. data: data,
  44530. fields: fields,
  44531. autoDestroy: true,
  44532. autoCreated: true,
  44533. expanded: !arrays
  44534. });
  44535. }
  44536. }
  44537. if (Ext.isString(store)) {
  44538. return this.get(store);
  44539. } else {
  44540. return Ext.Factory.store(store, defaultType);
  44541. }
  44542. },
  44543. getKey: function(o) {
  44544. return o.storeId;
  44545. },
  44546. addEmptyStore: function() {
  44547. var emptyStore = this.$emptyStore,
  44548. destoryable = {
  44549. destroy: Ext.emptyFn
  44550. };
  44551. if (!emptyStore) {
  44552. emptyStore = this.$emptyStore = Ext.regStore('ext-empty-store', {
  44553. proxy: 'memory',
  44554. useModelWarning: false
  44555. });
  44556. emptyStore.isEmptyStore = true;
  44557. emptyStore.on = emptyStore.addListener = function() {
  44558. return destoryable;
  44559. };
  44560. emptyStore.un = emptyStore.removeListener = Ext.emptyFn;
  44561. emptyStore.add = emptyStore.remove = emptyStore.insert = emptyStore.destroy = emptyStore.loadData = function() {
  44562. Ext.raise('Cannot modify ext-empty-store');
  44563. };
  44564. }
  44565. this.add(emptyStore);
  44566. },
  44567. clear: function() {
  44568. this.callParent();
  44569. this.addEmptyStore();
  44570. }
  44571. }, function() {
  44572. Ext.regStore = function(id, config) {
  44573. var store;
  44574. if (Ext.isObject(id)) {
  44575. config = id;
  44576. } else {
  44577. if (Ext.data.StoreManager.containsKey(id)) {
  44578. return Ext.data.StoreManager.lookup(id);
  44579. }
  44580. config.storeId = id;
  44581. }
  44582. if (config instanceof Ext.data.Store) {
  44583. store = config;
  44584. } else {
  44585. store = new Ext.data.Store(config);
  44586. }
  44587. Ext.data.StoreManager.register(store);
  44588. return store;
  44589. };
  44590. Ext.getStore = function(name) {
  44591. return Ext.data.StoreManager.lookup(name);
  44592. };
  44593. Ext.data.StoreManager.addEmptyStore();
  44594. });
  44595. Ext.define('Ext.app.domain.Store', {
  44596. extend: Ext.app.EventDomain,
  44597. singleton: true,
  44598. type: 'store',
  44599. prefix: 'store.',
  44600. idMatchRe: /^\#/,
  44601. constructor: function() {
  44602. var me = this;
  44603. me.callParent();
  44604. me.monitor(Ext.data.AbstractStore);
  44605. },
  44606. match: function(target, selector) {
  44607. var result = false,
  44608. alias = target.alias;
  44609. if (selector === '*') {
  44610. result = true;
  44611. } else if (this.idMatchRe.test(selector)) {
  44612. result = target.getStoreId() === selector.substring(1);
  44613. } else if (alias) {
  44614. result = Ext.Array.indexOf(alias, this.prefix + selector) > -1;
  44615. }
  44616. return result;
  44617. }
  44618. });
  44619. Ext.define('Ext.app.Controller', {
  44620. extend: Ext.app.BaseController,
  44621. statics: {
  44622. strings: {
  44623. model: {
  44624. getter: 'getModel',
  44625. upper: 'Model'
  44626. },
  44627. view: {
  44628. getter: 'getView',
  44629. upper: 'View'
  44630. },
  44631. controller: {
  44632. getter: 'getController',
  44633. upper: 'Controller'
  44634. },
  44635. store: {
  44636. getter: 'getStore',
  44637. upper: 'Store'
  44638. },
  44639. profile: {
  44640. getter: 'getProfile',
  44641. upper: 'Profiles'
  44642. }
  44643. },
  44644. controllerRegex: /^(.*)\.controller\./,
  44645. profileRegex: /^(.*)\.profile\./,
  44646. createGetter: function(baseGetter, name) {
  44647. return function() {
  44648. return this[baseGetter](name);
  44649. };
  44650. },
  44651. getGetterName: function(name, kindUpper) {
  44652. var fn = 'get',
  44653. parts = name.split('.'),
  44654. numParts = parts.length,
  44655. index;
  44656. for (index = 0; index < numParts; index++) {
  44657. fn += Ext.String.capitalize(parts[index]);
  44658. }
  44659. fn += kindUpper;
  44660. return fn;
  44661. },
  44662. resolveNamespace: function(cls, data) {
  44663. var Controller = Ext.app.Controller,
  44664. namespaceRe = cls.prototype.isProfile ? Controller.profileRegex : Controller.controllerRegex,
  44665. className, namespace, match;
  44666. className = Ext.getClassName(cls);
  44667. namespace = data.$namespace || data.namespace || Ext.app.getNamespace(className) || ((match = namespaceRe.exec(className)) && match[1]);
  44668. if (!namespace) {
  44669. Ext.log.warn("Missing namespace for " + className + ", please define it " + "in namespaces property of your Application class.");
  44670. }
  44671. return namespace;
  44672. },
  44673. processDependencies: function(cls, requires, namespace, kind, names, profileName) {
  44674. if (!names || !names.length) {
  44675. return;
  44676. }
  44677. var me = this,
  44678. strings = me.strings[kind],
  44679. o, absoluteName, shortName, name, j, subLn, getterName, getter;
  44680. if (!Ext.isArray(names)) {
  44681. names = [
  44682. names
  44683. ];
  44684. }
  44685. for (j = 0 , subLn = names.length; j < subLn; j++) {
  44686. name = names[j];
  44687. o = me.getFullName(name, kind, namespace, profileName);
  44688. names[j] = absoluteName = o.absoluteName;
  44689. shortName = o.shortName;
  44690. requires.push(absoluteName);
  44691. getterName = me.getGetterName(shortName, strings.upper);
  44692. if (!cls[getterName]) {
  44693. cls[getterName] = getter = me.createGetter(strings.getter, name);
  44694. }
  44695. else if (getterName === 'getMainView') {
  44696. Ext.log.warn('Cannot have a view named \'Main\' - getter conflicts with mainView config.');
  44697. }
  44698. if (getter && kind !== 'controller') {
  44699. getter['Ext.app.getter'] = true;
  44700. }
  44701. }
  44702. },
  44703. getFullName: function(name, kind, namespace, profileName) {
  44704. var shortName = name,
  44705. sep, absoluteName;
  44706. if ((sep = name.indexOf('@')) > 0) {
  44707. shortName = name.substring(0, sep);
  44708. absoluteName = name.substring(sep + 1) + '.' + shortName;
  44709. }
  44710. else if (name.indexOf('.') > 0 && (Ext.ClassManager.isCreated(name) || this.hasRegisteredPrefix(name))) {
  44711. absoluteName = name;
  44712. shortName = name.replace(namespace + '.' + kind + '.', '');
  44713. } else {
  44714. if (!namespace) {
  44715. Ext.log.warn("Cannot find namespace for " + kind + " " + name + ", " + "assuming it is fully qualified class name");
  44716. }
  44717. if (namespace) {
  44718. absoluteName = namespace + '.' + kind + '.' + (profileName ? profileName + '.' + name : name);
  44719. shortName = name;
  44720. } else {
  44721. absoluteName = name;
  44722. }
  44723. }
  44724. return {
  44725. absoluteName: absoluteName,
  44726. shortName: shortName
  44727. };
  44728. },
  44729. hasRegisteredPrefix: function(className) {
  44730. var inventory = Ext.ClassManager,
  44731. prefix = inventory.getPrefix(className);
  44732. return prefix && prefix !== className;
  44733. }
  44734. },
  44735. models: null,
  44736. views: null,
  44737. stores: null,
  44738. controllers: null,
  44739. config: {
  44740. application: null,
  44741. refs: null,
  44742. active: true,
  44743. moduleClassName: null
  44744. },
  44745. onClassExtended: function(cls, data, hooks) {
  44746. var onBeforeClassCreated = hooks.onBeforeCreated;
  44747. hooks.onBeforeCreated = function(cls, data) {
  44748. var Controller = Ext.app.Controller,
  44749. requires = [],
  44750. namespace, proto;
  44751. proto = cls.prototype;
  44752. namespace = Controller.resolveNamespace(cls, data);
  44753. if (namespace) {
  44754. proto.$namespace = namespace;
  44755. }
  44756. Controller.processDependencies(proto, requires, namespace, 'model', data.models);
  44757. Controller.processDependencies(proto, requires, namespace, 'view', data.views);
  44758. Controller.processDependencies(proto, requires, namespace, 'store', data.stores);
  44759. Controller.processDependencies(proto, requires, namespace, 'controller', data.controllers);
  44760. Ext.require(requires, Ext.Function.pass(onBeforeClassCreated, arguments, this));
  44761. };
  44762. },
  44763. constructor: function(config) {
  44764. this.initAutoGetters();
  44765. this.callParent([
  44766. config
  44767. ]);
  44768. },
  44769. normalizeRefs: function(refs) {
  44770. var me = this,
  44771. newRefs = [];
  44772. if (refs) {
  44773. if (Ext.isObject(refs)) {
  44774. Ext.Object.each(refs, function(key, value) {
  44775. if (Ext.isString(value)) {
  44776. value = {
  44777. selector: value
  44778. };
  44779. }
  44780. value.ref = key;
  44781. newRefs.push(value);
  44782. });
  44783. } else if (Ext.isArray(refs)) {
  44784. newRefs = Ext.Array.merge(newRefs, refs);
  44785. }
  44786. }
  44787. refs = me.refs;
  44788. if (refs) {
  44789. me.refs = null;
  44790. refs = me.normalizeRefs(refs);
  44791. if (refs) {
  44792. newRefs = Ext.Array.merge(newRefs, refs);
  44793. }
  44794. }
  44795. return newRefs;
  44796. },
  44797. getRefMap: function() {
  44798. var me = this,
  44799. refMap = me._refMap,
  44800. refs, ref, ln, i;
  44801. if (!refMap) {
  44802. refs = me.getRefs();
  44803. refMap = me._refMap = {};
  44804. if (refs) {
  44805. for (i = 0 , ln = refs.length; i < ln; i++) {
  44806. ref = refs[i];
  44807. refMap[ref.ref] = ref.selector;
  44808. }
  44809. }
  44810. }
  44811. return refMap;
  44812. },
  44813. applyId: function(id) {
  44814. return id || Ext.app.Controller.getFullName(this.$className, 'controller', this.$namespace).shortName;
  44815. },
  44816. applyRefs: function(refs) {
  44817. return this.normalizeRefs(Ext.clone(refs));
  44818. },
  44819. updateRefs: function(refs) {
  44820. if (refs) {
  44821. this.ref(refs);
  44822. }
  44823. },
  44824. initAutoGetters: function() {
  44825. var proto = this.self.prototype,
  44826. prop, fn;
  44827. for (prop in proto) {
  44828. fn = proto[prop];
  44829. if (fn && fn['Ext.app.getter']) {
  44830. fn.call(this);
  44831. }
  44832. }
  44833. },
  44834. doInit: function(app) {
  44835. var me = this;
  44836. if (!me._initialized) {
  44837. me.init(app);
  44838. me._initialized = true;
  44839. }
  44840. },
  44841. finishInit: function(app) {
  44842. var me = this,
  44843. controllers = me.controllers,
  44844. controller, i, l;
  44845. if (me._initialized && controllers && controllers.length) {
  44846. for (i = 0 , l = controllers.length; i < l; i++) {
  44847. controller = me.getController(controllers[i]);
  44848. controller.finishInit(app);
  44849. }
  44850. }
  44851. },
  44852. init: Ext.emptyFn,
  44853. onLaunch: Ext.emptyFn,
  44854. activate: function() {
  44855. this.setActive(true);
  44856. },
  44857. deactivate: function() {
  44858. this.setActive(false);
  44859. },
  44860. isActive: function() {
  44861. return this.getActive();
  44862. },
  44863. ref: function(refs) {
  44864. var me = this,
  44865. i = 0,
  44866. length = refs.length,
  44867. info, ref, fn;
  44868. refs = Ext.Array.from(refs);
  44869. me.references = me.references || [];
  44870. for (; i < length; i++) {
  44871. info = refs[i];
  44872. ref = info.ref;
  44873. fn = 'get' + Ext.String.capitalize(ref);
  44874. if (!me[fn]) {
  44875. me[fn] = Ext.Function.pass(me.getRef, [
  44876. ref,
  44877. info
  44878. ], me);
  44879. }
  44880. me.references.push(ref.toLowerCase());
  44881. }
  44882. },
  44883. addRef: function(refs) {
  44884. this.ref(refs);
  44885. },
  44886. getRef: function(ref, info, config) {
  44887. var me = this,
  44888. refCache = me.refCache || (me.refCache = {}),
  44889. cached = refCache[ref];
  44890. info = info || {};
  44891. config = config || {};
  44892. Ext.apply(info, config);
  44893. if (info.forceCreate) {
  44894. return Ext.ComponentManager.create(info, 'component');
  44895. }
  44896. if (!cached) {
  44897. if (info.selector) {
  44898. refCache[ref] = cached = Ext.ComponentQuery.query(info.selector)[0];
  44899. }
  44900. if (!cached && info.autoCreate) {
  44901. refCache[ref] = cached = Ext.ComponentManager.create(info, 'component');
  44902. }
  44903. if (cached) {
  44904. cached.on('destroy', function() {
  44905. refCache[ref] = null;
  44906. });
  44907. }
  44908. }
  44909. return cached;
  44910. },
  44911. hasRef: function(ref) {
  44912. var references = this.references;
  44913. return references && Ext.Array.indexOf(references, ref.toLowerCase()) !== -1;
  44914. },
  44915. getController: function(id) {
  44916. var app = this.getApplication();
  44917. if (id === this.getId()) {
  44918. return this;
  44919. }
  44920. return app && app.getController(id);
  44921. },
  44922. getStore: function(name) {
  44923. var storeId, store;
  44924. storeId = (name.indexOf('@') === -1) ? name : name.split('@')[0];
  44925. store = Ext.StoreManager.get(storeId);
  44926. if (!store) {
  44927. name = Ext.app.Controller.getFullName(name, 'store', this.$namespace);
  44928. if (name) {
  44929. store = Ext.create(name.absoluteName, {
  44930. id: storeId
  44931. });
  44932. }
  44933. }
  44934. return store;
  44935. },
  44936. getModel: function(modelName) {
  44937. var name = Ext.app.Controller.getFullName(modelName, 'model', this.$namespace),
  44938. ret = Ext.ClassManager.get(name.absoluteName);
  44939. if (!ret) {
  44940. ret = Ext.data.schema.Schema.lookupEntity(modelName);
  44941. }
  44942. return ret;
  44943. },
  44944. getProfile: function(name) {
  44945. name = Ext.app.Controller.getFullName(name, 'profile', this.$namespace);
  44946. return name;
  44947. },
  44948. getView: function(view) {
  44949. var name = Ext.app.Controller.getFullName(view, 'view', this.$namespace);
  44950. return name && Ext.ClassManager.get(name.absoluteName);
  44951. },
  44952. destroy: function(destroyRefs, fromApp) {
  44953. var me = this,
  44954. app = me.application,
  44955. refCache, ref;
  44956. if (!fromApp && app) {
  44957. app.unregister(me);
  44958. }
  44959. me.application = null;
  44960. if (destroyRefs) {
  44961. refCache = me.refCache;
  44962. for (ref in refCache) {
  44963. if (refCache.hasOwnProperty(ref)) {
  44964. Ext.destroy(refCache[ref]);
  44965. }
  44966. }
  44967. }
  44968. me.callParent();
  44969. }
  44970. });
  44971. Ext.define('Ext.app.Application', {
  44972. extend: Ext.app.Controller,
  44973. isApplication: true,
  44974. scope: undefined,
  44975. namespaces: [],
  44976. paths: null,
  44977. config: {
  44978. name: '',
  44979. appProperty: 'app',
  44980. profiles: [],
  44981. currentProfile: null,
  44982. mainView: {
  44983. $value: null,
  44984. lazy: true
  44985. },
  44986. defaultToken: null,
  44987. glyphFontFamily: null,
  44988. quickTips: true,
  44989. router: null
  44990. },
  44991. onClassExtended: function(cls, data, hooks) {
  44992. var Controller = Ext.app.Controller,
  44993. proto = cls.prototype,
  44994. requires = [],
  44995. onBeforeClassCreated, paths, namespace, ns;
  44996. namespace = data.name || cls.superclass.name;
  44997. if (namespace) {
  44998. data.$namespace = namespace;
  44999. Ext.app.addNamespaces(namespace);
  45000. }
  45001. if (data.namespaces) {
  45002. Ext.app.addNamespaces(data.namespaces);
  45003. }
  45004. if (data['paths processed']) {
  45005. delete data['paths processed'];
  45006. } else {
  45007. Ext.app.setupPaths(namespace, ('appFolder' in data) ? data.appFolder : cls.superclass.appFolder, data.paths);
  45008. }
  45009. Controller.processDependencies(proto, requires, namespace, 'profile', data.profiles);
  45010. proto.getDependencies(cls, data, requires);
  45011. if (requires.length) {
  45012. onBeforeClassCreated = hooks.onBeforeCreated;
  45013. hooks.onBeforeCreated = function(cls, data) {
  45014. var args = Ext.Array.clone(arguments);
  45015. if (data.__handleRequires) {
  45016. data.__handleRequires.call(this, requires, Ext.bind(function() {
  45017. return onBeforeClassCreated.apply(this, args);
  45018. }, this));
  45019. return;
  45020. }
  45021. Ext.require(requires, function() {
  45022. return onBeforeClassCreated.apply(this, args);
  45023. });
  45024. };
  45025. }
  45026. },
  45027. getDependencies: Ext.emptyFn,
  45028. constructor: function(config) {
  45029. var me = this;
  45030. Ext.route.Router.application = me;
  45031. me.callParent([
  45032. config
  45033. ]);
  45034. if (Ext.isEmpty(me.getName())) {
  45035. Ext.raise("[Ext.app.Application] Name property is required");
  45036. }
  45037. me.doInit(me);
  45038. Ext.on('appupdate', me.onAppUpdate, me, {
  45039. single: true
  45040. });
  45041. Ext.Loader.setConfig({
  45042. enabled: true
  45043. });
  45044. this.onProfilesReady();
  45045. },
  45046. applyId: function(id) {
  45047. return id || this.$className;
  45048. },
  45049. updateRouter: function(cfg) {
  45050. if (cfg) {
  45051. Ext.route.Router.setConfig(cfg);
  45052. }
  45053. },
  45054. onAppUpdate: Ext.emptyFn,
  45055. onProfilesReady: function() {
  45056. var me = this,
  45057. profiles = me.getProfiles(),
  45058. length = profiles.length,
  45059. current, i, instance;
  45060. for (i = 0; i < length; i++) {
  45061. instance = Ext.create(profiles[i], {
  45062. application: me
  45063. });
  45064. if (instance.isActive() && !current) {
  45065. current = instance;
  45066. me.setCurrentProfile(current);
  45067. }
  45068. }
  45069. if (current) {
  45070. current.init();
  45071. }
  45072. me.initControllers();
  45073. me.onBeforeLaunch();
  45074. me.finishInitControllers();
  45075. },
  45076. doInit: function(app) {
  45077. this.initNamespace(app);
  45078. this.callParent([
  45079. app
  45080. ]);
  45081. },
  45082. initNamespace: function(me) {
  45083. var appProperty = me.getAppProperty(),
  45084. ns = Ext.namespace(me.getName());
  45085. if (ns) {
  45086. ns.getApplication = function() {
  45087. return me;
  45088. };
  45089. if (appProperty) {
  45090. if (!ns[appProperty]) {
  45091. ns[appProperty] = me;
  45092. }
  45093. else if (ns[appProperty] !== me) {
  45094. Ext.log.warn('An existing reference is being overwritten for ' + name + '.' + appProperty + '. See the appProperty config.');
  45095. }
  45096. }
  45097. }
  45098. },
  45099. initControllers: function() {
  45100. var me = this,
  45101. controllers = Ext.Array.from(me.controllers),
  45102. profile = me.getCurrentProfile(),
  45103. i, ln;
  45104. me.controllers = new Ext.util.MixedCollection();
  45105. for (i = 0 , ln = controllers.length; i < ln; i++) {
  45106. me.getController(controllers[i]);
  45107. }
  45108. if (profile) {
  45109. controllers = profile.getControllers();
  45110. for (i = 0 , ln = controllers.length; i < ln; i++) {
  45111. me.getController(controllers[i]);
  45112. }
  45113. }
  45114. },
  45115. finishInitControllers: function() {
  45116. var me = this,
  45117. controllers, i, l;
  45118. controllers = me.controllers.getRange();
  45119. for (i = 0 , l = controllers.length; i < l; i++) {
  45120. controllers[i].finishInit(me);
  45121. }
  45122. },
  45123. launch: Ext.emptyFn,
  45124. onBeforeLaunch: function() {
  45125. var me = this,
  45126. History = Ext.util.History,
  45127. defaultToken = me.getDefaultToken(),
  45128. currentProfile = me.getCurrentProfile(),
  45129. controllers, c, cLen, controller, token;
  45130. me.initMainView();
  45131. if (currentProfile) {
  45132. currentProfile.launch();
  45133. }
  45134. me.launch.call(me.scope || me);
  45135. me.launched = true;
  45136. me.fireEvent('launch', me);
  45137. controllers = me.controllers.items;
  45138. cLen = controllers.length;
  45139. for (c = 0; c < cLen; c++) {
  45140. controller = controllers[c];
  45141. controller.onLaunch(me);
  45142. }
  45143. if (!History.ready) {
  45144. History.init();
  45145. }
  45146. token = History.getToken();
  45147. if (token || token === defaultToken) {
  45148. Ext.route.Router.onStateChange(token);
  45149. } else if (defaultToken) {
  45150. History.replace(defaultToken);
  45151. }
  45152. if (Ext.Microloader && Ext.Microloader.appUpdate && Ext.Microloader.appUpdate.updated) {
  45153. Ext.Microloader.fireAppUpdate();
  45154. }
  45155. if (!me.cnsTimer) {
  45156. me.cnsTimer = Ext.defer(Ext.ClassManager.clearNamespaceCache, 2000, Ext.ClassManager);
  45157. }
  45158. },
  45159. getModuleClassName: function(name, kind) {
  45160. return Ext.app.Controller.getFullName(name, kind, this.getName()).absoluteName;
  45161. },
  45162. initMainView: function() {
  45163. var me = this,
  45164. currentProfile = me.getCurrentProfile(),
  45165. mainView;
  45166. if (currentProfile) {
  45167. mainView = currentProfile.getMainView();
  45168. }
  45169. if (mainView) {
  45170. me.setMainView(mainView);
  45171. } else {
  45172. me.getMainView();
  45173. }
  45174. },
  45175. applyMainView: function(value) {
  45176. var view = this.getView(value);
  45177. return view.create({
  45178. $initParent: this.viewport
  45179. });
  45180. },
  45181. createController: function(name) {
  45182. return this.getController(name);
  45183. },
  45184. destroyController: function(controller) {
  45185. if (typeof controller === 'string') {
  45186. controller = this.getController(controller, true);
  45187. }
  45188. Ext.destroy(controller);
  45189. },
  45190. getController: function(name, preventCreate) {
  45191. var me = this,
  45192. controllers = me.controllers,
  45193. className, controller, len, i, c, all;
  45194. controller = controllers.get(name);
  45195. if (!controller) {
  45196. all = controllers.items;
  45197. for (i = 0 , len = all.length; i < len; ++i) {
  45198. c = all[i];
  45199. className = c.getModuleClassName();
  45200. if (className && className === name) {
  45201. controller = c;
  45202. break;
  45203. }
  45204. }
  45205. }
  45206. if (!controller && !preventCreate) {
  45207. className = me.getModuleClassName(name, 'controller');
  45208. controller = Ext.create(className, {
  45209. application: me,
  45210. moduleClassName: className
  45211. });
  45212. controllers.add(controller);
  45213. if (me._initialized) {
  45214. controller.doInit(me);
  45215. }
  45216. }
  45217. return controller;
  45218. },
  45219. unregister: function(controller) {
  45220. this.controllers.remove(controller);
  45221. },
  45222. getApplication: function() {
  45223. return this;
  45224. },
  45225. destroy: function(destroyRefs) {
  45226. var me = this,
  45227. controllers = me.controllers,
  45228. ns = Ext.namespace(me.getName()),
  45229. appProp = me.getAppProperty();
  45230. Ext.undefer(me.cnsTimer);
  45231. Ext.un('appupdate', me.onAppUpdate, me);
  45232. Ext.destroy(me.viewport);
  45233. if (controllers) {
  45234. controllers.each(function(controller) {
  45235. controller.destroy(destroyRefs, true);
  45236. });
  45237. }
  45238. me.controllers = null;
  45239. me.callParent([
  45240. destroyRefs,
  45241. true
  45242. ]);
  45243. if (ns && ns[appProp] === me) {
  45244. delete ns[appProp];
  45245. }
  45246. if (Ext.route.Router.application === me) {
  45247. Ext.route.Router.application = null;
  45248. }
  45249. if (Ext.app.Application.instance === me) {
  45250. Ext.app.Application.instance = null;
  45251. }
  45252. },
  45253. updateGlyphFontFamily: function(fontFamily) {
  45254. Ext.setGlyphFontFamily(fontFamily);
  45255. },
  45256. applyProfiles: function(profiles) {
  45257. var me = this;
  45258. return Ext.Array.map(profiles, function(profile) {
  45259. return me.getModuleClassName(profile, "profile");
  45260. });
  45261. }
  45262. }, function() {
  45263. Ext.getApplication = function() {
  45264. return Ext.app.Application.instance;
  45265. };
  45266. });
  45267. Ext.application = function(config) {
  45268. var createApp = function(App) {
  45269. Ext.onReady(function() {
  45270. var Viewport = Ext.viewport;
  45271. Viewport = Viewport && Viewport['Viewport'];
  45272. if (Viewport && Viewport.setup) {
  45273. Viewport.setup(App.prototype.config.viewport);
  45274. }
  45275. Ext.app.Application.instance = new App();
  45276. });
  45277. };
  45278. if (typeof config === "string") {
  45279. Ext.require(config, function() {
  45280. createApp(Ext.ClassManager.get(config));
  45281. });
  45282. } else {
  45283. config = Ext.apply({
  45284. extend: 'Ext.app.Application'
  45285. },
  45286. config);
  45287. Ext.app.setupPaths(config.name, config.appFolder, config.paths);
  45288. config['paths processed'] = true;
  45289. Ext.define(config.name + ".$application", config, function() {
  45290. createApp(this);
  45291. });
  45292. }
  45293. };
  45294. Ext.define('Ext.util.ItemCollection', {
  45295. extend: Ext.util.MixedCollection,
  45296. alternateClassName: 'Ext.ItemCollection',
  45297. getKey: function(item) {
  45298. return item.getItemId && item.getItemId();
  45299. },
  45300. has: function(item) {
  45301. return this.map.hasOwnProperty(item.getId());
  45302. }
  45303. });
  45304. Ext.define('Ext.mixin.Queryable', {
  45305. mixinId: 'queryable',
  45306. isQueryable: true,
  45307. query: function(selector) {
  45308. selector = selector || '*';
  45309. return Ext.ComponentQuery.query(selector, this.getQueryRoot());
  45310. },
  45311. queryBy: function(fn, scope) {
  45312. var out = [],
  45313. items = this.getQueryRoot().getRefItems(true),
  45314. i = 0,
  45315. len = items.length,
  45316. item;
  45317. for (; i < len; ++i) {
  45318. item = items[i];
  45319. if (fn.call(scope || item, item) !== false) {
  45320. out.push(item);
  45321. }
  45322. }
  45323. return out;
  45324. },
  45325. queryById: function(id) {
  45326. return this.down(Ext.makeIdSelector(id));
  45327. },
  45328. child: function(selector) {
  45329. var children = this.getQueryRoot().getRefItems();
  45330. if (selector && selector.isComponent) {
  45331. return this.matchById(children, selector.getItemId());
  45332. }
  45333. if (selector) {
  45334. children = Ext.ComponentQuery.query(selector, children);
  45335. }
  45336. if (children.length) {
  45337. return children[0];
  45338. }
  45339. return null;
  45340. },
  45341. down: function(selector) {
  45342. if (selector && selector.isComponent) {
  45343. return this.matchById(this.getRefItems(true), selector.getItemId());
  45344. }
  45345. selector = selector || '';
  45346. return this.query(selector)[0] || null;
  45347. },
  45348. visitPreOrder: function(selector, fn, scope, extraArgs) {
  45349. Ext.ComponentQuery._visit(true, selector, this.getQueryRoot(), fn, scope, extraArgs);
  45350. },
  45351. visitPostOrder: function(selector, fn, scope, extraArgs) {
  45352. Ext.ComponentQuery._visit(false, selector, this.getQueryRoot(), fn, scope, extraArgs);
  45353. },
  45354. getRefItems: function() {
  45355. return [];
  45356. },
  45357. getQueryRoot: function() {
  45358. return this;
  45359. },
  45360. privates: {
  45361. matchById: function(items, id) {
  45362. var len = items.length,
  45363. i, item;
  45364. for (i = 0; i < len; ++i) {
  45365. item = items[i];
  45366. if (item.getItemId() === id) {
  45367. return item;
  45368. }
  45369. }
  45370. return null;
  45371. }
  45372. }
  45373. });
  45374. Ext.define('Ext.mixin.Container', {
  45375. extend: Ext.Mixin,
  45376. mixinConfig: {
  45377. id: 'container'
  45378. },
  45379. isContainer: true,
  45380. nameHolder: false,
  45381. referenceHolder: false,
  45382. getNamedItems: function() {
  45383. var CM = Ext.ComponentManager;
  45384. if (CM.referencesDirty) {
  45385. CM.fixReferences();
  45386. }
  45387. return this.nameRefs || null;
  45388. },
  45389. getReferences: function() {
  45390. var CM = Ext.ComponentManager;
  45391. if (CM.referencesDirty) {
  45392. CM.fixReferences();
  45393. }
  45394. return this.refs || null;
  45395. },
  45396. lookup: function(ref) {
  45397. var refs = this.getReferences();
  45398. return (refs && refs[ref]) || null;
  45399. },
  45400. lookupName: function(name) {
  45401. var items = this.getNamedItems();
  45402. return (items && items[name]) || null;
  45403. },
  45404. lookupReference: function(ref) {
  45405. return this.lookup(ref);
  45406. },
  45407. privates: {
  45408. attachNameRef: function(component) {
  45409. var me = this,
  45410. key = component.name || component._name,
  45411. entry, nameRefs;
  45412. if (key && !me.destroying && !me.destroyed) {
  45413. nameRefs = me.nameRefs || (me.nameRefs = {});
  45414. entry = nameRefs[key];
  45415. if (!entry) {
  45416. entry = component.shareableName ? [
  45417. component
  45418. ] : component;
  45419. } else if (!entry.isInstance) {
  45420. entry.push(component);
  45421. } else
  45422. {
  45423. Ext.raise('Duplicate name: "' + key + '" on ' + me.id + ' between ' + entry.id + ' and ' + component.id);
  45424. }
  45425. nameRefs[key] = entry;
  45426. }
  45427. },
  45428. attachReference: function(component) {
  45429. var me = this,
  45430. key, refs;
  45431. if (!me.destroying && !me.destroyed) {
  45432. refs = me.refs || (me.refs = {});
  45433. key = component.referenceKey;
  45434. if (refs[key] && refs[key] !== component) {
  45435. Ext.log.warn('Duplicate reference: "' + key + '" on ' + me.id);
  45436. }
  45437. refs[key] = component;
  45438. }
  45439. },
  45440. containerOnAdded: function(component, instanced) {
  45441. if (instanced) {
  45442. Ext.ComponentManager.markReferencesDirty();
  45443. }
  45444. },
  45445. containerOnRemoved: function(destroying) {
  45446. if (!destroying) {
  45447. Ext.ComponentManager.markReferencesDirty();
  45448. }
  45449. },
  45450. initContainerInheritedState: function(inheritedState, inheritedStateInner) {
  45451. var me = this,
  45452. controller = me.getController(),
  45453. session = me.getSession(),
  45454. viewModel = me.getConfig('viewModel', true),
  45455. reference = me.reference,
  45456. referenceHolder = me.referenceHolder;
  45457. if (me.nameHolder) {
  45458. inheritedState.nameHolder = me;
  45459. }
  45460. if (controller) {
  45461. inheritedState.referenceHolder = controller;
  45462. referenceHolder = true;
  45463. } else if (referenceHolder) {
  45464. inheritedState.referenceHolder = me;
  45465. }
  45466. if (referenceHolder) {
  45467. inheritedState.referencePath = '';
  45468. } else if (reference && me.isParentReference) {
  45469. inheritedState.referencePath = me.referenceKey + '.';
  45470. }
  45471. if (session) {
  45472. inheritedState.session = session;
  45473. }
  45474. if (viewModel) {
  45475. inheritedState.viewModelPath = '';
  45476. } else if (reference && me.isParentReference) {
  45477. inheritedState.viewModelPath = me.viewModelKey + '.';
  45478. }
  45479. },
  45480. setupReference: function(reference) {
  45481. var len;
  45482. if (reference && reference.charAt(len = reference.length - 1) === '>') {
  45483. this.isParentReference = true;
  45484. reference = reference.substring(0, len);
  45485. }
  45486. if (reference && !Ext.validIdRe.test(reference)) {
  45487. Ext.Error.raise('Invalid reference "' + reference + '" for ' + this.getId() + ' - not a valid identifier');
  45488. }
  45489. return reference;
  45490. }
  45491. }
  45492. });
  45493. Ext.define('Ext.util.KeyMap', {
  45494. alternateClassName: 'Ext.KeyMap',
  45495. eventName: 'keydown',
  45496. constructor: function(config) {
  45497. var me = this;
  45498. if ((arguments.length !== 1) || (typeof config === 'string') || config.dom || config.tagName || config === document || config.isComponent) {
  45499. Ext.raise("Legacy multi-argument KeyMap constructor is removed. Use a config object instead.");
  45500. }
  45501. Ext.apply(me, config);
  45502. me.bindings = [];
  45503. if (!me.target.isComponent) {
  45504. me.target = Ext.get(me.target);
  45505. }
  45506. if (me.binding) {
  45507. me.addBinding(me.binding);
  45508. } else if (config.key) {
  45509. me.addBinding(config);
  45510. }
  45511. me.enable();
  45512. },
  45513. addBinding: function(binding) {
  45514. var me = this,
  45515. keyCode = binding.key,
  45516. i, len;
  45517. if (me.processing) {
  45518. me.bindings = me.bindings.slice(0);
  45519. }
  45520. if (Ext.isArray(binding)) {
  45521. for (i = 0 , len = binding.length; i < len; i++) {
  45522. me.addBinding(binding[i]);
  45523. }
  45524. return;
  45525. }
  45526. me.bindings.push(Ext.apply({
  45527. keyCode: me.processKeys(keyCode)
  45528. }, binding));
  45529. },
  45530. removeBinding: function(binding) {
  45531. var me = this,
  45532. bindings = me.bindings,
  45533. len = bindings.length,
  45534. i, item, keys;
  45535. if (me.processing) {
  45536. me.bindings = bindings.slice(0);
  45537. }
  45538. keys = me.processKeys(binding.key);
  45539. for (i = 0; i < len; i++) {
  45540. item = bindings[i];
  45541. if ((item.fn || item.handler) === (binding.fn || binding.handler) && item.scope === binding.scope) {
  45542. if (binding.alt === item.alt && binding.ctrl === item.ctrl && binding.shift === item.shift) {
  45543. if (Ext.Array.equals(item.keyCode, keys)) {
  45544. Ext.Array.erase(me.bindings, i, 1);
  45545. return;
  45546. }
  45547. }
  45548. }
  45549. }
  45550. },
  45551. processKeys: function(keyCode) {
  45552. var processed = false,
  45553. key, keys, keyString, len, i;
  45554. if (keyCode.test) {
  45555. return keyCode;
  45556. }
  45557. if (Ext.isString(keyCode)) {
  45558. keys = [];
  45559. keyString = keyCode.toUpperCase();
  45560. for (i = 0 , len = keyString.length; i < len; i++) {
  45561. keys.push(keyString.charCodeAt(i));
  45562. }
  45563. keyCode = keys;
  45564. processed = true;
  45565. }
  45566. if (!Ext.isArray(keyCode)) {
  45567. keyCode = [
  45568. keyCode
  45569. ];
  45570. }
  45571. if (!processed) {
  45572. for (i = 0 , len = keyCode.length; i < len; i++) {
  45573. key = keyCode[i];
  45574. if (Ext.isString(key)) {
  45575. keyCode[i] = key.toUpperCase().charCodeAt(0);
  45576. }
  45577. }
  45578. }
  45579. return keyCode;
  45580. },
  45581. handleTargetEvent: function(event) {
  45582. var me = this,
  45583. bindings, i, len, result;
  45584. if (me.enabled) {
  45585. bindings = me.bindings;
  45586. event = me.processEvent.apply(me.processEventScope || me, arguments);
  45587. if (event) {
  45588. me.lastKeyEvent = event;
  45589. if (me.ignoreInputFields && Ext.fly(event.target).isInputField()) {
  45590. return;
  45591. }
  45592. if (!event.getKey) {
  45593. return event;
  45594. }
  45595. me.processing = true;
  45596. for (i = 0 , len = bindings.length; i < len; i++) {
  45597. result = me.processBinding(bindings[i], event);
  45598. if (result === false) {
  45599. me.processing = false;
  45600. return result;
  45601. }
  45602. }
  45603. me.processing = false;
  45604. }
  45605. }
  45606. },
  45607. processEvent: Ext.identityFn,
  45608. processBinding: function(binding, event) {
  45609. if (this.checkModifiers(binding, event)) {
  45610. var key = event.getKey(),
  45611. handler = binding.fn || binding.handler,
  45612. scope = binding.scope || this,
  45613. keyCode = binding.keyCode,
  45614. defaultEventAction = binding.defaultEventAction,
  45615. i, len, result;
  45616. if (keyCode.test) {
  45617. if (keyCode.test(String.fromCharCode(event.getCharCode()))) {
  45618. result = handler.call(scope, key, event);
  45619. if (result !== true && defaultEventAction) {
  45620. event[defaultEventAction]();
  45621. }
  45622. if (result === false) {
  45623. return result;
  45624. }
  45625. }
  45626. }
  45627. else if (keyCode.length) {
  45628. for (i = 0 , len = keyCode.length; i < len; i++) {
  45629. if (key === keyCode[i]) {
  45630. result = handler.call(scope, key, event);
  45631. if (result !== true && defaultEventAction) {
  45632. event[defaultEventAction]();
  45633. }
  45634. if (result === false) {
  45635. return result;
  45636. }
  45637. break;
  45638. }
  45639. }
  45640. }
  45641. }
  45642. },
  45643. checkModifiers: function(binding, event) {
  45644. var keys = [
  45645. 'shift',
  45646. 'ctrl',
  45647. 'alt'
  45648. ],
  45649. i, len, val, key;
  45650. for (i = 0 , len = keys.length; i < len; i++) {
  45651. key = keys[i];
  45652. val = binding[key];
  45653. if (!(val === undefined || (val === event[key + 'Key']))) {
  45654. return false;
  45655. }
  45656. }
  45657. return true;
  45658. },
  45659. on: function(key, fn, scope) {
  45660. var keyCode, shift, ctrl, alt;
  45661. if (Ext.isObject(key) && !Ext.isArray(key)) {
  45662. keyCode = key.key;
  45663. shift = key.shift;
  45664. ctrl = key.ctrl;
  45665. alt = key.alt;
  45666. } else {
  45667. keyCode = key;
  45668. }
  45669. this.addBinding({
  45670. key: keyCode,
  45671. shift: shift,
  45672. ctrl: ctrl,
  45673. alt: alt,
  45674. fn: fn,
  45675. scope: scope
  45676. });
  45677. },
  45678. un: function(key, fn, scope) {
  45679. var keyCode, shift, ctrl, alt;
  45680. if (Ext.isObject(key) && !Ext.isArray(key)) {
  45681. keyCode = key.key;
  45682. shift = key.shift;
  45683. ctrl = key.ctrl;
  45684. alt = key.alt;
  45685. } else {
  45686. keyCode = key;
  45687. }
  45688. this.removeBinding({
  45689. key: keyCode,
  45690. shift: shift,
  45691. ctrl: ctrl,
  45692. alt: alt,
  45693. fn: fn,
  45694. scope: scope
  45695. });
  45696. },
  45697. isEnabled: function() {
  45698. return !!this.enabled;
  45699. },
  45700. enable: function() {
  45701. var me = this;
  45702. if (!me.enabled) {
  45703. me.target.on(me.eventName, me.handleTargetEvent, me, {
  45704. capture: me.capture,
  45705. priority: me.priority
  45706. });
  45707. me.enabled = true;
  45708. }
  45709. },
  45710. disable: function() {
  45711. var me = this;
  45712. if (me.enabled) {
  45713. if (!me.target.destroyed) {
  45714. me.target.removeListener(me.eventName, me.handleTargetEvent, me);
  45715. }
  45716. me.enabled = false;
  45717. }
  45718. },
  45719. setDisabled: function(disabled) {
  45720. if (disabled) {
  45721. this.disable();
  45722. } else {
  45723. this.enable();
  45724. }
  45725. },
  45726. destroy: function(removeTarget) {
  45727. var me = this,
  45728. target = me.target;
  45729. me.bindings = [];
  45730. me.disable();
  45731. me.target = null;
  45732. if (removeTarget) {
  45733. target.destroy();
  45734. Ext.raise("Using removeTarget argument in KeyMap destructor is not supported.");
  45735. }
  45736. me.callParent();
  45737. }
  45738. });
  45739. Ext.define('Ext.util.KeyNav', {
  45740. alternateClassName: 'Ext.KeyNav',
  45741. disabled: false,
  45742. defaultEventAction: false,
  45743. forceKeyDown: false,
  45744. eventName: 'keypress',
  45745. statics: {
  45746. keyOptions: {
  45747. left: 37,
  45748. right: 39,
  45749. up: 38,
  45750. down: 40,
  45751. space: 32,
  45752. pageUp: 33,
  45753. pageDown: 34,
  45754. del: 46,
  45755. backspace: 8,
  45756. home: 36,
  45757. end: 35,
  45758. enter: 13,
  45759. esc: 27,
  45760. tab: 9
  45761. }
  45762. },
  45763. constructor: function(config) {
  45764. var me = this,
  45765. keymapCfg, map;
  45766. if (arguments.length === 2) {
  45767. Ext.raise("2-argument KeyNav constructor is removed. Use a config object instead.");
  45768. }
  45769. config = config || {};
  45770. keymapCfg = {
  45771. target: config.target,
  45772. ignoreInputFields: config.ignoreInputFields,
  45773. eventName: me.getKeyEvent('forceKeyDown' in config ? config.forceKeyDown : me.forceKeyDown, config.eventName),
  45774. capture: config.capture
  45775. };
  45776. if (me.map) {
  45777. me.map.destroy();
  45778. }
  45779. me.initConfig(config);
  45780. if (config.processEvent) {
  45781. keymapCfg.processEvent = config.processEvent;
  45782. keymapCfg.processEventScope = config.processEventScope || me;
  45783. }
  45784. if (config.priority) {
  45785. keymapCfg.priority = config.priority;
  45786. }
  45787. if (config.keyMap) {
  45788. map = me.map = config.keyMap;
  45789. } else
  45790. {
  45791. map = me.map = new Ext.util.KeyMap(keymapCfg);
  45792. me.destroyKeyMap = true;
  45793. }
  45794. me.addBindings(config);
  45795. map.disable();
  45796. if (!config.disabled) {
  45797. map.enable();
  45798. }
  45799. },
  45800. addBindings: function(bindings) {
  45801. var me = this,
  45802. map = me.map,
  45803. keyCodes = Ext.util.KeyNav.keyOptions,
  45804. Event = Ext.event.Event,
  45805. defaultScope = bindings.scope || me,
  45806. binding, keyName, keyCode;
  45807. for (keyName in bindings) {
  45808. binding = bindings[keyName];
  45809. keyCode = keyName.length === 1 ? keyName.charCodeAt(0) : (keyCodes[keyName] || Event[keyName.toUpperCase()]);
  45810. if (keyCode != null) {
  45811. keyName = keyCode;
  45812. }
  45813. if (binding && (keyName.length === 1 || !isNaN(keyName = parseInt(keyName, 10)))) {
  45814. if (typeof binding === 'function') {
  45815. binding = {
  45816. handler: binding,
  45817. defaultEventAction: (bindings.defaultEventAction !== undefined) ? bindings.defaultEventAction : me.defaultEventAction
  45818. };
  45819. }
  45820. map.addBinding({
  45821. key: keyName,
  45822. ctrl: binding.ctrl,
  45823. shift: binding.shift,
  45824. alt: binding.alt,
  45825. handler: Ext.Function.bind(me.handleEvent, binding.scope || defaultScope, [
  45826. binding.handler || binding.fn,
  45827. me
  45828. ], true),
  45829. defaultEventAction: (binding.defaultEventAction !== undefined) ? binding.defaultEventAction : me.defaultEventAction
  45830. });
  45831. }
  45832. }
  45833. },
  45834. handleEvent: function(keyCode, event, handler, keyNav) {
  45835. keyNav.lastKeyEvent = event;
  45836. return handler.call(this, event);
  45837. },
  45838. destroy: function(removeEl) {
  45839. var me = this;
  45840. if (removeEl) {
  45841. Ext.raise("removeEl argument in KeyNav destructor is not supported anymore.");
  45842. }
  45843. if (me.destroyKeyMap) {
  45844. me.map.destroy(removeEl);
  45845. }
  45846. me.map = null;
  45847. me.callParent();
  45848. },
  45849. enable: function() {
  45850. if (this.map) {
  45851. this.map.enable();
  45852. this.disabled = false;
  45853. }
  45854. },
  45855. disable: function() {
  45856. if (this.map) {
  45857. this.map.disable();
  45858. }
  45859. this.disabled = true;
  45860. },
  45861. setDisabled: function(disabled) {
  45862. this.map.setDisabled(disabled);
  45863. this.disabled = disabled;
  45864. },
  45865. isEnabled: function() {
  45866. return !this.disabled;
  45867. },
  45868. getKeyEvent: function(forceKeyDown, configuredEventName) {
  45869. if (forceKeyDown || (Ext.supports.SpecialKeyDownRepeat && !configuredEventName)) {
  45870. return 'keydown';
  45871. } else {
  45872. return configuredEventName || this.eventName;
  45873. }
  45874. }
  45875. });
  45876. Ext.define('Ext.mixin.FocusableContainer', {
  45877. extend: Ext.Mixin,
  45878. mixinConfig: {
  45879. id: 'focusablecontainer'
  45880. },
  45881. isFocusableContainer: true,
  45882. focusableContainer: false,
  45883. resetFocusPosition: false,
  45884. activeChildTabIndex: 0,
  45885. inactiveChildTabIndex: -1,
  45886. allowFocusingDisabledChildren: false,
  45887. focusableContainerEl: 'el',
  45888. privates: {
  45889. initFocusableContainer: function(clearChildren) {
  45890. var items, i, len;
  45891. if (this.focusableContainer) {
  45892. clearChildren = clearChildren != null ? clearChildren : true;
  45893. this.doInitFocusableContainer(clearChildren);
  45894. } else
  45895. {
  45896. items = this.getFocusables();
  45897. for (i = 0 , len = items.length; i < len; i++) {
  45898. items[i].ownerFocusableContainer = null;
  45899. }
  45900. }
  45901. },
  45902. doInitFocusableContainer: function(clearChildren) {
  45903. var me = this,
  45904. el = me.focusableContainerEl,
  45905. child;
  45906. if (!el.isElement) {
  45907. el = me.focusableContainerEl = me[el];
  45908. }
  45909. if (me.initFocusableContainerKeyNav) {
  45910. me.initFocusableContainerKeyNav(el);
  45911. }
  45912. if (clearChildren) {
  45913. me.clearFocusables();
  45914. if (!me.isDisabled()) {
  45915. child = me.findNextFocusableChild({
  45916. step: 1
  45917. }) || me.findNextFocusableChild({
  45918. beforeRender: true
  45919. });
  45920. if (child) {
  45921. me.activateFocusable(child);
  45922. }
  45923. }
  45924. }
  45925. child = me.findNextFocusableChild({
  45926. firstTabbable: true
  45927. });
  45928. me.activateFocusableContainer(!!child && !me.isDisabled());
  45929. },
  45930. initFocusableContainerKeyNav: function(el) {
  45931. var me = this;
  45932. if (!me.focusableKeyNav) {
  45933. el = el || me.focusableContainerEl;
  45934. me.focusableKeyNav = new Ext.util.KeyNav({
  45935. target: el,
  45936. disabled: true,
  45937. eventName: 'keydown',
  45938. processEvent: me.processFocusableContainerKeyEvent,
  45939. processEventScope: me,
  45940. scope: me,
  45941. tab: me.onFocusableContainerTabKey,
  45942. enter: {
  45943. handler: me.onFocusableContainerEnterKey,
  45944. ctrl: false,
  45945. shift: false,
  45946. alt: false
  45947. },
  45948. space: {
  45949. handler: me.onFocusableContainerSpaceKey,
  45950. ctrl: false,
  45951. shift: false,
  45952. alt: false
  45953. },
  45954. up: {
  45955. handler: me.onFocusableContainerUpKey,
  45956. ctrl: false,
  45957. shift: false,
  45958. alt: false
  45959. },
  45960. down: {
  45961. handler: me.onFocusableContainerDownKey,
  45962. ctrl: false,
  45963. shift: false,
  45964. alt: false
  45965. },
  45966. left: {
  45967. handler: me.onFocusableContainerLeftKey,
  45968. ctrl: false,
  45969. shift: false,
  45970. alt: false
  45971. },
  45972. right: {
  45973. handler: me.onFocusableContainerRightKey,
  45974. ctrl: false,
  45975. shift: false,
  45976. alt: false
  45977. }
  45978. });
  45979. }
  45980. },
  45981. destroyFocusableContainer: function() {
  45982. this.focusableKeyNav = Ext.destroy(this.focusableKeyNav);
  45983. },
  45984. activateFocusableContainer: function(enable) {
  45985. var keyNav = this.focusableKeyNav;
  45986. if (keyNav) {
  45987. keyNav.setDisabled(!enable);
  45988. }
  45989. },
  45990. isFocusableContainerActive: function() {
  45991. var keyNav = this.focusableKeyNav;
  45992. return keyNav ? !keyNav.disabled : false;
  45993. },
  45994. getFocusables: function() {
  45995. return this.items.items;
  45996. },
  45997. initDefaultFocusable: function() {
  45998. var me = this,
  45999. haveFocusable = false,
  46000. items, item, i, len;
  46001. items = me.getFocusables();
  46002. len = items.length;
  46003. if (!len) {
  46004. return;
  46005. }
  46006. for (i = 0; i < len; i++) {
  46007. item = items[i];
  46008. if (!item.isDisabled() && item.isFocusable()) {
  46009. haveFocusable = true;
  46010. break;
  46011. }
  46012. }
  46013. if (!haveFocusable) {
  46014. return;
  46015. }
  46016. item = me.findNextFocusableChild({
  46017. items: items,
  46018. step: true
  46019. });
  46020. if (item) {
  46021. me.activateFocusable(item);
  46022. }
  46023. return item;
  46024. },
  46025. clearFocusables: function(skipFocused) {
  46026. var me = this,
  46027. items = me.getFocusables(),
  46028. len = items.length,
  46029. item, i;
  46030. for (i = 0; i < len; i++) {
  46031. item = items[i];
  46032. if (!item.destroyed && item.focusable && item.isTabbable()) {
  46033. me.deactivateFocusable(item);
  46034. }
  46035. }
  46036. },
  46037. processFocusableContainerKeyEvent: function(e) {
  46038. if (!Ext.fly(e.target).isInputField()) {
  46039. return e;
  46040. }
  46041. },
  46042. activateFocusable: function(child) {
  46043. child.setTabIndex(this.activeChildTabIndex);
  46044. },
  46045. deactivateFocusable: function(child) {
  46046. child.setTabIndex(this.inactiveChildTabIndex);
  46047. },
  46048. onFocusableContainerTabKey: function() {
  46049. return true;
  46050. },
  46051. onFocusableContainerEnterKey: function() {
  46052. return true;
  46053. },
  46054. onFocusableContainerSpaceKey: function() {
  46055. return true;
  46056. },
  46057. onFocusableContainerUpKey: function(e) {
  46058. e.preventDefault();
  46059. return this.moveChildFocus(e, false);
  46060. },
  46061. onFocusableContainerDownKey: function(e) {
  46062. e.preventDefault();
  46063. return this.moveChildFocus(e, true);
  46064. },
  46065. onFocusableContainerLeftKey: function(e) {
  46066. e.preventDefault();
  46067. return this.moveChildFocus(e, false);
  46068. },
  46069. onFocusableContainerRightKey: function(e) {
  46070. e.preventDefault();
  46071. return this.moveChildFocus(e, true);
  46072. },
  46073. getFocusableFromEvent: function(e) {
  46074. var child = Ext.Component.from(e);
  46075. if (!child) {
  46076. Ext.raise("No focusable child found for keyboard event!");
  46077. }
  46078. return child;
  46079. },
  46080. moveChildFocus: function(e, forward) {
  46081. var child = this.getFocusableFromEvent(e);
  46082. return this.focusChild(child, forward, e);
  46083. },
  46084. focusChild: function(child, forward) {
  46085. var nextChild = this.findNextFocusableChild({
  46086. child: child,
  46087. step: forward
  46088. });
  46089. if (nextChild) {
  46090. nextChild.focus();
  46091. }
  46092. return nextChild;
  46093. },
  46094. findNextFocusableChild: function(options) {
  46095. var beforeRender = options.beforeRender,
  46096. firstTabbable = options.firstTabbable,
  46097. items, item, child, step, idx, i, len, allowDisabled;
  46098. items = options.items || this.getFocusables();
  46099. step = options.step != null ? options.step : 1;
  46100. child = options.child;
  46101. allowDisabled = !!this.allowFocusingDisabledChildren;
  46102. idx = Ext.Array.indexOf(items, child);
  46103. step = step === true ? 1 : step === false ? -1 : step;
  46104. len = items.length;
  46105. i = step > 0 ? (idx < len ? idx + step : 0) : (idx > 0 ? idx + step : len - 1);
  46106. for (; ; i += step) {
  46107. if (idx < 0 && (i >= len || i < 0)) {
  46108. return null;
  46109. }
  46110. else if (i >= len) {
  46111. i = -1;
  46112. continue;
  46113. }
  46114. else if (i < 0) {
  46115. i = len;
  46116. continue;
  46117. }
  46118. else if (i === idx) {
  46119. return null;
  46120. }
  46121. item = items[i];
  46122. if (!item || !item.focusable || (item.isDisabled() && !allowDisabled)) {
  46123. continue;
  46124. }
  46125. if (firstTabbable) {
  46126. if (item.isTabbable && item.isTabbable()) {
  46127. return item;
  46128. }
  46129. }
  46130. else if (beforeRender || (item.isFocusable && item.isFocusable())) {
  46131. return item;
  46132. }
  46133. }
  46134. return null;
  46135. },
  46136. onFocusEnter: function(e) {
  46137. var me = this,
  46138. target = e.toComponent,
  46139. child;
  46140. if (target === me) {
  46141. child = me.initDefaultFocusable();
  46142. if (child) {
  46143. child.focus();
  46144. }
  46145. }
  46146. me.activateFocusableContainer(true);
  46147. },
  46148. onFocusLeave: function(e) {
  46149. var me = this;
  46150. if (me.resetFocusPosition) {
  46151. me.clearFocusables();
  46152. me.initDefaultFocusable();
  46153. }
  46154. },
  46155. beforeFocusableChildBlur: Ext.privateFn,
  46156. afterFocusableChildBlur: Ext.privateFn,
  46157. beforeFocusableChildFocus: function(child) {
  46158. var me = this;
  46159. if (!me.focusableContainer || me.destroying || me.destroyed) {
  46160. return;
  46161. }
  46162. me.clearFocusables();
  46163. me.activateFocusable(child);
  46164. },
  46165. afterFocusableChildFocus: function(child) {
  46166. var me = this;
  46167. if (!me.focusableContainer || me.destroying || me.destroyed) {
  46168. return;
  46169. }
  46170. me.lastFocusedChild = child;
  46171. },
  46172. onFocusableChildAdd: function(child) {
  46173. var me = this;
  46174. if (child.focusable) {
  46175. child.ownerFocusableContainer = me;
  46176. }
  46177. },
  46178. onFocusableChildRemove: function(child) {
  46179. var me = this,
  46180. next;
  46181. child.ownerFocusableContainer = null;
  46182. if (child === me.lastFocusedChild) {
  46183. me.lastFocusedChild = null;
  46184. next = me.initDefaultFocusable();
  46185. if (child.hasFocus) {
  46186. next = next || child.findFocusTarget();
  46187. if (next) {
  46188. next.focus();
  46189. }
  46190. }
  46191. }
  46192. child = next || me.findNextFocusableChild({
  46193. step: 1,
  46194. beforeRender: true
  46195. });
  46196. if (!child) {
  46197. me.activateFocusableContainer(false);
  46198. }
  46199. },
  46200. beforeFocusableChildEnable: Ext.privateFn,
  46201. onFocusableChildEnable: function(child) {
  46202. var me = this,
  46203. active;
  46204. if (!me.focusableContainer || me.destroying || me.destroyed) {
  46205. return;
  46206. }
  46207. if (me.containsFocus) {
  46208. active = Ext.ComponentManager.getActiveComponent();
  46209. me.clearFocusables();
  46210. me.activateFocusable(active);
  46211. } else if (me.resetFocusPosition || me.lastFocusedChild == null) {
  46212. me.clearFocusables();
  46213. if (child.hasFocus) {
  46214. me.activateFocusable(child);
  46215. active = child;
  46216. }
  46217. } else {
  46218. me.deactivateFocusable(child);
  46219. if (child === me.lastFocusedChild) {
  46220. me.clearFocusables();
  46221. me.activateFocusable(child);
  46222. }
  46223. active = me.findNextFocusableChild({
  46224. firstTabbable: true
  46225. });
  46226. }
  46227. if (!active) {
  46228. me.initDefaultFocusable();
  46229. }
  46230. me.activateFocusableContainer(true);
  46231. },
  46232. beforeFocusableChildDisable: function(child) {
  46233. var me = this,
  46234. next;
  46235. if (!me.focusableContainer || me.destroying || me.destroyed) {
  46236. return;
  46237. }
  46238. if (child.hasFocus) {
  46239. next = me.findNextFocusableChild({
  46240. child: child
  46241. }) || child.findFocusTarget();
  46242. if (next) {
  46243. next.focus();
  46244. }
  46245. }
  46246. },
  46247. onFocusableChildDisable: function(child) {
  46248. var me = this,
  46249. next;
  46250. if (!me.focusableContainer || me.destroying || me.destroyed) {
  46251. return;
  46252. }
  46253. next = me.findNextFocusableChild({
  46254. firstTabbable: true
  46255. });
  46256. if (!next) {
  46257. next = me.initDefaultFocusable();
  46258. }
  46259. if (!next) {
  46260. me.activateFocusableContainer(false);
  46261. }
  46262. },
  46263. beforeFocusableChildHide: function(child) {
  46264. return this.beforeFocusableChildDisable(child);
  46265. },
  46266. onFocusableChildHide: function(child) {
  46267. return this.onFocusableChildDisable(child);
  46268. },
  46269. beforeFocusableChildShow: function(child) {
  46270. return this.beforeFocusableChildEnable(child);
  46271. },
  46272. onFocusableChildShow: function(child) {
  46273. return this.onFocusableChildEnable(child);
  46274. },
  46275. onFocusableChildMasked: Ext.privateFn,
  46276. onFocusableChildDestroy: Ext.privateFn,
  46277. onFocusableChildUpdate: Ext.privateFn
  46278. },
  46279. deprecated: {
  46280. 7: {
  46281. configs: {
  46282. enableFocusableContainer: 'focusableContainer'
  46283. }
  46284. }
  46285. }
  46286. });
  46287. Ext.define('Ext.mixin.Hookable', {
  46288. extend: Ext.Mixin,
  46289. mixinConfig: {
  46290. id: 'hookable'
  46291. },
  46292. bindHook: function(instance, boundMethod, bindingMethod, preventDefault, extraArgs) {
  46293. instance.afterMethod(boundMethod, bindingMethod || boundMethod, this, preventDefault, extraArgs);
  46294. return this;
  46295. },
  46296. unbindHook: function(instance, boundMethod, bindingMethod) {
  46297. instance.removeMethodListener(boundMethod, bindingMethod || boundMethod, this);
  46298. return this;
  46299. }
  46300. });
  46301. Ext.define('Ext.app.Profile', {
  46302. mixins: [
  46303. Ext.mixin.Observable
  46304. ],
  46305. isProfile: true,
  46306. config: {
  46307. mainView: {
  46308. $value: null,
  46309. lazy: true
  46310. },
  46311. application: null,
  46312. controllers: [],
  46313. models: [],
  46314. views: [],
  46315. stores: []
  46316. },
  46317. constructor: function(config) {
  46318. this.initConfig(config);
  46319. this.mixins.observable.constructor.apply(this, arguments);
  46320. },
  46321. isActive: function() {
  46322. return false;
  46323. },
  46324. init: function() {
  46325. var views = this.getViews(),
  46326. xtype;
  46327. if (views && !(views instanceof Array)) {
  46328. for (xtype in views) {
  46329. Ext.ClassManager.setXType(views[xtype], xtype);
  46330. }
  46331. }
  46332. },
  46333. launch: Ext.emptyFn,
  46334. onClassExtended: function(cls, data, hooks) {
  46335. var onBeforeClassCreated = hooks.onBeforeCreated;
  46336. hooks.onBeforeCreated = function(cls, data) {
  46337. var Controller = Ext.app.Controller,
  46338. className = cls.$className,
  46339. requires = [],
  46340. proto = cls.prototype,
  46341. views = data.views,
  46342. name, namespace;
  46343. name = data.name;
  46344. if (name) {
  46345. delete data.name;
  46346. } else {
  46347. name = className.split('.');
  46348. name = name[name.length - 1];
  46349. }
  46350. cls._name = name;
  46351. cls._namespace = name = (data.namespace || name).toLowerCase();
  46352. delete data.namespace;
  46353. namespace = Controller.resolveNamespace(cls, data);
  46354. Controller.processDependencies(proto, requires, namespace, 'model', data.models, name);
  46355. Controller.processDependencies(proto, requires, namespace, 'store', data.stores, name);
  46356. Controller.processDependencies(proto, requires, namespace, 'controller', data.controllers, name);
  46357. if (views) {
  46358. if (views instanceof Array) {
  46359. Controller.processDependencies(proto, requires, namespace, 'view', views, name);
  46360. } else {
  46361. Ext.app.Profile.processViews(className, views, requires);
  46362. }
  46363. }
  46364. Ext.require(requires, Ext.Function.pass(onBeforeClassCreated, arguments, this));
  46365. };
  46366. },
  46367. getName: function() {
  46368. return this.self._name;
  46369. },
  46370. getNamespace: function() {
  46371. return this.self._namespace;
  46372. },
  46373. privates: {
  46374. statics: {
  46375. processViews: function(className, views, requires) {
  46376. var body, cls, s, xtype;
  46377. for (xtype in views) {
  46378. cls = views[xtype];
  46379. if (typeof cls !== 'string') {
  46380. s = cls.xclass;
  46381. if (!s) {
  46382. Ext.raise('Views must specify an xclass');
  46383. }
  46384. body = Ext.apply({
  46385. extend: s
  46386. }, cls);
  46387. delete body.xclass;
  46388. Ext.define(views[xtype] = className + '$' + xtype, body);
  46389. cls = s;
  46390. }
  46391. requires.push(cls);
  46392. }
  46393. }
  46394. }
  46395. }
  46396. });
  46397. Ext.define('Ext.app.domain.View', {
  46398. extend: Ext.app.EventDomain,
  46399. isInstance: true,
  46400. constructor: function(controller) {
  46401. this.callParent([
  46402. controller
  46403. ]);
  46404. this.controller = controller;
  46405. this.monitoredClasses = [
  46406. Ext.Widget
  46407. ];
  46408. },
  46409. match: function(target, selector, controller) {
  46410. var out = false;
  46411. if (selector === '#') {
  46412. out = controller === target.getController();
  46413. } else {
  46414. out = target.is(selector);
  46415. }
  46416. return out;
  46417. },
  46418. destroy: function() {
  46419. this.controller = null;
  46420. this.callParent();
  46421. }
  46422. });
  46423. Ext.define('Ext.app.ViewController', {
  46424. extend: Ext.app.BaseController,
  46425. alias: 'controller.controller',
  46426. mixins: [
  46427. Ext.mixin.Factoryable
  46428. ],
  46429. isViewController: true,
  46430. factoryConfig: {
  46431. type: 'controller'
  46432. },
  46433. config: {
  46434. bindings: {
  46435. $value: null,
  46436. lazy: true
  46437. },
  46438. closeViewAction: 'destroy'
  46439. },
  46440. view: null,
  46441. constructor: function(config) {
  46442. this.compDomain = new Ext.app.domain.View(this);
  46443. this.callParent([
  46444. config
  46445. ]);
  46446. },
  46447. beforeInit: Ext.emptyFn,
  46448. init: Ext.emptyFn,
  46449. initViewModel: Ext.emptyFn,
  46450. destroy: function() {
  46451. var me = this,
  46452. domain = me.compDomain,
  46453. bind, b, key;
  46454. if (me.$hasBinds) {
  46455. bind = me.getBindings();
  46456. for (key in bind) {
  46457. b = bind[key];
  46458. if (b) {
  46459. b.destroy();
  46460. }
  46461. }
  46462. }
  46463. if (domain) {
  46464. domain.unlisten(me);
  46465. domain.destroy();
  46466. }
  46467. me.compDomain = me.view = null;
  46468. me.callParent();
  46469. },
  46470. closeView: function() {
  46471. var view = this.getView(),
  46472. action;
  46473. if (view) {
  46474. action = this.getCloseViewAction();
  46475. view[action]();
  46476. }
  46477. },
  46478. control: function(selectors, listeners) {
  46479. var obj = selectors;
  46480. if (Ext.isString(selectors)) {
  46481. obj = {};
  46482. obj[selectors] = listeners;
  46483. }
  46484. this.compDomain.listen(obj, this);
  46485. },
  46486. listen: function(to, controller) {
  46487. var component = to.component;
  46488. if (component) {
  46489. to = Ext.apply({}, to);
  46490. delete to.component;
  46491. this.control(component);
  46492. }
  46493. this.callParent([
  46494. to,
  46495. controller
  46496. ]);
  46497. },
  46498. applyId: function(id) {
  46499. if (!id) {
  46500. id = Ext.id(null, 'controller-');
  46501. }
  46502. return id;
  46503. },
  46504. getReferences: function() {
  46505. var view = this.view;
  46506. return view && view.getReferences();
  46507. },
  46508. getView: function() {
  46509. return this.view;
  46510. },
  46511. lookup: function(key) {
  46512. var view = this.view;
  46513. return view && view.lookup(key);
  46514. },
  46515. lookupReference: function(key) {
  46516. return this.lookup(key);
  46517. },
  46518. getSession: function() {
  46519. var view = this.view;
  46520. return view && view.lookupSession();
  46521. },
  46522. getViewModel: function() {
  46523. var view = this.view;
  46524. return view && view.lookupViewModel();
  46525. },
  46526. getStore: function(name) {
  46527. var viewModel = this.getViewModel();
  46528. return viewModel ? viewModel.getStore(name) : null;
  46529. },
  46530. fireViewEvent: function(eventName, args) {
  46531. var view = this.view,
  46532. result = false,
  46533. a = arguments;
  46534. if (view) {
  46535. if (view !== args) {
  46536. a = Ext.Array.slice(a);
  46537. a.splice(1, 0, view);
  46538. }
  46539. result = view.fireEvent.apply(view, a);
  46540. }
  46541. return result;
  46542. },
  46543. applyBindings: function(bindings) {
  46544. if (!bindings) {
  46545. return null;
  46546. }
  46547. var me = this,
  46548. viewModel = me.getViewModel(),
  46549. getBindTemplateScope = me.getBindTemplateScope(),
  46550. b, fn, descriptor;
  46551. me.$hasBinds = true;
  46552. if (!viewModel) {
  46553. Ext.raise('Cannot use bind config without a viewModel');
  46554. }
  46555. for (fn in bindings) {
  46556. descriptor = bindings[fn];
  46557. b = null;
  46558. if (descriptor) {
  46559. b = viewModel.bind(descriptor, fn, me);
  46560. b.getTemplateScope = getBindTemplateScope;
  46561. }
  46562. bindings[fn] = b;
  46563. }
  46564. return bindings;
  46565. },
  46566. privates: {
  46567. view: null,
  46568. attachReference: function(component) {
  46569. var view = this.view;
  46570. if (view) {
  46571. view.attachReference(component);
  46572. }
  46573. },
  46574. getBindTemplateScope: function() {
  46575. return this.scope;
  46576. },
  46577. initBindings: function() {
  46578. this.getBindings();
  46579. },
  46580. setView: function(view) {
  46581. this.view = view;
  46582. if (!this.beforeInit.$nullFn) {
  46583. this.beforeInit(view);
  46584. }
  46585. }
  46586. }
  46587. });
  46588. Ext.define('Ext.util.Bag', {
  46589. isBag: true,
  46590. constructor: function() {
  46591. this.items = [];
  46592. this.map = {};
  46593. },
  46594. generation: 0,
  46595. length: 0,
  46596. beginUpdate: Ext.emptyFn,
  46597. endUpdate: Ext.emptyFn,
  46598. add: function(item) {
  46599. var me = this,
  46600. items = me.items,
  46601. map = me.map,
  46602. n = 1,
  46603. old, i, idx, id, it, ret, was;
  46604. if (Ext.isArray(item)) {
  46605. old = ret = [];
  46606. n = item.length;
  46607. }
  46608. for (i = 0; i < n; i++) {
  46609. id = me.getKey(it = old ? item[i] : item);
  46610. idx = map[id];
  46611. if (idx === undefined) {
  46612. items.push(it);
  46613. map[id] = me.length++;
  46614. if (old) {
  46615. old.push(it);
  46616. } else {
  46617. ret = it;
  46618. }
  46619. } else {
  46620. was = items[idx];
  46621. if (old) {
  46622. old.push(was);
  46623. } else {
  46624. ret = was;
  46625. }
  46626. items[idx] = it;
  46627. }
  46628. }
  46629. ++me.generation;
  46630. return ret;
  46631. },
  46632. clear: function() {
  46633. var me = this,
  46634. needsClear = me.generation || me.length,
  46635. ret = needsClear ? me.items : [];
  46636. if (needsClear) {
  46637. me.items = [];
  46638. me.length = 0;
  46639. me.map = {};
  46640. ++me.generation;
  46641. }
  46642. return ret;
  46643. },
  46644. clone: function() {
  46645. var me = this,
  46646. ret = new me.self(),
  46647. len = me.length;
  46648. if (len) {
  46649. Ext.apply(ret.map, me.map);
  46650. ret.items = me.items.slice();
  46651. ret.length = me.length;
  46652. }
  46653. return ret;
  46654. },
  46655. contains: function(item) {
  46656. var ret = false,
  46657. map = this.map,
  46658. key;
  46659. if (item != null) {
  46660. key = this.getKey(item);
  46661. if (key in map) {
  46662. ret = this.items[map[key]] === item;
  46663. }
  46664. }
  46665. return ret;
  46666. },
  46667. containsKey: function(key) {
  46668. return key in this.map;
  46669. },
  46670. destroy: function() {
  46671. this.items = this.map = null;
  46672. this.callParent();
  46673. },
  46674. each: function(fn, scope) {
  46675. var items = this.items,
  46676. len = items.length,
  46677. i, ret;
  46678. if (len) {
  46679. scope = scope || this;
  46680. items = items.slice(0);
  46681. for (i = 0; i < len; i++) {
  46682. ret = fn.call(scope, items[i], i, len);
  46683. if (ret === false) {
  46684. break;
  46685. }
  46686. }
  46687. }
  46688. return ret;
  46689. },
  46690. getAt: function(index) {
  46691. var out = null;
  46692. if (index < this.length) {
  46693. out = this.items[index];
  46694. }
  46695. return out;
  46696. },
  46697. get: function(key) {
  46698. return this.getByKey(key);
  46699. },
  46700. getByKey: function(key) {
  46701. var map = this.map,
  46702. ret = (key in map) ? this.items[map[key]] : null;
  46703. return ret;
  46704. },
  46705. indexOfKey: function(key) {
  46706. var map = this.map,
  46707. ret = (key in map) ? map[key] : -1;
  46708. return ret;
  46709. },
  46710. last: function() {
  46711. return this.items[this.length - 1];
  46712. },
  46713. updateKey: function(item, oldKey) {
  46714. var me = this,
  46715. map = me.map,
  46716. newKey;
  46717. if (!item || !oldKey) {
  46718. return;
  46719. }
  46720. if ((newKey = me.getKey(item)) !== oldKey) {
  46721. if (me.getAt(map[oldKey]) === item && !(newKey in map)) {
  46722. me.generation++;
  46723. map[newKey] = map[oldKey];
  46724. delete map[oldKey];
  46725. }
  46726. } else
  46727. {
  46728. if (newKey in map && me.getAt(map[newKey]) !== item) {
  46729. Ext.raise('Duplicate newKey "' + newKey + '" for item with oldKey "' + oldKey + '"');
  46730. }
  46731. if (oldKey in map && me.getAt(map[oldKey]) !== item) {
  46732. Ext.raise('Incorrect oldKey "' + oldKey + '" for item with newKey "' + newKey + '"');
  46733. }
  46734. }
  46735. },
  46736. getCount: function() {
  46737. return this.length;
  46738. },
  46739. getKey: function(item) {
  46740. return item.id || item.getId();
  46741. },
  46742. getRange: function(begin, end) {
  46743. var items = this.items,
  46744. length = items.length,
  46745. range;
  46746. if (!length) {
  46747. range = [];
  46748. } else {
  46749. range = Ext.Number.clipIndices(length, [
  46750. begin,
  46751. end
  46752. ]);
  46753. range = items.slice(range[0], range[1]);
  46754. }
  46755. return range;
  46756. },
  46757. remove: function(item) {
  46758. var me = this,
  46759. map = me.map,
  46760. items = me.items,
  46761. ret = null,
  46762. n = 1,
  46763. changed, old, i, idx, id, last, was;
  46764. if (Ext.isArray(item)) {
  46765. n = item.length;
  46766. old = ret = [];
  46767. }
  46768. if (me.length) {
  46769. for (i = 0; i < n; i++) {
  46770. idx = map[id = me.getKey(old ? item[i] : item)];
  46771. if (idx !== undefined) {
  46772. delete map[id];
  46773. was = items[idx];
  46774. if (old) {
  46775. old.push(was);
  46776. } else {
  46777. ret = was;
  46778. }
  46779. last = items.pop();
  46780. if (idx < --me.length) {
  46781. items[idx] = last;
  46782. map[me.getKey(last)] = idx;
  46783. }
  46784. changed = true;
  46785. }
  46786. }
  46787. if (changed) {
  46788. ++me.generation;
  46789. }
  46790. }
  46791. return ret;
  46792. },
  46793. removeByKey: function(key) {
  46794. var item = this.getByKey(key);
  46795. if (item) {
  46796. this.remove(item);
  46797. }
  46798. return item || null;
  46799. },
  46800. replace: function(item) {
  46801. this.add(item);
  46802. return item;
  46803. },
  46804. sort: function(fn) {
  46805. var me = this,
  46806. items = me.items,
  46807. n = items.length,
  46808. item;
  46809. if (n) {
  46810. Ext.Array.sort(items, fn);
  46811. me.map = {};
  46812. while (n-- > 0) {
  46813. item = items[n];
  46814. me.map[me.getKey(item)] = n;
  46815. }
  46816. ++me.generation;
  46817. }
  46818. }
  46819. });
  46820. Ext.define('Ext.util.Scheduler', {
  46821. mixins: [
  46822. Ext.mixin.Observable
  46823. ],
  46824. busyCounter: 0,
  46825. lastBusyCounter: 0,
  46826. destroyed: false,
  46827. firing: null,
  46828. notifyIndex: -1,
  46829. nextId: 0,
  46830. orderedItems: null,
  46831. passes: 0,
  46832. scheduledCount: 0,
  46833. validIdRe: null,
  46834. config: {
  46835. cycleLimit: 5,
  46836. preSort: null,
  46837. tickDelay: 5
  46838. },
  46839. suspendOnNotify: true,
  46840. constructor: function(config) {
  46841. if (Ext.util.Scheduler.instances) {
  46842. Ext.util.Scheduler.instances.push(this);
  46843. } else {
  46844. Ext.util.Scheduler.instances = [
  46845. this
  46846. ];
  46847. }
  46848. this.id = Ext.util.Scheduler.count = (Ext.util.Scheduler.count || 0) + 1;
  46849. this.mixins.observable.constructor.call(this, config);
  46850. this.items = new Ext.util.Bag();
  46851. },
  46852. destroy: function() {
  46853. var me = this,
  46854. timer = me.timer;
  46855. if (timer) {
  46856. window.clearTimeout(timer);
  46857. me.timer = null;
  46858. }
  46859. me.items.destroy();
  46860. me.items = me.orderedItems = null;
  46861. me.callParent();
  46862. Ext.Array.remove(Ext.util.Scheduler.instances, this);
  46863. },
  46864. add: function(item) {
  46865. var me = this,
  46866. items = me.items;
  46867. if (items === me.firing) {
  46868. me.items = items = items.clone();
  46869. }
  46870. item.id = item.id || ++me.nextId;
  46871. item.scheduler = me;
  46872. items.add(item);
  46873. if (!me.sortMap) {
  46874. me.orderedItems = null;
  46875. }
  46876. },
  46877. remove: function(item) {
  46878. var me = this,
  46879. items = me.items;
  46880. if (me.destroyed) {
  46881. return;
  46882. }
  46883. if (me.sortMap) {
  46884. Ext.raise('Items cannot be removed during sort');
  46885. }
  46886. if (items === me.firing) {
  46887. me.items = items = items.clone();
  46888. }
  46889. if (item.scheduled) {
  46890. me.unscheduleItem(item);
  46891. item.scheduled = false;
  46892. }
  46893. items.remove(item);
  46894. me.orderedItems = null;
  46895. },
  46896. sort: function() {
  46897. var me = this,
  46898. items = me.items,
  46899. sortMap = {},
  46900. preSort = me.getPreSort(),
  46901. i, item;
  46902. me.orderedItems = [];
  46903. me.sortMap = sortMap;
  46904. me.sortStack = [];
  46905. if (preSort) {
  46906. items.sort(preSort);
  46907. }
  46908. items = items.items;
  46909. for (i = 0; i < items.length; ++i) {
  46910. item = items[i];
  46911. if (!sortMap[item.id]) {
  46912. me.sortItem(item);
  46913. }
  46914. }
  46915. me.sortMap = null;
  46916. me.sortStack = null;
  46917. },
  46918. sortItem: function(item) {
  46919. var me = this,
  46920. sortMap = me.sortMap,
  46921. orderedItems = me.orderedItems,
  46922. itemId;
  46923. if (!item.scheduler) {
  46924. me.add(item);
  46925. }
  46926. itemId = item.id;
  46927. if (item.scheduler !== me) {
  46928. Ext.raise('Item ' + itemId + ' belongs to another Scheduler');
  46929. }
  46930. me.sortStack.push(item);
  46931. if (sortMap[itemId] === 0) {
  46932. for (var cycle = [],
  46933. i = 0; i < me.sortStack.length; ++i) {
  46934. cycle[i] = me.sortStack[i].getFullName();
  46935. }
  46936. Ext.raise('Dependency cycle detected: ' + cycle.join('\n --> '));
  46937. }
  46938. if (!(itemId in sortMap)) {
  46939. sortMap[itemId] = 0;
  46940. if (!item.sort.$nullFn) {
  46941. item.sort();
  46942. }
  46943. sortMap[itemId] = 1;
  46944. item.order = me.orderedItems.length;
  46945. orderedItems.push(item);
  46946. }
  46947. me.sortStack.pop();
  46948. return me;
  46949. },
  46950. sortItems: function(items) {
  46951. var me = this,
  46952. sortItem = me.sortItem;
  46953. if (items) {
  46954. if (items instanceof Array) {
  46955. Ext.each(items, sortItem, me);
  46956. } else {
  46957. Ext.Object.eachValue(items, sortItem, me);
  46958. }
  46959. }
  46960. return me;
  46961. },
  46962. applyPreSort: function(preSort) {
  46963. if (typeof preSort === 'function') {
  46964. return preSort;
  46965. }
  46966. var parts = preSort.split(','),
  46967. direction = [],
  46968. length = parts.length,
  46969. c, i, s;
  46970. for (i = 0; i < length; ++i) {
  46971. direction[i] = 1;
  46972. s = parts[i];
  46973. if ((c = s.charAt(0)) === '-') {
  46974. direction[i] = -1;
  46975. } else if (c !== '+') {
  46976. c = 0;
  46977. }
  46978. if (c) {
  46979. parts[i] = s.substring(1);
  46980. }
  46981. }
  46982. return function(lhs, rhs) {
  46983. var ret = 0,
  46984. i, prop, v1, v2;
  46985. for (i = 0; !ret && i < length; ++i) {
  46986. prop = parts[i];
  46987. v1 = lhs[prop];
  46988. v2 = rhs[prop];
  46989. ret = direction[i] * ((v1 < v2) ? -1 : ((v2 < v1) ? 1 : 0));
  46990. }
  46991. return ret;
  46992. };
  46993. },
  46994. notify: function() {
  46995. var me = this,
  46996. timer = me.timer,
  46997. cyclesLeft = me.getCycleLimit(),
  46998. globalEvents = Ext.GlobalEvents,
  46999. suspend = me.suspendOnNotify,
  47000. busyCounter, i, item, len, queue, firedEvent;
  47001. if (timer) {
  47002. window.clearTimeout(timer);
  47003. me.timer = null;
  47004. }
  47005. if (!me.firing && me.scheduledCount) {
  47006. if (suspend) {
  47007. Ext.suspendLayouts();
  47008. }
  47009. while (me.scheduledCount) {
  47010. if (cyclesLeft) {
  47011. --cyclesLeft;
  47012. } else {
  47013. me.firing = null;
  47014. if (me.onCycleLimitExceeded) {
  47015. me.onCycleLimitExceeded();
  47016. }
  47017. break;
  47018. }
  47019. if (!firedEvent) {
  47020. firedEvent = true;
  47021. if (globalEvents.hasListeners.beforebindnotify) {
  47022. globalEvents.fireEvent('beforebindnotify', me);
  47023. }
  47024. }
  47025. ++me.passes;
  47026. if (!(queue = me.orderedItems)) {
  47027. me.sort();
  47028. queue = me.orderedItems;
  47029. }
  47030. len = queue.length;
  47031. if (len) {
  47032. me.firing = me.items;
  47033. for (i = 0; i < len; ++i) {
  47034. item = queue[i];
  47035. if (item.scheduled) {
  47036. item.scheduled = false;
  47037. --me.scheduledCount;
  47038. me.notifyIndex = i;
  47039. item.react();
  47040. if (!me.scheduledCount) {
  47041. break;
  47042. }
  47043. }
  47044. }
  47045. }
  47046. }
  47047. me.firing = null;
  47048. me.notifyIndex = -1;
  47049. if (suspend) {
  47050. Ext.resumeLayouts(true);
  47051. }
  47052. }
  47053. if ((busyCounter = me.busyCounter) !== me.lastBusyCounter) {
  47054. if (!(me.lastBusyCounter = busyCounter)) {
  47055. me.fireEvent('idle', me);
  47056. }
  47057. }
  47058. },
  47059. onTick: function() {
  47060. this.timer = null;
  47061. this.notify();
  47062. },
  47063. scheduleItem: function(item) {
  47064. var me = this;
  47065. ++me.scheduledCount;
  47066. if (!me.timer && !me.firing) {
  47067. me.scheduleTick();
  47068. }
  47069. },
  47070. scheduleTick: function() {
  47071. var me = this;
  47072. if (!me.destroyed && !me.timer) {
  47073. me.timer = Ext.defer(me.onTick, me.getTickDelay(), me);
  47074. }
  47075. },
  47076. unscheduleItem: function(item) {
  47077. if (this.scheduledCount) {
  47078. --this.scheduledCount;
  47079. }
  47080. },
  47081. adjustBusy: function(adjustment) {
  47082. var me = this,
  47083. busyCounter = me.busyCounter + adjustment;
  47084. me.busyCounter = busyCounter;
  47085. if (busyCounter) {
  47086. if (!me.lastBusyCounter) {
  47087. me.lastBusyCounter = busyCounter;
  47088. me.fireEvent('busy', me);
  47089. }
  47090. } else if (me.lastBusyCounter && !me.timer) {
  47091. me.scheduleTick();
  47092. }
  47093. },
  47094. isBusy: function() {
  47095. return !this.isIdle();
  47096. },
  47097. isIdle: function() {
  47098. return !(this.busyCounter + this.lastBusyCounter);
  47099. },
  47100. debugHooks: {
  47101. $enabled: false,
  47102. onCycleLimitExceeded: function() {
  47103. Ext.raise('Exceeded cycleLimit ' + this.getCycleLimit());
  47104. },
  47105. scheduleItem: function(item) {
  47106. if (!item) {
  47107. Ext.raise('scheduleItem: Invalid argument');
  47108. }
  47109. Ext.log('Schedule item: ' + item.getFullName() + ' - ' + (this.scheduledCount + 1));
  47110. if (item.order <= this.notifyIndex) {
  47111. Ext.log.warn('Suboptimal order: ' + item.order + ' < ' + this.notifyIndex);
  47112. }
  47113. this.callParent([
  47114. item
  47115. ]);
  47116. },
  47117. unscheduleItem: function(item) {
  47118. if (!this.scheduledCount) {
  47119. Ext.raise('Invalid scheduleCount');
  47120. }
  47121. this.callParent([
  47122. item
  47123. ]);
  47124. Ext.log('Unschedule item: ' + item.getFullName() + ' - ' + this.scheduledCount);
  47125. }
  47126. }
  47127. });
  47128. Ext.define('Ext.data.Batch', {
  47129. mixins: {
  47130. observable: Ext.mixin.Observable
  47131. },
  47132. config: {
  47133. pauseOnException: false
  47134. },
  47135. current: -1,
  47136. total: 0,
  47137. running: false,
  47138. complete: false,
  47139. exception: false,
  47140. constructor: function(config) {
  47141. var me = this;
  47142. me.mixins.observable.constructor.call(me, config);
  47143. me.operations = [];
  47144. me.exceptions = [];
  47145. },
  47146. add: function(operation) {
  47147. var me = this,
  47148. i, len;
  47149. if (Ext.isArray(operation)) {
  47150. for (i = 0 , len = operation.length; i < len; ++i) {
  47151. me.add(operation[i]);
  47152. }
  47153. } else {
  47154. me.total++;
  47155. operation.setBatch(me);
  47156. me.operations.push(operation);
  47157. }
  47158. return me;
  47159. },
  47160. sort: function() {
  47161. this.operations.sort(this.sortFn);
  47162. },
  47163. sortFn: function(operation1, operation2) {
  47164. var ret = operation1.order - operation2.order;
  47165. if (ret) {
  47166. return ret;
  47167. }
  47168. var entityType1 = operation1.entityType,
  47169. entityType2 = operation2.entityType,
  47170. rank;
  47171. if (!entityType1 || !entityType2) {
  47172. return 0;
  47173. }
  47174. if (!(rank = entityType1.rank)) {
  47175. entityType1.schema.rankEntities();
  47176. rank = entityType1.rank;
  47177. }
  47178. return (rank - entityType2.rank) * operation1.foreignKeyDirection;
  47179. },
  47180. start: function(index) {
  47181. var me = this;
  47182. if (me.destroyed || !me.operations.length || me.running) {
  47183. return me;
  47184. }
  47185. me.exceptions.length = 0;
  47186. me.exception = false;
  47187. me.running = true;
  47188. return me.runOperation(Ext.isDefined(index) ? index : me.current + 1);
  47189. },
  47190. abort: function() {
  47191. var me = this,
  47192. op;
  47193. if (me.running) {
  47194. op = me.getCurrent();
  47195. if (!op.destroyed) {
  47196. op.abort();
  47197. }
  47198. }
  47199. me.running = false;
  47200. me.aborted = true;
  47201. me.current = undefined;
  47202. },
  47203. retry: function() {
  47204. return this.start(this.current);
  47205. },
  47206. runNextOperation: function() {
  47207. var me = this;
  47208. if (me.running) {
  47209. me.runOperation(me.current + 1);
  47210. }
  47211. return me;
  47212. },
  47213. pause: function() {
  47214. this.running = false;
  47215. return this;
  47216. },
  47217. getOperations: function() {
  47218. return this.operations;
  47219. },
  47220. getExceptions: function() {
  47221. return this.exceptions;
  47222. },
  47223. getCurrent: function() {
  47224. var out = null,
  47225. current = this.current;
  47226. if (!(current === -1 || this.complete)) {
  47227. out = this.operations[current];
  47228. }
  47229. return out;
  47230. },
  47231. getTotal: function() {
  47232. return this.total;
  47233. },
  47234. isRunning: function() {
  47235. return this.running;
  47236. },
  47237. isComplete: function() {
  47238. return this.complete;
  47239. },
  47240. hasException: function() {
  47241. return this.exception;
  47242. },
  47243. runOperation: function(index) {
  47244. var me = this,
  47245. operations = me.operations,
  47246. operation = operations[index];
  47247. if (operation === undefined) {
  47248. me.running = false;
  47249. me.complete = true;
  47250. me.fireEvent('complete', me, operations[operations.length - 1]);
  47251. } else {
  47252. me.current = index;
  47253. operation.setInternalCallback(me.onOperationComplete);
  47254. operation.setInternalScope(me);
  47255. operation.execute();
  47256. }
  47257. return me;
  47258. },
  47259. onOperationComplete: function(operation) {
  47260. var me = this,
  47261. exception = operation.hasException();
  47262. if (exception) {
  47263. me.exception = true;
  47264. me.exceptions.push(operation);
  47265. me.fireEvent('exception', me, operation);
  47266. }
  47267. if (exception && me.getPauseOnException()) {
  47268. me.pause();
  47269. } else {
  47270. me.fireEvent('operationcomplete', me, operation);
  47271. me.runNextOperation();
  47272. }
  47273. },
  47274. destroy: function() {
  47275. var me = this,
  47276. operations = me.operations,
  47277. op, i, len;
  47278. if (me.running) {
  47279. me.abort();
  47280. }
  47281. for (i = 0 , len = me.operations.length; i < len; i++) {
  47282. op = operations[i];
  47283. if (op) {
  47284. if (!op.destroyed && !op.$destroyOwner) {
  47285. op.destroy();
  47286. }
  47287. op[i] = null;
  47288. }
  47289. }
  47290. me.operations = me.exceptions = null;
  47291. me.callParent();
  47292. }
  47293. });
  47294. Ext.define('Ext.data.matrix.Slice', {
  47295. constructor: function(side, id) {
  47296. this.id = id;
  47297. this.side = side;
  47298. this.members = {};
  47299. },
  47300. attach: function(store) {
  47301. var me = this;
  47302. Ext.Assert.falsey(me.store, 'Store is already attached');
  47303. me.store = store;
  47304. store.matrix = me;
  47305. store.on('load', me.onStoreLoad, me, {
  47306. single: true
  47307. });
  47308. },
  47309. commit: function() {
  47310. var members = this.members,
  47311. id;
  47312. for (id in members) {
  47313. members[id][2] = 0;
  47314. }
  47315. },
  47316. onStoreLoad: function(store) {
  47317. this.update(store.getData().items, 0);
  47318. },
  47319. update: function(recordsOrIds, state) {
  47320. if (!(recordsOrIds instanceof Array)) {
  47321. Ext.raise('Only array of records or record ids are supported');
  47322. }
  47323. var me = this,
  47324. MatrixSlice = Ext.data.matrix.Slice,
  47325. side = me.side,
  47326. assocIndex = side.index,
  47327. length = recordsOrIds.length,
  47328. id = me.id,
  47329. members = me.members,
  47330. otherSide = side.inverse,
  47331. otherSlices = otherSide.slices,
  47332. assoc, call, i, item, otherId, otherSlice, record;
  47333. for (i = 0; i < length; ++i) {
  47334. call = record = null;
  47335. item = recordsOrIds[i];
  47336. otherId = item.isEntity ? (record = item).id : item;
  47337. assoc = members[otherId];
  47338. if (state < 0 && assoc && assoc[2] === 1) {
  47339. delete members[otherId];
  47340. otherSlice = otherSlices[otherId];
  47341. if (otherSlice) {
  47342. delete otherSlice.members[id];
  47343. }
  47344. call = 1;
  47345. } else {
  47346. if (!assoc) {
  47347. assoc = [
  47348. otherId,
  47349. otherId,
  47350. state
  47351. ];
  47352. assoc[assocIndex] = id;
  47353. members[otherId] = assoc;
  47354. otherSlice = otherSlices[otherId];
  47355. if (!otherSlice) {
  47356. otherSlices[otherId] = otherSlice = new MatrixSlice(otherSide, otherId);
  47357. }
  47358. otherSlice.members[id] = assoc;
  47359. call = 1;
  47360. } else if (state !== assoc[2] && state !== 0 && !(state === 1 && assoc[2] === 0)) {
  47361. assoc[2] = state;
  47362. otherSlice = otherSlices[otherId];
  47363. call = 1;
  47364. }
  47365. }
  47366. if (call) {
  47367. if (me.notify) {
  47368. me.notify.call(me.scope, me, otherId, state);
  47369. }
  47370. if (otherSlice && otherSlice.notify) {
  47371. otherSlice.notify.call(otherSlice.scope, otherSlice, id, state);
  47372. }
  47373. }
  47374. }
  47375. },
  47376. updateId: function(newId) {
  47377. var me = this,
  47378. oldId = me.id,
  47379. side = me.side,
  47380. slices = side.slices,
  47381. slice = slices[oldId],
  47382. members = slice.members,
  47383. index = side.index,
  47384. otherSlices = side.inverse.slices,
  47385. assoc, otherId, otherMembers;
  47386. me.id = newId;
  47387. slices[newId] = slice;
  47388. delete slices[oldId];
  47389. for (otherId in members) {
  47390. assoc = members[otherId];
  47391. assoc[index] = newId;
  47392. otherMembers = otherSlices[otherId].members;
  47393. otherMembers[newId] = otherMembers[oldId];
  47394. delete otherMembers[oldId];
  47395. }
  47396. },
  47397. destroy: function() {
  47398. var me = this,
  47399. store = me.store;
  47400. if (store) {
  47401. store.matrix = null;
  47402. store.un('load', me.onStoreLoad, me);
  47403. }
  47404. me.notify = me.scope = me.store = me.side = me.members = null;
  47405. me.callParent();
  47406. }
  47407. });
  47408. Ext.define('Ext.data.matrix.Side', {
  47409. constructor: function(matrix, index, role) {
  47410. var me = this;
  47411. me.matrix = matrix;
  47412. me.index = index;
  47413. me.role = role;
  47414. me.slices = {};
  47415. },
  47416. commit: function() {
  47417. var slices = this.slices,
  47418. id;
  47419. for (id in slices) {
  47420. slices[id].commit();
  47421. }
  47422. },
  47423. get: function(id1, id2) {
  47424. var me = this,
  47425. slices = me.slices,
  47426. slice = slices[id1] || (slices[id1] = new Ext.data.matrix.Slice(me, id1));
  47427. return (id2 || id2 === 0) ? slice.members[id2] : slice;
  47428. },
  47429. update: function(id1, id2, state) {
  47430. var slice = this.get(id1);
  47431. return slice.update(id2, state);
  47432. },
  47433. updateId: function(oldId, newId) {
  47434. var slice = this.get(oldId);
  47435. if (slice) {
  47436. slice.updateId(newId);
  47437. }
  47438. },
  47439. destroy: function() {
  47440. var me = this,
  47441. slices = me.slices,
  47442. id;
  47443. for (id in slices) {
  47444. slices[id].destroy();
  47445. }
  47446. me.inverse = me.matrix = me.role = me.slices = null;
  47447. me.callParent();
  47448. }
  47449. });
  47450. Ext.define('Ext.data.matrix.Matrix', {
  47451. constructor: function(session, matrix) {
  47452. var me = this,
  47453. association = matrix.isManyToMany ? matrix : session.getSchema().getAssociation(matrix),
  47454. Side = Ext.data.matrix.Side,
  47455. left = new Side(me, 0, association.left),
  47456. right = new Side(me, 1, association.right);
  47457. Ext.Assert.truthy(association.isManyToMany, 'Association is not many-to-many');
  47458. me.association = association;
  47459. me.session = session;
  47460. me.left = left;
  47461. me.right = right;
  47462. left.inverse = right;
  47463. right.inverse = left;
  47464. },
  47465. commit: function() {
  47466. this.left.commit();
  47467. this.right.commit();
  47468. },
  47469. update: function(id1, id2, state) {
  47470. return this.left.update(id1, id2, state);
  47471. },
  47472. updateId: function(record, oldId, newId) {
  47473. var Type = record.self,
  47474. left = this.left,
  47475. right = this.right,
  47476. matchSide;
  47477. if (Type === left.role.cls) {
  47478. matchSide = left;
  47479. }
  47480. if (Type === right.role.cls) {
  47481. matchSide = right;
  47482. }
  47483. if (matchSide) {
  47484. matchSide.updateId(oldId, newId);
  47485. }
  47486. },
  47487. destroy: function() {
  47488. var me = this;
  47489. me.left.destroy();
  47490. me.right.destroy();
  47491. me.association = me.session = me.left = me.right = null;
  47492. me.callParent();
  47493. }
  47494. });
  47495. Ext.define('Ext.data.session.ChangesVisitor', {
  47496. constructor: function(session) {
  47497. var me = this,
  47498. crud;
  47499. me.session = session;
  47500. crud = session.getCrudProperties();
  47501. me.result = null;
  47502. me.writerOptions = {};
  47503. me.createKey = crud.create;
  47504. me.readKey = crud.read;
  47505. me.updateKey = crud.update;
  47506. me.dropKey = crud.drop;
  47507. },
  47508. onDirtyRecord: function(record) {
  47509. var me = this,
  47510. crud = me.crud,
  47511. created = record.phantom,
  47512. dropped = record.dropped,
  47513. updated = !created && !dropped,
  47514. type = record.$className,
  47515. prop = (created || dropped) ? 'allDataOptions' : 'partialDataOptions',
  47516. writerOptions = me.writerOptions,
  47517. name = record.entityName,
  47518. options, bucket, entry, result;
  47519. if (created && dropped) {
  47520. return false;
  47521. }
  47522. crud = created ? me.createKey : (dropped ? me.dropKey : me.updateKey);
  47523. writerOptions = writerOptions[type] || (writerOptions[type] = {});
  47524. if (dropped) {
  47525. if (!(options = writerOptions.drop)) {
  47526. writerOptions.drop = options = {
  47527. all: record.getProxy().getWriter().getWriteAllFields()
  47528. };
  47529. }
  47530. if (!options.all) {
  47531. entry = record.id;
  47532. }
  47533. }
  47534. if (!entry) {
  47535. if (!(options = writerOptions[prop])) {
  47536. options = record.getProxy().getWriter().getConfig(prop);
  47537. writerOptions[prop] = options = Ext.Object.chain(options);
  47538. me.setupOptions(options);
  47539. }
  47540. entry = record.getData(options);
  47541. }
  47542. result = me.result || (me.result = {});
  47543. bucket = result[name] || (result[name] = {});
  47544. bucket = bucket[crud] || (bucket[crud] = []);
  47545. bucket.push(entry);
  47546. },
  47547. setupOptions: function(options) {
  47548. options.serialize = true;
  47549. },
  47550. onMatrixChange: function(association, id1, id2, state) {
  47551. var me = this,
  47552. name = association.left.type,
  47553. assocName = association.right.role,
  47554. operation = state < 0 ? me.dropKey : me.createKey,
  47555. bucket, result;
  47556. result = me.result || (me.result = {});
  47557. bucket = result[name] || (result[name] = {});
  47558. bucket = bucket[assocName] || (bucket[assocName] = {});
  47559. bucket = bucket[operation] || (bucket[operation] = {});
  47560. bucket = bucket[id1] || (bucket[id1] = []);
  47561. bucket.push(id2);
  47562. }
  47563. });
  47564. Ext.define('Ext.data.session.ChildChangesVisitor', {
  47565. extend: Ext.data.session.ChangesVisitor,
  47566. constructor: function() {
  47567. this.seen = {};
  47568. this.callParent(arguments);
  47569. },
  47570. setupOptions: function(options) {
  47571. this.callParent([
  47572. options
  47573. ]);
  47574. options.serialize = false;
  47575. },
  47576. onDirtyRecord: function(record) {
  47577. if (this.callParent(arguments) !== false) {
  47578. if (!record.$source && (record.dropped || !record.phantom)) {
  47579. this.readEntity(record);
  47580. }
  47581. }
  47582. },
  47583. readEntity: function(record) {
  47584. var me = this,
  47585. readKey = me.readKey,
  47586. name = record.entityName,
  47587. id = record.id,
  47588. seen = me.seen,
  47589. seenKey = name + id,
  47590. result, bucket;
  47591. if (seen[seenKey]) {
  47592. return;
  47593. }
  47594. seen[seenKey] = true;
  47595. result = me.result || (me.result = {});
  47596. bucket = result[name] || (result[name] = {});
  47597. bucket = bucket[readKey] || (bucket[readKey] = []);
  47598. bucket.push(Ext.apply({}, record.modified, record.data));
  47599. }
  47600. });
  47601. Ext.define('Ext.data.session.BatchVisitor', {
  47602. map: null,
  47603. constructor: function(batch) {
  47604. this.batch = batch;
  47605. },
  47606. getBatch: function(sort) {
  47607. var map = this.map,
  47608. batch = this.batch,
  47609. bucket, entity, name, operation, operationType, proxy, batchActions, records, len, i;
  47610. if (map) {
  47611. if (!batch) {
  47612. batch = new Ext.data.Batch();
  47613. }
  47614. for (name in map) {
  47615. bucket = map[name];
  47616. entity = bucket.entity;
  47617. proxy = entity.getProxy();
  47618. batchActions = proxy.getBatchActions();
  47619. delete bucket.entity;
  47620. for (operationType in bucket) {
  47621. if (batchActions) {
  47622. operation = proxy.createOperation(operationType, {
  47623. records: bucket[operationType]
  47624. });
  47625. operation.entityType = entity;
  47626. batch.add(operation);
  47627. } else {
  47628. records = bucket[operationType];
  47629. for (i = 0 , len = records.length; i < len; ++i) {
  47630. operation = proxy.createOperation(operationType, {
  47631. records: [
  47632. records[i]
  47633. ]
  47634. });
  47635. operation.entityType = entity;
  47636. batch.add(operation);
  47637. }
  47638. }
  47639. }
  47640. }
  47641. }
  47642. if (batch && sort !== false) {
  47643. batch.sort();
  47644. }
  47645. return batch;
  47646. },
  47647. onDirtyRecord: function(record) {
  47648. var me = this,
  47649. operation = record.phantom ? 'create' : (record.dropped ? 'destroy' : 'update'),
  47650. name = record.$className,
  47651. map = (me.map || (me.map = {})),
  47652. bucket = (map[name] || (map[name] = {
  47653. entity: record.self
  47654. }));
  47655. bucket = bucket[operation] || (bucket[operation] = []);
  47656. bucket.push(record);
  47657. }
  47658. });
  47659. Ext.define('Ext.mixin.Dirty', {
  47660. mixinId: 'dirty',
  47661. config: {
  47662. dirty: {
  47663. $value: false,
  47664. lazy: true
  47665. }
  47666. },
  47667. dirty: false,
  47668. _dirtyRecordCount: 0,
  47669. ignoreDirty: false,
  47670. recordStateIsDirtyState: true,
  47671. isDirty: function() {
  47672. return this.getDirty();
  47673. },
  47674. applyDirty: function(dirty) {
  47675. return this.ignoreDirty ? false : dirty;
  47676. },
  47677. updateDirty: function(dirty) {
  47678. var me = this;
  47679. me.dirty = dirty;
  47680. if (me.fireEvent && !me.isDirtyInitializing) {
  47681. me.fireDirtyChange();
  47682. }
  47683. },
  47684. clearRecordStates: function() {
  47685. var me = this,
  47686. counters = me._crudCounters;
  47687. if (counters) {
  47688. counters.C = counters.U = counters.D = 0;
  47689. }
  47690. me._dirtyRecordCount = 0;
  47691. if (me.recordStateIsDirtyState) {
  47692. me.setDirty(false);
  47693. }
  47694. },
  47695. fireDirtyChange: function() {
  47696. var me = this;
  47697. if (!me.ignoreDirty && me.hasListeners.dirtychange) {
  47698. me.fireEvent('dirtychange', me, me.dirty);
  47699. }
  47700. },
  47701. trackRecordState: function(record, initial) {
  47702. var me = this,
  47703. counters = me._crudCounters || (me._crudCounters = {
  47704. C: 0,
  47705. R: 0,
  47706. U: 0,
  47707. D: 0
  47708. }),
  47709. dirtyRecordCountWas = me._dirtyRecordCount,
  47710. state = record.crudState,
  47711. stateWas = record.crudStateWas,
  47712. changed, dirtyRecordCount;
  47713. if (initial || state !== stateWas) {
  47714. if (!initial && stateWas) {
  47715. --counters[stateWas];
  47716. }
  47717. if (!(record.phantom && state === 'D')) {
  47718. ++counters[state];
  47719. }
  47720. me.checkCounters();
  47721. me._dirtyRecordCount = dirtyRecordCount = counters.C + counters.U + counters.D;
  47722. changed = !dirtyRecordCount !== !dirtyRecordCountWas;
  47723. if (changed && me.recordStateIsDirtyState) {
  47724. me.setDirty(dirtyRecordCount > 0);
  47725. }
  47726. }
  47727. return changed;
  47728. },
  47729. untrackRecordState: function(record) {
  47730. var me = this,
  47731. counters = me._crudCounters,
  47732. dirtyRecordCountWas = me._dirtyRecordCount,
  47733. state = record.crudState,
  47734. changed, dirtyRecordCount;
  47735. if (counters && state !== 'D' && !record.erased) {
  47736. --counters[state];
  47737. me.checkCounters();
  47738. me._dirtyRecordCount = dirtyRecordCount = counters.C + counters.U + counters.D;
  47739. changed = !dirtyRecordCount !== !dirtyRecordCountWas;
  47740. if (changed && me.recordStateIsDirtyState) {
  47741. me.setDirty(dirtyRecordCount > 0);
  47742. }
  47743. }
  47744. return changed;
  47745. },
  47746. checkCounters: function() {
  47747. var counters = this._crudCounters,
  47748. key;
  47749. for (key in counters) {
  47750. if (counters[key] < 0) {
  47751. Ext.raise('Invalid state for ' + key);
  47752. }
  47753. }
  47754. }
  47755. });
  47756. Ext.define('Ext.data.Session', {
  47757. mixins: [
  47758. Ext.mixin.Dirty,
  47759. Ext.mixin.Observable
  47760. ],
  47761. isSession: true,
  47762. config: {
  47763. schema: 'default',
  47764. parent: null,
  47765. autoDestroy: true,
  47766. crudProperties: {
  47767. create: 'C',
  47768. read: 'R',
  47769. update: 'U',
  47770. drop: 'D'
  47771. }
  47772. },
  47773. crudOperations: [
  47774. {
  47775. type: 'R',
  47776. entityMethod: 'readEntities'
  47777. },
  47778. {
  47779. type: 'C',
  47780. entityMethod: 'createEntities'
  47781. },
  47782. {
  47783. type: 'U',
  47784. entityMethod: 'updateEntities'
  47785. },
  47786. {
  47787. type: 'D',
  47788. entityMethod: 'dropEntities'
  47789. }
  47790. ],
  47791. crudKeys: {
  47792. C: 1,
  47793. R: 1,
  47794. U: 1,
  47795. D: 1
  47796. },
  47797. statics: {
  47798. nextId: 1
  47799. },
  47800. constructor: function(config) {
  47801. var me = this;
  47802. me.data = {};
  47803. me.matrices = {};
  47804. me.id = Ext.data.Session.nextId++;
  47805. me.identifierCache = {};
  47806. me.recordCreator = me.recordCreator.bind(me);
  47807. me.mixins.observable.constructor.call(me, config);
  47808. },
  47809. destroy: function() {
  47810. var me = this,
  47811. matrices = me.matrices,
  47812. data = me.data,
  47813. entityName, entities, record, id;
  47814. for (id in matrices) {
  47815. matrices[id].destroy();
  47816. }
  47817. for (entityName in data) {
  47818. entities = data[entityName];
  47819. for (id in entities) {
  47820. record = entities[id].record;
  47821. if (record) {
  47822. record.$source = null;
  47823. record.unjoin(me);
  47824. }
  47825. }
  47826. }
  47827. me.identifierCache = me.recordCreator = me.matrices = me.data = null;
  47828. me.setSchema(null);
  47829. me.callParent();
  47830. },
  47831. adopt: function(record) {
  47832. var me = this,
  47833. associations = record.associations,
  47834. roleName;
  47835. me.checkModelType(record.self);
  47836. if (record.session && record.session !== me) {
  47837. Ext.raise('Record already belongs to an existing session');
  47838. }
  47839. if (record.session !== me) {
  47840. me.add(record);
  47841. if (associations) {
  47842. for (roleName in associations) {
  47843. associations[roleName].adoptAssociated(record, me);
  47844. }
  47845. }
  47846. }
  47847. },
  47848. commit: function() {
  47849. var me = this,
  47850. data = me.data,
  47851. matrices = me.matrices,
  47852. dirtyWas = me.getDirty(),
  47853. entityName, entities, id, record;
  47854. me.suspendEvent('dirtychange');
  47855. for (entityName in data) {
  47856. entities = data[entityName];
  47857. for (id in entities) {
  47858. record = entities[id].record;
  47859. if (record) {
  47860. record.commit();
  47861. }
  47862. }
  47863. }
  47864. for (id in matrices) {
  47865. matrices[id].commit();
  47866. }
  47867. me.clearRecordStates();
  47868. me.resumeEvent('dirtychange');
  47869. if (me.getDirty() !== dirtyWas) {
  47870. me.fireDirtyChange();
  47871. }
  47872. },
  47873. createRecord: function(type, data, preventAdd) {
  47874. this.checkModelType(type);
  47875. var Model = type.$isClass ? type : this.getSchema().getEntity(type),
  47876. parent = this.getParent(),
  47877. id;
  47878. if (data && parent) {
  47879. id = Model.getIdFromData(data);
  47880. if (parent.peekRecord(Model, id)) {
  47881. Ext.raise('A parent session already contains an entry for ' + Model.entityName + ': ' + id);
  47882. }
  47883. }
  47884. return new Model(data, preventAdd ? null : this);
  47885. },
  47886. getChanges: function() {
  47887. var visitor = new Ext.data.session.ChangesVisitor(this);
  47888. this.visitData(visitor);
  47889. return visitor.result;
  47890. },
  47891. getChangesForParent: function() {
  47892. var visitor = new Ext.data.session.ChildChangesVisitor(this);
  47893. this.visitData(visitor);
  47894. return visitor.result;
  47895. },
  47896. getRecord: function(type, id, autoLoad) {
  47897. var me = this,
  47898. wasInstance = type.isModel,
  47899. record, Model, parent, parentRec;
  47900. if (wasInstance) {
  47901. wasInstance = type;
  47902. id = type.id;
  47903. type = type.self;
  47904. }
  47905. record = me.peekRecord(type, id);
  47906. if (!record) {
  47907. Model = type.$isClass ? type : me.getSchema().getEntity(type);
  47908. parent = me.getParent();
  47909. if (parent) {
  47910. parentRec = parent.peekRecord(Model, id);
  47911. }
  47912. if (parentRec) {
  47913. if (parentRec.isLoading()) {
  47914. wasInstance = false;
  47915. } else {
  47916. record = parentRec.copy(undefined, me);
  47917. record.$source = parentRec;
  47918. }
  47919. }
  47920. if (!record) {
  47921. if (wasInstance) {
  47922. record = wasInstance;
  47923. me.adopt(record);
  47924. } else {
  47925. record = Model.createWithId(id, null, me);
  47926. if (autoLoad !== false) {
  47927. record.load(Ext.isObject(autoLoad) ? autoLoad : undefined);
  47928. }
  47929. }
  47930. }
  47931. }
  47932. return record;
  47933. },
  47934. getSaveBatch: function(sort) {
  47935. var visitor = new Ext.data.session.BatchVisitor();
  47936. this.visitData(visitor);
  47937. return visitor.getBatch(sort);
  47938. },
  47939. onInvalidAssociationEntity: function(entityType, id) {
  47940. Ext.raise('Unable to read association entity: ' + this.getModelIdentifier(entityType, id));
  47941. },
  47942. onInvalidEntityCreate: function(entityType, id) {
  47943. Ext.raise('Cannot create, record already not exists: ' + this.getModelIdentifier(entityType, id));
  47944. },
  47945. onInvalidEntityDrop: function(entityType, id) {
  47946. Ext.raise('Cannot drop, record does not exist: ' + this.getModelIdentifier(entityType, id));
  47947. },
  47948. onInvalidEntityRead: function(entityType, id) {
  47949. Ext.raise('Cannot read, record already not exists: ' + this.getModelIdentifier(entityType, id));
  47950. },
  47951. onInvalidEntityUpdate: function(entityType, id, dropped) {
  47952. if (dropped) {
  47953. Ext.raise('Cannot update, record dropped: ' + this.getModelIdentifier(entityType, id));
  47954. } else {
  47955. Ext.raise('Cannot update, record does not exist: ' + this.getModelIdentifier(entityType, id));
  47956. }
  47957. },
  47958. peekRecord: function(type, id, deep) {
  47959. this.checkModelType(type);
  47960. var entityType = type.$isClass ? type : this.getSchema().getEntity(type),
  47961. entityName = entityType.entityName,
  47962. entry = this.data[entityName],
  47963. ret, parent;
  47964. entry = entry && entry[id];
  47965. ret = entry && entry.record;
  47966. if (!ret && deep) {
  47967. parent = this.getParent();
  47968. ret = parent && parent.peekRecord(type, id, deep);
  47969. }
  47970. return ret || null;
  47971. },
  47972. save: function() {
  47973. var me = this,
  47974. parent = me.getParent(),
  47975. visitor;
  47976. if (parent) {
  47977. visitor = new Ext.data.session.ChildChangesVisitor(me);
  47978. me.visitData(visitor);
  47979. parent.update(visitor.result);
  47980. me.commit();
  47981. } else
  47982. {
  47983. Ext.raise('Cannot commit session, no parent exists');
  47984. }
  47985. },
  47986. spawn: function() {
  47987. return new this.self({
  47988. schema: this.getSchema(),
  47989. parent: this
  47990. });
  47991. },
  47992. update: function(data) {
  47993. var me = this,
  47994. schema = me.getSchema(),
  47995. crudOperations = me.crudOperations,
  47996. len = crudOperations.length,
  47997. crudKeys = me.crudKeys,
  47998. dirtyWas = me.getDirty(),
  47999. entityName, entityType, entityInfo, i, operation, item, associations, key, role, associationData;
  48000. me.suspendEvent('dirtychange');
  48001. me.getSchema().processKeyChecks(true);
  48002. for (entityName in data) {
  48003. entityType = schema.getEntity(entityName);
  48004. if (!entityType) {
  48005. Ext.raise('Invalid entity type: ' + entityName);
  48006. }
  48007. entityInfo = data[entityName];
  48008. for (i = 0; i < len; ++i) {
  48009. operation = crudOperations[i];
  48010. item = entityInfo[operation.type];
  48011. if (item) {
  48012. me[operation.entityMethod](entityType, item);
  48013. }
  48014. }
  48015. }
  48016. for (entityName in data) {
  48017. entityType = schema.getEntity(entityName);
  48018. associations = entityType.associations;
  48019. entityInfo = data[entityName];
  48020. for (key in entityInfo) {
  48021. if (crudKeys[key]) {
  48022. continue;
  48023. }
  48024. role = associations[key];
  48025. if (!role) {
  48026. Ext.raise('Invalid association key for ' + entityName + ', "' + key + '"');
  48027. }
  48028. associationData = entityInfo[role.role];
  48029. role.processUpdate(me, associationData);
  48030. }
  48031. }
  48032. me.resumeEvent('dirtychange');
  48033. if (me.getDirty() !== dirtyWas) {
  48034. me.fireDirtyChange();
  48035. }
  48036. },
  48037. afterCommit: function(record) {
  48038. this.trackRecordState(record);
  48039. },
  48040. afterDrop: function(record) {
  48041. this.trackRecordState(record);
  48042. },
  48043. afterEdit: function(record) {
  48044. this.trackRecordState(record);
  48045. },
  48046. afterErase: function(record) {
  48047. this.evict(record);
  48048. },
  48049. afterReject: function(record) {
  48050. this.trackRecordState(record);
  48051. },
  48052. privates: {
  48053. add: function(record) {
  48054. var me = this,
  48055. id = record.id,
  48056. entry = me.getEntry(record.self, id),
  48057. associations, roleName;
  48058. if (entry.record) {
  48059. Ext.raise('Duplicate id ' + record.id + ' for ' + record.entityName);
  48060. }
  48061. record.session = me;
  48062. entry.record = record;
  48063. me.trackRecordState(record, true);
  48064. me.registerReferences(record);
  48065. associations = record.associations;
  48066. for (roleName in associations) {
  48067. associations[roleName].checkMembership(me, record);
  48068. }
  48069. },
  48070. applySchema: function(schema) {
  48071. return Ext.data.schema.Schema.get(schema);
  48072. },
  48073. checkModelType: function(name) {
  48074. if (name.$isClass) {
  48075. name = name.entityName;
  48076. }
  48077. if (!name) {
  48078. Ext.raise('Unable to use anonymous models in a Session');
  48079. } else if (!this.getSchema().getEntity(name)) {
  48080. Ext.raise('Unknown entity type ' + name);
  48081. }
  48082. },
  48083. createEntities: function(entityType, items) {
  48084. var me = this,
  48085. len = items.length,
  48086. i, data, rec, id;
  48087. for (i = 0; i < len; ++i) {
  48088. data = items[i];
  48089. id = entityType.getIdFromData(data);
  48090. rec = me.peekRecord(entityType, id);
  48091. if (!rec) {
  48092. rec = me.createRecord(entityType, data, true);
  48093. rec.phantom = true;
  48094. rec.crudState = 'C';
  48095. me.add(rec);
  48096. rec.crudStateWas = 'C';
  48097. } else {
  48098. me.onInvalidEntityCreate(entityType, id);
  48099. }
  48100. }
  48101. },
  48102. dropEntities: function(entityType, ids) {
  48103. var len = ids.length,
  48104. i, rec, id, extractId;
  48105. if (len) {
  48106. extractId = Ext.isObject(ids[0]);
  48107. }
  48108. for (i = 0; i < len; ++i) {
  48109. id = ids[i];
  48110. if (extractId) {
  48111. id = entityType.getIdFromData(id);
  48112. }
  48113. rec = this.peekRecord(entityType, id);
  48114. if (rec) {
  48115. rec.drop();
  48116. } else {
  48117. this.onInvalidEntityDrop(entityType, id);
  48118. }
  48119. }
  48120. },
  48121. evict: function(record) {
  48122. var me = this,
  48123. entityName = record.entityName,
  48124. entities = me.data[entityName],
  48125. id = record.id;
  48126. if (entities && entities[id]) {
  48127. me.untrackRecordState(record);
  48128. record.unjoin(me);
  48129. delete entities[id];
  48130. }
  48131. },
  48132. getEntityList: function(entityType, ids) {
  48133. var len = ids.length,
  48134. i, id, rec, invalid;
  48135. for (i = 0; i < len; ++i) {
  48136. id = ids[i];
  48137. rec = this.peekRecord(entityType, id);
  48138. if (rec) {
  48139. ids[i] = rec;
  48140. } else {
  48141. invalid = true;
  48142. ids[i] = null;
  48143. this.onInvalidAssociationEntity(entityType, id);
  48144. }
  48145. }
  48146. if (invalid) {
  48147. ids = Ext.Array.clean(ids);
  48148. }
  48149. return ids;
  48150. },
  48151. getEntry: function(type, id) {
  48152. if (type.isModel) {
  48153. id = type.getId();
  48154. type = type.self;
  48155. }
  48156. var entityType = type.$isClass ? type : this.getSchema().getEntity(type),
  48157. entityName = entityType.entityName,
  48158. data = this.data,
  48159. entry;
  48160. entry = data[entityName] || (data[entityName] = {});
  48161. entry = entry[id] || (entry[id] = {});
  48162. return entry;
  48163. },
  48164. getRefs: function(record, role, includeParent) {
  48165. var entry = this.getEntry(record),
  48166. refs = entry && entry.refs && entry.refs[role.role],
  48167. parent = includeParent && this.getParent(),
  48168. parentRefs, id, rec;
  48169. if (parent) {
  48170. parentRefs = parent.getRefs(record, role);
  48171. if (parentRefs) {
  48172. for (id in parentRefs) {
  48173. rec = parentRefs[id];
  48174. if ((!refs || !refs[id])) {
  48175. this.getRecord(rec.self, rec.id);
  48176. }
  48177. }
  48178. refs = entry && entry.refs && entry.refs[role.role];
  48179. }
  48180. }
  48181. return refs || null;
  48182. },
  48183. getIdentifier: function(entityType) {
  48184. var parent = this.getParent(),
  48185. cache, identifier, key, ret;
  48186. if (parent) {
  48187. ret = parent.getIdentifier(entityType);
  48188. } else {
  48189. cache = this.identifierCache;
  48190. identifier = entityType.identifier;
  48191. key = identifier.getId() || entityType.entityName;
  48192. ret = cache[key];
  48193. if (!ret) {
  48194. if (identifier.clone) {
  48195. ret = identifier.clone({
  48196. id: null
  48197. });
  48198. } else {
  48199. ret = identifier;
  48200. }
  48201. cache[key] = ret;
  48202. }
  48203. }
  48204. return ret;
  48205. },
  48206. getMatrix: function(matrix, preventCreate) {
  48207. var name = matrix.isManyToMany ? matrix.name : matrix,
  48208. matrices = this.matrices,
  48209. ret;
  48210. ret = matrices[name];
  48211. if (!ret && !preventCreate) {
  48212. ret = matrices[name] = new Ext.data.matrix.Matrix(this, matrix);
  48213. }
  48214. return ret || null;
  48215. },
  48216. getMatrixSlice: function(role, id) {
  48217. var matrix = this.getMatrix(role.association),
  48218. side = matrix[role.side];
  48219. return side.get(id);
  48220. },
  48221. getModelIdentifier: function(entityType, id) {
  48222. return id + '@' + entityType.entityName;
  48223. },
  48224. onIdChanged: function(record, oldId, newId) {
  48225. var me = this,
  48226. matrices = me.matrices,
  48227. entityName = record.entityName,
  48228. id = record.id,
  48229. bucket = me.data[entityName],
  48230. entry = bucket[oldId],
  48231. associations = record.associations,
  48232. refs = entry.refs,
  48233. setNoRefs = me._setNoRefs,
  48234. association, fieldName, matrix, refId, role, roleName, roleRefs, key;
  48235. if (bucket[newId]) {
  48236. Ext.raise('Cannot change ' + entityName + ' id from ' + oldId + ' to ' + newId + ' id already exists');
  48237. }
  48238. delete bucket[oldId];
  48239. bucket[newId] = entry;
  48240. for (key in matrices) {
  48241. matrices[key].updateId(record, oldId, newId);
  48242. }
  48243. if (refs) {
  48244. for (roleName in refs) {
  48245. roleRefs = refs[roleName];
  48246. role = associations[roleName];
  48247. association = role.association;
  48248. if (!association.isManyToMany) {
  48249. fieldName = association.field.name;
  48250. for (refId in roleRefs) {
  48251. roleRefs[refId].set(fieldName, id, setNoRefs);
  48252. }
  48253. }
  48254. }
  48255. }
  48256. me.registerReferences(record, oldId);
  48257. },
  48258. processManyBlock: function(entityType, role, items, processor) {
  48259. var me = this,
  48260. id, record, records, store;
  48261. if (items) {
  48262. for (id in items) {
  48263. record = me.peekRecord(entityType, id);
  48264. if (record) {
  48265. records = me.getEntityList(role.cls, items[id]);
  48266. store = role.getAssociatedItem(record);
  48267. me[processor](role, store, record, records);
  48268. } else {
  48269. me.onInvalidAssociationEntity(entityType, id);
  48270. }
  48271. }
  48272. }
  48273. },
  48274. processManyCreate: function(role, store, record, records) {
  48275. if (store) {
  48276. store.add(records);
  48277. } else {
  48278. record[role.getterName](null, null, records);
  48279. }
  48280. },
  48281. processManyDrop: function(role, store, record, records) {
  48282. if (store) {
  48283. store.remove(records);
  48284. }
  48285. },
  48286. processManyRead: function(role, store, record, records) {
  48287. if (store) {
  48288. store.setRecords(records);
  48289. } else {
  48290. record[role.getterName](null, null, records);
  48291. }
  48292. },
  48293. readEntities: function(entityType, items) {
  48294. var me = this,
  48295. len = items.length,
  48296. i, data, rec, id;
  48297. for (i = 0; i < len; ++i) {
  48298. data = items[i];
  48299. id = entityType.getIdFromData(data);
  48300. rec = me.peekRecord(entityType, id);
  48301. if (!rec) {
  48302. rec = me.createRecord(entityType, data, true);
  48303. } else {
  48304. me.onInvalidEntityRead(entityType, id);
  48305. }
  48306. rec.phantom = false;
  48307. me.add(rec);
  48308. }
  48309. },
  48310. recordCreator: function(data, Model) {
  48311. var me = this,
  48312. id = Model.getIdFromData(data),
  48313. record = me.peekRecord(Model, id, true);
  48314. if (!record) {
  48315. record = new Model(data, me);
  48316. } else {
  48317. record = me.getRecord(Model, id);
  48318. record.mergeData(data);
  48319. }
  48320. return record;
  48321. },
  48322. registerReferences: function(record, oldId) {
  48323. var entityName = record.entityName,
  48324. id = record.id,
  48325. recordData = record.data,
  48326. remove = oldId || oldId === 0,
  48327. entry, i, fk, len, reference, references, refs, roleName;
  48328. len = (references = record.references).length;
  48329. for (i = 0; i < len; ++i) {
  48330. reference = references[i];
  48331. fk = recordData[reference.name];
  48332. if (fk || fk === 0) {
  48333. reference = reference.reference;
  48334. entityName = reference.type;
  48335. roleName = reference.inverse.role;
  48336. entry = this.getEntry(reference.cls, fk);
  48337. refs = entry.refs || (entry.refs = {});
  48338. refs = refs[roleName] || (refs[roleName] = {});
  48339. refs[id] = record;
  48340. if (remove) {
  48341. delete refs[oldId];
  48342. }
  48343. }
  48344. }
  48345. },
  48346. updateEntities: function(entityType, items) {
  48347. var len = items.length,
  48348. i, data, rec, id, modified;
  48349. if (Ext.isArray(items)) {
  48350. for (i = 0; i < len; ++i) {
  48351. data = items[i];
  48352. id = entityType.getIdFromData(data);
  48353. rec = this.peekRecord(entityType, id);
  48354. if (rec) {
  48355. rec.set(data);
  48356. } else {
  48357. this.onInvalidEntityUpdate(entityType, id);
  48358. }
  48359. }
  48360. } else {
  48361. for (id in items) {
  48362. data = items[id];
  48363. rec = this.peekRecord(entityType, id);
  48364. if (rec && !rec.dropped) {
  48365. modified = rec.set(data);
  48366. } else {
  48367. this.onInvalidEntityUpdate(entityType, id, !!rec);
  48368. }
  48369. }
  48370. }
  48371. },
  48372. updateReference: function(record, field, newValue, oldValue) {
  48373. var reference = field.reference,
  48374. entityName = reference.type,
  48375. roleName = reference.inverse.role,
  48376. id = record.id,
  48377. entry, refs;
  48378. if (oldValue || oldValue === 0) {
  48379. refs = this.getEntry(entityName, oldValue).refs[roleName];
  48380. delete refs[id];
  48381. }
  48382. if (newValue || newValue === 0) {
  48383. entry = this.getEntry(entityName, newValue);
  48384. refs = entry.refs || (entry.refs = {});
  48385. refs = refs[roleName] || (refs[roleName] = {});
  48386. refs[id] = record;
  48387. }
  48388. },
  48389. visitData: function(visitor) {
  48390. var me = this,
  48391. data = me.data,
  48392. matrices = me.matrices,
  48393. all, assoc, id, id2, matrix, members, name, record, slice, slices, state;
  48394. me.getSchema().processKeyChecks(true);
  48395. for (name in data) {
  48396. all = data[name];
  48397. for (id in all) {
  48398. record = all[id].record;
  48399. if (record) {
  48400. if (record.phantom || record.dirty || record.dropped) {
  48401. if (visitor.onDirtyRecord) {
  48402. visitor.onDirtyRecord(record);
  48403. }
  48404. } else if (visitor.onCleanRecord) {
  48405. visitor.onCleanRecord(record);
  48406. }
  48407. }
  48408. }
  48409. }
  48410. if (visitor.onMatrixChange) {
  48411. for (name in matrices) {
  48412. matrix = matrices[name].left;
  48413. slices = matrix.slices;
  48414. assoc = matrix.role.association;
  48415. for (id in slices) {
  48416. slice = slices[id];
  48417. members = slice.members;
  48418. for (id2 in members) {
  48419. state = (record = members[id2])[2];
  48420. if (state) {
  48421. visitor.onMatrixChange(assoc, record[0], record[1], state);
  48422. }
  48423. }
  48424. }
  48425. }
  48426. }
  48427. return visitor;
  48428. },
  48429. _setNoRefs: {
  48430. refs: false
  48431. }
  48432. }
  48433. });
  48434. Ext.define('Ext.util.Schedulable', {
  48435. 'abstract': true,
  48436. isSchedulable: true,
  48437. scheduled: false,
  48438. constructor: function() {
  48439. this.getScheduler().add(this);
  48440. },
  48441. destroy: function() {
  48442. var me = this,
  48443. scheduler = me.getScheduler();
  48444. if (scheduler && !scheduler.destroyed) {
  48445. scheduler.remove(me);
  48446. }
  48447. me.scheduler = null;
  48448. me.schedule = me.react = Ext.emptyFn;
  48449. me.callParent();
  48450. },
  48451. getFullName: function() {
  48452. return this.name || this.id;
  48453. },
  48454. privates: {
  48455. getScheduler: function() {
  48456. return this.scheduler;
  48457. },
  48458. schedule: function() {
  48459. var me = this,
  48460. scheduler;
  48461. if (!me.scheduled) {
  48462. scheduler = me.getScheduler();
  48463. if (scheduler) {
  48464. me.scheduled = true;
  48465. if (me.onSchedule) {
  48466. me.onSchedule();
  48467. }
  48468. scheduler.scheduleItem(me);
  48469. }
  48470. }
  48471. },
  48472. unschedule: function() {
  48473. var me = this,
  48474. scheduler;
  48475. if (me.scheduled) {
  48476. scheduler = me.getScheduler();
  48477. if (scheduler && !scheduler.destroyed) {
  48478. scheduler.unscheduleItem(me);
  48479. }
  48480. me.scheduled = false;
  48481. }
  48482. },
  48483. sort: function() {}
  48484. }
  48485. });
  48486. Ext.define('Ext.app.bind.BaseBinding', {
  48487. extend: Ext.util.Schedulable,
  48488. isBinding: true,
  48489. calls: 0,
  48490. kind: 20,
  48491. defaultOptions: {},
  48492. lastValue: undefined,
  48493. constructor: function(owner, callback, scope, options) {
  48494. var me = this;
  48495. me.options = options;
  48496. me.owner = owner;
  48497. me.scope = scope;
  48498. me.callback = callback;
  48499. if (!callback) {
  48500. Ext.raise('Callback is required');
  48501. }
  48502. me.lateBound = Ext.isString(callback);
  48503. if (options && options.deep) {
  48504. me.deep = true;
  48505. }
  48506. me.callParent();
  48507. },
  48508. destroy: function() {
  48509. var me = this,
  48510. owner = me.owner;
  48511. if (owner) {
  48512. owner.onBindDestroy(me);
  48513. }
  48514. me.callParent();
  48515. me.scope = me.callback = me.owner = null;
  48516. },
  48517. isReadOnly: function() {
  48518. return true;
  48519. },
  48520. privates: {
  48521. getScheduler: function() {
  48522. var owner = this.owner;
  48523. return owner && owner.getScheduler();
  48524. },
  48525. getSession: function() {
  48526. var owner = this.owner;
  48527. return owner.isSession ? owner : owner.getSession();
  48528. },
  48529. notify: function(value) {
  48530. var me = this,
  48531. options = me.options || me.defaultOptions,
  48532. previous = me.lastValue;
  48533. if (!me.calls || me.deep || me.valueChanged(value, previous)) {
  48534. ++me.calls;
  48535. me.lastValue = value;
  48536. if (me.lateBound) {
  48537. me.scope[me.callback](value, previous, me);
  48538. } else {
  48539. me.callback.call(me.scope, value, previous, me);
  48540. }
  48541. if (options.single) {
  48542. me.destroy();
  48543. }
  48544. }
  48545. },
  48546. valueChanged: function(value, previous) {
  48547. var ret = true;
  48548. if (previous !== value) {
  48549. if (value && previous && value instanceof Date && previous instanceof Date) {
  48550. ret = value.getTime() !== previous.getTime();
  48551. }
  48552. } else {
  48553. ret = Ext.isArray(value);
  48554. }
  48555. return ret;
  48556. }
  48557. }
  48558. });
  48559. Ext.define('Ext.app.bind.Binding', {
  48560. extend: Ext.app.bind.BaseBinding,
  48561. constructor: function(stub, callback, scope, options) {
  48562. var me = this;
  48563. me.callParent([
  48564. stub.owner,
  48565. callback,
  48566. scope,
  48567. options
  48568. ]);
  48569. me.stub = stub;
  48570. me.depth = stub.depth;
  48571. if (stub.isAvailable() && !stub.scheduled) {
  48572. me.schedule();
  48573. }
  48574. },
  48575. destroy: function(fromParent) {
  48576. var me = this,
  48577. stub = me.stub;
  48578. if (stub && !fromParent) {
  48579. stub.unbind(me);
  48580. me.stub = null;
  48581. }
  48582. me.callParent();
  48583. },
  48584. bindValidation: function(callback, scope) {
  48585. var stub = this.stub;
  48586. return stub && stub.bindValidation(callback, scope);
  48587. },
  48588. bindValidationField: function(callback, scope) {
  48589. var stub = this.stub;
  48590. return stub && stub.bindValidationField(callback, scope);
  48591. },
  48592. getFullName: function() {
  48593. return this.fullName || (this.fullName = '@(' + this.stub.getFullName() + ')');
  48594. },
  48595. getValue: function() {
  48596. var me = this,
  48597. stub = me.stub;
  48598. return stub && stub.getValue();
  48599. },
  48600. isAvailable: function() {
  48601. var stub = this.stub;
  48602. return stub && stub.isAvailable();
  48603. },
  48604. isLoading: function() {
  48605. var stub = this.stub;
  48606. return stub && stub.isLoading();
  48607. },
  48608. isReadOnly: function() {
  48609. var stub = this.stub,
  48610. options = this.options,
  48611. ret = true;
  48612. if (!(options && options.twoWay === false)) {
  48613. if (stub) {
  48614. ret = stub.isReadOnly();
  48615. }
  48616. }
  48617. return ret;
  48618. },
  48619. refresh: function() {},
  48620. setValue: function(value) {
  48621. if (this.isReadOnly()) {
  48622. Ext.raise('Cannot setValue on a readonly binding');
  48623. }
  48624. this.stub.set(value);
  48625. },
  48626. privates: {
  48627. getDataObject: function() {
  48628. var stub = this.stub;
  48629. return stub && stub.getDataObject();
  48630. },
  48631. getRawValue: function() {
  48632. var me = this,
  48633. stub = me.stub;
  48634. return stub && stub.getRawValue();
  48635. },
  48636. isDescendantOf: function(item) {
  48637. var stub = this.stub;
  48638. return stub ? (item === stub) || stub.isDescendantOf(item) : false;
  48639. },
  48640. react: function() {
  48641. this.notify(this.getValue());
  48642. },
  48643. schedule: function() {
  48644. if (!this.stub.scheduled) {
  48645. this.callParent();
  48646. }
  48647. },
  48648. sort: function() {
  48649. var stub = this.stub;
  48650. stub.scheduler.sortItem(stub);
  48651. }
  48652. }
  48653. });
  48654. Ext.define('Ext.app.bind.AbstractStub', {
  48655. extend: Ext.util.Schedulable,
  48656. children: null,
  48657. depth: 0,
  48658. generation: 1,
  48659. kind: 10,
  48660. parent: null,
  48661. constructor: function(owner, name) {
  48662. var me = this;
  48663. me.owner = owner;
  48664. me.name = name;
  48665. me.callParent();
  48666. },
  48667. destroy: function() {
  48668. var me = this,
  48669. children = me.children,
  48670. bindings = me.bindings,
  48671. len, i, key;
  48672. if (bindings) {
  48673. for (i = 0 , len = bindings.length; i < len; ++i) {
  48674. bindings[i].destroy(true);
  48675. }
  48676. }
  48677. for (key in children) {
  48678. children[key].destroy();
  48679. }
  48680. if (me.scheduled) {
  48681. me.unschedule();
  48682. }
  48683. me.callParent();
  48684. },
  48685. add: function(child) {
  48686. var me = this;
  48687. (me.children || (me.children = {}))[child.name] = child;
  48688. child.depth = me.depth + 1;
  48689. child.parent = me;
  48690. },
  48691. getChild: function(path) {
  48692. var pathArray = Ext.isString(path) ? path.split('.') : path;
  48693. if (pathArray && pathArray.length) {
  48694. return this.descend(pathArray, 0);
  48695. }
  48696. return this;
  48697. },
  48698. getFullName: function() {
  48699. var me = this,
  48700. name = me.fullName,
  48701. parent = me.parent,
  48702. s;
  48703. if (!name) {
  48704. name = me.name || me.id;
  48705. if (parent && (s = parent.getFullName())) {
  48706. name = ((s.charAt(s.length - 1) !== ':') ? s + '.' : s) + name;
  48707. }
  48708. me.fullName = name;
  48709. }
  48710. return name;
  48711. },
  48712. getSession: function() {
  48713. var owner = this.owner;
  48714. return owner.isSession ? owner : owner.getSession();
  48715. },
  48716. bind: function(callback, scope, options) {
  48717. var me = this,
  48718. binding = new Ext.app.bind.Binding(me, callback, scope, options),
  48719. bindings = (me.bindings || (me.bindings = []));
  48720. binding.depth = me.depth;
  48721. bindings.push(binding);
  48722. return binding;
  48723. },
  48724. getValue: function() {
  48725. return this.isAvailable() ? this.getRawValue() : null;
  48726. },
  48727. graft: function(replacement) {
  48728. var me = this,
  48729. bindings = me.bindings,
  48730. name = me.name,
  48731. i;
  48732. me.parent = me.bindings = null;
  48733. me.destroy();
  48734. replacement.depth = me.depth;
  48735. replacement.bindings = bindings;
  48736. replacement.generation = me.generation + 1;
  48737. replacement.name = name;
  48738. replacement.id = me.id;
  48739. replacement.path = me.path;
  48740. if (bindings) {
  48741. for (i = bindings.length; i-- > 0; ) {
  48742. bindings[i].stub = replacement;
  48743. }
  48744. }
  48745. return replacement;
  48746. },
  48747. isDescendantOf: function(item) {
  48748. for (var parent = this; parent = parent.parent; ) {
  48749. if (parent === item) {
  48750. return true;
  48751. }
  48752. }
  48753. return false;
  48754. },
  48755. isAvailable: function() {
  48756. return true;
  48757. },
  48758. isLoading: function() {
  48759. return false;
  48760. },
  48761. onSchedule: function() {
  48762. for (var i, len, binding, bindings,
  48763. p = this.parent; p; p = p.parent) {
  48764. bindings = p.bindings;
  48765. if (bindings) {
  48766. for (i = 0 , len = bindings.length; i < len; ++i) {
  48767. binding = bindings[i];
  48768. if (binding.deep && !binding.scheduled) {
  48769. binding.schedule();
  48770. }
  48771. }
  48772. }
  48773. }
  48774. },
  48775. react: function() {
  48776. var bindings = this.bindings,
  48777. binding, i, len;
  48778. if (bindings) {
  48779. for (i = 0 , len = bindings.length; i < len; ++i) {
  48780. binding = bindings[i];
  48781. if (!binding.scheduled) {
  48782. binding.schedule();
  48783. }
  48784. }
  48785. }
  48786. },
  48787. unbind: function(binding) {
  48788. var bindings = this.bindings;
  48789. if (bindings && bindings.length) {
  48790. Ext.Array.remove(bindings, binding);
  48791. }
  48792. },
  48793. privates: {
  48794. collect: function() {
  48795. var children = this.children,
  48796. bindings = this.bindings,
  48797. totalCount = 0,
  48798. count = 0,
  48799. child, key;
  48800. if (children) {
  48801. for (key in children) {
  48802. child = children[key];
  48803. count = child.collect();
  48804. if (count === 0) {
  48805. child.destroy();
  48806. delete children[key];
  48807. }
  48808. totalCount += count;
  48809. }
  48810. }
  48811. if (bindings) {
  48812. totalCount += bindings.length;
  48813. }
  48814. return totalCount;
  48815. },
  48816. getScheduler: function() {
  48817. var owner = this.owner;
  48818. return owner && owner.getScheduler();
  48819. },
  48820. sort: function() {
  48821. var parent = this.parent;
  48822. if (parent) {
  48823. this.scheduler.sortItem(parent);
  48824. }
  48825. }
  48826. }
  48827. });
  48828. Ext.define('Ext.app.bind.Stub', {
  48829. extend: Ext.app.bind.AbstractStub,
  48830. isStub: true,
  48831. dirty: true,
  48832. formula: null,
  48833. validationKey: 'validation',
  48834. constructor: function(owner, name, parent) {
  48835. var me = this,
  48836. path = name;
  48837. me.callParent([
  48838. owner,
  48839. name
  48840. ]);
  48841. me.boundValue = null;
  48842. if (parent) {
  48843. parent.add(me);
  48844. if (!parent.isRootStub) {
  48845. path = parent.path + '.' + name;
  48846. }
  48847. me.checkHadValue();
  48848. }
  48849. me.path = path;
  48850. },
  48851. destroy: function() {
  48852. var me = this,
  48853. formula = me.formula,
  48854. storeBinding = me.storeBinding;
  48855. if (formula) {
  48856. formula.destroy();
  48857. }
  48858. if (storeBinding) {
  48859. storeBinding.destroy();
  48860. }
  48861. me.detachBound();
  48862. me.callParent();
  48863. },
  48864. bindValidation: function(callback, scope) {
  48865. var parent = this.parent;
  48866. return parent && parent.descend([
  48867. this.validationKey,
  48868. this.name
  48869. ]).bind(callback, scope);
  48870. },
  48871. bindValidationField: function(callback, scope) {
  48872. var parent = this.parent,
  48873. name = this.name,
  48874. lateBound = typeof callback === 'string',
  48875. ret;
  48876. if (parent) {
  48877. ret = parent.bind(function(value) {
  48878. var field = null;
  48879. if (value && value.isModel) {
  48880. field = value.getField(name);
  48881. }
  48882. if (lateBound) {
  48883. scope[callback](field, value, this);
  48884. } else {
  48885. callback.call(scope, field, value, this);
  48886. }
  48887. });
  48888. }
  48889. return ret || null;
  48890. },
  48891. descend: function(path, index) {
  48892. var me = this,
  48893. children = me.children || (me.children = {}),
  48894. pos = index || 0,
  48895. name = path[pos++],
  48896. ret;
  48897. if (!(ret = children[name])) {
  48898. ret = new Ext.app.bind.Stub(me.owner, name, me);
  48899. }
  48900. if (pos < path.length) {
  48901. ret = ret.descend(path, pos);
  48902. }
  48903. return ret;
  48904. },
  48905. getChildValue: function(parentData) {
  48906. var me = this,
  48907. name = me.name,
  48908. bindMappings = me.bindMappings,
  48909. storeMappings = bindMappings.store,
  48910. modelMappings = bindMappings.model,
  48911. ret;
  48912. if (!parentData && !Ext.isString(parentData)) {
  48913. ret = me.hadValue ? null : undefined;
  48914. } else {
  48915. ret = me.inspectValue(parentData);
  48916. if (!ret) {
  48917. if (parentData.isEntity) {
  48918. if (modelMappings[name]) {
  48919. ret = parentData[modelMappings[name]]();
  48920. } else {
  48921. ret = parentData.data[name];
  48922. }
  48923. } else if (parentData.isStore && storeMappings[name]) {
  48924. ret = parentData[storeMappings[name]]();
  48925. } else {
  48926. ret = parentData[name];
  48927. if (ret === undefined && me.hadValue) {
  48928. ret = null;
  48929. }
  48930. }
  48931. }
  48932. }
  48933. return ret;
  48934. },
  48935. getDataObject: function() {
  48936. var me = this,
  48937. parentData = me.parent.getDataObject(),
  48938. name = me.name,
  48939. ret = parentData ? parentData[name] : null,
  48940. storeMappings = me.bindMappings.store,
  48941. associations;
  48942. if (!ret) {
  48943. if (parentData && parentData.isEntity) {
  48944. associations = parentData.associations;
  48945. if (associations && name in associations) {
  48946. ret = parentData[associations[name].getterName]();
  48947. }
  48948. }
  48949. } else if (parentData.isStore && name in storeMappings) {
  48950. ret = parentData[storeMappings[name]]();
  48951. }
  48952. if (!ret || !(ret.$className || Ext.isObject(ret))) {
  48953. parentData[name] = ret = {};
  48954. me.hadValue = true;
  48955. me.invalidate(true, true);
  48956. }
  48957. return ret;
  48958. },
  48959. getRawValue: function() {
  48960. return this.getChildValue(this.getParentValue());
  48961. },
  48962. graft: function(replacement) {
  48963. var me = this,
  48964. parent = me.parent,
  48965. children = me.children,
  48966. name = me.name,
  48967. i, ret;
  48968. replacement.parent = parent;
  48969. replacement.children = children;
  48970. if (parent) {
  48971. parent.children[name] = replacement;
  48972. }
  48973. if (children) {
  48974. for (i in children) {
  48975. children[i].parent = replacement;
  48976. }
  48977. }
  48978. me.children = null;
  48979. replacement.checkHadValue();
  48980. ret = me.callParent([
  48981. replacement
  48982. ]);
  48983. ret.invalidate(true, true);
  48984. return ret;
  48985. },
  48986. isAvailable: function() {
  48987. return this.checkAvailability();
  48988. },
  48989. isLoading: function() {
  48990. return !this.checkAvailability(true);
  48991. },
  48992. invalidate: function(deep, dirtyOnly) {
  48993. var me = this,
  48994. children = me.children,
  48995. name;
  48996. me.dirty = true;
  48997. me.checkHadValue();
  48998. if (!dirtyOnly && me.isAvailable()) {
  48999. if (!me.scheduled) {
  49000. me.schedule();
  49001. }
  49002. }
  49003. if (deep && children) {
  49004. for (name in children) {
  49005. children[name].invalidate(deep, dirtyOnly);
  49006. }
  49007. }
  49008. },
  49009. isReadOnly: function() {
  49010. var formula = this.formula;
  49011. return !!(formula && !formula.set);
  49012. },
  49013. set: function(value, preventClimb) {
  49014. var me = this,
  49015. parent = me.parent,
  49016. name = me.name,
  49017. formula = me.formula,
  49018. parentData, associations, association, formulaStub, setterName;
  49019. if (formula && !formula.settingValue && formula.set) {
  49020. formula.setValue(value);
  49021. return;
  49022. } else if (me.isLinkStub) {
  49023. formulaStub = me.getLinkFormulaStub();
  49024. formula = formulaStub ? formulaStub.formula : null;
  49025. if (formula) {
  49026. if (formulaStub.isReadOnly()) {
  49027. Ext.raise('Cannot setValue on a readonly formula');
  49028. }
  49029. formula.setValue(value);
  49030. return;
  49031. }
  49032. }
  49033. parentData = parent.getDataObject();
  49034. if (parentData.isEntity) {
  49035. associations = parentData.associations;
  49036. if (associations && (name in associations)) {
  49037. association = associations[name];
  49038. setterName = association.setterName;
  49039. if (setterName) {
  49040. parentData[setterName](value);
  49041. }
  49042. me.invalidate(true);
  49043. } else {
  49044. parentData.set(name, value);
  49045. }
  49046. }
  49047. else if ((value && value.constructor === Object) || !(value === parentData[name] && parentData.hasOwnProperty(name))) {
  49048. if (preventClimb || !me.setByLink(value)) {
  49049. if (value === undefined) {
  49050. delete parentData[name];
  49051. } else {
  49052. parentData[name] = value;
  49053. }
  49054. me.inspectValue(parentData);
  49055. me.invalidate(true);
  49056. }
  49057. }
  49058. },
  49059. onStoreDataChanged: function() {
  49060. this.invalidate(true);
  49061. },
  49062. afterLoad: function(record) {
  49063. this.invalidate(true);
  49064. },
  49065. afterCommit: function(record) {
  49066. this.afterEdit(record, null);
  49067. },
  49068. afterEdit: function(record, modifiedFieldNames) {
  49069. var children = this.children,
  49070. len = modifiedFieldNames && modifiedFieldNames.length,
  49071. associations = record.associations,
  49072. bindMappings = this.bindMappings.model,
  49073. key, i, child, name, ref;
  49074. if (children) {
  49075. if (len) {
  49076. for (i = 0; i < len; ++i) {
  49077. name = modifiedFieldNames[i];
  49078. child = children[name];
  49079. if (!child) {
  49080. ref = record.fieldsMap[name];
  49081. ref = ref && ref.reference;
  49082. child = ref && children[ref.role];
  49083. }
  49084. if (child) {
  49085. child.invalidate(true);
  49086. }
  49087. }
  49088. } else {
  49089. for (key in children) {
  49090. if (!(associations && key in associations)) {
  49091. children[key].invalidate(true);
  49092. }
  49093. }
  49094. }
  49095. for (key in bindMappings) {
  49096. child = children[key];
  49097. if (child) {
  49098. child.invalidate();
  49099. }
  49100. }
  49101. }
  49102. this.invalidate();
  49103. },
  49104. afterReject: function(record) {
  49105. this.afterEdit(record, null);
  49106. },
  49107. afterAssociatedRecordSet: function(record, associated, role) {
  49108. var children = this.children,
  49109. key = role.role;
  49110. if (children && key in children) {
  49111. children[key].invalidate(true);
  49112. }
  49113. },
  49114. setByLink: function(value) {
  49115. var me = this,
  49116. n = 0,
  49117. ret = false,
  49118. i, link, path, stub, root, name;
  49119. for (stub = me; stub; stub = stub.parent) {
  49120. if (stub.isLinkStub) {
  49121. link = stub;
  49122. if (n) {
  49123. for (path = [] , i = 0 , stub = me; stub !== link; stub = stub.parent) {
  49124. ++i;
  49125. path[n - i] = stub.name;
  49126. }
  49127. }
  49128. break;
  49129. }
  49130. ++n;
  49131. }
  49132. stub = null;
  49133. if (link) {
  49134. root = link.parent;
  49135. name = link.name;
  49136. if (!root.shouldClimb(name)) {
  49137. stub = root.insertChild(name);
  49138. } else {
  49139. stub = link.getTargetStub();
  49140. }
  49141. }
  49142. if (stub) {
  49143. if (path) {
  49144. stub = stub.descend(path);
  49145. }
  49146. stub.set(value);
  49147. ret = true;
  49148. }
  49149. return ret;
  49150. },
  49151. setFormula: function(formula) {
  49152. var me = this,
  49153. oldFormula = me.formula;
  49154. if (oldFormula) {
  49155. oldFormula.destroy();
  49156. }
  49157. me.formula = new Ext.app.bind.Formula(me, formula);
  49158. },
  49159. react: function() {
  49160. var me = this,
  49161. bound = this.boundValue,
  49162. children = me.children,
  49163. generation;
  49164. if (bound) {
  49165. if (bound.isValidation) {
  49166. bound.refresh();
  49167. generation = bound.generation;
  49168. if (me.lastValidationGeneration === generation) {
  49169. return;
  49170. }
  49171. me.lastValidationGeneration = generation;
  49172. } else if (bound.isModel) {
  49173. if (children && children[me.validationKey]) {
  49174. bound.isValid();
  49175. }
  49176. }
  49177. }
  49178. this.callParent();
  49179. },
  49180. privates: {
  49181. bindMappings: {
  49182. store: {
  49183. count: 'getCount',
  49184. first: 'first',
  49185. last: 'last',
  49186. loading: 'hasPendingLoad',
  49187. totalCount: 'getTotalCount'
  49188. },
  49189. model: {
  49190. dirty: 'isDirty',
  49191. phantom: 'isPhantom',
  49192. valid: 'isValid'
  49193. }
  49194. },
  49195. checkAvailability: function(isLoading) {
  49196. var me = this,
  49197. parent = me.parent,
  49198. bindMappings = me.bindMappings,
  49199. name = me.name,
  49200. available = !!(parent && parent.checkAvailability(isLoading)),
  49201. associations, parentValue, value, availableSet, loading;
  49202. if (available) {
  49203. parentValue = me.getParentValue();
  49204. value = me.inspectValue(parentValue);
  49205. if (value) {
  49206. if (isLoading) {
  49207. available = !value.hasPendingLoad();
  49208. } else {
  49209. if (value.isStore) {
  49210. available = true;
  49211. } else {
  49212. available = !value.isLoading() || value.loadCount > 0;
  49213. }
  49214. }
  49215. } else {
  49216. if (parentValue) {
  49217. if (parentValue.isModel) {
  49218. if (bindMappings.model[name]) {
  49219. available = !parent.isLoading();
  49220. availableSet = true;
  49221. } else {
  49222. associations = parentValue.associations;
  49223. if (!(associations && name in associations)) {
  49224. available = true;
  49225. availableSet = true;
  49226. }
  49227. }
  49228. } else if (parentValue.isStore && bindMappings.store[name] && name !== 'loading') {
  49229. available = !parent.isLoading();
  49230. availableSet = true;
  49231. }
  49232. }
  49233. if (!availableSet) {
  49234. available = me.hadValue || me.getRawValue() !== undefined;
  49235. }
  49236. }
  49237. }
  49238. return available;
  49239. },
  49240. checkHadValue: function() {
  49241. if (!this.hadValue) {
  49242. this.hadValue = this.getRawValue() !== undefined;
  49243. }
  49244. },
  49245. collect: function() {
  49246. var me = this,
  49247. result = me.callParent(),
  49248. storeBinding = me.storeBinding ? 1 : 0,
  49249. formula = me.formula ? 1 : 0;
  49250. return result + storeBinding + formula;
  49251. },
  49252. getLinkFormulaStub: function() {
  49253. var stub = this;
  49254. while (stub.isLinkStub) {
  49255. stub = stub.binding.stub;
  49256. }
  49257. return stub.formula ? stub : null;
  49258. },
  49259. getParentValue: function() {
  49260. var me = this;
  49261. if (me.dirty) {
  49262. me.parentValue = me.parent.getValue();
  49263. me.dirty = false;
  49264. }
  49265. return me.parentValue;
  49266. },
  49267. setStore: function(storeBinding) {
  49268. this.storeBinding = storeBinding;
  49269. },
  49270. inspectValue: function(parentData) {
  49271. var me = this,
  49272. name = me.name,
  49273. current = me.boundValue,
  49274. boundValue = null,
  49275. associations, raw, changed, associatedEntity;
  49276. if (parentData && parentData.isEntity) {
  49277. associations = parentData.associations;
  49278. if (associations && (name in associations)) {
  49279. boundValue = parentData[associations[name].getterName]();
  49280. } else if (name === me.validationKey) {
  49281. boundValue = parentData.getValidation();
  49282. me.lastValidationGeneration = null;
  49283. }
  49284. } else if (parentData) {
  49285. raw = parentData[name];
  49286. if (raw && (raw.isModel || raw.isStore)) {
  49287. boundValue = raw;
  49288. }
  49289. }
  49290. changed = current !== boundValue;
  49291. if (changed) {
  49292. if (current) {
  49293. me.detachBound();
  49294. }
  49295. if (boundValue) {
  49296. if (boundValue.isModel) {
  49297. boundValue.join(me);
  49298. } else {
  49299. associatedEntity = boundValue.associatedEntity;
  49300. if (associatedEntity && boundValue.autoLoad !== false && !boundValue.complete && !boundValue.hasPendingLoad()) {
  49301. boundValue.load();
  49302. }
  49303. boundValue.on({
  49304. scope: me,
  49305. beginload: 'onStoreDataChanged',
  49306. load: 'onStoreDataChanged',
  49307. datachanged: 'onStoreDataChanged',
  49308. destroy: 'onDestroyBound'
  49309. });
  49310. }
  49311. }
  49312. me.boundValue = boundValue;
  49313. }
  49314. return boundValue;
  49315. },
  49316. detachBound: function() {
  49317. var me = this,
  49318. current = me.boundValue;
  49319. if (current && !current.destroyed) {
  49320. if (current.isModel) {
  49321. current.unjoin(me);
  49322. } else {
  49323. current.un({
  49324. scope: me,
  49325. beginload: 'onStoreDataChanged',
  49326. load: 'onStoreDataChanged',
  49327. datachanged: 'onStoreDataChanged',
  49328. destroy: 'onDestroyBound'
  49329. });
  49330. }
  49331. }
  49332. },
  49333. onDestroyBound: function() {
  49334. if (!this.owner.destroying) {
  49335. this.set(null);
  49336. }
  49337. },
  49338. sort: function() {
  49339. var me = this,
  49340. formula = me.formula,
  49341. scheduler = me.scheduler,
  49342. storeBinding = me.storeBinding;
  49343. me.callParent();
  49344. if (storeBinding) {
  49345. scheduler.sortItem(storeBinding);
  49346. }
  49347. if (formula) {
  49348. scheduler.sortItem(formula);
  49349. }
  49350. }
  49351. }
  49352. });
  49353. Ext.define('Ext.app.bind.LinkStub', {
  49354. extend: Ext.app.bind.Stub,
  49355. isLinkStub: true,
  49356. binding: null,
  49357. destroy: function() {
  49358. var me = this,
  49359. binding = me.binding,
  49360. owner = me.owner;
  49361. if (binding) {
  49362. me.binding = null;
  49363. binding.destroy();
  49364. if (owner) {
  49365. delete owner.linkData[me.name];
  49366. }
  49367. }
  49368. me.target = null;
  49369. me.callParent();
  49370. },
  49371. getFullName: function() {
  49372. var me = this;
  49373. return me.fullName || (me.fullName = '(' + me.callParent() + ' -> ' + me.binding.getFullName() + ')');
  49374. },
  49375. getDataObject: function() {
  49376. var binding = this.binding,
  49377. root = this.parent,
  49378. name = this.name,
  49379. rootData, ret;
  49380. if (root.isRootStub && !root.shouldClimb(name)) {
  49381. rootData = root.owner.getData();
  49382. if (!rootData.hasOwnProperty(name)) {
  49383. rootData[name] = ret = {};
  49384. }
  49385. } else {
  49386. ret = binding && binding.getDataObject();
  49387. }
  49388. return ret;
  49389. },
  49390. getRawValue: function() {
  49391. var binding = this.binding;
  49392. return binding && binding.getRawValue();
  49393. },
  49394. getValue: function() {
  49395. var binding = this.binding;
  49396. return binding && binding.getValue();
  49397. },
  49398. getTargetStub: function() {
  49399. var binding = this.binding;
  49400. return binding && binding.stub;
  49401. },
  49402. isAvailable: function() {
  49403. var binding = this.binding;
  49404. return binding ? binding.isAvailable() : false;
  49405. },
  49406. isLoading: function() {
  49407. var binding = this.binding;
  49408. return binding ? binding.isLoading() : false;
  49409. },
  49410. link: function(bindDescriptor, target) {
  49411. var me = this,
  49412. binding = me.binding;
  49413. if (binding) {
  49414. binding.destroy();
  49415. }
  49416. target = me.target = target || me.owner;
  49417. me.linkDescriptor = bindDescriptor;
  49418. me.binding = target.bind(bindDescriptor, me.onChange, me);
  49419. me.binding.deep = true;
  49420. },
  49421. onChange: function() {
  49422. this.invalidate(true);
  49423. },
  49424. react: function() {
  49425. var me = this,
  49426. linkData = me.owner.linkData;
  49427. linkData[me.name] = me.getValue();
  49428. me.callParent();
  49429. },
  49430. privates: {
  49431. collect: function() {
  49432. var me = this,
  49433. result = me.callParent(),
  49434. binding = me.binding ? 1 : 0;
  49435. return result + binding;
  49436. },
  49437. sort: function() {
  49438. var binding = this.binding;
  49439. if (binding) {
  49440. this.scheduler.sortItem(binding);
  49441. }
  49442. }
  49443. }
  49444. });
  49445. Ext.define('Ext.app.bind.RootStub', {
  49446. extend: Ext.app.bind.AbstractStub,
  49447. isRootStub: true,
  49448. depth: 0,
  49449. createRootChild: function(name, direct) {
  49450. var me = this,
  49451. owner = me.owner,
  49452. ownerData = owner.getData(),
  49453. children = me.children,
  49454. previous = children && children[name],
  49455. parentStub = previous ? null : me,
  49456. parentVM, stub;
  49457. if (direct || ownerData.hasOwnProperty(name) || !(parentVM = owner.getParent())) {
  49458. stub = new Ext.app.bind.Stub(owner, name, parentStub);
  49459. } else {
  49460. stub = new Ext.app.bind.LinkStub(owner, name, parentStub);
  49461. stub.link('{' + name + '}', parentVM);
  49462. }
  49463. if (previous) {
  49464. previous.graft(stub);
  49465. }
  49466. return stub;
  49467. },
  49468. createStubChild: function(name) {
  49469. return this.createRootChild(name, true);
  49470. },
  49471. descend: function(path, index) {
  49472. var me = this,
  49473. children = me.children,
  49474. pos = index || 0,
  49475. name = path[pos++],
  49476. ret = (children && children[name]) || me.createRootChild(name);
  49477. if (pos < path.length) {
  49478. ret = ret.descend(path, pos);
  49479. }
  49480. return ret;
  49481. },
  49482. getFullName: function() {
  49483. return this.fullName || (this.fullName = this.owner.id + ':');
  49484. },
  49485. getDataObject: function() {
  49486. return this.owner.data;
  49487. },
  49488. getRawValue: function() {
  49489. return this.owner.data;
  49490. },
  49491. getValue: function() {
  49492. return this.owner.data;
  49493. },
  49494. isDescendantOf: function() {
  49495. return false;
  49496. },
  49497. set: function(value, preventClimb) {
  49498. if (!value || value.constructor !== Object) {
  49499. Ext.raise('Only an object can be set at the root');
  49500. }
  49501. var me = this,
  49502. children = me.children || (me.children = {}),
  49503. owner = me.owner,
  49504. data = owner.data,
  49505. parentVM = owner.getParent(),
  49506. stub, v, key, setSelf, created;
  49507. for (key in value) {
  49508. if (key.indexOf('.') >= 0) {
  49509. Ext.raise('Value names cannot contain dots');
  49510. }
  49511. v = value[key];
  49512. if (v !== undefined) {
  49513. stub = children[key];
  49514. setSelf = preventClimb || !me.shouldClimb(key);
  49515. if (!stub) {
  49516. stub = me.createRootChild(key, setSelf);
  49517. created = true;
  49518. } else if (setSelf && stub.isLinkStub && !stub.getLinkFormulaStub()) {
  49519. stub = me.insertChild(key);
  49520. }
  49521. if (!created || !data.hasOwnProperty(value)) {
  49522. owner.invalidateChildLinks(key);
  49523. }
  49524. stub.set(v, setSelf);
  49525. }
  49526. else if (data.hasOwnProperty(key)) {
  49527. delete data[key];
  49528. stub = children[key];
  49529. if (stub) {
  49530. if (!stub.isLinkStub && parentVM) {
  49531. stub = me.createRootChild(key);
  49532. }
  49533. owner.invalidateChildLinks(key, true);
  49534. stub.invalidate(true);
  49535. }
  49536. }
  49537. }
  49538. },
  49539. schedule: Ext.emptyFn,
  49540. unschedule: Ext.emptyFn,
  49541. privates: {
  49542. checkAvailability: function() {
  49543. return true;
  49544. },
  49545. insertChild: function(name) {
  49546. return this.createRootChild(name, true);
  49547. },
  49548. invalidateChildLink: function(name, clear) {
  49549. var children = this.children,
  49550. stub = children && children[name];
  49551. if (stub && stub.isLinkStub && !stub.getLinkFormulaStub()) {
  49552. stub = this.createRootChild(name);
  49553. if (clear) {
  49554. stub.invalidate(true);
  49555. }
  49556. this.owner.invalidateChildLinks(name, clear);
  49557. }
  49558. },
  49559. shouldClimb: function(name) {
  49560. var parent = this.owner.getParent();
  49561. while (parent) {
  49562. if (parent.getData().hasOwnProperty(name)) {
  49563. return true;
  49564. }
  49565. parent = parent.getParent();
  49566. }
  49567. return false;
  49568. }
  49569. }
  49570. });
  49571. Ext.define('Ext.app.bind.Multi', {
  49572. extend: Ext.app.bind.BaseBinding,
  49573. isMultiBinding: true,
  49574. missing: 1,
  49575. deep: true,
  49576. constructor: function(descriptor, owner, callback, scope, options) {
  49577. var me = this,
  49578. trackStatics = options && options.trackStatics;
  49579. me.callParent([
  49580. owner,
  49581. callback,
  49582. scope,
  49583. options
  49584. ]);
  49585. me.bindings = [];
  49586. me.literal = descriptor.$literal;
  49587. if (descriptor.constructor === Object) {
  49588. if (trackStatics) {
  49589. me.staticKeys = [];
  49590. }
  49591. me.addObject(descriptor, me.lastValue = {}, me.staticKeys);
  49592. } else {
  49593. me.addArray(descriptor, me.lastValue = []);
  49594. }
  49595. if (!--me.missing && !me.scheduled) {
  49596. me.schedule();
  49597. }
  49598. },
  49599. destroy: function() {
  49600. var me = this;
  49601. me.bindings = Ext.destroy(me.bindings);
  49602. me.callParent();
  49603. },
  49604. add: function(descriptor, data, property) {
  49605. var me = this,
  49606. owner = me.owner,
  49607. bindings = me.bindings,
  49608. method = me.literal ? (descriptor.reference ? 'bindEntity' : 'bindExpression') : 'bind',
  49609. binding, depth;
  49610. ++me.missing;
  49611. binding = owner[method](descriptor, function(value) {
  49612. data[property] = value;
  49613. if (binding.calls === 1) {
  49614. --me.missing;
  49615. }
  49616. if (!me.missing && !me.scheduled) {
  49617. me.schedule();
  49618. }
  49619. },
  49620. me, null);
  49621. depth = binding.depth;
  49622. if (!bindings.length || depth < me.depth) {
  49623. me.depth = depth;
  49624. }
  49625. bindings.push(binding);
  49626. return !this.isBindingStatic(binding);
  49627. },
  49628. addArray: function(multiBindDescr, array) {
  49629. var me = this,
  49630. n = multiBindDescr.length,
  49631. hasDynamic = false,
  49632. dynamic, b, i;
  49633. for (i = 0; i < n; ++i) {
  49634. b = multiBindDescr[i];
  49635. if (b && (b.reference || Ext.isString(b))) {
  49636. dynamic = me.add(b, array, i);
  49637. } else if (Ext.isArray(b)) {
  49638. dynamic = me.addArray(b, array[i] = []);
  49639. } else if (b && b.constructor === Object) {
  49640. dynamic = me.addObject(b, array[i] = {});
  49641. } else {
  49642. array[i] = b;
  49643. dynamic = false;
  49644. }
  49645. hasDynamic = hasDynamic || dynamic;
  49646. }
  49647. return hasDynamic;
  49648. },
  49649. addObject: function(multiBindDescr, object, staticKeys) {
  49650. var me = this,
  49651. hasDynamic = false,
  49652. dynamic, b, name;
  49653. for (name in multiBindDescr) {
  49654. b = multiBindDescr[name];
  49655. if (b && (b.reference || Ext.isString(b))) {
  49656. dynamic = me.add(b, object, name);
  49657. } else if (Ext.isArray(b)) {
  49658. dynamic = me.addArray(b, object[name] = []);
  49659. } else if (b && b.constructor === Object) {
  49660. dynamic = me.addObject(b, object[name] = {});
  49661. } else {
  49662. object[name] = b;
  49663. dynamic = false;
  49664. }
  49665. if (staticKeys && !dynamic) {
  49666. staticKeys.push(name);
  49667. }
  49668. hasDynamic = hasDynamic || dynamic;
  49669. }
  49670. return hasDynamic;
  49671. },
  49672. getFullName: function() {
  49673. var me = this,
  49674. fullName = me.fullName,
  49675. bindings = me.bindings,
  49676. length = bindings.length,
  49677. i;
  49678. if (!fullName) {
  49679. fullName = '@[';
  49680. for (i = 0; i < length; ++i) {
  49681. if (i) {
  49682. fullName += ',';
  49683. }
  49684. fullName += bindings[i].getFullName();
  49685. }
  49686. fullName += ']';
  49687. me.fullName = fullName;
  49688. }
  49689. return fullName;
  49690. },
  49691. getRawValue: function() {
  49692. return this.lastValue;
  49693. },
  49694. isDescendantOf: function() {
  49695. return false;
  49696. },
  49697. isLoading: function() {
  49698. for (var bindings = this.bindings,
  49699. n = bindings.length; n-- > 0; ) {
  49700. if (bindings[n].isLoading()) {
  49701. return true;
  49702. }
  49703. }
  49704. return false;
  49705. },
  49706. isAvailable: function() {
  49707. for (var bindings = this.bindings,
  49708. n = bindings.length; n-- > 0; ) {
  49709. if (bindings[n].isAvailable()) {
  49710. return true;
  49711. }
  49712. }
  49713. return false;
  49714. },
  49715. isBindingStatic: function(binding) {
  49716. return binding.isTemplateBinding && binding.isStatic;
  49717. },
  49718. isStatic: function() {
  49719. var bindings = this.bindings,
  49720. len = bindings.length,
  49721. i, binding;
  49722. for (i = 0; i < len; ++i) {
  49723. binding = bindings[i];
  49724. if (!this.isBindingStatic(binding)) {
  49725. return false;
  49726. }
  49727. }
  49728. return true;
  49729. },
  49730. pruneStaticKeys: function() {
  49731. var value = Ext.apply({}, this.lastValue),
  49732. keys = this.staticKeys,
  49733. len = keys.length,
  49734. i;
  49735. for (i = 0; i < len; ++i) {
  49736. delete value[keys[i]];
  49737. }
  49738. return value;
  49739. },
  49740. react: function() {
  49741. this.notify(this.lastValue);
  49742. },
  49743. refresh: function() {},
  49744. privates: {
  49745. sort: function() {
  49746. this.scheduler.sortItems(this.bindings);
  49747. }
  49748. }
  49749. });
  49750. Ext.define('Ext.app.bind.Formula', {
  49751. extend: Ext.util.Schedulable,
  49752. statics: {
  49753. getFormulaParser: function(name) {
  49754. var cache = this.formulaCache,
  49755. parser, s;
  49756. if (!cache) {
  49757. cache = this.formulaCache = new Ext.util.LruCache({
  49758. maxSize: 20
  49759. });
  49760. }
  49761. parser = cache.get(name);
  49762. if (!parser) {
  49763. s = '[^\\.a-z0-9_]' + Ext.String.escapeRegex(name) + '\\(\\s*([\'"])(.*?)\\1\\s*\\)';
  49764. parser = new RegExp(s, 'gi');
  49765. cache.add(name, parser);
  49766. }
  49767. return parser;
  49768. }
  49769. },
  49770. isFormula: true,
  49771. calculation: null,
  49772. explicit: false,
  49773. set: null,
  49774. single: false,
  49775. fnKeywordArgumentNamesRe: /^function\s*[^\(]*\(\s*([^,\)\s]+)/,
  49776. fnKeywordRe: /^\s*function/,
  49777. replaceParenRe: /[\(\)]/g,
  49778. constructor: function(stub, formula) {
  49779. var me = this,
  49780. owner = stub.owner,
  49781. bindTo, expressions, getter, options;
  49782. me.owner = owner;
  49783. me.stub = stub;
  49784. me.callParent();
  49785. if (formula instanceof Function) {
  49786. me.get = getter = formula;
  49787. } else {
  49788. me.get = getter = formula.get;
  49789. me.set = formula.set;
  49790. expressions = formula.bind;
  49791. if (formula.single) {
  49792. me.single = formula.single;
  49793. }
  49794. if (expressions) {
  49795. bindTo = expressions.bindTo;
  49796. if (bindTo) {
  49797. options = Ext.apply({}, expressions);
  49798. delete options.bindTo;
  49799. expressions = bindTo;
  49800. }
  49801. }
  49802. }
  49803. if (!getter) {
  49804. Ext.raise('Must specify a getter method for a formula');
  49805. }
  49806. if (expressions) {
  49807. me.explicit = true;
  49808. } else {
  49809. expressions = getter.$expressions || me.parseFormula(getter);
  49810. }
  49811. me.binding = owner.bind(expressions, me.onChange, me, options);
  49812. },
  49813. destroy: function() {
  49814. var me = this,
  49815. binding = me.binding,
  49816. stub = me.stub;
  49817. if (binding) {
  49818. binding.destroy();
  49819. me.binding = null;
  49820. }
  49821. if (stub) {
  49822. stub.formula = null;
  49823. }
  49824. me.callParent();
  49825. me.getterFn = me.owner = null;
  49826. },
  49827. getFullName: function() {
  49828. return this.fullName || (this.fullName = this.stub.getFullName() + '=' + this.callParent() + ')');
  49829. },
  49830. getRawValue: function() {
  49831. return this.calculation;
  49832. },
  49833. onChange: function() {
  49834. if (!this.scheduled) {
  49835. this.schedule();
  49836. }
  49837. },
  49838. parseFormula: function(formula) {
  49839. var str = Ext.Function.toCode(formula),
  49840. defaultProp = 'get',
  49841. expressions = {
  49842. $literal: true
  49843. },
  49844. match, getterProp, formulaRe, expr;
  49845. if (this.fnKeywordRe.test(str)) {
  49846. match = this.fnKeywordArgumentNamesRe.exec(str);
  49847. if (match) {
  49848. getterProp = match[1];
  49849. }
  49850. } else {
  49851. match = str.split('=>')[0];
  49852. if (match) {
  49853. match = Ext.String.trim(match.replace(this.replaceParenRe, '')).split(',');
  49854. getterProp = match[0];
  49855. }
  49856. }
  49857. getterProp = getterProp || defaultProp;
  49858. formulaRe = Ext.app.bind.Formula.getFormulaParser(getterProp);
  49859. while ((match = formulaRe.exec(str))) {
  49860. expr = match[2];
  49861. expressions[expr] = expr;
  49862. }
  49863. expressions.$literal = true;
  49864. formula.$expressions = expressions;
  49865. return expressions;
  49866. },
  49867. react: function() {
  49868. var me = this,
  49869. owner = me.owner,
  49870. data = me.binding.lastValue,
  49871. getterFn = me.getterFn,
  49872. arg;
  49873. if (me.explicit) {
  49874. arg = data;
  49875. } else {
  49876. arg = owner.getFormulaFn(data);
  49877. }
  49878. me.settingValue = true;
  49879. me.stub.set(me.calculation = me.get.call(owner, arg));
  49880. me.settingValue = false;
  49881. if (me.single) {
  49882. me.destroy();
  49883. }
  49884. },
  49885. setValue: function(value) {
  49886. this.set.call(this.stub.owner, value);
  49887. },
  49888. privates: {
  49889. getScheduler: function() {
  49890. var owner = this.owner;
  49891. return owner && owner.getScheduler();
  49892. },
  49893. sort: function() {
  49894. var me = this,
  49895. binding = me.binding;
  49896. if (!binding.destroyed) {
  49897. me.scheduler.sortItem(binding);
  49898. }
  49899. }
  49900. }
  49901. });
  49902. Ext.define('Ext.util.Fly', {
  49903. inheritableStatics: {
  49904. flyPoolSize: 2,
  49905. fly: function() {
  49906. var T = this,
  49907. flyweights = T.flyweights || (T.flyweights = []),
  49908. instance = flyweights.length ? flyweights.pop() : new T();
  49909. instance.reset.apply(instance, arguments);
  49910. return instance;
  49911. }
  49912. },
  49913. release: function() {
  49914. var me = this,
  49915. T = me.self,
  49916. flyweights = T.flyweights || (T.flyweights = []);
  49917. me.reset();
  49918. if (flyweights.length < T.flyPoolSize) {
  49919. flyweights.push(me);
  49920. }
  49921. },
  49922. reset: Ext.emptyFn
  49923. });
  49924. Ext.define('Ext.parse.Tokenizer', function(Tokenizer) {
  49925. var flyweights = (Tokenizer.flyweights = []),
  49926. BOOLEAN = {
  49927. literal: true,
  49928. "boolean": true
  49929. },
  49930. ERROR = {
  49931. error: true
  49932. },
  49933. IDENT = {
  49934. ident: true
  49935. },
  49936. LITERAL = {
  49937. literal: true
  49938. },
  49939. NULL = {
  49940. literal: true,
  49941. nil: true
  49942. },
  49943. NUMBER = {
  49944. literal: true,
  49945. number: true
  49946. },
  49947. STRING = {
  49948. literal: true,
  49949. string: true
  49950. };
  49951. return {
  49952. extend: Ext.util.Fly,
  49953. isTokenizer: true,
  49954. statics: {
  49955. BOOLEAN: BOOLEAN,
  49956. ERROR: ERROR,
  49957. IDENT: IDENT,
  49958. LITERAL: LITERAL,
  49959. NULL: NULL,
  49960. NUMBER: NUMBER,
  49961. STRING: STRING
  49962. },
  49963. config: {
  49964. keywords: {
  49965. 'null': {
  49966. type: 'literal',
  49967. is: NULL,
  49968. value: null
  49969. },
  49970. 'false': {
  49971. type: 'literal',
  49972. is: BOOLEAN,
  49973. value: false
  49974. },
  49975. 'true': {
  49976. type: 'literal',
  49977. is: BOOLEAN,
  49978. value: true
  49979. }
  49980. },
  49981. operators: {
  49982. '+': 'plus',
  49983. '-': 'minus',
  49984. '*': 'multiply',
  49985. '/': 'divide',
  49986. '!': 'bang',
  49987. ',': 'comma',
  49988. ':': 'colon',
  49989. '[': 'arrayOpen',
  49990. ']': 'arrayClose',
  49991. '{': 'curlyOpen',
  49992. '}': 'curlyClose',
  49993. '(': 'parenOpen',
  49994. ')': 'parenClose'
  49995. }
  49996. },
  49997. error: null,
  49998. index: -1,
  49999. constructor: function(config) {
  50000. this.operators = {};
  50001. this.initConfig(config);
  50002. },
  50003. next: function() {
  50004. var token = this.peek();
  50005. this.head = undefined;
  50006. return token;
  50007. },
  50008. peek: function() {
  50009. var me = this,
  50010. error = me.error,
  50011. token = me.head;
  50012. if (error) {
  50013. return error;
  50014. }
  50015. if (token === undefined) {
  50016. me.head = token = me.advance();
  50017. }
  50018. return token;
  50019. },
  50020. release: function() {
  50021. this.reset();
  50022. if (flyweights.length < Tokenizer.flyPoolSize) {
  50023. flyweights.push(this);
  50024. }
  50025. },
  50026. reset: function(text, pos, end) {
  50027. var me = this;
  50028. me.error = null;
  50029. me.head = undefined;
  50030. me.index = -1;
  50031. me.text = text || null;
  50032. me.pos = pos || 0;
  50033. me.end = (text && end == null) ? text.length : end;
  50034. return me;
  50035. },
  50036. privates: {
  50037. digitRe: /[0-9]/,
  50038. identFirstRe: /[a-z_$]/i,
  50039. identRe: /[0-9a-z_$]/i,
  50040. spaceRe: /[ \t]/,
  50041. end: 0,
  50042. head: undefined,
  50043. pos: 0,
  50044. text: null,
  50045. applyOperators: function(ops) {
  50046. var operators = this.operators,
  50047. block, c, def, i, len, name, op;
  50048. for (op in ops) {
  50049. block = operators;
  50050. name = ops[op];
  50051. len = op.length;
  50052. for (i = 0; i < len; ++i) {
  50053. c = op.charAt(i);
  50054. block = block[c] || (block[c] = {});
  50055. }
  50056. if (name) {
  50057. block.token = def = {
  50058. type: 'operator',
  50059. value: op,
  50060. is: {
  50061. operator: true
  50062. }
  50063. };
  50064. def.is[name] = true;
  50065. } else {
  50066. block.token = null;
  50067. }
  50068. }
  50069. },
  50070. advance: function() {
  50071. var me = this,
  50072. spaceRe = me.spaceRe,
  50073. text = me.text,
  50074. length = me.end,
  50075. c;
  50076. while (me.pos < length) {
  50077. c = text.charAt(me.pos);
  50078. if (spaceRe.test(c)) {
  50079. ++me.pos;
  50080. continue;
  50081. }
  50082. me.index = me.pos;
  50083. return me.parse(c);
  50084. }
  50085. return null;
  50086. },
  50087. parse: function(c) {
  50088. var me = this,
  50089. digitRe = me.digitRe,
  50090. text = me.text,
  50091. length = me.end,
  50092. ret;
  50093. if (c === '.' && me.pos + 1 < length) {
  50094. if (digitRe.test(text.charAt(me.pos + 1))) {
  50095. ret = me.parseNumber();
  50096. }
  50097. }
  50098. if (!ret && me.operators[c]) {
  50099. ret = me.parseOperator(c);
  50100. }
  50101. if (!ret) {
  50102. if (c === '"' || c === "'") {
  50103. ret = me.parseString();
  50104. } else if (digitRe.test(c)) {
  50105. ret = me.parseNumber();
  50106. } else if (me.identFirstRe.test(c)) {
  50107. ret = me.parseIdent();
  50108. } else {
  50109. ret = me.syntaxError('Unexpected character');
  50110. }
  50111. }
  50112. return ret;
  50113. },
  50114. parseIdent: function() {
  50115. var me = this,
  50116. identRe = me.identRe,
  50117. keywords = me.getKeywords(),
  50118. includeDots = !me.operators['.'],
  50119. text = me.text,
  50120. start = me.pos,
  50121. end = start,
  50122. length = me.end,
  50123. prev = 0,
  50124. c, value;
  50125. while (end < length) {
  50126. c = text.charAt(end);
  50127. if (includeDots && c === '.') {
  50128. if (prev === '.') {
  50129. return me.syntaxError(end, 'Unexpected dot operator');
  50130. }
  50131. ++end;
  50132. } else if (identRe.test(c)) {
  50133. ++end;
  50134. } else {
  50135. break;
  50136. }
  50137. prev = c;
  50138. }
  50139. if (prev === '.') {
  50140. return me.syntaxError(end - 1, 'Unexpected dot operator');
  50141. }
  50142. value = text.substring(start, me.pos = end);
  50143. return (keywords && keywords[value]) || {
  50144. type: 'ident',
  50145. is: IDENT,
  50146. value: value
  50147. };
  50148. },
  50149. parseNumber: function() {
  50150. var me = this,
  50151. digitRe = me.digitRe,
  50152. text = me.text,
  50153. start = me.pos,
  50154. length = me.end,
  50155. c, decimal, exp, token;
  50156. while (me.pos < length) {
  50157. c = text.charAt(me.pos);
  50158. if (c === '-' || c === '+') {
  50159. if (me.pos !== start) {
  50160. return me.syntaxError(start, 'Invalid number');
  50161. }
  50162. ++me.pos;
  50163. } else if (c === '.') {
  50164. if (decimal) {
  50165. break;
  50166. }
  50167. decimal = true;
  50168. ++me.pos;
  50169. } else if (c === 'e' || c === 'E') {
  50170. if (exp) {
  50171. break;
  50172. }
  50173. decimal = exp = true;
  50174. c = text.charAt(++me.pos);
  50175. if (c === '-' || c === '+') {
  50176. ++me.pos;
  50177. }
  50178. }
  50179. else if (digitRe.test(c)) {
  50180. ++me.pos;
  50181. } else {
  50182. break;
  50183. }
  50184. }
  50185. token = {
  50186. type: 'literal',
  50187. is: NUMBER,
  50188. value: +text.substring(start, me.pos)
  50189. };
  50190. if (!isFinite(token.value)) {
  50191. token = me.syntaxError(start, 'Invalid number');
  50192. }
  50193. return token;
  50194. },
  50195. parseOperator: function(c) {
  50196. var me = this,
  50197. block = me.operators,
  50198. text = me.text,
  50199. length = me.end,
  50200. end = me.pos,
  50201. match, matchEnd, token;
  50202. while (block[c]) {
  50203. block = block[c];
  50204. token = block.token;
  50205. ++end;
  50206. if (token) {
  50207. match = token;
  50208. matchEnd = end;
  50209. }
  50210. if (end < length) {
  50211. c = text.charAt(end);
  50212. } else {
  50213. break;
  50214. }
  50215. }
  50216. if (match) {
  50217. me.pos = matchEnd;
  50218. }
  50219. return match;
  50220. },
  50221. parseString: function() {
  50222. var me = this,
  50223. text = me.text,
  50224. pos = me.pos,
  50225. start = pos,
  50226. length = me.end,
  50227. str = '',
  50228. c, closed, quote;
  50229. quote = text.charAt(pos++);
  50230. while (pos < length) {
  50231. c = text.charAt(pos++);
  50232. if (c === quote) {
  50233. closed = true;
  50234. break;
  50235. }
  50236. if (c === '\\' && pos < length) {
  50237. c = text.charAt(pos++);
  50238. }
  50239. str += c;
  50240. }
  50241. me.pos = pos;
  50242. if (!closed) {
  50243. return me.syntaxError(start, 'Unterminated string');
  50244. }
  50245. return {
  50246. type: 'literal',
  50247. is: STRING,
  50248. value: str
  50249. };
  50250. },
  50251. syntaxError: function(at, message) {
  50252. if (typeof at === 'string') {
  50253. message = at;
  50254. at = this.pos;
  50255. }
  50256. var suffix = (at == null) ? '' : (' (at index ' + at + ')'),
  50257. error = new Error(message + suffix);
  50258. error.type = 'error';
  50259. error.is = ERROR;
  50260. if (suffix) {
  50261. error.at = at;
  50262. }
  50263. return this.error = error;
  50264. }
  50265. }
  50266. };
  50267. });
  50268. Ext.define('Ext.parse.Symbol', {
  50269. priority: 0,
  50270. constructor: function(id, config) {
  50271. var me = this,
  50272. defaultProperty = me.defaultProperty;
  50273. if (config && typeof config === 'object') {
  50274. Ext.apply(me, config);
  50275. } else if (config !== undefined && defaultProperty) {
  50276. me[defaultProperty] = config;
  50277. }
  50278. me.id = id;
  50279. },
  50280. dump: function() {
  50281. var me = this,
  50282. ret = {
  50283. at: me.at,
  50284. arity: me.arity
  50285. },
  50286. i;
  50287. if ('value' in me) {
  50288. ret.value = me.value;
  50289. }
  50290. if (me.lhs) {
  50291. ret.lhs = me.lhs.dump();
  50292. ret.rhs = me.rhs.dump();
  50293. }
  50294. if (me.operand) {
  50295. ret.operand = me.operand.dump();
  50296. }
  50297. if (me.args) {
  50298. ret.args = [];
  50299. for (i = 0; i < me.args.length; ++i) {
  50300. ret.args.push(me.args[i].dump());
  50301. }
  50302. }
  50303. return ret;
  50304. },
  50305. led: function() {
  50306. this.parser.syntaxError(this.at, 'Missing operator');
  50307. },
  50308. nud: function() {
  50309. this.parser.syntaxError(this.at, 'Undefined');
  50310. },
  50311. update: function(config) {
  50312. if (config && typeof config === 'object') {
  50313. var me = this,
  50314. priority = config.priority,
  50315. led = config.led,
  50316. nud = config.nud;
  50317. if (me.priority <= priority) {
  50318. me.priority = priority;
  50319. }
  50320. if (led) {
  50321. me.led = led;
  50322. }
  50323. if (nud) {
  50324. me.nud = nud;
  50325. }
  50326. }
  50327. }
  50328. });
  50329. Ext.define('Ext.parse.symbol.Constant', {
  50330. extend: Ext.parse.Symbol,
  50331. arity: 'literal',
  50332. isLiteral: true,
  50333. defaultProperty: 'value',
  50334. constructor: function(id, config) {
  50335. this.callParent([
  50336. id,
  50337. config
  50338. ]);
  50339. this._value = this.value;
  50340. },
  50341. nud: function() {
  50342. var me = this;
  50343. me.value = me._value;
  50344. me.arity = 'literal';
  50345. me.isLiteral = true;
  50346. return me;
  50347. }
  50348. });
  50349. Ext.define('Ext.parse.symbol.Infix', {
  50350. extend: Ext.parse.Symbol,
  50351. arity: 'binary',
  50352. isBinary: true,
  50353. defaultProperty: 'priority',
  50354. led: function(left) {
  50355. var me = this;
  50356. me.lhs = left;
  50357. me.rhs = me.parser.parseExpression(me.priority);
  50358. me.arity = 'binary';
  50359. me.isBinary = true;
  50360. return me;
  50361. }
  50362. });
  50363. Ext.define('Ext.parse.symbol.InfixRight', {
  50364. extend: Ext.parse.symbol.Infix,
  50365. led: function(left) {
  50366. var me = this;
  50367. me.lhs = left;
  50368. me.rhs = me.parser.parseExpression(me.priority - 1);
  50369. me.arity = 'binary';
  50370. me.isBinary = true;
  50371. return me;
  50372. }
  50373. });
  50374. Ext.define('Ext.parse.symbol.Paren', {
  50375. extend: Ext.parse.Symbol,
  50376. arity: 'binary',
  50377. isBinary: true,
  50378. priority: 80,
  50379. led: function(left) {
  50380. var me = this,
  50381. args = [],
  50382. parser = me.parser,
  50383. id = left.id,
  50384. type = left.arity;
  50385. if (id !== '.' && id !== '[') {
  50386. if ((type !== "unary" || id !== "function") && type !== "ident" && id !== "(" && id !== "&&" && id !== "||" && id !== "?") {
  50387. parser.syntaxError(left.at, "Expected a variable name.");
  50388. }
  50389. }
  50390. me.arity = 'invoke';
  50391. me.isInvoke = true;
  50392. me.operand = left;
  50393. me.args = args;
  50394. while (parser.token.id !== ')') {
  50395. if (args.length) {
  50396. parser.advance(',');
  50397. }
  50398. args.push(parser.parseExpression());
  50399. }
  50400. parser.advance(')');
  50401. return me;
  50402. },
  50403. nud: function() {
  50404. var parser = this.parser,
  50405. ret = parser.parseExpression();
  50406. parser.advance(")");
  50407. return ret;
  50408. }
  50409. });
  50410. Ext.define('Ext.parse.symbol.Prefix', {
  50411. extend: Ext.parse.Symbol,
  50412. arity: 'unary',
  50413. isUnary: true,
  50414. priority: 70,
  50415. nud: function() {
  50416. var me = this;
  50417. me.operand = me.parser.parseExpression(me.priority);
  50418. me.arity = 'unary';
  50419. me.isUnary = true;
  50420. return me;
  50421. }
  50422. });
  50423. Ext.define('Ext.parse.Parser', function() {
  50424. var ITSELF = function() {
  50425. return this;
  50426. };
  50427. return {
  50428. extend: Ext.util.Fly,
  50429. isParser: true,
  50430. config: {
  50431. constants: {
  50432. 'null': null,
  50433. 'false': false,
  50434. 'true': true
  50435. },
  50436. infix: {
  50437. '+': 50,
  50438. '-': 50,
  50439. '*': 60,
  50440. '/': 60
  50441. },
  50442. infixRight: {
  50443. '&&': 30,
  50444. '||': 30
  50445. },
  50446. prefix: {
  50447. '!': 0,
  50448. '-': 0,
  50449. '+': 0
  50450. },
  50451. symbols: {
  50452. ':': 0,
  50453. ',': 0,
  50454. ')': 0,
  50455. '[': 0,
  50456. ']': 0,
  50457. '{': 0,
  50458. '}': 0,
  50459. '(end)': 0,
  50460. '(ident)': {
  50461. arity: 'ident',
  50462. isIdent: true,
  50463. nud: ITSELF
  50464. },
  50465. '(literal)': {
  50466. arity: 'literal',
  50467. isLiteral: true,
  50468. nud: ITSELF
  50469. },
  50470. '(': {
  50471. xclass: 'Ext.parse.symbol.Paren'
  50472. }
  50473. },
  50474. tokenizer: {
  50475. keywords: null
  50476. }
  50477. },
  50478. token: null,
  50479. constructor: function(config) {
  50480. this.symbols = {};
  50481. this.initConfig(config);
  50482. },
  50483. advance: function(expected) {
  50484. var me = this,
  50485. tokenizer = me.tokenizer,
  50486. token = tokenizer.peek(),
  50487. symbols = me.symbols,
  50488. index = tokenizer.index,
  50489. is, symbol, value;
  50490. if (me.error) {
  50491. throw me.error;
  50492. }
  50493. if (expected) {
  50494. me.expect(expected);
  50495. }
  50496. if (!token) {
  50497. return me.token = symbols['(end)'];
  50498. }
  50499. tokenizer.next();
  50500. is = token.is;
  50501. value = token.value;
  50502. if (is.ident) {
  50503. symbol = symbols[value] || symbols['(ident)'];
  50504. } else if (is.operator) {
  50505. if (!(symbol = symbols[value])) {
  50506. me.syntaxError(token.at, 'Unknown operator "' + value + '"');
  50507. }
  50508. } else if (is.literal) {
  50509. symbol = symbols['(literal)'];
  50510. } else {
  50511. me.syntaxError(token.at, 'Unexpected token');
  50512. }
  50513. me.token = symbol = Ext.Object.chain(symbol);
  50514. symbol.at = index;
  50515. symbol.value = value;
  50516. if (!symbol.arity) {
  50517. symbol.arity = token.type;
  50518. }
  50519. return symbol;
  50520. },
  50521. expect: function(expected) {
  50522. var token = this.token;
  50523. if (expected !== token.id) {
  50524. this.syntaxError(token.at, 'Expected "' + expected + '"');
  50525. }
  50526. return this;
  50527. },
  50528. parseExpression: function(rightPriority) {
  50529. var me = this,
  50530. token = me.token,
  50531. left;
  50532. rightPriority = rightPriority || 0;
  50533. me.advance();
  50534. left = token.nud();
  50535. while (rightPriority < (token = me.token).priority) {
  50536. me.advance();
  50537. left = token.led(left);
  50538. }
  50539. return left;
  50540. },
  50541. reset: function(text, pos, end) {
  50542. var me = this;
  50543. me.error = me.token = null;
  50544. me.tokenizer.reset(text, pos, end);
  50545. me.advance();
  50546. return me;
  50547. },
  50548. syntaxError: function(at, message) {
  50549. if (typeof at === 'string') {
  50550. message = at;
  50551. at = this.pos;
  50552. }
  50553. var suffix = (at == null) ? '' : (' (at index ' + at + ')'),
  50554. error = new Error(message + suffix);
  50555. error.type = 'error';
  50556. if (suffix) {
  50557. error.at = at;
  50558. }
  50559. throw this.error = error;
  50560. },
  50561. privates: {
  50562. error: null,
  50563. addSymbol: function(id, config, type, update) {
  50564. var symbols = this.symbols,
  50565. symbol = symbols[id],
  50566. cfg, length, i;
  50567. if (symbol) {
  50568. if (typeof config === 'object') {
  50569. cfg = config;
  50570. } else if (update && type) {
  50571. update = Ext.Array.from(update);
  50572. length = update.length;
  50573. cfg = {};
  50574. for (i = 0; i < length; i++) {
  50575. cfg[update[i]] = type.prototype[update[i]];
  50576. }
  50577. } else {
  50578. return symbol;
  50579. }
  50580. symbol.update(cfg);
  50581. } else {
  50582. if (config && config.xclass) {
  50583. type = Ext.ClassManager.get(config.xclass);
  50584. } else {
  50585. type = type || Ext.parse.Symbol;
  50586. }
  50587. symbols[id] = symbol = new type(id, config);
  50588. symbol.parser = this;
  50589. }
  50590. return symbol;
  50591. },
  50592. addSymbols: function(symbols, type, update) {
  50593. for (var id in symbols) {
  50594. this.addSymbol(id, symbols[id], type, update);
  50595. }
  50596. },
  50597. applyConstants: function(constants) {
  50598. this.addSymbols(constants, Ext.parse.symbol.Constant, 'nud');
  50599. },
  50600. applyInfix: function(operators) {
  50601. this.addSymbols(operators, Ext.parse.symbol.Infix, 'led');
  50602. },
  50603. applyInfixRight: function(operators) {
  50604. this.addSymbols(operators, Ext.parse.symbol.InfixRight, 'led');
  50605. },
  50606. applyPrefix: function(operators) {
  50607. this.addSymbols(operators, Ext.parse.symbol.Prefix, 'nud');
  50608. },
  50609. applySymbols: function(symbols) {
  50610. this.addSymbols(symbols);
  50611. },
  50612. applyTokenizer: function(config) {
  50613. var ret = config;
  50614. if (config && !config.isTokenizer) {
  50615. ret = new Ext.parse.Tokenizer(config);
  50616. }
  50617. this.tokenizer = ret;
  50618. }
  50619. }
  50620. };
  50621. });
  50622. Ext.define('Ext.app.bind.Parser', {
  50623. extend: Ext.parse.Parser,
  50624. infix: {
  50625. ':': {
  50626. priority: 70,
  50627. dump: function() {
  50628. var me = this,
  50629. ret = {
  50630. at: me.at,
  50631. arity: me.arity,
  50632. value: me.value,
  50633. operand: me.operand.dump(),
  50634. fmt: []
  50635. },
  50636. fmt = me.fmt,
  50637. i;
  50638. for (i = 0; i < fmt.length; ++i) {
  50639. ret.fmt.push(fmt[i].dump());
  50640. }
  50641. return ret;
  50642. },
  50643. led: function(left) {
  50644. var me = this;
  50645. me.arity = 'formatter';
  50646. me.operand = left;
  50647. me.fmt = me.parser.parseFmt();
  50648. return me;
  50649. }
  50650. },
  50651. '?': {
  50652. priority: 20,
  50653. led: function(left) {
  50654. var me = this,
  50655. parser = me.parser,
  50656. symbol = parser.symbols[':'],
  50657. temp;
  50658. me.condition = left;
  50659. temp = symbol.priority;
  50660. symbol.priority = 0;
  50661. me.tv = parser.parseExpression(0);
  50662. me.parser.advance(':');
  50663. symbol.priority = temp;
  50664. me.fv = parser.parseExpression(0);
  50665. me.arity = 'ternary';
  50666. return me;
  50667. }
  50668. },
  50669. '===': 40,
  50670. '!==': 40,
  50671. '==': 40,
  50672. '!=': 40,
  50673. '<': 40,
  50674. '<=': 40,
  50675. '>': 40,
  50676. '>=': 40
  50677. },
  50678. symbols: {
  50679. '(': {
  50680. nud: function() {
  50681. var parser = this.parser,
  50682. symbol = parser.symbols[':'],
  50683. ret, temp;
  50684. temp = symbol.priority;
  50685. symbol.priority = 70;
  50686. ret = parser.parseExpression();
  50687. parser.advance(")");
  50688. symbol.priority = temp;
  50689. return ret;
  50690. }
  50691. }
  50692. },
  50693. prefix: {
  50694. '@': 0
  50695. },
  50696. tokenizer: {
  50697. operators: {
  50698. '@': 'at',
  50699. '?': 'qmark',
  50700. '===': 'feq',
  50701. '!==': 'fneq',
  50702. '==': 'eq',
  50703. '!=': 'neq',
  50704. '<': 'lt',
  50705. '<=': 'lte',
  50706. '>': 'gt',
  50707. '>=': 'gte',
  50708. '&&': 'and',
  50709. '||': 'or'
  50710. }
  50711. },
  50712. compileExpression: function(tokens, tokensMaps) {
  50713. var me = this,
  50714. debug, fn;
  50715. me.tokens = tokens;
  50716. me.tokensMap = tokensMaps;
  50717. debug = me.token.value === '@' && me.tokenizer.peek();
  50718. if (debug) {
  50719. debug = debug.value === 'debugger';
  50720. if (debug) {
  50721. me.advance();
  50722. me.advance();
  50723. }
  50724. }
  50725. fn = me.parseSlot(me.parseExpression(), debug);
  50726. me.tokens = me.tokensMap = null;
  50727. return fn;
  50728. },
  50729. compileFormat: function() {
  50730. var fn;
  50731. try {
  50732. fn = this.parseSlot({
  50733. arity: 'formatter',
  50734. fmt: this.parseFmt(),
  50735. operand: {
  50736. arity: 'ident',
  50737. value: 'dummy'
  50738. }
  50739. });
  50740. this.expect('(end)');
  50741. }
  50742. catch (e) {
  50743. Ext.raise('Invalid format expression: "' + this.tokenizer.text + '"');
  50744. }
  50745. return fn;
  50746. },
  50747. privates: {
  50748. useEval: Ext.isGecko,
  50749. escapeRe: /("|'|\\)/g,
  50750. parseFmt: function() {
  50751. var me = this,
  50752. fmt = [],
  50753. priority = me.symbols[':'].priority,
  50754. expr;
  50755. do {
  50756. if (fmt.length) {
  50757. me.advance();
  50758. }
  50759. expr = me.parseExpression(priority);
  50760. if (expr.isIdent || expr.isInvoke) {
  50761. fmt.push(expr);
  50762. } else {
  50763. me.syntaxError(expr.at, 'Expected formatter name');
  50764. }
  50765. } while (me.token.id === ':');
  50766. return fmt;
  50767. },
  50768. parseSlot: function(expr, debug) {
  50769. var me = this,
  50770. defs = [],
  50771. body = [],
  50772. tokens = me.tokens || [],
  50773. fn, code, i, length, temp;
  50774. me.definitions = defs;
  50775. me.body = body;
  50776. body.push('return ' + me.compile(expr) + ';');
  50777. length = tokens.length;
  50778. code = 'var fm = Ext.util.Format,\nme,';
  50779. temp = 'var a = Ext.Array.from(values);\nme = scope;\n';
  50780. if (tokens.length) {
  50781. for (i = 0; i < length; i++) {
  50782. code += 'v' + i + ((i == length - 1) ? ';' : ',');
  50783. temp += 'v' + i + ' = a[' + i + ']; ';
  50784. }
  50785. } else {
  50786. code += 'v0;';
  50787. temp += 'v0 = a[0];';
  50788. }
  50789. defs = Ext.Array.insert(defs, 0, [
  50790. code
  50791. ]);
  50792. body = Ext.Array.insert(body, 0, [
  50793. temp
  50794. ]);
  50795. body = body.join('\n');
  50796. if (debug) {
  50797. body = 'debugger;\n' + body;
  50798. }
  50799. defs.push((me.useEval ? '$=' : 'return') + ' function (values, scope) {', body, '}');
  50800. code = defs.join('\n');
  50801. fn = me.useEval ? me.evalFn(code) : (new Function('Ext', code))(Ext);
  50802. me.definitions = me.body = null;
  50803. return fn;
  50804. },
  50805. compile: function(expr) {
  50806. var me = this,
  50807. v;
  50808. switch (expr.arity) {
  50809. case 'ident':
  50810. return me.addToken(expr.value);
  50811. case 'literal':
  50812. v = expr.value;
  50813. return (typeof v === 'string') ? '"' + String(v).replace(me.escapeRe, '\\$1') + '"' : v;
  50814. case 'unary':
  50815. return me.compileUnary(expr);
  50816. case 'binary':
  50817. return me.compileBinary(expr);
  50818. case 'ternary':
  50819. return me.compileTernary(expr);
  50820. case 'formatter':
  50821. return me.compileFormatter(expr);
  50822. }
  50823. return this.syntaxError(expr.at, 'Compile error! Unknown symbol');
  50824. },
  50825. compileUnary: function(expr) {
  50826. var v = expr.value,
  50827. op = expr.operand;
  50828. if (v === '!' || v === '-' || v === '+') {
  50829. return v + '(' + this.compile(op) + ')';
  50830. } else if (v === '@') {
  50831. if (!op.isIdent) {
  50832. return this.syntaxError(expr.at, 'Compile error! Unexpected symbol');
  50833. }
  50834. return op.value;
  50835. }
  50836. return '';
  50837. },
  50838. compileBinary: function(expr) {
  50839. return '(' + this.compile(expr.lhs) + ' ' + expr.value + ' ' + this.compile(expr.rhs) + ')';
  50840. },
  50841. compileTernary: function(expr) {
  50842. return '(' + this.compile(expr.condition) + ' ? ' + this.compile(expr.tv) + ' : ' + this.compile(expr.fv) + ')';
  50843. },
  50844. compileFormatter: function(expr) {
  50845. var me = this,
  50846. fmt = expr.fmt,
  50847. length = fmt.length,
  50848. body = [
  50849. 'var ret;'
  50850. ],
  50851. i;
  50852. if (fmt.length) {
  50853. body.push('ret = ' + me.compileFormatFn(fmt[0], me.compile(expr.operand)) + ';');
  50854. for (i = 1; i < length; i++) {
  50855. body.push('ret = ' + me.compileFormatFn(fmt[i], 'ret') + ';');
  50856. }
  50857. }
  50858. body.push('return ret;');
  50859. return me.addFn(body.join('\n'));
  50860. },
  50861. compileFormatFn: function(expr, value) {
  50862. var fmt,
  50863. args = [],
  50864. code = '',
  50865. length, i;
  50866. if (expr.isIdent) {
  50867. fmt = expr.value;
  50868. } else if (expr.isInvoke) {
  50869. fmt = expr.operand.value;
  50870. args = expr.args;
  50871. }
  50872. if (fmt.substring(0, 5) === 'this.') {
  50873. fmt = 'me.' + fmt.substring(5);
  50874. } else {
  50875. if (!(fmt in Ext.util.Format)) {
  50876. return this.syntaxError(expr.at, 'Compile error! Invalid format specified "' + fmt + '"');
  50877. }
  50878. fmt = 'fm.' + fmt;
  50879. }
  50880. code += value;
  50881. length = args.length;
  50882. for (i = 0; i < length; i++) {
  50883. code += ', ' + this.compile(args[i]);
  50884. }
  50885. return fmt + '(' + code + ')';
  50886. },
  50887. addFn: function(body) {
  50888. var defs = this.definitions,
  50889. name = 'f' + defs.length;
  50890. defs.push('function ' + name + '() {', body, '}');
  50891. return name + '()';
  50892. },
  50893. evalFn: function($) {
  50894. eval($);
  50895. return $;
  50896. },
  50897. addToken: function(token) {
  50898. var tokensMap = this.tokensMap,
  50899. tokens = this.tokens,
  50900. pos = 0;
  50901. if (tokensMap && tokens) {
  50902. if (token in tokensMap) {
  50903. pos = tokensMap[token];
  50904. } else {
  50905. tokensMap[token] = pos = tokens.length;
  50906. tokens.push(token);
  50907. }
  50908. }
  50909. return 'v' + pos;
  50910. }
  50911. }
  50912. });
  50913. Ext.define('Ext.app.bind.Template', {
  50914. escapes: false,
  50915. buffer: null,
  50916. slots: null,
  50917. tokens: null,
  50918. constructor: function(text) {
  50919. var me = this,
  50920. initters = me._initters,
  50921. name;
  50922. me.text = text;
  50923. for (name in initters) {
  50924. me[name] = initters[name];
  50925. }
  50926. },
  50927. _initters: {
  50928. apply: function(values, scope) {
  50929. return this.parse().apply(values, scope);
  50930. },
  50931. getTokens: function() {
  50932. return this.parse().getTokens();
  50933. }
  50934. },
  50935. apply: function(values, scope) {
  50936. var me = this,
  50937. slots = me.slots,
  50938. buffer = me.buffer,
  50939. length = slots.length,
  50940. i, slot;
  50941. for (i = 0; i < length; ++i) {
  50942. slot = slots[i];
  50943. if (slot) {
  50944. buffer[i] = slot(values, scope);
  50945. }
  50946. }
  50947. if (slot && me.single) {
  50948. return buffer[0];
  50949. }
  50950. return buffer.join('');
  50951. },
  50952. getText: function() {
  50953. return this.buffer.join('');
  50954. },
  50955. getTokens: function() {
  50956. return this.tokens;
  50957. },
  50958. isStatic: function() {
  50959. var tokens = this.getTokens(),
  50960. slots = this.slots;
  50961. return (tokens.length === 0 && slots.length === 0);
  50962. },
  50963. privates: {
  50964. literalChar: '~',
  50965. escapeChar: '\\',
  50966. parse: function() {
  50967. var me = this,
  50968. text = me.text,
  50969. parser = Ext.app.bind.Parser.fly(),
  50970. buffer = (me.buffer = []),
  50971. slots = (me.slots = []),
  50972. length = text.length,
  50973. pos = 0,
  50974. escapes = me.escapes,
  50975. current = '',
  50976. i = 0,
  50977. esc = me.escapeChar,
  50978. lit = me.literalChar,
  50979. escaped, tokens, tokensMap, lastEscaped, c, prev, key;
  50980. for (key in me._initters) {
  50981. delete me[key];
  50982. }
  50983. me.tokens = tokens = [];
  50984. me.tokensMap = tokensMap = {};
  50985. while (i < length) {
  50986. c = text[i];
  50987. lastEscaped = escaped;
  50988. escaped = escapes && c === esc;
  50989. if (escaped) {
  50990. c = text[i + 1];
  50991. ++i;
  50992. } else if (c === lit && prev === lit && !lastEscaped) {
  50993. current = current.slice(0, -1);
  50994. current += text.substring(i + 1);
  50995. break;
  50996. } else if (c === '{') {
  50997. if (current) {
  50998. buffer[pos++] = current;
  50999. current = '';
  51000. }
  51001. parser.reset(text, i + 1);
  51002. i = me.parseExpression(parser, pos);
  51003. ++pos;
  51004. continue;
  51005. }
  51006. current += c;
  51007. ++i;
  51008. prev = c;
  51009. }
  51010. if (current) {
  51011. buffer[pos] = current;
  51012. }
  51013. parser.release();
  51014. me.single = buffer.length === 0 && slots.length === 1;
  51015. return me;
  51016. },
  51017. parseExpression: function(parser, pos) {
  51018. var i;
  51019. this.slots[pos] = parser.compileExpression(this.tokens, this.tokensMap);
  51020. i = parser.token.at + 1;
  51021. parser.expect('}');
  51022. return i;
  51023. }
  51024. }
  51025. });
  51026. Ext.define('Ext.app.bind.TemplateBinding', {
  51027. extend: Ext.app.bind.BaseBinding,
  51028. isTemplateBinding: true,
  51029. lastValue: undefined,
  51030. value: undefined,
  51031. constructor: function(template, owner, callback, scope, options) {
  51032. var me = this,
  51033. tpl = new Ext.app.bind.Template(template),
  51034. tokens = tpl.getTokens();
  51035. me.callParent([
  51036. owner,
  51037. callback,
  51038. scope,
  51039. options
  51040. ]);
  51041. me.tpl = tpl;
  51042. me.tokens = tokens;
  51043. tokens.$literal = true;
  51044. if (!tpl.isStatic()) {
  51045. me.multiBinding = new Ext.app.bind.Multi(tokens, owner, me.onBindData, me);
  51046. } else {
  51047. me.isStatic = true;
  51048. me.onData(tpl.getText());
  51049. }
  51050. },
  51051. destroy: function() {
  51052. var me = this;
  51053. Ext.destroy(me.multiBinding);
  51054. me.tpl = me.multiBinding = null;
  51055. me.callParent();
  51056. },
  51057. getFullName: function() {
  51058. var multi = this.multiBinding;
  51059. return this.fullName || (this.fullName = '$' + (multi ? multi.getFullName() : this.callParent()));
  51060. },
  51061. getRawValue: function() {
  51062. return this.value;
  51063. },
  51064. getTemplateScope: function() {
  51065. return null;
  51066. },
  51067. isAvailable: function() {
  51068. var multi = this.multiBinding;
  51069. return multi ? multi.isAvailable() : false;
  51070. },
  51071. isDescendantOf: function() {
  51072. return false;
  51073. },
  51074. isLoading: function() {
  51075. var multi = this.multiBinding;
  51076. return multi ? multi.isLoading() : false;
  51077. },
  51078. onBindData: function(data) {
  51079. this.onData(this.tpl.apply(data, this.getTemplateScope()));
  51080. },
  51081. onData: function(value) {
  51082. var me = this,
  51083. lastValue = me.value;
  51084. if (lastValue !== (me.value = value)) {
  51085. me.lastValue = lastValue;
  51086. me.schedule();
  51087. }
  51088. },
  51089. react: function() {
  51090. this.notify(this.value);
  51091. },
  51092. refresh: function() {
  51093. var multi = this.multiBinding;
  51094. if (multi) {
  51095. multi.refresh();
  51096. }
  51097. },
  51098. privates: {
  51099. sort: function() {
  51100. var multi = this.multiBinding;
  51101. if (multi) {
  51102. this.scheduler.sortItem(multi);
  51103. }
  51104. }
  51105. }
  51106. });
  51107. Ext.define('Ext.data.ChainedStore', {
  51108. extend: Ext.data.AbstractStore,
  51109. alias: 'store.chained',
  51110. isChainedStore: true,
  51111. config: {
  51112. source: null,
  51113. remoteFilter: false,
  51114. remoteSort: false
  51115. },
  51116. mixins: [
  51117. Ext.data.LocalStore
  51118. ],
  51119. updateRemoteFilter: function(remoteFilter, oldRemoteFilter) {
  51120. if (remoteFilter) {
  51121. Ext.raise('Remote filtering cannot be used with chained stores.');
  51122. }
  51123. this.callParent([
  51124. remoteFilter,
  51125. oldRemoteFilter
  51126. ]);
  51127. },
  51128. updateRemoteSort: function(remoteSort, oldRemoteSort) {
  51129. if (remoteSort) {
  51130. Ext.raise('Remote sorting cannot be used with chained stores.');
  51131. }
  51132. this.callParent([
  51133. remoteSort,
  51134. oldRemoteSort
  51135. ]);
  51136. },
  51137. remove: function() {
  51138. var source = this.getSource();
  51139. if (!source) {
  51140. Ext.raise('Cannot remove records with no source.');
  51141. }
  51142. return source.remove.apply(source, arguments);
  51143. },
  51144. removeAll: function() {
  51145. var source = this.getSource();
  51146. if (!source) {
  51147. Ext.raise('Cannot remove records with no source.');
  51148. }
  51149. return source.removeAll();
  51150. },
  51151. getData: function() {
  51152. var me = this,
  51153. data = me.data;
  51154. if (!data) {
  51155. me.data = data = me.constructDataCollection();
  51156. }
  51157. return data;
  51158. },
  51159. getTotalCount: function() {
  51160. return this.getCount();
  51161. },
  51162. getSession: function() {
  51163. return this.getSourceValue('getSession', null);
  51164. },
  51165. applySource: function(source) {
  51166. if (source) {
  51167. var original = source,
  51168. s;
  51169. source = Ext.data.StoreManager.lookup(source);
  51170. if (!source) {
  51171. s = 'Invalid source {0}specified for Ext.data.ChainedStore';
  51172. s = Ext.String.format(s, typeof original === 'string' ? '"' + original + '" ' : '');
  51173. Ext.raise(s);
  51174. }
  51175. }
  51176. return source;
  51177. },
  51178. updateSource: function(source, oldSource) {
  51179. var me = this,
  51180. data;
  51181. if (oldSource && !oldSource.destroyed) {
  51182. oldSource.removeObserver(me);
  51183. }
  51184. if (source) {
  51185. data = me.getData();
  51186. data.setSource(source.getData());
  51187. if (!me.isInitializing) {
  51188. me.fireEvent('refresh', me);
  51189. me.fireEvent('datachanged', me);
  51190. }
  51191. source.addObserver(me);
  51192. }
  51193. },
  51194. getModel: function() {
  51195. return this.getSourceValue('getModel', null);
  51196. },
  51197. getProxy: function() {
  51198. return null;
  51199. },
  51200. onCollectionAdd: function(collection, info) {
  51201. var me = this,
  51202. records = info.items,
  51203. lastChunk = !info.next;
  51204. if (me.ignoreCollectionAdd) {
  51205. return;
  51206. }
  51207. if (me.activeRanges) {
  51208. me.syncActiveRanges();
  51209. }
  51210. me.fireEvent('add', me, records, info.at);
  51211. if (lastChunk) {
  51212. me.fireEvent('datachanged', me);
  51213. }
  51214. },
  51215. onCollectionItemChange: function(collection, info) {
  51216. var me = this,
  51217. record = info.item,
  51218. modifiedFieldNames = info.modified || null,
  51219. type = info.meta;
  51220. me.onUpdate(record, type, modifiedFieldNames, info);
  51221. me.fireEvent('update', me, record, type, modifiedFieldNames, info);
  51222. me.fireEvent('datachanged', me);
  51223. },
  51224. onCollectionUpdateKey: function(source, details) {
  51225. this.fireEvent('idchanged', this, details.item, details.oldKey, details.newKey);
  51226. },
  51227. onUpdate: Ext.emptyFn,
  51228. onCollectionRemove: function(collection, info) {
  51229. var me = this,
  51230. records = info.items,
  51231. lastChunk = !info.next;
  51232. if (me.ignoreCollectionRemove) {
  51233. return;
  51234. }
  51235. me.fireEvent('remove', me, records, info.at, false);
  51236. if (lastChunk) {
  51237. me.fireEvent('datachanged', me);
  51238. }
  51239. },
  51240. onSourceBeforeLoad: function(source, operation) {
  51241. this.fireEvent('beforeload', this, operation);
  51242. this.callObservers('BeforeLoad', [
  51243. operation
  51244. ]);
  51245. },
  51246. onSourceAfterLoad: function(source, records, successful, operation) {
  51247. this.fireEvent('load', this, records, successful, operation);
  51248. this.callObservers('AfterLoad', [
  51249. records,
  51250. successful,
  51251. operation
  51252. ]);
  51253. },
  51254. onFilterEndUpdate: function() {
  51255. this.callParent(arguments);
  51256. this.callObservers('Filter');
  51257. },
  51258. onSourceBeforePopulate: function() {
  51259. this.ignoreCollectionAdd = true;
  51260. this.callObservers('BeforePopulate');
  51261. },
  51262. onSourceAfterPopulate: function() {
  51263. var me = this;
  51264. me.ignoreCollectionAdd = false;
  51265. me.fireEvent('datachanged', me);
  51266. me.fireEvent('refresh', me);
  51267. this.callObservers('AfterPopulate');
  51268. },
  51269. onSourceBeforeClear: function() {
  51270. this.ignoreCollectionRemove = true;
  51271. this.callObservers('BeforeClear');
  51272. },
  51273. onSourceAfterClear: function() {
  51274. this.ignoreCollectionRemove = false;
  51275. this.callObservers('AfterClear');
  51276. },
  51277. onSourceBeforeRemoveAll: function() {
  51278. this.ignoreCollectionRemove = true;
  51279. this.callObservers('BeforeRemoveAll');
  51280. },
  51281. onSourceAfterRemoveAll: function(source, silent) {
  51282. var me = this;
  51283. me.ignoreCollectionRemove = false;
  51284. if (!silent) {
  51285. me.fireEvent('clear', me);
  51286. me.fireEvent('datachanged', me);
  51287. }
  51288. this.callObservers('AfterRemoveAll', [
  51289. silent
  51290. ]);
  51291. },
  51292. onSourceFilter: function() {
  51293. var me = this;
  51294. me.fireEvent('refresh', me);
  51295. me.fireEvent('datachanged', me);
  51296. },
  51297. hasPendingLoad: function() {
  51298. return this.getSourceValue('hasPendingLoad', false);
  51299. },
  51300. isLoaded: function() {
  51301. return this.getSourceValue('isLoaded', false);
  51302. },
  51303. isLoading: function() {
  51304. return this.getSourceValue('isLoading', false);
  51305. },
  51306. doDestroy: function() {
  51307. var me = this;
  51308. me.observers = null;
  51309. me.setSource(null);
  51310. me.getData().destroy(true);
  51311. me.data = null;
  51312. me.callParent();
  51313. },
  51314. privates: {
  51315. getSourceValue: function(method, defaultValue) {
  51316. var source = this.getSource(),
  51317. val = defaultValue;
  51318. if (source && !source.destroyed) {
  51319. val = source[method]();
  51320. }
  51321. return val;
  51322. },
  51323. isMoving: function() {
  51324. var source = this.getSource();
  51325. return source.isMoving ? source.isMoving.apply(source, arguments) : false;
  51326. },
  51327. loadsSynchronously: function() {
  51328. return this.getSource().loadsSynchronously();
  51329. }
  51330. }
  51331. });
  51332. Ext.define('Ext.app.ViewModel', {
  51333. mixins: [
  51334. Ext.mixin.Factoryable,
  51335. Ext.mixin.Identifiable
  51336. ],
  51337. alias: 'viewmodel.default',
  51338. isViewModel: true,
  51339. factoryConfig: {
  51340. name: 'viewModel'
  51341. },
  51342. collectTimeout: 100,
  51343. expressionRe: /^(?:\{(?:(\d+)|([a-z_][\w\.]*))\})$/i,
  51344. statics: {
  51345. escape: function(value) {
  51346. var ret = value,
  51347. key;
  51348. if (typeof value === 'string') {
  51349. ret = '~~' + value;
  51350. } else if (value && value.constructor === Object) {
  51351. ret = {};
  51352. for (key in value) {
  51353. ret[key] = this.escape(value[key]);
  51354. }
  51355. }
  51356. return ret;
  51357. }
  51358. },
  51359. $configStrict: false,
  51360. config: {
  51361. data: true,
  51362. formulas: {
  51363. $value: null,
  51364. merge: function(newValue, currentValue, target, mixinClass) {
  51365. return this.mergeNew(newValue, currentValue, target, mixinClass);
  51366. }
  51367. },
  51368. links: null,
  51369. parent: null,
  51370. root: true,
  51371. scheduler: null,
  51372. schema: 'default',
  51373. session: null,
  51374. stores: null,
  51375. view: null
  51376. },
  51377. constructor: function(config) {
  51378. this.bindings = {};
  51379. this.initConfig(config);
  51380. },
  51381. destroy: function() {
  51382. var me = this,
  51383. scheduler = me._scheduler,
  51384. stores = me.storeInfo,
  51385. parent = me.getParent(),
  51386. task = me.collectTask,
  51387. children = me.children,
  51388. bindings = me.bindings,
  51389. key, store, autoDestroy, storeBinding;
  51390. me.destroying = true;
  51391. if (task) {
  51392. task.cancel();
  51393. me.collectTask = null;
  51394. }
  51395. if (children) {
  51396. for (key in children) {
  51397. children[key].destroy();
  51398. }
  51399. }
  51400. if (stores) {
  51401. for (key in stores) {
  51402. store = stores[key];
  51403. storeBinding = store.$binding;
  51404. autoDestroy = store.autoDestroy;
  51405. if (autoDestroy || (!store.$wasInstance && autoDestroy !== false)) {
  51406. store.destroy();
  51407. }
  51408. Ext.destroy(storeBinding);
  51409. }
  51410. }
  51411. if (parent) {
  51412. parent.unregisterChild(me);
  51413. }
  51414. me.getRoot().destroy();
  51415. for (key in bindings) {
  51416. bindings[key].destroy();
  51417. }
  51418. if (scheduler && scheduler.$owner === me) {
  51419. scheduler.$owner = null;
  51420. scheduler.destroy();
  51421. }
  51422. me.children = me.storeInfo = me._session = me._view = me._scheduler = me.bindings = me._root = me._parent = me.formulaFn = me.$formulaData = null;
  51423. me.destroying = false;
  51424. me.callParent();
  51425. },
  51426. bind: function(descriptor, callback, scope, options) {
  51427. var me = this,
  51428. track = true,
  51429. binding;
  51430. scope = scope || me;
  51431. if (!options && descriptor.bindTo !== undefined && !Ext.isString(descriptor)) {
  51432. options = descriptor;
  51433. descriptor = options.bindTo;
  51434. }
  51435. if (!Ext.isString(descriptor)) {
  51436. binding = new Ext.app.bind.Multi(descriptor, me, callback, scope, options);
  51437. } else if (me.expressionRe.test(descriptor)) {
  51438. descriptor = descriptor.substring(1, descriptor.length - 1);
  51439. binding = me.bindExpression(descriptor, callback, scope, options);
  51440. track = false;
  51441. } else {
  51442. binding = new Ext.app.bind.TemplateBinding(descriptor, me, callback, scope, options);
  51443. }
  51444. if (track) {
  51445. me.bindings[binding.id] = binding;
  51446. }
  51447. return binding;
  51448. },
  51449. getSession: function() {
  51450. var me = this,
  51451. session = me._session,
  51452. parent;
  51453. if (!session && (parent = me.getParent())) {
  51454. me.setSession(session = parent.getSession());
  51455. }
  51456. return session || null;
  51457. },
  51458. getStore: function(key) {
  51459. var storeInfo = this.storeInfo,
  51460. store;
  51461. if (storeInfo) {
  51462. store = storeInfo[key];
  51463. }
  51464. return store || null;
  51465. },
  51466. linkTo: function(key, reference) {
  51467. var me = this,
  51468. stub, create, id, modelType, linkStub, rec;
  51469. if (key.indexOf('.') > -1) {
  51470. Ext.raise('Links can only be at the top-level: "' + key + '"');
  51471. }
  51472. if (reference.isModel) {
  51473. reference = {
  51474. type: reference.entityName,
  51475. id: reference.id
  51476. };
  51477. }
  51478. modelType = reference.type || reference.reference;
  51479. create = reference.create;
  51480. if (modelType) {
  51481. id = reference.id;
  51482. if (!reference.create && Ext.isEmpty(id)) {
  51483. Ext.raise('No id specified. To create a phantom model, specify "create: true" as part of the reference.');
  51484. }
  51485. if (create) {
  51486. id = undefined;
  51487. }
  51488. rec = me.getRecord(modelType, id);
  51489. if (Ext.isObject(create)) {
  51490. rec.set(create);
  51491. rec.commit();
  51492. rec.phantom = true;
  51493. }
  51494. stub = me.getRoot().createStubChild(key);
  51495. stub.set(rec);
  51496. } else {
  51497. stub = me.getStub(key);
  51498. if (!stub.isLinkStub) {
  51499. linkStub = new Ext.app.bind.LinkStub(me, stub.name);
  51500. stub.graft(linkStub);
  51501. stub = linkStub;
  51502. }
  51503. stub.link(reference);
  51504. }
  51505. },
  51506. notify: function() {
  51507. var scheduler = this.getScheduler();
  51508. if (!scheduler.firing) {
  51509. scheduler.notify();
  51510. }
  51511. },
  51512. get: function(path) {
  51513. return this.getStub(path).getValue();
  51514. },
  51515. set: function(path, value) {
  51516. var me = this,
  51517. obj, stub;
  51518. me.getData();
  51519. if (value === undefined && path && path.constructor === Object) {
  51520. stub = me.getRoot();
  51521. value = path;
  51522. } else if (path && path.indexOf('.') < 0) {
  51523. obj = {};
  51524. obj[path] = value;
  51525. value = obj;
  51526. stub = me.getRoot();
  51527. } else {
  51528. stub = me.getStub(path);
  51529. }
  51530. stub.set(value);
  51531. },
  51532. privates: {
  51533. registerChild: function(child) {
  51534. var children = this.children;
  51535. if (!children) {
  51536. this.children = children = {};
  51537. }
  51538. children[child.getId()] = child;
  51539. },
  51540. unregisterChild: function(child) {
  51541. var children = this.children;
  51542. if (!this.destroying && children) {
  51543. delete children[child.getId()];
  51544. }
  51545. },
  51546. getRecord: function(type, id) {
  51547. var session = this.getSession(),
  51548. Model = type,
  51549. hasId = id !== undefined,
  51550. record;
  51551. if (session) {
  51552. if (hasId) {
  51553. record = session.getRecord(type, id);
  51554. } else {
  51555. record = session.createRecord(type);
  51556. }
  51557. } else {
  51558. if (!Model.$isClass) {
  51559. Model = this.getSchema().getEntity(Model);
  51560. if (!Model) {
  51561. Ext.raise('Invalid model name: ' + type);
  51562. }
  51563. }
  51564. if (hasId) {
  51565. record = Model.createWithId(id);
  51566. record.load();
  51567. } else {
  51568. record = new Model();
  51569. }
  51570. }
  51571. return record;
  51572. },
  51573. bindExpression: function(descriptor, callback, scope, options) {
  51574. var stub = this.getStub(descriptor);
  51575. return stub.bind(callback, scope, options);
  51576. },
  51577. applyScheduler: function(scheduler) {
  51578. if (scheduler && !scheduler.isInstance) {
  51579. if (scheduler === true) {
  51580. scheduler = {};
  51581. }
  51582. if (!('preSort' in scheduler)) {
  51583. scheduler = Ext.apply({
  51584. preSort: 'kind,-depth'
  51585. }, scheduler);
  51586. }
  51587. scheduler = new Ext.util.Scheduler(scheduler);
  51588. scheduler.$owner = this;
  51589. }
  51590. return scheduler;
  51591. },
  51592. getScheduler: function() {
  51593. var me = this,
  51594. scheduler = me._scheduler,
  51595. parent;
  51596. if (!scheduler) {
  51597. if (!(parent = me.getParent())) {
  51598. scheduler = new Ext.util.Scheduler({
  51599. preSort: 'kind,-depth'
  51600. });
  51601. scheduler.$owner = me;
  51602. } else {
  51603. scheduler = parent.getScheduler();
  51604. }
  51605. me.setScheduler(scheduler);
  51606. }
  51607. return scheduler;
  51608. },
  51609. getStub: function(bindDescr) {
  51610. var root = this.getRoot();
  51611. return bindDescr ? root.getChild(bindDescr) : root;
  51612. },
  51613. collect: function() {
  51614. var me = this,
  51615. parent = me.getParent(),
  51616. task = me.collectTask;
  51617. if (parent) {
  51618. parent.collect();
  51619. return;
  51620. }
  51621. if (!task) {
  51622. task = me.collectTask = new Ext.util.DelayedTask(me.doCollect, me);
  51623. }
  51624. if (me.collectTimeout === 0) {
  51625. me.doCollect();
  51626. } else {
  51627. task.delay(me.collectTimeout);
  51628. }
  51629. },
  51630. doCollect: function() {
  51631. var children = this.children,
  51632. key;
  51633. if (children) {
  51634. for (key in children) {
  51635. children[key].doCollect();
  51636. }
  51637. }
  51638. this.getRoot().collect();
  51639. },
  51640. invalidateChildLinks: function(name, clear) {
  51641. var children = this.children,
  51642. key;
  51643. if (children) {
  51644. for (key in children) {
  51645. children[key].getRoot().invalidateChildLink(name, clear);
  51646. }
  51647. }
  51648. },
  51649. onBindDestroy: function(binding, fromChild) {
  51650. var me = this,
  51651. parent;
  51652. if (me.destroying) {
  51653. return;
  51654. }
  51655. if (!fromChild) {
  51656. delete me.bindings[binding.id];
  51657. }
  51658. parent = me.getParent();
  51659. if (parent) {
  51660. parent.onBindDestroy(binding, true);
  51661. } else {
  51662. me.collect();
  51663. }
  51664. },
  51665. applyData: function(newData, data) {
  51666. var me = this,
  51667. linkData, parent;
  51668. me.getSession();
  51669. if (!data) {
  51670. parent = me.getParent();
  51671. me.linkData = linkData = parent ? Ext.Object.chain(parent.getData()) : {};
  51672. me.data = me._data = Ext.Object.chain(linkData);
  51673. }
  51674. if (newData && newData.constructor === Object) {
  51675. me.getRoot().set(newData, true);
  51676. }
  51677. },
  51678. applyParent: function(parent) {
  51679. if (parent) {
  51680. parent.registerChild(this);
  51681. }
  51682. return parent;
  51683. },
  51684. applyStores: function(stores) {
  51685. var me = this,
  51686. root = me.getRoot(),
  51687. key, cfg, storeBind, stub, listeners;
  51688. me.storeInfo = {};
  51689. me.listenerScopeFn = function() {
  51690. return me.getView().getInheritedConfig('defaultListenerScope');
  51691. };
  51692. for (key in stores) {
  51693. cfg = stores[key];
  51694. if (cfg.isStore) {
  51695. cfg.$wasInstance = true;
  51696. me.setupStore(cfg, key);
  51697. continue;
  51698. } else if (Ext.isString(cfg)) {
  51699. cfg = {
  51700. source: cfg
  51701. };
  51702. } else {
  51703. cfg = Ext.apply({}, cfg);
  51704. }
  51705. listeners = cfg.listeners;
  51706. delete cfg.listeners;
  51707. storeBind = me.bind(cfg, me.onStoreBind, me, {
  51708. trackStatics: true
  51709. });
  51710. if (storeBind.isStatic()) {
  51711. storeBind.destroy();
  51712. me.createStore(key, cfg, listeners);
  51713. } else {
  51714. storeBind.$storeKey = key;
  51715. storeBind.$listeners = listeners;
  51716. stub = root.createStubChild(key);
  51717. stub.setStore(storeBind);
  51718. }
  51719. }
  51720. },
  51721. onStoreBind: function(cfg, oldValue, binding) {
  51722. var info = this.storeInfo,
  51723. key = binding.$storeKey,
  51724. store = info[key],
  51725. proxy;
  51726. if (!store) {
  51727. this.createStore(key, cfg, binding.$listeners, binding);
  51728. } else {
  51729. cfg = Ext.merge({}, binding.pruneStaticKeys());
  51730. proxy = cfg.proxy;
  51731. delete cfg.type;
  51732. delete cfg.model;
  51733. delete cfg.fields;
  51734. delete cfg.proxy;
  51735. delete cfg.listeners;
  51736. if (proxy) {
  51737. delete proxy.reader;
  51738. delete proxy.writer;
  51739. store.getProxy().setConfig(proxy);
  51740. }
  51741. store.setConfig(cfg);
  51742. }
  51743. },
  51744. createStore: function(key, cfg, listeners, binding) {
  51745. var session = this.getSession(),
  51746. store;
  51747. cfg = Ext.apply({}, cfg);
  51748. if (cfg.session) {
  51749. cfg.session = session;
  51750. }
  51751. if (cfg.source) {
  51752. cfg.type = cfg.type || 'chained';
  51753. }
  51754. cfg.listeners = listeners;
  51755. cfg.resolveListenerScope = this.listenerScopeFn;
  51756. store = Ext.Factory.store(cfg);
  51757. store.$binding = binding;
  51758. this.setupStore(store, key);
  51759. },
  51760. setupStore: function(store, key) {
  51761. var me = this,
  51762. obj = {};
  51763. me.getData();
  51764. store.resolveListenerScope = me.listenerScopeFn;
  51765. me.storeInfo[key] = store;
  51766. obj[key] = store;
  51767. me.setData(obj);
  51768. },
  51769. applyFormulas: function(formulas) {
  51770. var me = this,
  51771. root = me.getRoot(),
  51772. name, stub;
  51773. me.getData();
  51774. for (name in formulas) {
  51775. if (name.indexOf('.') >= 0) {
  51776. Ext.raise('Formula names cannot contain dots: ' + name);
  51777. }
  51778. root.createStubChild(name);
  51779. stub = me.getStub(name);
  51780. stub.setFormula(formulas[name]);
  51781. }
  51782. return formulas;
  51783. },
  51784. applyLinks: function(links) {
  51785. for (var link in links) {
  51786. this.linkTo(link, links[link]);
  51787. }
  51788. },
  51789. applySchema: function(schema) {
  51790. return Ext.data.schema.Schema.get(schema);
  51791. },
  51792. applyRoot: function() {
  51793. var root = new Ext.app.bind.RootStub(this),
  51794. parent = this.getParent();
  51795. if (parent) {
  51796. root.depth = parent.getRoot().depth - 1000;
  51797. }
  51798. return root;
  51799. },
  51800. getFormulaFn: function(data) {
  51801. var me = this,
  51802. fn = me.formulaFn;
  51803. if (!fn) {
  51804. fn = me.formulaFn = function(name) {
  51805. return me.$formulaData[name];
  51806. };
  51807. }
  51808. me.$formulaData = data;
  51809. return fn;
  51810. }
  51811. }
  51812. });
  51813. Ext.define('Ext.app.domain.Controller', {
  51814. extend: Ext.app.EventDomain,
  51815. singleton: true,
  51816. type: 'controller',
  51817. prefix: 'controller.',
  51818. idMatchRe: /^\#/,
  51819. constructor: function() {
  51820. var me = this;
  51821. me.callParent();
  51822. me.monitor(Ext.app.BaseController);
  51823. },
  51824. match: function(target, selector) {
  51825. var result = false,
  51826. alias = target.alias;
  51827. if (selector === '*') {
  51828. result = true;
  51829. } else if (selector === '#') {
  51830. result = !!target.isApplication;
  51831. } else if (this.idMatchRe.test(selector)) {
  51832. result = target.getId() === selector.substring(1);
  51833. } else if (alias) {
  51834. result = Ext.Array.indexOf(alias, this.prefix + selector) > -1;
  51835. }
  51836. return result;
  51837. }
  51838. });
  51839. Ext.define('Ext.direct.Manager', {
  51840. singleton: true,
  51841. mixins: [
  51842. Ext.mixin.Observable
  51843. ],
  51844. exceptions: {
  51845. TRANSPORT: 'xhr',
  51846. PARSE: 'parse',
  51847. DATA: 'data',
  51848. LOGIN: 'login',
  51849. SERVER: 'exception'
  51850. },
  51851. providerClasses: {},
  51852. remotingMethods: {},
  51853. config: {
  51854. varName: 'Ext.REMOTING_API'
  51855. },
  51856. apiNotFoundError: 'Ext Direct API was not found at {0}',
  51857. constructor: function() {
  51858. var me = this;
  51859. me.mixins.observable.constructor.call(me);
  51860. me.transactions = new Ext.util.MixedCollection();
  51861. me.providers = new Ext.util.MixedCollection();
  51862. },
  51863. addProvider: function(provider) {
  51864. var me = this,
  51865. args = arguments,
  51866. relayers = me.relayers || (me.relayers = {}),
  51867. i, len;
  51868. if (args.length > 1) {
  51869. for (i = 0 , len = args.length; i < len; ++i) {
  51870. me.addProvider(args[i]);
  51871. }
  51872. return;
  51873. }
  51874. if (!provider.isProvider) {
  51875. provider = Ext.create('direct.' + provider.type + 'provider', provider);
  51876. }
  51877. me.providers.add(provider);
  51878. provider.on('data', me.onProviderData, me);
  51879. if (provider.relayedEvents) {
  51880. relayers[provider.id] = me.relayEvents(provider, provider.relayedEvents);
  51881. }
  51882. if (!provider.isConnected()) {
  51883. provider.connect();
  51884. }
  51885. return provider;
  51886. },
  51887. loadProvider: function(config, callback, scope) {
  51888. var me = this,
  51889. classes = me.providerClasses,
  51890. type, url, varName, provider, i, len;
  51891. if (Ext.isArray(config)) {
  51892. for (i = 0 , len = config.length; i < len; i++) {
  51893. me.loadProvider(config[i], callback, scope);
  51894. }
  51895. return;
  51896. }
  51897. type = config.type;
  51898. url = config.url;
  51899. if (classes[type] && classes[type].checkConfig(config)) {
  51900. provider = me.addProvider(config);
  51901. me.fireEventArgs('providerload', [
  51902. url,
  51903. provider
  51904. ]);
  51905. Ext.callback(callback, scope, [
  51906. url,
  51907. provider
  51908. ]);
  51909. return;
  51910. }
  51911. varName = config.varName || me.getVarName();
  51912. delete config.varName;
  51913. if (!url) {
  51914. Ext.raise("Need API discovery URL to load a Remoting provider!");
  51915. }
  51916. delete config.url;
  51917. Ext.Loader.loadScript({
  51918. url: url,
  51919. scope: me,
  51920. onLoad: function() {
  51921. this.onApiLoadSuccess({
  51922. url: url,
  51923. varName: varName,
  51924. config: config,
  51925. callback: callback,
  51926. scope: scope
  51927. });
  51928. },
  51929. onError: function() {
  51930. this.onApiLoadFailure({
  51931. url: url,
  51932. callback: callback,
  51933. scope: scope
  51934. });
  51935. }
  51936. });
  51937. },
  51938. getProvider: function(id) {
  51939. return id.isProvider ? id : this.providers.get(id);
  51940. },
  51941. removeProvider: function(provider) {
  51942. var me = this,
  51943. providers = me.providers,
  51944. relayers = me.relayers,
  51945. id;
  51946. provider = provider.isProvider ? provider : providers.get(provider);
  51947. if (provider) {
  51948. provider.un('data', me.onProviderData, me);
  51949. id = provider.id;
  51950. if (relayers[id]) {
  51951. relayers[id].destroy();
  51952. delete relayers[id];
  51953. }
  51954. providers.remove(provider);
  51955. return provider;
  51956. }
  51957. return null;
  51958. },
  51959. addTransaction: function(transaction) {
  51960. this.transactions.add(transaction);
  51961. return transaction;
  51962. },
  51963. removeTransaction: function(transaction) {
  51964. var me = this;
  51965. transaction = me.getTransaction(transaction);
  51966. me.transactions.remove(transaction);
  51967. return transaction;
  51968. },
  51969. getTransaction: function(transaction) {
  51970. return typeof transaction === 'object' ? transaction : this.transactions.get(transaction);
  51971. },
  51972. onProviderData: function(provider, event) {
  51973. var me = this,
  51974. i, len;
  51975. if (Ext.isArray(event)) {
  51976. for (i = 0 , len = event.length; i < len; ++i) {
  51977. me.onProviderData(provider, event[i]);
  51978. }
  51979. return;
  51980. }
  51981. if (event.name && event.name !== 'event' && event.name !== 'exception') {
  51982. me.fireEvent(event.name, event);
  51983. } else if (event.status === false) {
  51984. me.fireEvent('exception', event);
  51985. }
  51986. me.fireEvent('event', event, provider);
  51987. },
  51988. parseMethod: function(fn) {
  51989. var current = Ext.global,
  51990. i = 0,
  51991. resolved, parts, len;
  51992. if (Ext.isFunction(fn)) {
  51993. resolved = fn;
  51994. } else if (Ext.isString(fn)) {
  51995. resolved = this.remotingMethods[fn];
  51996. if (!resolved) {
  51997. parts = fn.split('.');
  51998. len = parts.length;
  51999. while (current && i < len) {
  52000. current = current[parts[i]];
  52001. ++i;
  52002. }
  52003. resolved = Ext.isFunction(current) ? current : null;
  52004. }
  52005. }
  52006. return resolved || null;
  52007. },
  52008. resolveApi: function(api, caller) {
  52009. var prefix, action, method, fullName, fn;
  52010. prefix = api && api.prefix;
  52011. if (prefix && prefix.substr(prefix.length - 1) !== '.') {
  52012. prefix += '.';
  52013. }
  52014. for (action in api) {
  52015. method = api[action];
  52016. if (action !== 'prefix' && typeof method !== 'function') {
  52017. fullName = (prefix || '') + method;
  52018. fn = this.parseMethod(fullName);
  52019. if (typeof fn === 'function') {
  52020. api[action] = fn;
  52021. } else
  52022. {
  52023. Ext.raise("Cannot resolve Direct API method '" + fullName + "' for " + action + " action in " + caller.$className + " instance with id: " + (caller.id != null ? caller.id : 'unknown'));
  52024. }
  52025. }
  52026. }
  52027. return api;
  52028. },
  52029. privates: {
  52030. addProviderClass: function(type, cls) {
  52031. this.providerClasses[type] = cls;
  52032. },
  52033. onApiLoadSuccess: function(options) {
  52034. var me = this,
  52035. url = options.url,
  52036. varName = options.varName,
  52037. api, provider, error;
  52038. try {
  52039. api = Ext.apply(options.config, eval(varName));
  52040. provider = me.addProvider(api);
  52041. } catch (e) {
  52042. error = e + '';
  52043. }
  52044. if (error) {
  52045. me.fireEventArgs('providerloaderror', [
  52046. url,
  52047. error
  52048. ]);
  52049. Ext.callback(options.callback, options.scope, [
  52050. url,
  52051. error
  52052. ]);
  52053. } else {
  52054. me.fireEventArgs('providerload', [
  52055. url,
  52056. provider
  52057. ]);
  52058. Ext.callback(options.callback, options.scope, [
  52059. url,
  52060. provider
  52061. ]);
  52062. }
  52063. },
  52064. onApiLoadFailure: function(options) {
  52065. var url = options.url,
  52066. error;
  52067. error = Ext.String.format(this.apiNotFoundError, url);
  52068. this.fireEventArgs('providerloaderror', [
  52069. url,
  52070. error
  52071. ]);
  52072. Ext.callback(options.callback, options.scope, [
  52073. url,
  52074. error
  52075. ]);
  52076. },
  52077. registerMethod: function(name, method) {
  52078. this.remotingMethods[name] = method;
  52079. },
  52080. clearAllMethods: function() {
  52081. this.remotingMethods = {};
  52082. }
  52083. }
  52084. }, function() {
  52085. Ext.Direct = Ext.direct.Manager;
  52086. });
  52087. Ext.define('Ext.direct.Provider', {
  52088. alias: 'direct.provider',
  52089. mixins: [
  52090. Ext.mixin.Observable
  52091. ],
  52092. isProvider: true,
  52093. $configPrefixed: false,
  52094. $configStrict: false,
  52095. config: {
  52096. headers: undefined
  52097. },
  52098. subscribers: 0,
  52099. constructor: function(config) {
  52100. var me = this;
  52101. me.mixins.observable.constructor.call(me, config);
  52102. me.requests = {};
  52103. Ext.applyIf(me, {
  52104. id: Ext.id(null, 'provider-')
  52105. });
  52106. },
  52107. destroy: function() {
  52108. var me = this;
  52109. me.disconnect(true);
  52110. me.callParent();
  52111. },
  52112. isConnected: function() {
  52113. return this.subscribers > 0;
  52114. },
  52115. connect: function() {
  52116. var me = this;
  52117. if (me.subscribers === 0) {
  52118. me.doConnect();
  52119. me.fireEventArgs('connect', [
  52120. me
  52121. ]);
  52122. }
  52123. me.subscribers++;
  52124. },
  52125. doConnect: Ext.emptyFn,
  52126. disconnect: function(
  52127. force) {
  52128. var me = this;
  52129. if (me.subscribers > 0 || force) {
  52130. if (force) {
  52131. me.subscribers = 0;
  52132. } else {
  52133. me.subscribers--;
  52134. }
  52135. if (me.subscribers === 0) {
  52136. me.doDisconnect();
  52137. me.fireEventArgs('disconnect', [
  52138. me
  52139. ]);
  52140. }
  52141. }
  52142. },
  52143. doDisconnect: function() {
  52144. var requests = this.requests,
  52145. request, id;
  52146. for (id in requests) {
  52147. request = requests[id];
  52148. request.abort();
  52149. }
  52150. this.requests = {};
  52151. },
  52152. sendAjaxRequest: function(params) {
  52153. var request = Ext.Ajax.request(params);
  52154. if (request && request.id) {
  52155. this.requests[request.id] = request;
  52156. }
  52157. return request;
  52158. },
  52159. onData: function(options, success, response) {
  52160. if (response && response.request) {
  52161. delete this.requests[response.request.id];
  52162. }
  52163. },
  52164. inheritableStatics: {
  52165. checkConfig: Ext.returnFalse
  52166. },
  52167. onClassExtended: function(cls, data, hooks) {
  52168. if (data.type) {
  52169. Ext.direct.Manager.addProviderClass(data.type, cls);
  52170. }
  52171. }
  52172. });
  52173. Ext.define('Ext.app.domain.Direct', {
  52174. extend: Ext.app.EventDomain,
  52175. singleton: true,
  52176. type: 'direct',
  52177. idProperty: 'id',
  52178. constructor: function() {
  52179. var me = this;
  52180. me.callParent();
  52181. me.monitor(Ext.direct.Provider);
  52182. }
  52183. });
  52184. Ext.define('Ext.data.PageMap', {
  52185. extend: Ext.util.LruCache,
  52186. config: {
  52187. store: null,
  52188. pageSize: 0,
  52189. rootProperty: ''
  52190. },
  52191. clear: function(initial) {
  52192. var me = this;
  52193. me.pageMapGeneration = (me.pageMapGeneration || 0) + 1;
  52194. me.indexMap = {};
  52195. me.callParent([
  52196. initial
  52197. ]);
  52198. },
  52199. updatePageSize: function(value, oldValue) {
  52200. if (oldValue != null) {
  52201. throw "pageMap page size may not be changed";
  52202. }
  52203. },
  52204. forEach: function(fn, scope) {
  52205. var me = this,
  52206. pageNumbers = Ext.Object.getKeys(me.map),
  52207. pageCount = pageNumbers.length,
  52208. pageSize = me.getPageSize(),
  52209. i, j, pageNumber, page, len;
  52210. for (i = 0; i < pageCount; i++) {
  52211. pageNumbers[i] = +pageNumbers[i];
  52212. }
  52213. Ext.Array.sort(pageNumbers, Ext.Array.numericSortFn);
  52214. scope = scope || me;
  52215. for (i = 0; i < pageCount; i++) {
  52216. pageNumber = pageNumbers[i];
  52217. page = me.getPage(pageNumber);
  52218. len = page.length;
  52219. for (j = 0; j < len; j++) {
  52220. if (fn.call(scope, page[j], (pageNumber - 1) * pageSize + j) === false) {
  52221. return;
  52222. }
  52223. }
  52224. }
  52225. },
  52226. findBy: function(fn, scope) {
  52227. var me = this,
  52228. result = null;
  52229. scope = scope || me;
  52230. me.forEach(function(rec, index) {
  52231. if (fn.call(scope, rec, index)) {
  52232. result = rec;
  52233. return false;
  52234. }
  52235. });
  52236. return result;
  52237. },
  52238. findIndexBy: function(fn, scope) {
  52239. var me = this,
  52240. result = -1;
  52241. scope = scope || me;
  52242. me.forEach(function(rec, index) {
  52243. if (fn.call(scope, rec)) {
  52244. result = index;
  52245. return false;
  52246. }
  52247. });
  52248. return result;
  52249. },
  52250. find: function(property, value, start, startsWith, endsWith, ignoreCase) {
  52251. if (Ext.isEmpty(value, false)) {
  52252. return null;
  52253. }
  52254. var regex = Ext.String.createRegex(value, startsWith, endsWith, ignoreCase),
  52255. root = this.getRootProperty();
  52256. return this.findBy(function(item) {
  52257. return item && regex.test((root ? item[root] : item)[property]);
  52258. }, null, start);
  52259. },
  52260. findIndex: function(property, value, start, startsWith, endsWith, ignoreCase) {
  52261. if (Ext.isEmpty(value, false)) {
  52262. return null;
  52263. }
  52264. var regex = Ext.String.createRegex(value, startsWith, endsWith, ignoreCase),
  52265. root = this.getRootProperty();
  52266. return this.findIndexBy(function(item) {
  52267. return item && regex.test((root ? item[root] : item)[property]);
  52268. }, null, start);
  52269. },
  52270. getPageFromRecordIndex: function(index) {
  52271. return Math.floor(index / this.getPageSize()) + 1;
  52272. },
  52273. addAll: function(records) {
  52274. if (this.getCount()) {
  52275. Ext.raise('Cannot addAll to a non-empty PageMap');
  52276. }
  52277. this.addPage(1, records);
  52278. },
  52279. addPage: function(pageNumber, records) {
  52280. var me = this,
  52281. pageSize = me.getPageSize(),
  52282. lastPage = pageNumber + Math.floor((records.length - 1) / pageSize),
  52283. storeIndex = (pageNumber - 1) * pageSize,
  52284. indexMap = me.indexMap,
  52285. page, i, len, startIdx;
  52286. for (startIdx = 0; pageNumber <= lastPage; pageNumber++ , startIdx += pageSize) {
  52287. page = Ext.Array.slice(records, startIdx, startIdx + pageSize);
  52288. for (i = 0 , len = page.length; i < len; i++) {
  52289. indexMap[page[i].internalId] = storeIndex++;
  52290. }
  52291. me.add(pageNumber, page);
  52292. me.fireEvent('pageadd', me, pageNumber, page);
  52293. }
  52294. },
  52295. getCount: function() {
  52296. var result = this.callParent();
  52297. if (result) {
  52298. result = (result - 1) * this.getPageSize() + this.last.value.length;
  52299. }
  52300. return result;
  52301. },
  52302. getByInternalId: function(internalId) {
  52303. var index = this.indexMap[internalId];
  52304. if (index != null) {
  52305. return this.getAt(index);
  52306. }
  52307. },
  52308. indexOf: function(record) {
  52309. var result = -1;
  52310. if (record) {
  52311. result = this.indexMap[record.internalId];
  52312. if (result == null) {
  52313. result = -1;
  52314. }
  52315. }
  52316. return result;
  52317. },
  52318. insert: function() {
  52319. Ext.raise('insert operation not suppported into buffered Store');
  52320. },
  52321. remove: function() {
  52322. Ext.raise('remove operation not suppported from buffered Store');
  52323. },
  52324. removeAt: function() {
  52325. Ext.raise('removeAt operation not suppported from buffered Store');
  52326. },
  52327. removeAtKey: function(page) {
  52328. var me = this,
  52329. thePage = me.getPage(page),
  52330. len, i, result;
  52331. if (thePage) {
  52332. if (me.fireEvent('beforepageremove', me, page, thePage) !== false) {
  52333. len = thePage.length;
  52334. for (i = 0; i < len; i++) {
  52335. delete me.indexMap[thePage[i].internalId];
  52336. }
  52337. result = me.callParent(arguments);
  52338. me.fireEvent('pageremove', me, page, thePage);
  52339. thePage.length = 0;
  52340. }
  52341. }
  52342. return result;
  52343. },
  52344. getPage: function(pageNumber) {
  52345. return this.get(pageNumber);
  52346. },
  52347. hasRange: function(start, end) {
  52348. var me = this,
  52349. pageNumber = me.getPageFromRecordIndex(start),
  52350. endPageNumber = me.getPageFromRecordIndex(end);
  52351. for (; pageNumber <= endPageNumber; pageNumber++) {
  52352. if (!me.hasPage(pageNumber)) {
  52353. return false;
  52354. }
  52355. }
  52356. return (endPageNumber - 1) * me._pageSize + me.getPage(endPageNumber).length > end;
  52357. },
  52358. hasPage: function(pageNumber) {
  52359. return !!this.get(pageNumber);
  52360. },
  52361. peekPage: function(pageNumber) {
  52362. return this.map[pageNumber];
  52363. },
  52364. getAt: function(index) {
  52365. return this.getRange(index, index + 1)[0];
  52366. },
  52367. getRange: function(start, end) {
  52368. if (end) {
  52369. end--;
  52370. }
  52371. if (!this.hasRange(start, end)) {
  52372. Ext.raise('PageMap asked for range which it does not have');
  52373. }
  52374. var me = this,
  52375. Array = Ext.Array,
  52376. pageSize = me.getPageSize(),
  52377. startPageNumber = me.getPageFromRecordIndex(start),
  52378. endPageNumber = me.getPageFromRecordIndex(end),
  52379. dataStart = (startPageNumber - 1) * pageSize,
  52380. dataEnd = (endPageNumber * pageSize) - 1,
  52381. pageNumber = startPageNumber,
  52382. result = [],
  52383. sliceBegin, sliceEnd, doSlice;
  52384. for (; pageNumber <= endPageNumber; pageNumber++) {
  52385. if (pageNumber === startPageNumber) {
  52386. sliceBegin = start - dataStart;
  52387. doSlice = sliceBegin > 0;
  52388. } else {
  52389. sliceBegin = 0;
  52390. doSlice = false;
  52391. }
  52392. if (pageNumber === endPageNumber) {
  52393. sliceEnd = pageSize - (dataEnd - end);
  52394. doSlice = doSlice || sliceEnd < pageSize;
  52395. }
  52396. if (doSlice) {
  52397. Array.push(result, Array.slice(me.getPage(pageNumber), sliceBegin, sliceEnd));
  52398. } else {
  52399. Array.push(result, me.getPage(pageNumber));
  52400. }
  52401. }
  52402. return result;
  52403. }
  52404. });
  52405. Ext.define('Ext.data.BufferedStore', {
  52406. extend: Ext.data.ProxyStore,
  52407. alias: 'store.buffered',
  52408. isBufferedStore: true,
  52409. buffered: true,
  52410. config: {
  52411. data: 0,
  52412. pageSize: 25,
  52413. remoteSort: true,
  52414. remoteFilter: true,
  52415. sortOnLoad: false,
  52416. purgePageCount: 5,
  52417. trailingBufferZone: 25,
  52418. leadingBufferZone: 200,
  52419. defaultViewSize: 100,
  52420. viewSize: 0,
  52421. trackRemoved: false
  52422. },
  52423. applyData: function(data) {
  52424. var dataCollection = this.data || (this.data = this.createDataCollection());
  52425. if (data && data !== true) {
  52426. Ext.raise('Cannot load a buffered store with local data - the store is a map of remote data');
  52427. }
  52428. return dataCollection;
  52429. },
  52430. applyProxy: function(proxy) {
  52431. proxy = this.callParent([
  52432. proxy
  52433. ]);
  52434. if (proxy && proxy.setEnablePaging) {
  52435. proxy.setEnablePaging(true);
  52436. }
  52437. return proxy;
  52438. },
  52439. applyAutoSort: function() {},
  52440. createFiltersCollection: function() {
  52441. return new Ext.util.FilterCollection();
  52442. },
  52443. createSortersCollection: function() {
  52444. return new Ext.util.SorterCollection();
  52445. },
  52446. updateRemoteFilter: function(remoteFilter, oldRemoteFilter) {
  52447. if (remoteFilter === false) {
  52448. Ext.raise('Buffered stores are always remotely filtered.');
  52449. }
  52450. this.callParent([
  52451. remoteFilter,
  52452. oldRemoteFilter
  52453. ]);
  52454. },
  52455. updateRemoteSort: function(remoteSort, oldRemoteSort) {
  52456. if (remoteSort === false) {
  52457. Ext.raise('Buffered stores are always remotely sorted.');
  52458. }
  52459. this.callParent([
  52460. remoteSort,
  52461. oldRemoteSort
  52462. ]);
  52463. },
  52464. updateTrackRemoved: function(value) {
  52465. if (value !== false) {
  52466. Ext.raise('Cannot use trackRemoved with a buffered store.');
  52467. }
  52468. this.callParent(arguments);
  52469. },
  52470. updateGroupField: function(field) {
  52471. this.group(field);
  52472. },
  52473. getGrouper: function() {
  52474. return this.grouper;
  52475. },
  52476. isGrouped: function() {
  52477. return !!this.grouper;
  52478. },
  52479. createDataCollection: function() {
  52480. var me = this,
  52481. result = new Ext.data.PageMap({
  52482. store: me,
  52483. rootProperty: 'data',
  52484. pageSize: me.getPageSize(),
  52485. maxSize: me.getPurgePageCount(),
  52486. listeners: {
  52487. clear: me.onPageMapClear,
  52488. scope: me
  52489. }
  52490. });
  52491. me.relayEvents(result, [
  52492. 'beforepageremove',
  52493. 'pageadd',
  52494. 'pageremove'
  52495. ]);
  52496. me.pageRequests = {};
  52497. return result;
  52498. },
  52499. add: function() {
  52500. Ext.raise('add method may not be called on a buffered store - the store is a map of remote data');
  52501. },
  52502. insert: function() {
  52503. Ext.raise('insert method may not be called on a buffered store - the store is a map of remote data');
  52504. },
  52505. removeAll: function(silent) {
  52506. var me = this,
  52507. data = me.getData();
  52508. if (data) {
  52509. if (silent) {
  52510. me.suspendEvent('clear');
  52511. }
  52512. data.clear();
  52513. if (silent) {
  52514. me.resumeEvent('clear');
  52515. }
  52516. }
  52517. },
  52518. flushLoad: function() {
  52519. var me = this,
  52520. options = me.pendingLoadOptions;
  52521. me.clearLoadTask();
  52522. if (!options) {
  52523. return;
  52524. }
  52525. if (!options.preserveOnFlush) {
  52526. me.getData().clear();
  52527. options.page = 1;
  52528. options.start = 0;
  52529. options.limit = me.getViewSize() || me.getDefaultViewSize();
  52530. }
  52531. options.loadCallback = options.callback;
  52532. options.callback = null;
  52533. return me.loadToPrefetch(options);
  52534. },
  52535. reload: function(options) {
  52536. var me = this,
  52537. data = me.getData(),
  52538. lastTotal = Number.MAX_VALUE,
  52539. startIdx, endIdx, startPage, endPage, i, waitForReload, bufferZone, records;
  52540. if (!options) {
  52541. options = {};
  52542. }
  52543. if (me.loading || me.fireEvent('beforeload', me, options) === false) {
  52544. return;
  52545. }
  52546. waitForReload = function() {
  52547. var newCount = me.totalCount,
  52548. oldRequestSize = endIdx - startIdx;
  52549. if (endIdx >= newCount) {
  52550. endIdx = newCount - 1;
  52551. startIdx = Math.max(endIdx - oldRequestSize, 0);
  52552. }
  52553. if (me.rangeCached(startIdx, endIdx, false)) {
  52554. me.loadCount = (me.loadCount || 0) + 1;
  52555. me.loading = false;
  52556. data.un('pageadd', waitForReload);
  52557. records = data.getRange(startIdx, endIdx);
  52558. me.fireEvent('refresh', me);
  52559. me.fireEvent('load', me, records, true);
  52560. }
  52561. };
  52562. bufferZone = Math.ceil((me.getLeadingBufferZone() + me.getTrailingBufferZone()) / 2);
  52563. if (me.lastRequestStart && me.preserveScrollOnReload) {
  52564. startIdx = me.lastRequestStart;
  52565. endIdx = me.lastRequestEnd;
  52566. lastTotal = me.getTotalCount();
  52567. } else
  52568. {
  52569. startIdx = options.start || 0;
  52570. endIdx = startIdx + (options.count || me.getPageSize()) - 1;
  52571. }
  52572. data.clear(true);
  52573. delete me.totalCount;
  52574. startIdx = Math.max(startIdx - bufferZone, 0);
  52575. endIdx = Math.min(endIdx + bufferZone, lastTotal);
  52576. startIdx = startIdx === 0 ? 0 : startIdx - 1;
  52577. endIdx = endIdx === lastTotal ? endIdx : endIdx + 1;
  52578. startPage = me.getPageFromRecordIndex(startIdx);
  52579. endPage = me.getPageFromRecordIndex(endIdx);
  52580. me.loading = true;
  52581. options.waitForReload = waitForReload;
  52582. data.on('pageadd', waitForReload);
  52583. for (i = startPage; i <= endPage; i++) {
  52584. me.prefetchPage(i, options);
  52585. }
  52586. },
  52587. filter: function() {
  52588. if (!this.getRemoteFilter()) {
  52589. Ext.raise('Local filtering may not be used on a buffered store - the store is a map of remote data');
  52590. }
  52591. this.callParent(arguments);
  52592. },
  52593. filterBy: function(fn, scope) {
  52594. Ext.raise('Local filtering may not be used on a buffered store - the store is a map of remote data');
  52595. },
  52596. loadData: function(data, append) {
  52597. Ext.raise('LoadData may not be used on a buffered store - the store is a map of remote data');
  52598. },
  52599. loadPage: function(page, options) {
  52600. var me = this;
  52601. options = options || {};
  52602. options.page = me.currentPage = page;
  52603. options.start = (page - 1) * me.getPageSize();
  52604. options.limit = me.getViewSize() || me.getDefaultViewSize();
  52605. options.loadCallback = options.callback;
  52606. options.callback = null;
  52607. options.preserveOnFlush = true;
  52608. return me.load(options);
  52609. },
  52610. clearData: function(isLoad) {
  52611. var me = this,
  52612. data = me.getData();
  52613. if (data) {
  52614. data.clear();
  52615. }
  52616. },
  52617. getCount: function() {
  52618. return this.totalCount || 0;
  52619. },
  52620. getRange: function(start, end, options) {
  52621. var me = this,
  52622. maxIndex = me.totalCount - 1,
  52623. lastRequestStart = me.lastRequestStart,
  52624. result = [],
  52625. data = me.getData(),
  52626. pageAddHandler, requiredStart, requiredEnd, requiredStartPage, requiredEndPage;
  52627. options = Ext.apply({
  52628. prefetchStart: start,
  52629. prefetchEnd: end
  52630. }, options);
  52631. end = (end >= me.totalCount) ? maxIndex : end;
  52632. if (options.forRender !== false) {
  52633. requiredStart = start === 0 ? 0 : start - 1;
  52634. requiredEnd = end === maxIndex ? end : end + 1;
  52635. } else {
  52636. requiredStart = start;
  52637. requiredEnd = end;
  52638. }
  52639. me.lastRequestStart = start;
  52640. me.lastRequestEnd = end;
  52641. if (me.rangeCached(start, end, options.forRender)) {
  52642. me.onRangeAvailable(options);
  52643. result = data.getRange(start, end + 1);
  52644. } else
  52645. {
  52646. me.fireEvent('cachemiss', me, start, end);
  52647. requiredStartPage = me.getPageFromRecordIndex(requiredStart);
  52648. requiredEndPage = me.getPageFromRecordIndex(requiredEnd);
  52649. pageAddHandler = function(pageMap, page, records) {
  52650. if (page >= requiredStartPage && page <= requiredEndPage && me.rangeCached(start, end)) {
  52651. me.fireEvent('cachefilled', me, start, end);
  52652. data.un('pageadd', pageAddHandler);
  52653. me.onRangeAvailable(options);
  52654. }
  52655. };
  52656. data.on('pageadd', pageAddHandler);
  52657. me.prefetchRange(start, end);
  52658. }
  52659. me.primeCache(start, end, start < lastRequestStart ? -1 : 1);
  52660. return result;
  52661. },
  52662. getById: function(id) {
  52663. var result = this.data.findBy(function(record) {
  52664. return record.getId() === id;
  52665. });
  52666. return result;
  52667. },
  52668. getAt: function(index) {
  52669. var data = this.getData();
  52670. if (data.hasRange(index, index)) {
  52671. return data.getAt(index);
  52672. }
  52673. },
  52674. getByInternalId: function(internalId) {
  52675. return this.data.getByInternalId(internalId);
  52676. },
  52677. contains: function(record) {
  52678. return this.indexOf(record) > -1;
  52679. },
  52680. indexOf: function(record) {
  52681. return this.getData().indexOf(record);
  52682. },
  52683. indexOfId: function(id) {
  52684. return this.indexOf(this.getById(id));
  52685. },
  52686. group: function(grouper, direction) {
  52687. var me = this,
  52688. oldGrouper;
  52689. if (grouper && typeof grouper === 'string') {
  52690. oldGrouper = me.grouper;
  52691. if (oldGrouper && direction !== undefined) {
  52692. oldGrouper.setDirection(direction);
  52693. } else {
  52694. me.grouper = new Ext.util.Grouper({
  52695. property: grouper,
  52696. direction: direction || 'ASC',
  52697. root: 'data'
  52698. });
  52699. }
  52700. } else {
  52701. me.grouper = grouper ? me.getSorters().decodeSorter(grouper, Ext.util.Grouper) : null;
  52702. }
  52703. me.getData().clear();
  52704. me.loadPage(1, {
  52705. callback: function() {
  52706. me.fireEvent('groupchange', me, me.getGrouper());
  52707. }
  52708. });
  52709. },
  52710. getPageFromRecordIndex: function(index) {
  52711. return Math.floor(index / this.getPageSize()) + 1;
  52712. },
  52713. calculatePageCacheSize: function(rangeSizeRequested) {
  52714. var me = this,
  52715. purgePageCount = me.getPurgePageCount();
  52716. return purgePageCount ? Math.max(me.getData().getMaxSize() || 0, Math.ceil((rangeSizeRequested + me.getTrailingBufferZone() + me.getLeadingBufferZone()) / me.getPageSize()) * 2 + purgePageCount) : 0;
  52717. },
  52718. loadToPrefetch: function(options) {
  52719. var me = this,
  52720. prefetchOptions = options,
  52721. i, records, dataSetSize,
  52722. startIdx = options.start,
  52723. endIdx = options.start + options.limit - 1,
  52724. rangeSizeRequested = (me.getViewSize() || options.limit),
  52725. loadEndIdx = Math.min(endIdx, options.start + rangeSizeRequested - 1),
  52726. startPage = me.getPageFromRecordIndex(Math.max(startIdx - me.getTrailingBufferZone(), 0)),
  52727. endPage = me.getPageFromRecordIndex(endIdx + me.getLeadingBufferZone()),
  52728. data = me.getData(),
  52729. callbackFn = function() {
  52730. records = records || [];
  52731. if (options.loadCallback) {
  52732. options.loadCallback.call(options.scope || me, records, operation, true);
  52733. }
  52734. if (options.callback) {
  52735. options.callback.call(options.scope || me, records, startIdx || 0, endIdx || 0, options);
  52736. }
  52737. },
  52738. fireEventsFn = function() {
  52739. me.loadCount = (me.loadCount || 0) + 1;
  52740. me.fireEvent('datachanged', me);
  52741. me.fireEvent('refresh', me);
  52742. me.fireEvent('load', me, records, true);
  52743. },
  52744. waitForRequestedRange = function() {
  52745. if (me.rangeCached(startIdx, loadEndIdx)) {
  52746. me.loading = false;
  52747. records = data.getRange(startIdx, loadEndIdx + 1);
  52748. data.un('pageadd', waitForRequestedRange);
  52749. if (me.hasListeners.guaranteedrange) {
  52750. me.guaranteeRange(startIdx, loadEndIdx, options.callback, options.scope);
  52751. }
  52752. callbackFn();
  52753. fireEventsFn();
  52754. }
  52755. },
  52756. operation;
  52757. if (isNaN(me.pageSize) || !me.pageSize) {
  52758. Ext.raise('Buffered store configured without a pageSize', me);
  52759. }
  52760. data.setMaxSize(me.calculatePageCacheSize(rangeSizeRequested));
  52761. if (me.fireEvent('beforeload', me, options) !== false) {
  52762. delete me.totalCount;
  52763. me.loading = true;
  52764. if (options.callback) {
  52765. prefetchOptions = Ext.apply({}, options);
  52766. delete prefetchOptions.callback;
  52767. }
  52768. me.on('prefetch', function(store, records, successful, op) {
  52769. operation = op;
  52770. if (successful) {
  52771. if ((dataSetSize = me.getTotalCount())) {
  52772. data.on('pageadd', waitForRequestedRange);
  52773. loadEndIdx = Math.min(loadEndIdx, dataSetSize - 1);
  52774. endPage = me.getPageFromRecordIndex(Math.min(loadEndIdx + me.getLeadingBufferZone(), dataSetSize - 1));
  52775. for (i = startPage + 1; i <= endPage; ++i) {
  52776. me.prefetchPage(i, prefetchOptions);
  52777. }
  52778. } else {
  52779. callbackFn();
  52780. fireEventsFn();
  52781. }
  52782. } else
  52783. {
  52784. me.loading = false;
  52785. callbackFn();
  52786. me.fireEvent('load', me, records, false);
  52787. }
  52788. }, null, {
  52789. single: true
  52790. });
  52791. me.prefetchPage(startPage, prefetchOptions);
  52792. }
  52793. },
  52794. prefetch: function(options) {
  52795. var me = this,
  52796. pageSize = me.getPageSize(),
  52797. data = me.getData(),
  52798. operation, existingPageRequest;
  52799. if (pageSize) {
  52800. if (me.lastPageSize && pageSize != me.lastPageSize) {
  52801. Ext.raise("pageSize cannot be dynamically altered");
  52802. }
  52803. if (!data.getPageSize()) {
  52804. data.setPageSize(pageSize);
  52805. }
  52806. } else
  52807. {
  52808. me.pageSize = data.setPageSize(pageSize = options.limit);
  52809. }
  52810. me.lastPageSize = pageSize;
  52811. if (!options.page) {
  52812. options.page = me.getPageFromRecordIndex(options.start);
  52813. options.start = (options.page - 1) * pageSize;
  52814. options.limit = Math.ceil(options.limit / pageSize) * pageSize;
  52815. }
  52816. existingPageRequest = me.pageRequests[options.page];
  52817. if (!existingPageRequest || existingPageRequest.getOperation().pageMapGeneration !== data.pageMapGeneration) {
  52818. options = Ext.apply({
  52819. action: 'read',
  52820. filters: me.getFilters().items,
  52821. sorters: me.getSorters().items,
  52822. grouper: me.getGrouper(),
  52823. internalCallback: me.onProxyPrefetch,
  52824. internalScope: me
  52825. }, options);
  52826. operation = me.createOperation('read', options);
  52827. operation.pageMapGeneration = data.pageMapGeneration;
  52828. if (me.fireEvent('beforeprefetch', me, operation) !== false) {
  52829. me.pageRequests[options.page] = operation.execute();
  52830. if (me.getProxy().isSynchronous) {
  52831. delete me.pageRequests[options.page];
  52832. }
  52833. }
  52834. }
  52835. return me;
  52836. },
  52837. onPageMapClear: function() {
  52838. var me = this,
  52839. loadingFlag = me.wasLoading,
  52840. reqs = me.pageRequests,
  52841. data = me.getData(),
  52842. page;
  52843. data.clearListeners();
  52844. data.on('clear', me.onPageMapClear, me);
  52845. me.relayEvents(data, [
  52846. 'beforepageremove',
  52847. 'pageadd',
  52848. 'pageremove'
  52849. ]);
  52850. me.loading = true;
  52851. me.totalCount = 0;
  52852. for (page in reqs) {
  52853. if (reqs.hasOwnProperty(page)) {
  52854. reqs[page].getOperation().abort();
  52855. }
  52856. }
  52857. me.fireEvent('clear', me);
  52858. me.loading = loadingFlag;
  52859. },
  52860. prefetchPage: function(page, options) {
  52861. var me = this,
  52862. pageSize = me.getPageSize(),
  52863. start = (page - 1) * pageSize,
  52864. total = me.totalCount;
  52865. if (total !== undefined && me.data.getCount() === total) {
  52866. return;
  52867. }
  52868. me.prefetch(Ext.applyIf({
  52869. page: page,
  52870. start: start,
  52871. limit: pageSize
  52872. }, options));
  52873. },
  52874. onProxyPrefetch: function(operation) {
  52875. if (this.destroying || this.destroyed) {
  52876. return;
  52877. }
  52878. var me = this,
  52879. resultSet = operation.getResultSet(),
  52880. records = operation.getRecords(),
  52881. successful = operation.wasSuccessful(),
  52882. page = operation.getPage(),
  52883. waitForReload = operation.waitForReload,
  52884. oldTotal = me.totalCount,
  52885. requests = me.pageRequests,
  52886. key, op;
  52887. if (operation.pageMapGeneration === me.getData().pageMapGeneration) {
  52888. if (resultSet) {
  52889. me.totalCount = resultSet.getTotal();
  52890. if (me.totalCount !== oldTotal) {
  52891. me.fireEvent('totalcountchange', me.totalCount);
  52892. }
  52893. }
  52894. if (page !== undefined) {
  52895. delete me.pageRequests[page];
  52896. }
  52897. me.loading = false;
  52898. me.fireEvent('prefetch', me, records, successful, operation);
  52899. if (successful) {
  52900. if (me.totalCount === 0) {
  52901. if (waitForReload) {
  52902. for (key in requests) {
  52903. op = requests[key].getOperation();
  52904. if (op.waitForReload === waitForReload) {
  52905. delete op.waitForReload;
  52906. }
  52907. }
  52908. me.getData().un('pageadd', waitForReload);
  52909. me.fireEvent('refresh', me);
  52910. me.fireEvent('load', me, [], true);
  52911. }
  52912. } else {
  52913. me.cachePage(records, operation.getPage());
  52914. }
  52915. }
  52916. Ext.callback(operation.getCallback(), operation.getScope() || me, [
  52917. records,
  52918. operation,
  52919. successful
  52920. ]);
  52921. }
  52922. },
  52923. cachePage: function(records, page) {
  52924. var me = this,
  52925. len = records.length,
  52926. i;
  52927. if (!Ext.isDefined(me.totalCount)) {
  52928. me.totalCount = records.length;
  52929. me.fireEvent('totalcountchange', me.totalCount);
  52930. }
  52931. for (i = 0; i < len; i++) {
  52932. records[i].join(me);
  52933. }
  52934. me.getData().addPage(page, records);
  52935. },
  52936. rangeCached: function(start, end, forRender) {
  52937. var requiredStart = start,
  52938. requiredEnd = end;
  52939. if (forRender !== false) {
  52940. requiredStart = start === 0 ? 0 : start - 1 , requiredEnd = end === this.totalCount - 1 ? end : end + 1;
  52941. }
  52942. return this.getData().hasRange(requiredStart, requiredEnd);
  52943. },
  52944. pageCached: function(page) {
  52945. return this.getData().hasPage(page);
  52946. },
  52947. pagePending: function(page) {
  52948. return !!this.pageRequests[page];
  52949. },
  52950. rangeSatisfied: function(start, end) {
  52951. return this.rangeCached(start, end);
  52952. },
  52953. onRangeAvailable: function(options) {
  52954. var me = this,
  52955. totalCount = me.getTotalCount(),
  52956. start = options.prefetchStart,
  52957. end = (options.prefetchEnd > totalCount - 1) ? totalCount - 1 : options.prefetchEnd,
  52958. range;
  52959. end = Math.max(0, end);
  52960. if (start > end) {
  52961. Ext.log({
  52962. level: 'warn',
  52963. msg: 'Start (' + start + ') was greater than end (' + end + ') for the range of records requested (' + start + '-' + options.prefetchEnd + ')' + (this.storeId ? ' from store "' + this.storeId + '"' : '')
  52964. });
  52965. }
  52966. range = me.getData().getRange(start, end + 1);
  52967. if (options.fireEvent !== false) {
  52968. me.fireEvent('guaranteedrange', range, start, end, options);
  52969. }
  52970. if (options.callback) {
  52971. options.callback.call(options.scope || me, range, start, end, options);
  52972. }
  52973. },
  52974. guaranteeRange: function(start, end, callback, scope, options) {
  52975. options = Ext.apply({
  52976. callback: callback,
  52977. scope: scope
  52978. }, options);
  52979. this.getRange(start, end + 1, options);
  52980. },
  52981. prefetchRange: function(start, end) {
  52982. var me = this,
  52983. startPage, endPage, page,
  52984. data = me.getData();
  52985. if (!me.rangeCached(start, end)) {
  52986. startPage = me.getPageFromRecordIndex(start);
  52987. endPage = me.getPageFromRecordIndex(end);
  52988. data.setMaxSize(me.calculatePageCacheSize(end - start + 1));
  52989. for (page = startPage; page <= endPage; page++) {
  52990. if (!me.pageCached(page)) {
  52991. me.prefetchPage(page);
  52992. }
  52993. }
  52994. }
  52995. },
  52996. primeCache: function(start, end, direction) {
  52997. var me = this,
  52998. leadingBufferZone = me.getLeadingBufferZone(),
  52999. trailingBufferZone = me.getTrailingBufferZone(),
  53000. pageSize = me.getPageSize(),
  53001. totalCount = me.totalCount;
  53002. if (direction === -1) {
  53003. start = Math.max(start - leadingBufferZone, 0);
  53004. end = Math.min(end + trailingBufferZone, totalCount - 1);
  53005. }
  53006. else if (direction === 1) {
  53007. start = Math.max(Math.min(start - trailingBufferZone, totalCount - pageSize), 0);
  53008. end = Math.min(end + leadingBufferZone, totalCount - 1);
  53009. } else
  53010. {
  53011. start = Math.min(Math.max(Math.floor(start - ((leadingBufferZone + trailingBufferZone) / 2)), 0), totalCount - me.pageSize);
  53012. end = Math.min(Math.max(Math.ceil(end + ((leadingBufferZone + trailingBufferZone) / 2)), 0), totalCount - 1);
  53013. }
  53014. me.prefetchRange(start, end);
  53015. },
  53016. sort: function(field, direction, mode) {
  53017. if (arguments.length === 0) {
  53018. this.clearAndLoad();
  53019. } else {
  53020. this.getSorters().addSort(field, direction, mode);
  53021. }
  53022. },
  53023. onSorterEndUpdate: function() {
  53024. var me = this,
  53025. sorters = me.getSorters().getRange();
  53026. if (sorters.length) {
  53027. me.fireEvent('beforesort', me, sorters);
  53028. me.clearAndLoad({
  53029. callback: function() {
  53030. me.fireEvent('sort', me, sorters);
  53031. }
  53032. });
  53033. } else {
  53034. me.fireEvent('sort', me, sorters);
  53035. }
  53036. },
  53037. clearAndLoad: function(options) {
  53038. var me = this;
  53039. me.clearing = true;
  53040. me.getData().clear();
  53041. me.clearing = false;
  53042. me.loadPage(1, options);
  53043. },
  53044. privates: {
  53045. isLast: function(record) {
  53046. return this.indexOf(record) === this.getTotalCount() - 1;
  53047. },
  53048. isMoving: function() {
  53049. return false;
  53050. }
  53051. }
  53052. });
  53053. Ext.define('Ext.data.proxy.Direct', {
  53054. extend: Ext.data.proxy.Server,
  53055. alternateClassName: 'Ext.data.DirectProxy',
  53056. alias: 'proxy.direct',
  53057. config: {
  53058. paramOrder: undefined,
  53059. paramsAsHash: true,
  53060. directFn: undefined,
  53061. api: undefined,
  53062. metadata: undefined
  53063. },
  53064. paramOrderRe: /[\s,|]/,
  53065. constructor: function(config) {
  53066. this.callParent([
  53067. config
  53068. ]);
  53069. this.canceledOperations = {};
  53070. },
  53071. applyParamOrder: function(paramOrder) {
  53072. if (Ext.isString(paramOrder)) {
  53073. paramOrder = paramOrder.split(this.paramOrderRe);
  53074. }
  53075. return paramOrder;
  53076. },
  53077. updateApi: function() {
  53078. this.methodsResolved = false;
  53079. },
  53080. updateDirectFn: function() {
  53081. this.methodsResolved = false;
  53082. },
  53083. resolveMethods: function() {
  53084. var me = this,
  53085. fn = me.getDirectFn(),
  53086. api = me.getApi(),
  53087. method;
  53088. if (fn) {
  53089. me.setDirectFn(method = Ext.direct.Manager.parseMethod(fn));
  53090. if (!Ext.isFunction(method)) {
  53091. Ext.raise('Cannot resolve directFn ' + fn);
  53092. }
  53093. }
  53094. if (api) {
  53095. api = Ext.direct.Manager.resolveApi(api, me);
  53096. me.setApi(api);
  53097. }
  53098. me.methodsResolved = true;
  53099. },
  53100. doRequest: function(operation) {
  53101. var me = this,
  53102. writer, request, action, params, args, api, fn, callback;
  53103. if (!me.methodsResolved) {
  53104. me.resolveMethods();
  53105. }
  53106. request = me.buildRequest(operation);
  53107. action = request.getAction();
  53108. api = me.getApi();
  53109. if (api) {
  53110. fn = api[action];
  53111. }
  53112. fn = fn || me.getDirectFn();
  53113. if (!fn || !fn.directCfg) {
  53114. Ext.raise({
  53115. msg: 'No Ext Direct function specified for Direct proxy "' + action + '" operation',
  53116. proxy: me
  53117. });
  53118. }
  53119. if (!me.paramOrder && fn.directCfg.method.len > 1) {
  53120. Ext.raise({
  53121. msg: 'Incorrect parameters for Direct proxy "' + action + '" operation',
  53122. proxy: me
  53123. });
  53124. }
  53125. writer = me.getWriter();
  53126. if (writer && operation.allowWrite()) {
  53127. request = writer.write(request);
  53128. }
  53129. if (action === 'read') {
  53130. params = request.getParams();
  53131. } else {
  53132. params = request.getJsonData();
  53133. }
  53134. args = fn.directCfg.method.getArgs({
  53135. params: params,
  53136. allowSingle: writer.getAllowSingle(),
  53137. paramOrder: me.getParamOrder(),
  53138. paramsAsHash: me.getParamsAsHash(),
  53139. paramsAsArray: true,
  53140. metadata: me.getMetadata(),
  53141. callback: me.createRequestCallback(request, operation),
  53142. scope: me
  53143. });
  53144. request.setConfig({
  53145. args: args,
  53146. directFn: fn
  53147. });
  53148. fn.apply(window, args);
  53149. return request;
  53150. },
  53151. abort: function(operation) {
  53152. var id;
  53153. if (operation && operation.isDataRequest) {
  53154. operation = operation.getOperation();
  53155. }
  53156. if (operation && operation.isOperation) {
  53157. id = operation.id;
  53158. }
  53159. if (id != null) {
  53160. this.canceledOperations[id] = true;
  53161. }
  53162. },
  53163. applyEncoding: Ext.identityFn,
  53164. createRequestCallback: function(request, operation) {
  53165. var me = this;
  53166. return function(data, event) {
  53167. if (!me.canceledOperations[operation.id]) {
  53168. me.processResponse(event.status, operation, request, event);
  53169. }
  53170. delete me.canceledOperations[operation.id];
  53171. };
  53172. },
  53173. extractResponseData: function(response) {
  53174. return Ext.isDefined(response.result) ? response.result : response.data;
  53175. },
  53176. setException: function(operation, response) {
  53177. operation.setException(response.message);
  53178. },
  53179. buildUrl: function() {
  53180. return '';
  53181. }
  53182. });
  53183. Ext.define('Ext.data.DirectStore', {
  53184. extend: Ext.data.Store,
  53185. alias: 'store.direct',
  53186. constructor: function(config) {
  53187. config = Ext.apply({}, config);
  53188. if (!config.proxy) {
  53189. var proxy = {
  53190. type: 'direct',
  53191. reader: {
  53192. type: 'json'
  53193. }
  53194. };
  53195. Ext.copyTo(proxy, config, 'paramOrder,paramsAsHash,directFn,api,simpleSortMode,extraParams');
  53196. Ext.copyTo(proxy.reader, config, 'totalProperty,root,rootProperty,idProperty');
  53197. config.proxy = proxy;
  53198. }
  53199. this.callParent([
  53200. config
  53201. ]);
  53202. }
  53203. });
  53204. Ext.define('Ext.data.JsonP', {
  53205. singleton: true,
  53206. requestCount: 0,
  53207. requests: {},
  53208. timeout: 30000,
  53209. disableCaching: true,
  53210. disableCachingParam: '_dc',
  53211. callbackKey: 'callback',
  53212. request: function(options) {
  53213. options = Ext.apply({}, options);
  53214. if (!options.url) {
  53215. Ext.raise('A url must be specified for a JSONP request.');
  53216. }
  53217. var me = this,
  53218. disableCaching = Ext.isDefined(options.disableCaching) ? options.disableCaching : me.disableCaching,
  53219. cacheParam = options.disableCachingParam || me.disableCachingParam,
  53220. id = ++me.requestCount,
  53221. callbackName = options.callbackName || 'callback' + id,
  53222. callbackKey = options.callbackKey || me.callbackKey,
  53223. timeout = Ext.isDefined(options.timeout) ? options.timeout : me.timeout,
  53224. params = Ext.apply({}, options.params),
  53225. url = options.url,
  53226. name = Ext.name,
  53227. request, script;
  53228. if (disableCaching && !params[cacheParam]) {
  53229. params[cacheParam] = Ext.Date.now();
  53230. }
  53231. options.params = params;
  53232. params[callbackKey] = name + '.data.JsonP.' + callbackName;
  53233. script = me.createScript(url, params, options);
  53234. me.requests[id] = request = {
  53235. url: url,
  53236. params: params,
  53237. script: script,
  53238. id: id,
  53239. scope: options.scope,
  53240. success: options.success,
  53241. failure: options.failure,
  53242. callback: options.callback,
  53243. callbackKey: callbackKey,
  53244. callbackName: callbackName
  53245. };
  53246. if (timeout > 0) {
  53247. request.timeout = Ext.defer(me.handleTimeout, timeout, me, [
  53248. request
  53249. ]);
  53250. }
  53251. me.setupErrorHandling(request);
  53252. me[callbackName] = me.bindResponse(request);
  53253. me.loadScript(request);
  53254. return request;
  53255. },
  53256. bindResponse: function(request) {
  53257. var me = this;
  53258. return function(result) {
  53259. Ext.elevate(function() {
  53260. me.handleResponse(result, request);
  53261. });
  53262. };
  53263. },
  53264. abort: function(request) {
  53265. var me = this,
  53266. requests = me.requests,
  53267. key;
  53268. if (request) {
  53269. if (!request.id) {
  53270. request = requests[request];
  53271. }
  53272. me.handleAbort(request);
  53273. } else {
  53274. for (key in requests) {
  53275. if (requests.hasOwnProperty(key)) {
  53276. me.abort(requests[key]);
  53277. }
  53278. }
  53279. }
  53280. },
  53281. setupErrorHandling: function(request) {
  53282. request.script.onerror = Ext.bind(this.handleError, this, [
  53283. request
  53284. ]);
  53285. },
  53286. handleAbort: function(request) {
  53287. request.errorType = 'abort';
  53288. this.handleResponse(null, request);
  53289. },
  53290. handleError: function(request) {
  53291. request.errorType = 'error';
  53292. this.handleResponse(null, request);
  53293. },
  53294. cleanupErrorHandling: function(request) {
  53295. request.script.onerror = null;
  53296. },
  53297. handleTimeout: function(request) {
  53298. request.errorType = 'timeout';
  53299. this.handleResponse(null, request);
  53300. },
  53301. handleResponse: function(result, request) {
  53302. var success = true;
  53303. Ext.undefer(request.timeout);
  53304. delete this[request.callbackName];
  53305. delete this.requests[request.id];
  53306. this.cleanupErrorHandling(request);
  53307. Ext.fly(request.script).destroy();
  53308. if (request.errorType) {
  53309. success = false;
  53310. Ext.callback(request.failure, request.scope, [
  53311. request.errorType
  53312. ]);
  53313. } else {
  53314. Ext.callback(request.success, request.scope, [
  53315. result
  53316. ]);
  53317. }
  53318. Ext.callback(request.callback, request.scope, [
  53319. success,
  53320. result,
  53321. request.errorType
  53322. ]);
  53323. },
  53324. createScript: function(url, params, options) {
  53325. var script = document.createElement('script');
  53326. script.setAttribute("src", Ext.urlAppend(url, Ext.Object.toQueryString(params)));
  53327. script.setAttribute("async", true);
  53328. script.setAttribute("type", "text/javascript");
  53329. return script;
  53330. },
  53331. loadScript: function(request) {
  53332. Ext.getHead().appendChild(request.script);
  53333. }
  53334. });
  53335. Ext.define('Ext.data.proxy.JsonP', {
  53336. extend: Ext.data.proxy.Server,
  53337. alternateClassName: 'Ext.data.ScriptTagProxy',
  53338. alias: [
  53339. 'proxy.jsonp',
  53340. 'proxy.scripttag'
  53341. ],
  53342. config: {
  53343. callbackKey: 'callback',
  53344. recordParam: 'records',
  53345. autoAppendParams: true
  53346. },
  53347. doRequest: function(operation) {
  53348. var me = this,
  53349. request = me.buildRequest(operation),
  53350. params = request.getParams();
  53351. request.setConfig({
  53352. callbackKey: me.callbackKey,
  53353. timeout: me.timeout,
  53354. scope: me,
  53355. disableCaching: false,
  53356. callback: me.createRequestCallback(request, operation)
  53357. });
  53358. if (me.getAutoAppendParams()) {
  53359. request.setParams({});
  53360. }
  53361. request.setRawRequest(Ext.data.JsonP.request(request.getCurrentConfig()));
  53362. request.setParams(params);
  53363. me.lastRequest = request;
  53364. return request;
  53365. },
  53366. createRequestCallback: function(request, operation) {
  53367. var me = this;
  53368. return function(success, response, errorType) {
  53369. if (request === me.lastRequest) {
  53370. me.lastRequest = null;
  53371. }
  53372. me.processResponse(success, operation, request, response);
  53373. };
  53374. },
  53375. setException: function(operation, response) {
  53376. operation.setException(operation.getRequest().getRawRequest().errorType);
  53377. },
  53378. buildUrl: function(request) {
  53379. var me = this,
  53380. url = me.callParent(arguments),
  53381. records = request.getRecords(),
  53382. writer = me.getWriter(),
  53383. params, filters, filter, i, v;
  53384. if (writer && request.getOperation().allowWrite()) {
  53385. request = writer.write(request);
  53386. }
  53387. params = request.getParams();
  53388. filters = params.filters;
  53389. delete params.filters;
  53390. if (filters && filters.length) {
  53391. for (i = 0; i < filters.length; i++) {
  53392. filter = filters[i];
  53393. v = filter.getValue();
  53394. if (v) {
  53395. params[filter.getProperty()] = v;
  53396. }
  53397. }
  53398. }
  53399. if (Ext.isArray(records) && records.length > 0 && (!writer || !writer.getEncode())) {
  53400. params[me.getRecordParam()] = me.encodeRecords(records);
  53401. }
  53402. if (me.getAutoAppendParams()) {
  53403. url = Ext.urlAppend(url, Ext.Object.toQueryString(params));
  53404. }
  53405. return url;
  53406. },
  53407. abort: function(request) {
  53408. request = request || this.lastRequest;
  53409. if (request) {
  53410. Ext.data.JsonP.abort(request.getRawRequest());
  53411. }
  53412. },
  53413. encodeRecords: function(records) {
  53414. var encoded = [],
  53415. i = 0,
  53416. len = records.length;
  53417. for (; i < len; i++) {
  53418. encoded.push(Ext.encode(records[i].getData()));
  53419. }
  53420. return encoded;
  53421. }
  53422. });
  53423. Ext.define('Ext.data.JsonPStore', {
  53424. extend: Ext.data.Store,
  53425. alias: 'store.jsonp',
  53426. constructor: function(config) {
  53427. config = Ext.apply({
  53428. proxy: {
  53429. type: 'jsonp',
  53430. reader: 'json'
  53431. }
  53432. }, config);
  53433. this.callParent([
  53434. config
  53435. ]);
  53436. }
  53437. });
  53438. Ext.define('Ext.data.JsonStore', {
  53439. extend: Ext.data.Store,
  53440. alias: 'store.json',
  53441. constructor: function(config) {
  53442. config = Ext.apply({
  53443. proxy: {
  53444. type: 'ajax',
  53445. reader: 'json',
  53446. writer: 'json'
  53447. }
  53448. }, config);
  53449. this.callParent([
  53450. config
  53451. ]);
  53452. }
  53453. });
  53454. Ext.define('Ext.data.ModelManager', {
  53455. alternateClassName: 'Ext.ModelMgr',
  53456. singleton: true,
  53457. deprecated: {
  53458. 5: {
  53459. methods: {
  53460. clear: null,
  53461. create: function(data, name, id) {
  53462. var T = name;
  53463. if (!T.isEntity) {
  53464. T = this.getModel(name || data.name);
  53465. }
  53466. return T.createWithId(id, data);
  53467. },
  53468. each: function(fn, scope) {
  53469. Ext.data.Model.schema.eachEntity(fn, scope);
  53470. },
  53471. get: function(name) {
  53472. return this.getModel(name);
  53473. },
  53474. getCount: function() {
  53475. return Ext.data.Model.schema.entityCount;
  53476. },
  53477. getModel: function(id) {
  53478. return Ext.data.schema.Schema.lookupEntity(id);
  53479. },
  53480. isRegistered: function(name) {
  53481. return !!this.getModel(name);
  53482. }
  53483. }
  53484. }
  53485. }
  53486. });
  53487. Ext.define('Ext.data.NodeInterface', {
  53488. statics: {
  53489. decorate: function(modelClass) {
  53490. var model = Ext.data.schema.Schema.lookupEntity(modelClass),
  53491. proto = model.prototype,
  53492. idName, idField, idType;
  53493. if (!model.prototype.isObservable) {
  53494. model.mixin(Ext.mixin.Observable.prototype.mixinId, Ext.mixin.Observable);
  53495. }
  53496. if (proto.isNode) {
  53497. return;
  53498. }
  53499. idName = proto.idProperty;
  53500. idField = model.getField(idName);
  53501. idType = idField.type;
  53502. model.override(this.getPrototypeBody());
  53503. model.addFields([
  53504. {
  53505. name: 'parentId',
  53506. type: idType,
  53507. defaultValue: null,
  53508. allowNull: idField.allowNull
  53509. },
  53510. {
  53511. name: 'index',
  53512. type: 'int',
  53513. defaultValue: -1,
  53514. persist: false,
  53515. convert: null
  53516. },
  53517. {
  53518. name: 'depth',
  53519. type: 'int',
  53520. defaultValue: 0,
  53521. persist: false,
  53522. convert: null
  53523. },
  53524. {
  53525. name: 'expanded',
  53526. type: 'bool',
  53527. defaultValue: false,
  53528. persist: false,
  53529. convert: null
  53530. },
  53531. {
  53532. name: 'expandable',
  53533. type: 'bool',
  53534. defaultValue: true,
  53535. persist: false,
  53536. convert: null
  53537. },
  53538. {
  53539. name: 'checked',
  53540. type: 'auto',
  53541. defaultValue: null,
  53542. persist: false,
  53543. convert: null
  53544. },
  53545. {
  53546. name: 'leaf',
  53547. type: 'bool',
  53548. defaultValue: false
  53549. },
  53550. {
  53551. name: 'cls',
  53552. type: 'string',
  53553. defaultValue: '',
  53554. persist: false,
  53555. convert: null
  53556. },
  53557. {
  53558. name: 'iconCls',
  53559. type: 'string',
  53560. defaultValue: '',
  53561. persist: false,
  53562. convert: null
  53563. },
  53564. {
  53565. name: 'icon',
  53566. type: 'string',
  53567. defaultValue: '',
  53568. persist: false,
  53569. convert: null
  53570. },
  53571. {
  53572. name: 'glyph',
  53573. type: 'string',
  53574. defaultValue: '',
  53575. persist: false,
  53576. convert: null
  53577. },
  53578. {
  53579. name: 'root',
  53580. type: 'boolean',
  53581. defaultValue: false,
  53582. persist: false,
  53583. convert: null
  53584. },
  53585. {
  53586. name: 'isLast',
  53587. type: 'boolean',
  53588. defaultValue: false,
  53589. persist: false,
  53590. convert: null
  53591. },
  53592. {
  53593. name: 'isFirst',
  53594. type: 'boolean',
  53595. defaultValue: false,
  53596. persist: false,
  53597. convert: null
  53598. },
  53599. {
  53600. name: 'allowDrop',
  53601. type: 'boolean',
  53602. defaultValue: true,
  53603. persist: false,
  53604. convert: null
  53605. },
  53606. {
  53607. name: 'allowDrag',
  53608. type: 'boolean',
  53609. defaultValue: true,
  53610. persist: false,
  53611. convert: null
  53612. },
  53613. {
  53614. name: 'loaded',
  53615. type: 'boolean',
  53616. defaultValue: false,
  53617. persist: false,
  53618. convert: null
  53619. },
  53620. {
  53621. name: 'loading',
  53622. type: 'boolean',
  53623. defaultValue: false,
  53624. persist: false,
  53625. convert: null
  53626. },
  53627. {
  53628. name: 'href',
  53629. type: 'string',
  53630. defaultValue: '',
  53631. persist: false,
  53632. convert: null
  53633. },
  53634. {
  53635. name: 'hrefTarget',
  53636. type: 'string',
  53637. defaultValue: '',
  53638. persist: false,
  53639. convert: null
  53640. },
  53641. {
  53642. name: 'qtip',
  53643. type: 'string',
  53644. defaultValue: '',
  53645. persist: false,
  53646. convert: null
  53647. },
  53648. {
  53649. name: 'qtitle',
  53650. type: 'string',
  53651. defaultValue: '',
  53652. persist: false,
  53653. convert: null
  53654. },
  53655. {
  53656. name: 'qshowDelay',
  53657. type: 'int',
  53658. defaultValue: 0,
  53659. persist: false,
  53660. convert: null
  53661. },
  53662. {
  53663. name: 'children',
  53664. type: 'auto',
  53665. defaultValue: null,
  53666. persist: false,
  53667. convert: null
  53668. },
  53669. {
  53670. name: 'visible',
  53671. type: 'boolean',
  53672. defaultValue: true,
  53673. persist: false
  53674. },
  53675. {
  53676. name: 'text',
  53677. type: 'string',
  53678. persist: false
  53679. }
  53680. ]);
  53681. },
  53682. getPrototypeBody: function() {
  53683. var bubbledEvents = {
  53684. idchanged: true,
  53685. append: true,
  53686. remove: true,
  53687. move: true,
  53688. insert: true,
  53689. beforeappend: true,
  53690. beforeremove: true,
  53691. beforemove: true,
  53692. beforeinsert: true,
  53693. expand: true,
  53694. collapse: true,
  53695. beforeexpand: true,
  53696. beforecollapse: true,
  53697. sort: true
  53698. },
  53699. silently = {
  53700. silent: true
  53701. };
  53702. return {
  53703. isNode: true,
  53704. firstChild: null,
  53705. lastChild: null,
  53706. parentNode: null,
  53707. previousSibling: null,
  53708. nextSibling: null,
  53709. constructor: function() {
  53710. var me = this;
  53711. me.mixins.observable.constructor.call(me);
  53712. me.callParent(arguments);
  53713. me.childNodes = [];
  53714. return me;
  53715. },
  53716. createNode: function(node) {
  53717. var me = this,
  53718. childType = me.childType,
  53719. store, storeReader, nodeProxy, nodeReader, reader, typeProperty,
  53720. T = me.self;
  53721. if (!node.isModel) {
  53722. if (childType) {
  53723. T = me.schema.getEntity(childType);
  53724. } else
  53725. {
  53726. store = me.getTreeStore();
  53727. storeReader = store && store.getProxy().getReader();
  53728. nodeProxy = me.getProxy();
  53729. nodeReader = nodeProxy ? nodeProxy.getReader() : null;
  53730. reader = !storeReader || (nodeReader && nodeReader.initialConfig.typeProperty) ? nodeReader : storeReader;
  53731. if (reader) {
  53732. typeProperty = reader.getTypeProperty();
  53733. if (typeProperty) {
  53734. T = reader.getChildType(me.schema, node, typeProperty);
  53735. }
  53736. }
  53737. }
  53738. node = new T(node);
  53739. }
  53740. if (!node.childNodes) {
  53741. node.firstChild = node.lastChild = node.parentNode = node.previousSibling = node.nextSibling = null;
  53742. node.childNodes = [];
  53743. }
  53744. return node;
  53745. },
  53746. isLeaf: function() {
  53747. return this.get('leaf') === true;
  53748. },
  53749. setFirstChild: function(node) {
  53750. this.firstChild = node;
  53751. },
  53752. setLastChild: function(node) {
  53753. this.lastChild = node;
  53754. },
  53755. updateInfo: function(commit, info) {
  53756. var me = this,
  53757. phantom = me.phantom,
  53758. result;
  53759. commit = {
  53760. silent: true,
  53761. commit: commit
  53762. };
  53763. if (info.depth != null && info.depth !== me.data.depth) {
  53764. var childInfo = {
  53765. depth: info.depth + 1
  53766. },
  53767. children = me.childNodes,
  53768. childCount = children.length,
  53769. i;
  53770. for (i = 0; i < childCount; i++) {
  53771. children[i].updateInfo(commit, childInfo);
  53772. }
  53773. }
  53774. result = me.set(info, commit);
  53775. me.phantom = phantom;
  53776. return result;
  53777. },
  53778. isLast: function() {
  53779. return this.get('isLast');
  53780. },
  53781. isFirst: function() {
  53782. return this.get('isFirst');
  53783. },
  53784. hasChildNodes: function() {
  53785. return !this.isLeaf() && this.childNodes.length > 0;
  53786. },
  53787. isExpandable: function() {
  53788. var me = this;
  53789. if (me.get('expandable')) {
  53790. return !(me.isLeaf() || (me.isLoaded() && !me.phantom && !me.hasChildNodes()));
  53791. }
  53792. return false;
  53793. },
  53794. triggerUIUpdate: function() {
  53795. this.callJoined('afterEdit', []);
  53796. },
  53797. appendChild: function(node, suppressEvents, commit) {
  53798. var me = this,
  53799. i, ln, index, oldParent, previousSibling,
  53800. childInfo = {
  53801. isLast: true,
  53802. parentId: me.getId(),
  53803. depth: (me.data.depth || 0) + 1
  53804. },
  53805. result,
  53806. treeStore = me.getTreeStore(),
  53807. halfCheckedValue = treeStore && treeStore.triStateCheckbox ? 1 : false,
  53808. bulkUpdate = treeStore && treeStore.bulkUpdate,
  53809. meChecked, nodeChecked, modifiedFields;
  53810. Ext.suspendLayouts();
  53811. if (Ext.isArray(node)) {
  53812. ln = node.length;
  53813. result = new Array(ln);
  53814. me.callTreeStore('beginFill');
  53815. for (i = 0; i < ln; i++) {
  53816. result[i] = me.appendChild(node[i], suppressEvents, commit);
  53817. }
  53818. me.callTreeStore('endFill', [
  53819. result
  53820. ]);
  53821. } else {
  53822. node = me.createNode(node);
  53823. if (suppressEvents !== true && me.fireBubbledEvent('beforeappend', [
  53824. me,
  53825. node
  53826. ]) === false) {
  53827. Ext.resumeLayouts(true);
  53828. return false;
  53829. }
  53830. index = me.childNodes.length;
  53831. oldParent = node.parentNode;
  53832. if (oldParent) {
  53833. if (suppressEvents !== true && node.fireBubbledEvent('beforemove', [
  53834. node,
  53835. oldParent,
  53836. me,
  53837. index
  53838. ]) === false) {
  53839. Ext.resumeLayouts(true);
  53840. return false;
  53841. }
  53842. if (oldParent.removeChild(node, false, suppressEvents, oldParent.getTreeStore() === treeStore) === false) {
  53843. Ext.resumeLayouts(true);
  53844. return false;
  53845. }
  53846. }
  53847. treeStore && treeStore.beginUpdate();
  53848. index = me.childNodes.length;
  53849. if (index === 0) {
  53850. me.setFirstChild(node);
  53851. }
  53852. me.childNodes[index] = node;
  53853. node.parentNode = me;
  53854. node.nextSibling = null;
  53855. me.setLastChild(node);
  53856. previousSibling = me.childNodes[index - 1];
  53857. if (previousSibling) {
  53858. node.previousSibling = previousSibling;
  53859. previousSibling.nextSibling = node;
  53860. previousSibling.updateInfo(commit, {
  53861. isLast: false
  53862. });
  53863. if (!bulkUpdate) {
  53864. previousSibling.triggerUIUpdate();
  53865. }
  53866. } else {
  53867. node.previousSibling = null;
  53868. }
  53869. childInfo.isFirst = index === 0;
  53870. childInfo.index = index;
  53871. modifiedFields = node.updateInfo(commit, childInfo);
  53872. if (me.isLeaf()) {
  53873. me.set('leaf', false);
  53874. }
  53875. if (!me.isLoaded()) {
  53876. if (bulkUpdate) {
  53877. me.data.loaded = true;
  53878. } else {
  53879. me.set('loaded', true);
  53880. }
  53881. } else if (me.childNodes.length === 1 && !bulkUpdate) {
  53882. me.triggerUIUpdate();
  53883. }
  53884. if (index && me.childNodes[index - 1].isExpanded() && !bulkUpdate) {
  53885. me.childNodes[index - 1].cascade(me.triggerUIUpdate);
  53886. }
  53887. if (treeStore) {
  53888. treeStore.registerNode(me, !bulkUpdate);
  53889. if (bulkUpdate) {
  53890. treeStore.registerNode(node);
  53891. }
  53892. }
  53893. if (suppressEvents !== true) {
  53894. me.fireBubbledEvent('append', [
  53895. me,
  53896. node,
  53897. index
  53898. ]);
  53899. if (oldParent) {
  53900. node.fireBubbledEvent('move', [
  53901. node,
  53902. oldParent,
  53903. me,
  53904. index
  53905. ]);
  53906. }
  53907. }
  53908. me.callTreeStore('onNodeAppend', [
  53909. node,
  53910. index
  53911. ]);
  53912. if (modifiedFields) {
  53913. node.callJoined('afterEdit', [
  53914. modifiedFields
  53915. ]);
  53916. }
  53917. result = node;
  53918. if (treeStore) {
  53919. treeStore.endUpdate();
  53920. }
  53921. }
  53922. Ext.resumeLayouts(true);
  53923. return result;
  53924. },
  53925. getOwnerTree: function() {
  53926. var store = this.getTreeStore();
  53927. return store && store.ownerTree;
  53928. },
  53929. getTreeStore: function() {
  53930. var root = this;
  53931. while (root && !root.treeStore) {
  53932. root = root.parentNode;
  53933. }
  53934. return root && root.treeStore;
  53935. },
  53936. removeChild: function(node, erase, suppressEvents, isMove) {
  53937. var me = this,
  53938. index = me.indexOf(node),
  53939. i, childCount, previousSibling,
  53940. treeStore = me.getTreeStore(),
  53941. bulkUpdate = treeStore && treeStore.bulkUpdate,
  53942. removeContext,
  53943. removeRange = [];
  53944. if (index === -1 || (suppressEvents !== true && me.fireBubbledEvent('beforeremove', [
  53945. me,
  53946. node,
  53947. !!isMove
  53948. ]) === false)) {
  53949. return false;
  53950. }
  53951. Ext.suspendLayouts();
  53952. treeStore && treeStore.beginUpdate();
  53953. Ext.Array.erase(me.childNodes, index, 1);
  53954. if (me.firstChild === node) {
  53955. me.setFirstChild(node.nextSibling);
  53956. }
  53957. if (me.lastChild === node) {
  53958. me.setLastChild(node.previousSibling);
  53959. }
  53960. previousSibling = node.previousSibling;
  53961. if (previousSibling) {
  53962. node.previousSibling.nextSibling = node.nextSibling;
  53963. }
  53964. if (node.nextSibling) {
  53965. node.nextSibling.previousSibling = node.previousSibling;
  53966. if (index === 0) {
  53967. node.nextSibling.updateInfo(false, {
  53968. isFirst: true
  53969. });
  53970. }
  53971. for (i = index , childCount = me.childNodes.length; i < childCount; i++) {
  53972. me.childNodes[i].updateInfo(false, {
  53973. index: i
  53974. });
  53975. }
  53976. }
  53977. else if (previousSibling) {
  53978. previousSibling.updateInfo(false, {
  53979. isLast: true
  53980. });
  53981. if (!bulkUpdate) {
  53982. if (previousSibling.isExpanded()) {
  53983. previousSibling.cascade(me.triggerUIUpdate);
  53984. } else
  53985. {
  53986. previousSibling.triggerUIUpdate();
  53987. }
  53988. }
  53989. }
  53990. if (!me.childNodes.length && !bulkUpdate) {
  53991. me.triggerUIUpdate();
  53992. }
  53993. Ext.resumeLayouts(true);
  53994. if (suppressEvents !== true) {
  53995. removeContext = {
  53996. parentNode: node.parentNode,
  53997. previousSibling: node.previousSibling,
  53998. nextSibling: node.nextSibling
  53999. };
  54000. me.callTreeStore('beforeNodeRemove', [
  54001. [
  54002. node
  54003. ],
  54004. !!isMove,
  54005. removeRange
  54006. ]);
  54007. node.previousSibling = node.nextSibling = node.parentNode = null;
  54008. me.fireBubbledEvent('remove', [
  54009. me,
  54010. node,
  54011. !!isMove,
  54012. removeContext
  54013. ]);
  54014. me.callTreeStore('onNodeRemove', [
  54015. [
  54016. node
  54017. ],
  54018. !!isMove,
  54019. removeRange
  54020. ]);
  54021. }
  54022. if (erase) {
  54023. node.erase(true);
  54024. } else {
  54025. node.clear();
  54026. }
  54027. if (!isMove) {
  54028. node.set({
  54029. parentId: null,
  54030. lastParentId: me.getId()
  54031. }, silently);
  54032. }
  54033. if (treeStore) {
  54034. treeStore.endUpdate();
  54035. }
  54036. return node;
  54037. },
  54038. copy: function(newId, session, deep) {
  54039. var me = this,
  54040. result,
  54041. args = [
  54042. newId
  54043. ],
  54044. len = me.childNodes ? me.childNodes.length : 0,
  54045. i;
  54046. if (session && session.isSession) {
  54047. args.push(session);
  54048. } else if (arguments.length < 3) {
  54049. deep = session;
  54050. }
  54051. result = me.callParent(args);
  54052. if (deep) {
  54053. for (i = 0; i < len; i++) {
  54054. result.appendChild(me.childNodes[i].copy(undefined, true));
  54055. }
  54056. }
  54057. return result;
  54058. },
  54059. clear: function(erase, resetChildren) {
  54060. var me = this,
  54061. data;
  54062. me.parentNode = me.previousSibling = me.nextSibling = null;
  54063. if (erase) {
  54064. me.firstChild = me.lastChild = me.childNodes = null;
  54065. }
  54066. if (resetChildren) {
  54067. me.firstChild = me.lastChild = null;
  54068. me.childNodes.length = 0;
  54069. if (me.data) {
  54070. me.data.children = null;
  54071. }
  54072. }
  54073. },
  54074. drop: function() {
  54075. var me = this,
  54076. childNodes = me.childNodes,
  54077. parentNode = me.parentNode,
  54078. len, i, node,
  54079. treeStore = me.getTreeStore();
  54080. me.callParent();
  54081. if (parentNode) {
  54082. parentNode.removeChild(me);
  54083. }
  54084. else if (me.get('root')) {
  54085. treeStore.setRoot(null);
  54086. }
  54087. treeStore && treeStore.beginUpdate();
  54088. for (i = 0 , len = childNodes ? childNodes.length : 0; i < len; i++) {
  54089. node = childNodes[i];
  54090. node.clear();
  54091. node.drop();
  54092. }
  54093. treeStore && treeStore.endUpdate();
  54094. },
  54095. erase: function(options) {
  54096. var me = this,
  54097. childNodes = me.childNodes,
  54098. len = childNodes && childNodes.length,
  54099. i, node;
  54100. me.remove();
  54101. me.clear(true);
  54102. me.callParent([
  54103. options
  54104. ]);
  54105. for (i = 0; i < len; i++) {
  54106. node = childNodes[i];
  54107. node.parentNode = null;
  54108. node.erase(options);
  54109. }
  54110. },
  54111. insertBefore: function(node, refNode, suppressEvents) {
  54112. var me = this,
  54113. index = me.indexOf(refNode),
  54114. oldParent = node.parentNode,
  54115. refIndex = index,
  54116. childCount, previousSibling, i,
  54117. treeStore = me.getTreeStore(),
  54118. bulkUpdate = treeStore && treeStore.bulkUpdate,
  54119. modifiedFields, sibling, siblingModifiedFields;
  54120. if (!refNode) {
  54121. return me.appendChild(node);
  54122. }
  54123. if (node === refNode) {
  54124. return false;
  54125. }
  54126. node = me.createNode(node);
  54127. if (suppressEvents !== true && me.fireBubbledEvent('beforeinsert', [
  54128. me,
  54129. node,
  54130. refNode
  54131. ]) === false) {
  54132. return false;
  54133. }
  54134. if (oldParent === me && me.indexOf(node) < index) {
  54135. refIndex--;
  54136. }
  54137. if (oldParent) {
  54138. if (suppressEvents !== true && node.fireBubbledEvent('beforemove', [
  54139. node,
  54140. oldParent,
  54141. me,
  54142. index,
  54143. refNode
  54144. ]) === false) {
  54145. return false;
  54146. }
  54147. if (oldParent.removeChild(node, false, suppressEvents, oldParent.getTreeStore() === treeStore) === false) {
  54148. return false;
  54149. }
  54150. }
  54151. treeStore && treeStore.beginUpdate();
  54152. if (refIndex === 0) {
  54153. me.setFirstChild(node);
  54154. }
  54155. Ext.Array.splice(me.childNodes, refIndex, 0, node);
  54156. node.parentNode = me;
  54157. node.nextSibling = refNode;
  54158. refNode.previousSibling = node;
  54159. previousSibling = me.childNodes[refIndex - 1];
  54160. if (previousSibling) {
  54161. node.previousSibling = previousSibling;
  54162. previousSibling.nextSibling = node;
  54163. } else {
  54164. node.previousSibling = null;
  54165. }
  54166. modifiedFields = node.updateInfo(false, {
  54167. parentId: me.getId(),
  54168. index: refIndex,
  54169. isFirst: refIndex === 0,
  54170. isLast: false,
  54171. depth: (me.data.depth || 0) + 1
  54172. });
  54173. for (i = refIndex + 1 , childCount = me.childNodes.length; i < childCount; i++) {
  54174. sibling = me.childNodes[i];
  54175. siblingModifiedFields = sibling.updateInfo(false, {
  54176. index: i
  54177. });
  54178. if (siblingModifiedFields) {
  54179. sibling.callJoined('afterEdit', [
  54180. siblingModifiedFields
  54181. ]);
  54182. }
  54183. }
  54184. if (!me.isLoaded()) {
  54185. if (bulkUpdate) {
  54186. me.data.loaded = true;
  54187. } else {
  54188. me.set('loaded', true);
  54189. }
  54190. }
  54191. else if (me.childNodes.length === 1 && !bulkUpdate) {
  54192. me.triggerUIUpdate();
  54193. }
  54194. if (treeStore) {
  54195. treeStore.registerNode(me, !bulkUpdate);
  54196. }
  54197. if (suppressEvents !== true) {
  54198. me.fireBubbledEvent('insert', [
  54199. me,
  54200. node,
  54201. refNode
  54202. ]);
  54203. if (oldParent) {
  54204. node.fireBubbledEvent('move', [
  54205. node,
  54206. oldParent,
  54207. me,
  54208. refIndex,
  54209. refNode
  54210. ]);
  54211. }
  54212. }
  54213. me.callTreeStore('onNodeInsert', [
  54214. node,
  54215. refIndex
  54216. ]);
  54217. if (modifiedFields) {
  54218. node.callJoined('afterEdit', [
  54219. modifiedFields
  54220. ]);
  54221. }
  54222. if (treeStore) {
  54223. treeStore.endUpdate();
  54224. }
  54225. return node;
  54226. },
  54227. insertChild: function(index, node) {
  54228. var sibling = this.childNodes[index];
  54229. if (sibling) {
  54230. return this.insertBefore(node, sibling);
  54231. } else {
  54232. return this.appendChild(node);
  54233. }
  54234. },
  54235. isLastVisible: function() {
  54236. var me = this,
  54237. result = me.data.isLast,
  54238. next = me.nextSibling;
  54239. if (!result && me.getTreeStore().isFiltered()) {
  54240. while (next) {
  54241. if (next.data.visible) {
  54242. return false;
  54243. }
  54244. next = next.nextSibling;
  54245. }
  54246. return true;
  54247. }
  54248. return result;
  54249. },
  54250. remove: function(erase, suppressEvents) {
  54251. var me = this,
  54252. parentNode = me.parentNode;
  54253. if (parentNode) {
  54254. parentNode.removeChild(me, erase, suppressEvents);
  54255. } else if (erase) {
  54256. me.erase(true);
  54257. }
  54258. return me;
  54259. },
  54260. removeAll: function(erase, suppressEvents, fromParent) {
  54261. var me = this,
  54262. childNodes = me.childNodes,
  54263. len = childNodes.length,
  54264. node, treeStore, i,
  54265. removeRange = [];
  54266. if (!len) {
  54267. return me;
  54268. }
  54269. if (!fromParent) {
  54270. treeStore = me.getTreeStore();
  54271. if (treeStore) {
  54272. treeStore.beginUpdate();
  54273. treeStore.suspendEvent('remove');
  54274. me.callTreeStore('beforeNodeRemove', [
  54275. childNodes,
  54276. false,
  54277. removeRange
  54278. ]);
  54279. }
  54280. }
  54281. for (i = 0; i < len; ++i) {
  54282. node = childNodes[i];
  54283. node.previousSibling = node.nextSibling = node.parentNode = null;
  54284. me.fireBubbledEvent('remove', [
  54285. me,
  54286. node,
  54287. false
  54288. ]);
  54289. if (erase) {
  54290. node.erase(true);
  54291. } else
  54292. {
  54293. node.removeAll(false, suppressEvents, true);
  54294. }
  54295. }
  54296. if (!fromParent && treeStore) {
  54297. treeStore.resumeEvent('remove');
  54298. me.callTreeStore('onNodeRemove', [
  54299. childNodes,
  54300. false,
  54301. removeRange
  54302. ]);
  54303. treeStore.endUpdate();
  54304. }
  54305. me.firstChild = me.lastChild = null;
  54306. childNodes.length = 0;
  54307. if (!fromParent) {
  54308. me.triggerUIUpdate();
  54309. }
  54310. return me;
  54311. },
  54312. getChildAt: function(index) {
  54313. return this.childNodes[index];
  54314. },
  54315. replaceChild: function(newChild, oldChild, suppressEvents) {
  54316. var s = oldChild ? oldChild.nextSibling : null;
  54317. this.removeChild(oldChild, false, suppressEvents);
  54318. this.insertBefore(newChild, s, suppressEvents);
  54319. return oldChild;
  54320. },
  54321. indexOf: function(child) {
  54322. return Ext.Array.indexOf(this.childNodes, child);
  54323. },
  54324. indexOfId: function(id) {
  54325. var childNodes = this.childNodes,
  54326. len = childNodes.length,
  54327. i = 0;
  54328. for (; i < len; ++i) {
  54329. if (childNodes[i].getId() === id) {
  54330. return i;
  54331. }
  54332. }
  54333. return -1;
  54334. },
  54335. getPath: function(field, separator) {
  54336. field = field || this.idProperty;
  54337. separator = separator || '/';
  54338. var path = [
  54339. this.get(field)
  54340. ],
  54341. parent = this.parentNode;
  54342. while (parent) {
  54343. path.unshift(parent.get(field));
  54344. parent = parent.parentNode;
  54345. }
  54346. return separator + path.join(separator);
  54347. },
  54348. getDepth: function() {
  54349. return this.get('depth');
  54350. },
  54351. bubble: function(fn, scope, args) {
  54352. var p = this;
  54353. while (p) {
  54354. if (fn.apply(scope || p, args || [
  54355. p
  54356. ]) === false) {
  54357. break;
  54358. }
  54359. p = p.parentNode;
  54360. }
  54361. },
  54362. cascade: function(spec, scope, args, after) {
  54363. var me = this,
  54364. before = spec;
  54365. if (arguments.length === 1 && !Ext.isFunction(spec)) {
  54366. after = spec.after;
  54367. scope = spec.scope;
  54368. args = spec.args;
  54369. before = spec.before;
  54370. }
  54371. if (!before || before.apply(scope || me, args || [
  54372. me
  54373. ]) !== false) {
  54374. var childNodes = me.childNodes,
  54375. length = childNodes.length,
  54376. i;
  54377. for (i = 0; i < length; i++) {
  54378. childNodes[i].cascade.call(childNodes[i], before, scope, args, after);
  54379. }
  54380. if (after) {
  54381. after.apply(scope || me, args || [
  54382. me
  54383. ]);
  54384. }
  54385. }
  54386. },
  54387. cascadeBy: function() {
  54388. return this.cascade.apply(this, arguments);
  54389. },
  54390. eachChild: function(fn, scope, args) {
  54391. var childNodes = this.childNodes,
  54392. length = childNodes.length,
  54393. i;
  54394. for (i = 0; i < length; i++) {
  54395. if (fn.apply(scope || this, args || [
  54396. childNodes[i]
  54397. ]) === false) {
  54398. break;
  54399. }
  54400. }
  54401. },
  54402. findChild: function(attribute, value, deep) {
  54403. return this.findChildBy(function() {
  54404. return this.get(attribute) == value;
  54405. }, null, deep);
  54406. },
  54407. findChildBy: function(fn, scope, deep) {
  54408. var cs = this.childNodes,
  54409. len = cs.length,
  54410. i = 0,
  54411. n, res;
  54412. for (; i < len; i++) {
  54413. n = cs[i];
  54414. if (fn.call(scope || n, n) === true) {
  54415. return n;
  54416. } else if (deep) {
  54417. res = n.findChildBy(fn, scope, deep);
  54418. if (res !== null) {
  54419. return res;
  54420. }
  54421. }
  54422. }
  54423. return null;
  54424. },
  54425. contains: function(node) {
  54426. return node.isAncestor(this);
  54427. },
  54428. isAncestor: function(node) {
  54429. var p = this.parentNode;
  54430. while (p) {
  54431. if (p === node) {
  54432. return true;
  54433. }
  54434. p = p.parentNode;
  54435. }
  54436. return false;
  54437. },
  54438. sort: function(sortFn, recursive, suppressEvent) {
  54439. var me = this,
  54440. childNodes = me.childNodes,
  54441. ln = childNodes.length,
  54442. i, n,
  54443. info = {
  54444. isFirst: true
  54445. };
  54446. if (ln > 0) {
  54447. if (!sortFn) {
  54448. sortFn = me.getTreeStore().getSortFn();
  54449. }
  54450. Ext.Array.sort(childNodes, sortFn);
  54451. me.setFirstChild(childNodes[0]);
  54452. me.setLastChild(childNodes[ln - 1]);
  54453. for (i = 0; i < ln; i++) {
  54454. n = childNodes[i];
  54455. n.previousSibling = childNodes[i - 1];
  54456. n.nextSibling = childNodes[i + 1];
  54457. info.isLast = (i === ln - 1);
  54458. info.index = i;
  54459. n.updateInfo(false, info);
  54460. info.isFirst = false;
  54461. if (recursive && !n.isLeaf()) {
  54462. n.sort(sortFn, true, true);
  54463. }
  54464. }
  54465. if (suppressEvent !== true) {
  54466. me.fireBubbledEvent('sort', [
  54467. me,
  54468. childNodes
  54469. ]);
  54470. me.callTreeStore('onNodeSort', [
  54471. childNodes
  54472. ]);
  54473. }
  54474. }
  54475. },
  54476. isExpanded: function() {
  54477. return this.get('expanded');
  54478. },
  54479. isLoaded: function() {
  54480. return this.get('loaded');
  54481. },
  54482. isBranchLoaded: function() {
  54483. var isBranchLoaded = !this.isLeaf() && this.isLoaded();
  54484. if (isBranchLoaded) {
  54485. this.cascade(function(node) {
  54486. if (!node.isLeaf()) {
  54487. isBranchLoaded = isBranchLoaded || node.isBranchLoaded();
  54488. }
  54489. return isBranchLoaded;
  54490. });
  54491. }
  54492. return isBranchLoaded;
  54493. },
  54494. isLoading: function() {
  54495. return this.get('loading');
  54496. },
  54497. isRoot: function() {
  54498. return !this.parentNode;
  54499. },
  54500. isVisible: function() {
  54501. var parent = this.parentNode;
  54502. while (parent) {
  54503. if (!parent.isExpanded()) {
  54504. return false;
  54505. }
  54506. parent = parent.parentNode;
  54507. }
  54508. return true;
  54509. },
  54510. expand: function(recursive, callback, scope) {
  54511. var me = this,
  54512. treeStore, resumeAddEvent;
  54513. if (!me.isLeaf()) {
  54514. if (me.isLoading()) {
  54515. me.on('expand', function() {
  54516. me.expand(recursive, callback, scope);
  54517. }, me, {
  54518. single: true
  54519. });
  54520. } else {
  54521. if (!me.isExpanded()) {
  54522. if (me.fireBubbledEvent('beforeexpand', [
  54523. me
  54524. ]) !== false) {
  54525. if (recursive) {
  54526. if (me.parentNode && me.parentNode.isSynchronousRecursiveExpand) {
  54527. me.isSynchronousRecursiveExpand = true;
  54528. } else {
  54529. treeStore = me.getTreeStore();
  54530. if (treeStore.getProxy().isSynchronous || me.isBranchLoaded()) {
  54531. me.isSynchronousRecursiveExpand = true;
  54532. treeStore.suspendEvent('add', 'datachanged');
  54533. resumeAddEvent = true;
  54534. }
  54535. }
  54536. }
  54537. me.callTreeStore('onBeforeNodeExpand', [
  54538. me.onChildNodesAvailable,
  54539. me,
  54540. [
  54541. recursive,
  54542. callback,
  54543. scope
  54544. ]
  54545. ]);
  54546. if (resumeAddEvent) {
  54547. treeStore.resumeEvent('add', 'datachanged');
  54548. treeStore.fireEvent('datachanged', treeStore);
  54549. treeStore.fireEvent('refresh', treeStore);
  54550. }
  54551. me.isSynchronousRecursiveExpand = false;
  54552. }
  54553. } else if (recursive) {
  54554. me.expandChildren(true, callback, scope);
  54555. } else {
  54556. Ext.callback(callback, scope || me, [
  54557. me.childNodes
  54558. ]);
  54559. }
  54560. }
  54561. } else {
  54562. Ext.callback(callback, scope || me);
  54563. }
  54564. },
  54565. onChildNodesAvailable: function(records, recursive, callback, scope) {
  54566. var me = this,
  54567. treeStore = me.getTreeStore(),
  54568. bulkUpdate = treeStore && treeStore.bulkUpdate,
  54569. ancestor, i, collapsedAncestors;
  54570. Ext.suspendLayouts();
  54571. for (ancestor = me.parentNode; ancestor; ancestor = ancestor.parentNode) {
  54572. if (!ancestor.isExpanded()) {
  54573. (collapsedAncestors || (collapsedAncestors = [])).unshift(ancestor);
  54574. }
  54575. }
  54576. if (bulkUpdate || !treeStore.isVisible(me)) {
  54577. me.data.expanded = true;
  54578. } else {
  54579. me.set('expanded', true);
  54580. }
  54581. if (collapsedAncestors) {
  54582. for (i = 1; i < collapsedAncestors.length; i++) {
  54583. ancestor = collapsedAncestors[i];
  54584. if (bulkUpdate || !treeStore.isVisible(ancestor)) {
  54585. ancestor.data.expanded = true;
  54586. } else {
  54587. ancestor.set('expanded', true);
  54588. }
  54589. }
  54590. collapsedAncestors[0].expand();
  54591. for (i = 1; i < collapsedAncestors.length; i++) {
  54592. ancestor = collapsedAncestors[i];
  54593. ancestor.fireBubbledEvent('expand', [
  54594. ancestor,
  54595. ancestor.childNodes
  54596. ]);
  54597. }
  54598. } else {
  54599. me.callTreeStore('onNodeExpand', [
  54600. records,
  54601. false
  54602. ]);
  54603. }
  54604. me.fireBubbledEvent('expand', [
  54605. me,
  54606. records
  54607. ]);
  54608. if (recursive) {
  54609. me.expandChildren(true, callback, scope);
  54610. } else {
  54611. Ext.callback(callback, scope || me, [
  54612. me.childNodes
  54613. ]);
  54614. }
  54615. Ext.resumeLayouts(true);
  54616. },
  54617. expandChildren: function(recursive, callback, scope, singleExpand) {
  54618. var me = this,
  54619. origCallback, i, allNodes, expandNodes, ln, node, treeStore;
  54620. if (Ext.isBoolean(callback)) {
  54621. origCallback = callback;
  54622. callback = scope;
  54623. scope = singleExpand;
  54624. singleExpand = origCallback;
  54625. }
  54626. if (singleExpand === undefined) {
  54627. treeStore = me.getTreeStore();
  54628. singleExpand = treeStore && treeStore.singleExpand;
  54629. }
  54630. allNodes = me.childNodes;
  54631. expandNodes = [];
  54632. ln = singleExpand ? Math.min(allNodes.length, 1) : allNodes.length;
  54633. for (i = 0; i < ln; ++i) {
  54634. node = allNodes[i];
  54635. if (!node.isLeaf()) {
  54636. expandNodes[expandNodes.length] = node;
  54637. }
  54638. }
  54639. ln = expandNodes.length;
  54640. for (i = 0; i < ln; ++i) {
  54641. expandNodes[i].expand(recursive);
  54642. }
  54643. if (callback) {
  54644. Ext.callback(callback, scope || me, [
  54645. me.childNodes
  54646. ]);
  54647. }
  54648. },
  54649. collapse: function(recursive, callback, scope) {
  54650. var me = this,
  54651. expanded = me.isExpanded(),
  54652. treeStore = me.getTreeStore(),
  54653. bulkUpdate = treeStore && treeStore.bulkUpdate,
  54654. len = me.childNodes.length,
  54655. i, collapseChildren;
  54656. if (!me.isLeaf() && ((!expanded && recursive) || me.fireBubbledEvent('beforecollapse', [
  54657. me
  54658. ]) !== false)) {
  54659. Ext.suspendLayouts();
  54660. if (me.isExpanded()) {
  54661. if (recursive) {
  54662. collapseChildren = function() {
  54663. for (i = 0; i < len; i++) {
  54664. me.childNodes[i].setCollapsed(true);
  54665. }
  54666. };
  54667. if (callback) {
  54668. callback = Ext.Function.createSequence(collapseChildren, Ext.Function.bind(callback, scope, [
  54669. me.childNodes
  54670. ]));
  54671. } else {
  54672. callback = collapseChildren;
  54673. }
  54674. } else if (callback) {
  54675. callback = Ext.Function.bind(callback, scope, [
  54676. me.childNodes
  54677. ]);
  54678. }
  54679. if (bulkUpdate || !treeStore.contains(me)) {
  54680. me.data.expanded = false;
  54681. } else {
  54682. me.set('expanded', false);
  54683. }
  54684. me.callTreeStore('onNodeCollapse', [
  54685. me.childNodes,
  54686. callback,
  54687. scope
  54688. ]);
  54689. me.fireBubbledEvent('collapse', [
  54690. me,
  54691. me.childNodes
  54692. ]);
  54693. callback = null;
  54694. }
  54695. else if (recursive) {
  54696. for (i = 0; i < len; i++) {
  54697. me.childNodes[i].setCollapsed(true);
  54698. }
  54699. }
  54700. Ext.resumeLayouts(true);
  54701. }
  54702. Ext.callback(callback, scope || me, [
  54703. me.childNodes
  54704. ]);
  54705. },
  54706. setCollapsed: function(recursive) {
  54707. var me = this,
  54708. len = me.childNodes.length,
  54709. i;
  54710. if (!me.isLeaf() && me.fireBubbledEvent('beforecollapse', [
  54711. me
  54712. ]) !== false) {
  54713. me.data.expanded = false;
  54714. me.fireBubbledEvent('collapse', [
  54715. me,
  54716. me.childNodes
  54717. ]);
  54718. if (recursive) {
  54719. for (i = 0; i < len; i++) {
  54720. me.childNodes[i].setCollapsed(true);
  54721. }
  54722. }
  54723. }
  54724. },
  54725. collapseChildren: function(recursive, callback, scope) {
  54726. var me = this,
  54727. i,
  54728. allNodes = me.childNodes,
  54729. ln = allNodes.length,
  54730. collapseNodes = [],
  54731. node;
  54732. for (i = 0; i < ln; ++i) {
  54733. node = allNodes[i];
  54734. if (!node.isLeaf() && node.isLoaded() && node.isExpanded()) {
  54735. collapseNodes.push(node);
  54736. }
  54737. }
  54738. ln = collapseNodes.length;
  54739. if (ln) {
  54740. for (i = 0; i < ln; ++i) {
  54741. node = collapseNodes[i];
  54742. if (i === ln - 1) {
  54743. node.collapse(recursive, callback, scope);
  54744. } else {
  54745. node.collapse(recursive);
  54746. }
  54747. }
  54748. } else {
  54749. Ext.callback(callback, scope);
  54750. }
  54751. },
  54752. fireEvent: function(eventName) {
  54753. return this.fireBubbledEvent(eventName, Ext.Array.slice(arguments, 1));
  54754. },
  54755. fireBubbledEvent: function(eventName, args) {
  54756. var result, eventSource, topNode;
  54757. if (bubbledEvents[eventName]) {
  54758. for (eventSource = this; result !== false && eventSource; eventSource = (topNode = eventSource).parentNode) {
  54759. result = eventSource.fireEventArgs.call(eventSource, eventName, args);
  54760. }
  54761. if (result !== false) {
  54762. eventSource = topNode.getTreeStore();
  54763. if (eventSource && eventSource.hasListeners && eventSource.hasListeners[eventName = 'node' + eventName]) {
  54764. result = eventSource.fireEventArgs(eventName, args);
  54765. }
  54766. }
  54767. return result;
  54768. } else
  54769. {
  54770. return this.fireEventArgs.apply(this, arguments);
  54771. }
  54772. },
  54773. serialize: function(writerParam) {
  54774. var writer = writerParam || new Ext.data.writer.Json({
  54775. writeAllFields: true
  54776. }),
  54777. result = writer.getRecordData(this),
  54778. childNodes = this.childNodes,
  54779. len = childNodes.length,
  54780. children, i;
  54781. if (len > 0) {
  54782. result.children = children = [];
  54783. for (i = 0; i < len; i++) {
  54784. children.push(childNodes[i].serialize(writer));
  54785. }
  54786. }
  54787. return result;
  54788. },
  54789. callTreeStore: function(funcName, args) {
  54790. var me = this,
  54791. target = me.getTreeStore(),
  54792. fn = target && target[funcName];
  54793. if (target && fn) {
  54794. args = args || [];
  54795. if (args[0] !== me) {
  54796. args.unshift(me);
  54797. }
  54798. fn.apply(target, args);
  54799. }
  54800. },
  54801. addCls: function(cls) {
  54802. this.replaceCls(null, cls);
  54803. },
  54804. removeCls: function(cls) {
  54805. this.replaceCls(cls);
  54806. },
  54807. replaceCls: function(oldCls, newCls) {
  54808. var pieces = this._parseCls(this.data.cls),
  54809. parts = this._parseCls(oldCls);
  54810. if (parts.length) {
  54811. pieces = Ext.Array.difference(pieces, parts);
  54812. }
  54813. parts = this._parseCls(newCls);
  54814. if (parts.length) {
  54815. pieces = Ext.Array.unique(pieces.concat(parts));
  54816. }
  54817. this.set('cls', pieces.join(' '));
  54818. },
  54819. toggleCls: function(cls, state) {
  54820. if (state === undefined) {
  54821. var pieces = this._parseCls(this.data.cls),
  54822. parts = this._parseCls(cls),
  54823. len = parts.length,
  54824. i, p;
  54825. for (i = 0; i < len; ++i) {
  54826. p = parts[i];
  54827. if (Ext.Array.contains(pieces, p)) {
  54828. Ext.Array.remove(pieces, p);
  54829. } else {
  54830. pieces.push(p);
  54831. }
  54832. }
  54833. this.set('cls', pieces.join(' '));
  54834. } else if (state) {
  54835. this.addCls(cls);
  54836. } else {
  54837. this.removeCls(cls);
  54838. }
  54839. },
  54840. privates: {
  54841. _noCls: [],
  54842. spacesRe: /\s+/,
  54843. join: function(store) {
  54844. if (store.isTreeStore) {
  54845. if (this.isRoot()) {
  54846. this.treeStore = this.store = store;
  54847. }
  54848. } else
  54849. {
  54850. this.callParent([
  54851. store
  54852. ]);
  54853. }
  54854. },
  54855. callJoined: function(funcName, args) {
  54856. this.callParent([
  54857. funcName,
  54858. args
  54859. ]);
  54860. this.callTreeStore(funcName, args);
  54861. },
  54862. _parseCls: function(cls) {
  54863. if (!cls) {
  54864. return this._noCls;
  54865. }
  54866. if (typeof cls === 'string') {
  54867. return cls.split(this.spacesRe);
  54868. }
  54869. return cls;
  54870. }
  54871. }
  54872. };
  54873. }
  54874. }
  54875. });
  54876. Ext.define('Ext.data.TreeModel', {
  54877. extend: Ext.data.Model,
  54878. mixins: [
  54879. Ext.mixin.Queryable
  54880. ],
  54881. getRefItems: function() {
  54882. return this.childNodes;
  54883. },
  54884. getRefOwner: function() {
  54885. return this.parentNode;
  54886. },
  54887. statics: {
  54888. defaultProxy: 'memory'
  54889. }
  54890. }, function() {
  54891. Ext.data.NodeInterface.decorate(this);
  54892. });
  54893. Ext.define('Ext.data.NodeStore', {
  54894. extend: Ext.data.Store,
  54895. alias: 'store.node',
  54896. isNodeStore: true,
  54897. config: {
  54898. node: null,
  54899. recursive: false,
  54900. rootVisible: false,
  54901. folderSort: false
  54902. },
  54903. implicitModel: 'Ext.data.TreeModel',
  54904. getTotalCount: function() {
  54905. return this.getCount();
  54906. },
  54907. updateFolderSort: function(folderSort) {
  54908. var data = this.getData();
  54909. data.setTrackGroups(false);
  54910. if (folderSort) {
  54911. data.setGrouper({
  54912. groupFn: this.folderSortFn
  54913. });
  54914. } else {
  54915. data.setGrouper(null);
  54916. }
  54917. },
  54918. folderSortFn: function(node) {
  54919. return node.data.leaf ? 1 : 0;
  54920. },
  54921. afterReject: function(record) {
  54922. var me = this;
  54923. if (me.contains(record)) {
  54924. me.onUpdate(record, Ext.data.Model.REJECT, null);
  54925. me.fireEvent('update', me, record, Ext.data.Model.REJECT, null);
  54926. }
  54927. },
  54928. afterCommit: function(record, modifiedFieldNames) {
  54929. var me = this;
  54930. if (!modifiedFieldNames) {
  54931. modifiedFieldNames = null;
  54932. }
  54933. if (me.contains(record)) {
  54934. me.onUpdate(record, Ext.data.Model.COMMIT, modifiedFieldNames);
  54935. me.fireEvent('update', me, record, Ext.data.Model.COMMIT, modifiedFieldNames);
  54936. }
  54937. },
  54938. onNodeAppend: function(parent, node) {
  54939. if (parent === this.getNode()) {
  54940. this.add([
  54941. node
  54942. ].concat(this.retrieveChildNodes(node)));
  54943. }
  54944. },
  54945. onNodeInsert: function(parent, node, refNode) {
  54946. var me = this,
  54947. idx;
  54948. if (parent === me.getNode()) {
  54949. idx = me.indexOf(refNode) || 0;
  54950. me.insert(0, [
  54951. node
  54952. ].concat(me.retrieveChildNodes(node)));
  54953. }
  54954. },
  54955. onNodeRemove: function(parent, node) {
  54956. if (parent === this.getNode()) {
  54957. this.remove([
  54958. node
  54959. ].concat(this.retrieveChildNodes(node)));
  54960. }
  54961. },
  54962. onNodeExpand: function(parent, records) {
  54963. if (parent === this.getNode()) {
  54964. this.loadRecords(records);
  54965. }
  54966. },
  54967. applyNode: function(node) {
  54968. if (node) {
  54969. if (!node.isModel) {
  54970. node = new (this.getModel())(node);
  54971. }
  54972. if (!node.isNode) {
  54973. Ext.data.NodeInterface.decorate(node);
  54974. }
  54975. }
  54976. return node;
  54977. },
  54978. updateNode: function(node, oldNode) {
  54979. var me = this,
  54980. data;
  54981. if (oldNode && !oldNode.destroyed) {
  54982. oldNode.un({
  54983. append: 'onNodeAppend',
  54984. insert: 'onNodeInsert',
  54985. remove: 'onNodeRemove',
  54986. scope: me
  54987. });
  54988. oldNode.unjoin(me);
  54989. }
  54990. if (node) {
  54991. node.on({
  54992. scope: me,
  54993. append: 'onNodeAppend',
  54994. insert: 'onNodeInsert',
  54995. remove: 'onNodeRemove'
  54996. });
  54997. node.join(me);
  54998. data = [];
  54999. if (node.childNodes.length) {
  55000. data = data.concat(me.retrieveChildNodes(node));
  55001. }
  55002. if (me.getRootVisible()) {
  55003. data.push(node);
  55004. } else if (node.isLoaded() || node.isLoading()) {
  55005. node.set('expanded', true);
  55006. }
  55007. me.getData().clear();
  55008. me.fireEvent('clear', me);
  55009. me.suspendEvents();
  55010. if (me.isInitializing) {
  55011. me.inlineData = data;
  55012. } else {
  55013. me.add(data);
  55014. }
  55015. me.resumeEvents();
  55016. if (data.length === 0) {
  55017. me.loaded = node.loaded = true;
  55018. }
  55019. me.fireEvent('refresh', me, me.data);
  55020. }
  55021. },
  55022. isVisible: function(node) {
  55023. var parent = node.parentNode;
  55024. if (!this.getRecursive() && parent !== this.getNode()) {
  55025. return false;
  55026. }
  55027. while (parent) {
  55028. if (!parent.isExpanded()) {
  55029. return false;
  55030. }
  55031. if (parent === this.getNode()) {
  55032. break;
  55033. }
  55034. parent = parent.parentNode;
  55035. }
  55036. return true;
  55037. },
  55038. privates: {
  55039. retrieveChildNodes: function(root) {
  55040. var node = this.getNode(),
  55041. recursive = this.getRecursive(),
  55042. added = [],
  55043. child = root;
  55044. if (!root.childNodes.length || (!recursive && root !== node)) {
  55045. return added;
  55046. }
  55047. if (!recursive) {
  55048. return root.childNodes;
  55049. }
  55050. while (child) {
  55051. if (child._added) {
  55052. delete child._added;
  55053. if (child === root) {
  55054. break;
  55055. } else {
  55056. child = child.nextSibling || child.parentNode;
  55057. }
  55058. } else {
  55059. if (child !== root) {
  55060. added.push(child);
  55061. }
  55062. if (child.firstChild) {
  55063. child._added = true;
  55064. child = child.firstChild;
  55065. } else {
  55066. child = child.nextSibling || child.parentNode;
  55067. }
  55068. }
  55069. }
  55070. return added;
  55071. }
  55072. }
  55073. });
  55074. Ext.define('Ext.data.Request', {
  55075. isDataRequest: true,
  55076. config: {
  55077. action: undefined,
  55078. params: undefined,
  55079. method: 'GET',
  55080. url: null,
  55081. operation: null,
  55082. proxy: null,
  55083. disableCaching: false,
  55084. headers: {},
  55085. callbackKey: null,
  55086. rawRequest: null,
  55087. jsonData: undefined,
  55088. xmlData: undefined,
  55089. withCredentials: false,
  55090. username: null,
  55091. password: null,
  55092. binary: false,
  55093. callback: null,
  55094. scope: null,
  55095. timeout: 30000,
  55096. records: null,
  55097. directFn: null,
  55098. args: null,
  55099. useDefaultXhrHeader: null,
  55100. responseType: null
  55101. },
  55102. constructor: function(config) {
  55103. this.initConfig(config);
  55104. },
  55105. getParam: function(key) {
  55106. var params = this.getParams(),
  55107. val;
  55108. if (params) {
  55109. return params[key];
  55110. }
  55111. return val;
  55112. },
  55113. setParam: function(key, value) {
  55114. var params = this.getParams() || {};
  55115. params[key] = value;
  55116. this.setParams(params);
  55117. }
  55118. });
  55119. Ext.define('Ext.data.TreeStore', {
  55120. extend: Ext.data.Store,
  55121. alias: 'store.tree',
  55122. isTreeStore: true,
  55123. config: {
  55124. root: null,
  55125. rootVisible: false,
  55126. defaultRootProperty: 'children',
  55127. parentIdProperty: null,
  55128. clearOnLoad: true,
  55129. clearRemovedOnLoad: true,
  55130. nodeParam: 'node',
  55131. defaultRootId: 'root',
  55132. defaultRootText: 'Root',
  55133. folderSort: false,
  55134. pageSize: null
  55135. },
  55136. filterer: 'topdown',
  55137. lazyFill: false,
  55138. fillCount: 0,
  55139. bulkUpdate: 0,
  55140. nodesToUnregister: 0,
  55141. _silentOptions: {
  55142. silent: true
  55143. },
  55144. implicitModel: 'Ext.data.TreeModel',
  55145. groupField: null,
  55146. groupDir: null,
  55147. grouper: null,
  55148. constructor: function(config) {
  55149. var me = this;
  55150. me.byIdMap = {};
  55151. me.callParent([
  55152. config
  55153. ]);
  55154. if (Ext.isDefined(me.nodeParameter)) {
  55155. if (Ext.isDefined(Ext.global.console)) {
  55156. Ext.global.console.warn('Ext.data.TreeStore: nodeParameter has been deprecated. Please use nodeParam instead.');
  55157. }
  55158. me.nodeParam = me.nodeParameter;
  55159. delete me.nodeParameter;
  55160. }
  55161. },
  55162. applyFields: function(fields, oldFields) {
  55163. var me = this;
  55164. if (fields) {
  55165. if (me.defaultRootProperty !== me.self.prototype.config.defaultRootProperty) {
  55166. fields = fields.concat({
  55167. name: me.defaultRootProperty,
  55168. type: 'auto',
  55169. defaultValue: null,
  55170. persist: false
  55171. });
  55172. }
  55173. }
  55174. me.callParent([
  55175. fields,
  55176. oldFields
  55177. ]);
  55178. },
  55179. applyGroupField: function(field) {
  55180. return null;
  55181. },
  55182. applyGroupDir: function(dir) {
  55183. return null;
  55184. },
  55185. applyGrouper: function(grouper) {
  55186. if (grouper) {
  55187. Ext.raise('You can\'t group a TreeStore');
  55188. }
  55189. return null;
  55190. },
  55191. group: Ext.emptyFn,
  55192. onSorterEndUpdate: function() {
  55193. var me = this,
  55194. sorterCollection = me.getSorters(),
  55195. sorters = sorterCollection.getRange(),
  55196. rootNode = me.getRoot(),
  55197. folderSort = me.getFolderSort();
  55198. me.fireEvent('beforesort', me, sorters);
  55199. if (rootNode && (folderSort || sorters.length)) {
  55200. if (me.getRemoteSort()) {
  55201. if (sorters.length) {
  55202. me.load({
  55203. callback: function() {
  55204. me.fireEvent('sort', me, sorters);
  55205. }
  55206. });
  55207. }
  55208. } else {
  55209. rootNode.sort(this.getSortFn(), true);
  55210. me.fireEvent('datachanged', me);
  55211. me.fireEvent('refresh', me);
  55212. me.fireEvent('sort', me, sorters);
  55213. }
  55214. } else
  55215. {
  55216. me.fireEvent('sort', me, sorters);
  55217. }
  55218. },
  55219. updateFolderSort: function(folderSort) {
  55220. this.needsFolderSort = folderSort;
  55221. this.onSorterEndUpdate();
  55222. },
  55223. getSortFn: function() {
  55224. return this._sortFn || (this._sortFn = this.createSortFn());
  55225. },
  55226. createSortFn: function() {
  55227. var me = this,
  55228. sortersSortFn = this.sorters.getSortFn();
  55229. return function(node1, node2) {
  55230. var node1FolderOrder, node2FolderOrder,
  55231. result = 0;
  55232. if (me.needsFolderSort) {
  55233. node1FolderOrder = node1.data.leaf ? 1 : 0;
  55234. node2FolderOrder = node2.data.leaf ? 1 : 0;
  55235. result = node1FolderOrder - node2FolderOrder;
  55236. }
  55237. if (me.needsIndexSort && result === 0) {
  55238. result = node1.data.index - node2.data.index;
  55239. }
  55240. return result || sortersSortFn(node1, node2);
  55241. };
  55242. },
  55243. getTotalCount: function() {
  55244. return this.getCount();
  55245. },
  55246. afterEdit: function(node, modifiedFieldNames) {
  55247. var me = this,
  55248. parentNode = node.parentNode,
  55249. rootVisible = me.getRootVisible(),
  55250. isHiddenRoot = !parentNode && !rootVisible,
  55251. prevVisibleNodeIndex,
  55252. isVisible = node.get('visible'),
  55253. toAdd, removeStart;
  55254. if (!isHiddenRoot && isVisible !== me.contains(node)) {
  55255. if (isVisible) {
  55256. if (!parentNode || me.isVisible(node)) {
  55257. toAdd = [
  55258. node
  55259. ];
  55260. if (node.isExpanded()) {
  55261. me.handleNodeExpand(node, node.childNodes, toAdd);
  55262. }
  55263. prevVisibleNodeIndex = node.previousSibling ? me.indexOfPreviousVisibleNode(node.previousSibling) : (parentNode ? me.indexOf(parentNode) : -1);
  55264. me.insert(prevVisibleNodeIndex + 1, toAdd);
  55265. }
  55266. } else
  55267. {
  55268. removeStart = me.indexOf(node);
  55269. me.removeAt(removeStart, me.indexOfNextVisibleNode(node) - removeStart);
  55270. }
  55271. }
  55272. else if (me.getRoot() && me.needsLocalFilter()) {
  55273. me.onFilterEndUpdate(me.getFilters());
  55274. }
  55275. me.callParent([
  55276. node,
  55277. modifiedFieldNames
  55278. ]);
  55279. },
  55280. afterReject: function(record) {
  55281. var me = this;
  55282. if (me.contains(record)) {
  55283. me.onUpdate(record, Ext.data.Model.REJECT, null);
  55284. me.fireEvent('update', me, record, Ext.data.Model.REJECT, null);
  55285. }
  55286. },
  55287. afterCommit: function(record, modifiedFieldNames) {
  55288. var me = this;
  55289. if (!modifiedFieldNames) {
  55290. modifiedFieldNames = null;
  55291. }
  55292. if (me.contains(record)) {
  55293. me.onUpdate(record, Ext.data.Model.COMMIT, modifiedFieldNames);
  55294. me.fireEvent('update', me, record, Ext.data.Model.COMMIT, modifiedFieldNames);
  55295. }
  55296. },
  55297. updateRootVisible: function(rootVisible) {
  55298. var rootNode = this.getRoot(),
  55299. data;
  55300. if (rootNode) {
  55301. data = this.getData();
  55302. if (rootVisible) {
  55303. data.insert(0, rootNode);
  55304. } else {
  55305. data.remove(rootNode);
  55306. }
  55307. }
  55308. },
  55309. updateTrackRemoved: function(trackRemoved) {
  55310. this.callParent(arguments);
  55311. this.removedNodes = this.removed;
  55312. this.removed = null;
  55313. },
  55314. onDestroyRecords: function(records, operation, success) {
  55315. if (success) {
  55316. this.removedNodes.length = 0;
  55317. }
  55318. },
  55319. updateProxy: function(proxy) {
  55320. var reader;
  55321. if (proxy) {
  55322. if (proxy.setIdParam) {
  55323. proxy.setIdParam(this.getNodeParam());
  55324. }
  55325. reader = proxy.getReader();
  55326. if (Ext.isEmpty(reader.getRootProperty())) {
  55327. reader.setRootProperty(this.getDefaultRootProperty());
  55328. }
  55329. }
  55330. },
  55331. setProxy: function(proxy) {
  55332. this.changingProxy = true;
  55333. this.callParent([
  55334. proxy
  55335. ]);
  55336. this.changingProxy = false;
  55337. },
  55338. updateModel: function(model) {
  55339. if (model) {
  55340. var isNode = model.prototype.isNode;
  55341. Ext.data.NodeInterface.decorate(model);
  55342. if (!isNode && !this.changingProxy) {
  55343. this.getProxy().getReader().buildExtractors(true);
  55344. }
  55345. }
  55346. },
  55347. onCollectionFilter: Ext.emptyFn,
  55348. onFilterEndUpdate: function(filters) {
  55349. var me = this,
  55350. length = filters.length,
  55351. root = me.getRoot(),
  55352. childNodes, childNode, filteredNodes, i;
  55353. if (!me.getRemoteFilter()) {
  55354. if (length) {
  55355. me.doFilter(root);
  55356. } else {
  55357. root.cascade({
  55358. after: function(node) {
  55359. node.set('visible', true, me._silentOptions);
  55360. }
  55361. });
  55362. }
  55363. if (length) {
  55364. filteredNodes = [];
  55365. childNodes = root.childNodes;
  55366. for (i = 0 , length = childNodes.length; i < length; i++) {
  55367. childNode = childNodes[i];
  55368. if (childNode.get('visible')) {
  55369. filteredNodes.push(childNode);
  55370. }
  55371. }
  55372. } else {
  55373. filteredNodes = root.childNodes;
  55374. }
  55375. me.onNodeFilter(root, filteredNodes);
  55376. root.fireEvent('filterchange', root, filteredNodes);
  55377. me.suppressNextFilter = true;
  55378. me.callParent([
  55379. filters
  55380. ]);
  55381. me.suppressNextFilter = false;
  55382. } else {
  55383. me.callParent([
  55384. filters
  55385. ]);
  55386. }
  55387. },
  55388. onNodeFilter: function(root, childNodes) {
  55389. var me = this,
  55390. data = me.getData(),
  55391. toAdd = [];
  55392. if (me.getRootVisible() && root.get('visible')) {
  55393. toAdd.push(root);
  55394. }
  55395. me.handleNodeExpand(root, childNodes, toAdd);
  55396. me.suspendEvents();
  55397. data.splice(0, data.getCount(), toAdd);
  55398. me.resumeEvents();
  55399. if (!me.suppressNextFilter) {
  55400. me.fireEvent('datachanged', me);
  55401. me.fireEvent('refresh', me);
  55402. }
  55403. },
  55404. onBeforeNodeExpand: function(node, callback, scope, args) {
  55405. var me = this,
  55406. storeReader, nodeProxy, nodeReader, reader, children, callbackArgs;
  55407. if (node.isLoaded()) {
  55408. callbackArgs = [
  55409. node.childNodes
  55410. ];
  55411. if (args) {
  55412. callbackArgs.push.apply(callbackArgs, args);
  55413. }
  55414. Ext.callback(callback, scope || node, callbackArgs);
  55415. }
  55416. else if (node.isLoading()) {
  55417. me.on('load', function() {
  55418. callbackArgs = [
  55419. node.childNodes
  55420. ];
  55421. if (args) {
  55422. callbackArgs.push.apply(callbackArgs, args);
  55423. }
  55424. Ext.callback(callback, scope || node, callbackArgs);
  55425. }, me, {
  55426. single: true,
  55427. priority: 1001
  55428. });
  55429. } else
  55430. {
  55431. storeReader = me.getProxy().getReader();
  55432. nodeProxy = node.getProxy();
  55433. nodeReader = nodeProxy ? nodeProxy.getReader() : null;
  55434. reader = nodeReader && nodeReader.initialConfig.rootProperty ? nodeReader : storeReader;
  55435. children = reader.getRoot(node.raw || node.data);
  55436. if (children || (node.phantom && !node.isRoot())) {
  55437. me.fillNode(node, reader.extractData(children || [], {
  55438. model: node.childType,
  55439. recordCreator: me.recordCreator
  55440. }));
  55441. callbackArgs = [
  55442. node.childNodes
  55443. ];
  55444. if (args) {
  55445. callbackArgs.push.apply(callbackArgs, args);
  55446. }
  55447. Ext.callback(callback, scope || node, callbackArgs);
  55448. } else
  55449. {
  55450. me.read({
  55451. node: node,
  55452. onChildNodesAvailable: function() {
  55453. delete me.lastOptions.onChildNodesAvailable;
  55454. callbackArgs = [
  55455. node.childNodes
  55456. ];
  55457. if (args) {
  55458. callbackArgs.push.apply(callbackArgs, args);
  55459. }
  55460. Ext.callback(callback, scope || node, callbackArgs);
  55461. }
  55462. });
  55463. me.flushLoad();
  55464. }
  55465. }
  55466. },
  55467. onNodeExpand: function(parent, records) {
  55468. var me = this,
  55469. insertIndex = me.indexOf(parent) + 1,
  55470. toAdd = [];
  55471. me.handleNodeExpand(parent, records, toAdd);
  55472. if (!me.refreshCounter && parent.isRoot() && !parent.get('visible')) {
  55473. me.loadRecords(toAdd);
  55474. } else
  55475. {
  55476. ++me.loadCount;
  55477. me.insert(insertIndex, toAdd);
  55478. }
  55479. },
  55480. handleNodeExpand: function(parent, records, toAdd) {
  55481. var me = this,
  55482. ln = records ? records.length : 0,
  55483. i, record;
  55484. if (parent !== this.getRoot() && !me.isVisible(parent)) {
  55485. return;
  55486. }
  55487. if (ln) {
  55488. for (i = 0; i < ln; i++) {
  55489. record = records[i];
  55490. if (record.get('visible')) {
  55491. toAdd.push(record);
  55492. if (record.isExpanded()) {
  55493. if (record.isLoaded()) {
  55494. me.handleNodeExpand(record, record.childNodes, toAdd);
  55495. } else {
  55496. record.set('expanded', false, {
  55497. silent: true
  55498. });
  55499. record.expand();
  55500. }
  55501. }
  55502. }
  55503. }
  55504. }
  55505. },
  55506. onNodeCollapse: function(parent, records, callback, scope) {
  55507. var me = this,
  55508. collapseIndex = me.indexOf(parent) + 1,
  55509. lastNodeIndexPlus;
  55510. if (me.needsLocalFilter()) {
  55511. records = Ext.Array.filter(records, me.filterVisible);
  55512. }
  55513. if (records.length && me.isVisible(parent)) {
  55514. lastNodeIndexPlus = me.indexOfNextVisibleNode(parent);
  55515. me.removeAt(collapseIndex, lastNodeIndexPlus - collapseIndex);
  55516. }
  55517. Ext.callback(callback, scope);
  55518. },
  55519. indexOfNextVisibleNode: function(node) {
  55520. var result;
  55521. while (node.parentNode) {
  55522. for (result = node.nextSibling; result && !result.get('visible'); result = result.nextSibling) {}
  55523. if (result) {
  55524. return this.indexOf(result);
  55525. }
  55526. node = node.parentNode;
  55527. }
  55528. return this.getCount();
  55529. },
  55530. indexOfPreviousVisibleNode: function(node) {
  55531. var result;
  55532. for (result = node; result && !result.get('visible'); result = result.previousSibling) {}
  55533. if (result) {
  55534. if (result.isExpanded() && result.lastChild) {
  55535. return this.indexOfPreviousVisibleNode(result.lastChild);
  55536. }
  55537. } else
  55538. {
  55539. result = node.parentNode;
  55540. }
  55541. return this.indexOf(result);
  55542. },
  55543. filterNew: function(item) {
  55544. return !item.get('root') && this.callParent([
  55545. item
  55546. ]);
  55547. },
  55548. filterRejects: function(item) {
  55549. return !item.get('root') && this.callParent([
  55550. item
  55551. ]);
  55552. },
  55553. getNewRecords: function() {
  55554. return Ext.Array.filter(Ext.Object.getValues(this.byIdMap), this.filterNew, this);
  55555. },
  55556. getRejectRecords: function() {
  55557. return Ext.Array.filter(Ext.Object.getValues(this.byIdMap), this.filterRejects, this);
  55558. },
  55559. getUpdatedRecords: function() {
  55560. return Ext.Array.filter(Ext.Object.getValues(this.byIdMap), this.filterUpdated);
  55561. },
  55562. beforeNodeRemove: function(parentNode, childNodes, isMove, removeRange) {
  55563. if (!Ext.isArray(childNodes)) {
  55564. childNodes = [
  55565. childNodes
  55566. ];
  55567. }
  55568. var me = this,
  55569. len = childNodes.length,
  55570. removed = me.removedNodes,
  55571. i, startNode;
  55572. for (i = 0; !startNode && i < len; i++) {
  55573. if (childNodes[i].get('visible')) {
  55574. startNode = childNodes[i];
  55575. }
  55576. }
  55577. if (startNode) {
  55578. removeRange[0] = me.indexOf(childNodes[0]);
  55579. removeRange[1] = me.indexOfNextVisibleNode(childNodes[childNodes.length - 1]) - removeRange[0];
  55580. } else {
  55581. removeRange[0] = -1;
  55582. removeRange[1] = 0;
  55583. }
  55584. for (i = 0; i < len; i++) {
  55585. childNodes[i].cascade(function(node) {
  55586. me.unregisterNode(node, true);
  55587. if (removed && !isMove) {
  55588. if (!node.phantom && !node.erasing && !me.loading) {
  55589. node.removedFrom = me.indexOf(node);
  55590. removed.push(node);
  55591. me.needsSync = true;
  55592. }
  55593. }
  55594. });
  55595. }
  55596. },
  55597. afterDrop: Ext.emptyFn,
  55598. onNodeRemove: function(parentNode, childNodes, isMove, removeRange) {
  55599. var me = this;
  55600. me.suspendAutoSync();
  55601. if (removeRange[0] !== -1) {
  55602. me.removeIsMove = isMove;
  55603. me.removeAt.apply(me, removeRange);
  55604. me.removeIsMove = false;
  55605. }
  55606. me.resumeAutoSync();
  55607. },
  55608. onNodeAppend: function(parent, node, index) {
  55609. this.onNodeInsert(parent, node, index);
  55610. },
  55611. onNodeInsert: function(parent, node, index) {
  55612. var me = this,
  55613. data = node.raw || node.data,
  55614. removed = me.removedNodes,
  55615. storeReader, nodeProxy, nodeReader, reader, dataRoot, storeInsertionPoint;
  55616. if (parent && me.needsLocalFilter()) {
  55617. me.doFilter(parent);
  55618. }
  55619. me.beginUpdate();
  55620. if (me.isVisible(node)) {
  55621. if (index === 0 || !node.previousSibling) {
  55622. storeInsertionPoint = me.indexOf(parent);
  55623. } else
  55624. {
  55625. storeInsertionPoint = me.indexOfPreviousVisibleNode(node.previousSibling);
  55626. }
  55627. me.insert(storeInsertionPoint + 1, node);
  55628. if (!node.isLeaf() && node.isExpanded()) {
  55629. if (node.isLoaded()) {
  55630. me.onNodeExpand(node, node.childNodes);
  55631. } else if (!me.fillCount) {
  55632. node.set('expanded', false);
  55633. node.expand();
  55634. }
  55635. }
  55636. }
  55637. Ext.Array.remove(removed, node);
  55638. me.needsSync = me.needsSync || node.phantom || node.dirty;
  55639. if (!node.isLeaf() && !node.isLoaded() && !me.lazyFill) {
  55640. storeReader = me.getProxy().getReader();
  55641. nodeProxy = node.getProxy();
  55642. nodeReader = nodeProxy ? nodeProxy.getReader() : null;
  55643. reader = nodeReader && nodeReader.initialConfig.rootProperty ? nodeReader : storeReader;
  55644. dataRoot = reader.getRoot(data);
  55645. if (dataRoot) {
  55646. me.fillNode(node, reader.extractData(dataRoot, {
  55647. model: node.childType,
  55648. recordCreator: me.recordCreator
  55649. }));
  55650. }
  55651. }
  55652. me.endUpdate();
  55653. },
  55654. registerNode: function(node, includeChildren) {
  55655. var me = this,
  55656. was = me.byIdMap[node.id],
  55657. children, length, i;
  55658. me.byIdMap[node.id] = node;
  55659. if (node.onRegisterTreeNode && node !== was) {
  55660. node.onRegisterTreeNode(me);
  55661. }
  55662. if (node.onUnregisterTreeNode) {
  55663. me.nodesToUnregister++;
  55664. }
  55665. if (includeChildren === true) {
  55666. children = node.childNodes;
  55667. length = children.length;
  55668. for (i = 0; i < length; i++) {
  55669. me.registerNode(children[i], true);
  55670. }
  55671. }
  55672. },
  55673. unregisterNode: function(node, includeChildren) {
  55674. var me = this,
  55675. was = me.byIdMap[node.id],
  55676. children, length, i;
  55677. delete me.byIdMap[node.id];
  55678. if (includeChildren === true) {
  55679. children = node.childNodes;
  55680. length = children.length;
  55681. for (i = 0; i < length; i++) {
  55682. me.unregisterNode(children[i], true);
  55683. }
  55684. }
  55685. if (node.onUnregisterTreeNode && node === was) {
  55686. node.onUnregisterTreeNode(me);
  55687. me.nodesToUnregister--;
  55688. }
  55689. },
  55690. onNodeSort: function(node, childNodes) {
  55691. var me = this;
  55692. me.suspendAutoSync();
  55693. if ((me.indexOf(node) !== -1 && node.isExpanded()) || (node === me.getRoot() && !me.getRootVisible())) {
  55694. Ext.suspendLayouts();
  55695. me.onNodeCollapse(node, childNodes);
  55696. me.onNodeExpand(node, childNodes);
  55697. Ext.resumeLayouts(true);
  55698. }
  55699. me.resumeAutoSync(me.autoSync);
  55700. },
  55701. applyRoot: function(newRoot) {
  55702. var me = this,
  55703. Model = me.getModel(),
  55704. idProperty = Model.prototype.idProperty,
  55705. defaultRootId = me.getDefaultRootId();
  55706. if (newRoot && !newRoot.isNode) {
  55707. newRoot = Ext.apply({
  55708. text: me.getDefaultRootText(),
  55709. root: true,
  55710. isFirst: true,
  55711. isLast: true,
  55712. depth: 0,
  55713. index: 0,
  55714. parentId: null,
  55715. allowDrag: false
  55716. }, newRoot);
  55717. if (defaultRootId && newRoot[idProperty] === undefined) {
  55718. newRoot[idProperty] = defaultRootId;
  55719. }
  55720. newRoot = new Model(newRoot);
  55721. }
  55722. return newRoot;
  55723. },
  55724. updateRoot: function(newRoot, oldRoot) {
  55725. var me = this,
  55726. oldOwner,
  55727. initial = !oldRoot,
  55728. toRemove,
  55729. removeRange = [];
  55730. me.getTrackRemoved();
  55731. me.suspendEvent('add', 'remove');
  55732. if (initial) {
  55733. me.suspendEvent('refresh', 'datachanged');
  55734. }
  55735. if (oldRoot && oldRoot.isModel) {
  55736. if (me.getRootVisible()) {
  55737. toRemove = [
  55738. oldRoot
  55739. ];
  55740. } else {
  55741. toRemove = oldRoot.childNodes;
  55742. }
  55743. me.beforeNodeRemove(null, toRemove, false, removeRange);
  55744. oldRoot.set('root', false);
  55745. me.onNodeRemove(null, toRemove, false, removeRange);
  55746. oldRoot.fireEvent('remove', null, oldRoot, false);
  55747. oldRoot.fireEvent('rootchange', null);
  55748. oldRoot.clearListeners();
  55749. oldRoot.store = oldRoot.treeStore = null;
  55750. me.unregisterNode(oldRoot);
  55751. }
  55752. me.getData().clear();
  55753. if (newRoot) {
  55754. if (newRoot.fireEventArgs('beforeappend', [
  55755. null,
  55756. newRoot
  55757. ]) === false) {
  55758. newRoot = null;
  55759. } else {
  55760. oldOwner = newRoot.parentNode;
  55761. if (oldOwner) {
  55762. if (!oldOwner.removeChild(newRoot, false, false, oldOwner.getTreeStore() === me)) {
  55763. return;
  55764. }
  55765. }
  55766. else if ((oldOwner = newRoot.getTreeStore()) && oldOwner !== me && newRoot === oldOwner.getRoot()) {
  55767. oldOwner.setRoot(null);
  55768. }
  55769. newRoot.store = newRoot.treeStore = me;
  55770. newRoot.set('root', true);
  55771. newRoot.updateInfo(true, {
  55772. isFirst: true,
  55773. isLast: true,
  55774. depth: 0,
  55775. index: 0,
  55776. parentId: null
  55777. });
  55778. me.registerNode(newRoot, true);
  55779. newRoot.fireEvent('append', null, newRoot, false);
  55780. newRoot.fireEvent('rootchange', newRoot);
  55781. me.onNodeAppend(null, newRoot, 0);
  55782. newRoot.phantom = true;
  55783. }
  55784. }
  55785. if (!initial) {
  55786. me.fireEvent('rootchange', newRoot, oldRoot);
  55787. }
  55788. if (newRoot && (me.getAutoLoad() || newRoot.isExpanded())) {
  55789. if (newRoot.isLoaded()) {
  55790. me.onNodeExpand(newRoot, newRoot.childNodes);
  55791. if (!initial) {
  55792. me.fireEvent('datachanged', me);
  55793. me.fireEvent('refresh', me);
  55794. }
  55795. } else
  55796. {
  55797. newRoot.data.expanded = false;
  55798. newRoot.expand(false);
  55799. if (newRoot.isLoaded && !me.getProxy().isSynchronous && !initial) {
  55800. me.fireEvent('datachanged', me);
  55801. me.fireEvent('refresh', me);
  55802. }
  55803. }
  55804. } else if (!initial) {
  55805. me.fireEvent('datachanged', me);
  55806. me.fireEvent('refresh', me);
  55807. }
  55808. me.resumeEvent('add', 'remove');
  55809. if (initial) {
  55810. me.resumeEvent('refresh', 'datachanged');
  55811. }
  55812. },
  55813. doDestroy: function() {
  55814. var me = this,
  55815. root = me.getRoot();
  55816. if (root && me.nodesToUnregister) {
  55817. root.cascade(function(node) {
  55818. if (node.onUnregisterTreeNode) {
  55819. node.onUnregisterTreeNode(me);
  55820. }
  55821. });
  55822. }
  55823. me.callParent();
  55824. },
  55825. each: function(fn, scope, includeOptions) {
  55826. var i = 0,
  55827. filtered = includeOptions,
  55828. includeCollapsed;
  55829. if (includeOptions && typeof includeOptions === 'object') {
  55830. includeCollapsed = includeOptions.collapsed;
  55831. filtered = includeOptions.filtered;
  55832. }
  55833. if (includeCollapsed) {
  55834. this.getRoot().cascade(function(node) {
  55835. if (filtered === true || node.get('visible')) {
  55836. return fn.call(scope || node, node, i++);
  55837. }
  55838. });
  55839. } else {
  55840. return this.callParent([
  55841. fn,
  55842. scope,
  55843. filtered
  55844. ]);
  55845. }
  55846. },
  55847. collect: function(dataIndex, options, filtered) {
  55848. var includeCollapsed,
  55849. map = {},
  55850. result = [],
  55851. allowNull = options,
  55852. strValue, value;
  55853. if (options && typeof options === 'object') {
  55854. includeCollapsed = options.collapsed;
  55855. filtered = options.filtered;
  55856. allowNull = options.allowNull;
  55857. }
  55858. if (includeCollapsed || filtered) {
  55859. this.getRoot().cascade(function(node) {
  55860. if (filtered === true || node.get('visible')) {
  55861. value = node.get(dataIndex);
  55862. strValue = String(value);
  55863. if ((allowNull || !Ext.isEmpty(value)) && !map[strValue]) {
  55864. map[strValue] = 1;
  55865. result.push(value);
  55866. }
  55867. }
  55868. if (!includeCollapsed && !node.isExpanded()) {
  55869. return false;
  55870. }
  55871. });
  55872. } else {
  55873. result = this.callParent([
  55874. dataIndex,
  55875. allowNull,
  55876. filtered
  55877. ]);
  55878. }
  55879. return result;
  55880. },
  55881. getNodeById: function(id) {
  55882. return this.byIdMap[id] || null;
  55883. },
  55884. findNode: function(fieldName, value, startsWith, endsWith, ignoreCase) {
  55885. if (Ext.isEmpty(value, false)) {
  55886. return null;
  55887. }
  55888. if (fieldName === this.model.idProperty && arguments.length < 3) {
  55889. return this.byIdMap[value];
  55890. }
  55891. var regex = Ext.String.createRegex(value, startsWith, endsWith, ignoreCase),
  55892. result = null;
  55893. Ext.Object.eachValue(this.byIdMap, function(node) {
  55894. if (node && regex.test(node.get(fieldName))) {
  55895. result = node;
  55896. return false;
  55897. }
  55898. });
  55899. return result;
  55900. },
  55901. load: function(options) {
  55902. var node = options && options.node;
  55903. if (!node && !(node = this.getRoot())) {
  55904. node = this.setRoot({
  55905. expanded: true,
  55906. autoRoot: true
  55907. });
  55908. return;
  55909. }
  55910. if (node.isLoading()) {
  55911. return;
  55912. }
  55913. return this.callParent([
  55914. options
  55915. ]);
  55916. },
  55917. reload: function(options) {
  55918. var o = Ext.apply({}, options, this.lastOptions);
  55919. o.node = this.getRoot();
  55920. return this.load(o);
  55921. },
  55922. flushLoad: function() {
  55923. var me = this,
  55924. options = me.pendingLoadOptions,
  55925. node, callback, scope,
  55926. clearOnLoad = me.getClearOnLoad(),
  55927. isRootLoad, operation, doClear;
  55928. me.clearLoadTask();
  55929. if (!options) {
  55930. return;
  55931. }
  55932. node = options.node || me.getRoot();
  55933. isRootLoad = node && node.isRoot();
  55934. callback = options.callback;
  55935. scope = options.scope;
  55936. options.params = options.params || {};
  55937. if (node.data.expanded && !isRootLoad) {
  55938. node.data.loaded = false;
  55939. if (clearOnLoad) {
  55940. node.data.expanded = false;
  55941. }
  55942. options.callback = function(loadedNodes, operation, success) {
  55943. if (!clearOnLoad) {
  55944. node.collapse();
  55945. }
  55946. node.expand();
  55947. Ext.callback(callback, scope, [
  55948. loadedNodes,
  55949. operation,
  55950. success
  55951. ]);
  55952. };
  55953. }
  55954. options.id = node.getId();
  55955. me.setLoadOptions(options);
  55956. if (me.getRemoteSort() && options.sorters) {
  55957. me.fireEvent('beforesort', me, options.sorters);
  55958. }
  55959. options = Ext.apply({
  55960. node: options.node || node,
  55961. internalScope: me,
  55962. internalCallback: me.onProxyLoad
  55963. }, options);
  55964. me.lastOptions = Ext.apply({}, options);
  55965. options.isRootLoad = isRootLoad;
  55966. operation = me.createOperation('read', options);
  55967. if (me.fireEvent('beforeload', me, operation) !== false) {
  55968. me.loading = true;
  55969. if (isRootLoad) {
  55970. if (me.getClearRemovedOnLoad()) {
  55971. me.removedNodes.length = 0;
  55972. }
  55973. if (clearOnLoad) {
  55974. me.unregisterNode(node, true);
  55975. node.clear(false, true);
  55976. me.registerNode(node);
  55977. doClear = true;
  55978. }
  55979. } else
  55980. {
  55981. if (me.loading) {
  55982. node.data.loaded = false;
  55983. }
  55984. if (me.getTrackRemoved() && me.getClearRemovedOnLoad()) {
  55985. me.clearRemoved(node);
  55986. }
  55987. if (clearOnLoad) {
  55988. node.removeAll(false);
  55989. }
  55990. }
  55991. if (me.loading && node) {
  55992. node.set('loading', true, {
  55993. silent: !(me.contains(node) || node === me.getRoot())
  55994. });
  55995. }
  55996. if (doClear) {
  55997. me.clearData(true);
  55998. if (me.getRootVisible()) {
  55999. me.suspendEvents();
  56000. me.add(node);
  56001. me.resumeEvents();
  56002. }
  56003. }
  56004. operation.execute();
  56005. }
  56006. return me;
  56007. },
  56008. onProxyLoad: function(operation) {
  56009. var me = this,
  56010. options = operation.initialConfig,
  56011. successful = operation.wasSuccessful(),
  56012. records = operation.getRecords(),
  56013. node = options.node,
  56014. isRootLoad = options.isRootLoad,
  56015. scope = operation.getScope() || me,
  56016. args = [
  56017. records,
  56018. operation,
  56019. successful
  56020. ];
  56021. if (me.destroyed) {
  56022. return;
  56023. }
  56024. me.loading = false;
  56025. node.set('loading', false);
  56026. if (successful) {
  56027. ++me.loadCount;
  56028. if (!me.getClearOnLoad()) {
  56029. records = me.cleanRecords(node, records);
  56030. }
  56031. if (me.getParentIdProperty()) {
  56032. records = me.treeify(node, records);
  56033. }
  56034. if (isRootLoad) {
  56035. me.suspendEvent('add', 'update');
  56036. }
  56037. records = me.fillNode(node, records);
  56038. }
  56039. Ext.callback(options.onChildNodesAvailable, scope, args);
  56040. if (isRootLoad) {
  56041. me.resumeEvent('add', 'update');
  56042. me.callObservers('BeforePopulate');
  56043. me.fireEvent('datachanged', me);
  56044. me.fireEvent('refresh', me);
  56045. me.callObservers('AfterPopulate');
  56046. }
  56047. me.fireEvent('load', me, records, successful, operation, node);
  56048. },
  56049. clearRemoved: function(node) {
  56050. var me = this,
  56051. removed = me.removedNodes,
  56052. id = node.getId(),
  56053. removedLength = removed.length,
  56054. i = removedLength,
  56055. recordsToClear = {},
  56056. newRemoved = [],
  56057. removedHash = {},
  56058. removedNode, targetNode, targetId;
  56059. if (node === me.getRoot()) {
  56060. me.removedNodes.length = 0;
  56061. return;
  56062. }
  56063. for (; i--; ) {
  56064. removedNode = removed[i];
  56065. removedHash[removedNode.getId()] = removedNode;
  56066. }
  56067. for (i = removedLength; i--; ) {
  56068. removedNode = removed[i];
  56069. targetNode = removedNode;
  56070. while (targetNode && targetNode.getId() !== id) {
  56071. targetId = targetNode.get('parentId') || targetNode.get('lastParentId');
  56072. targetNode = targetNode.parentNode || me.getNodeById(targetId) || removedHash[targetId];
  56073. }
  56074. if (targetNode) {
  56075. recordsToClear[removedNode.getId()] = removedNode;
  56076. }
  56077. }
  56078. for (i = 0; i < removedLength; i++) {
  56079. removedNode = removed[i];
  56080. if (!recordsToClear[removedNode.getId()]) {
  56081. newRemoved.push(removedNode);
  56082. }
  56083. }
  56084. me.removedNodes = newRemoved;
  56085. },
  56086. fillNode: function(node, newNodes) {
  56087. var me = this,
  56088. newNodeCount = newNodes ? newNodes.length : 0;
  56089. if (++me.bulkUpdate === 1) {
  56090. me.suspendEvent('datachanged');
  56091. }
  56092. if (newNodeCount) {
  56093. me.setupNodes(newNodes);
  56094. node.appendChild(newNodes, undefined, true);
  56095. } else
  56096. {
  56097. if (me.bulkUpdate === 1) {
  56098. node.set('loaded', true);
  56099. } else {
  56100. node.data.loaded = true;
  56101. }
  56102. }
  56103. if (!--me.bulkUpdate) {
  56104. me.resumeEvent('datachanged');
  56105. }
  56106. return newNodes;
  56107. },
  56108. setupNodes: function(newNodes) {
  56109. var me = this,
  56110. sorters = me.getSorters(),
  56111. needsIndexSort = false,
  56112. newNodeCount = newNodes.length,
  56113. performLocalSort = me.sortOnLoad && newNodeCount > 1 && !me.getRemoteSort() && me.getFolderSort() || sorters.length,
  56114. performLocalFilter = me.needsLocalFilter(),
  56115. node1, node2, i;
  56116. if (performLocalFilter) {
  56117. me.doFilter(newNodes[0]);
  56118. }
  56119. for (i = 1; i < newNodeCount; i++) {
  56120. node1 = newNodes[i];
  56121. node2 = newNodes[i - 1];
  56122. if (performLocalFilter) {
  56123. me.doFilter(node1);
  56124. }
  56125. needsIndexSort = node1.data.index !== node2.data.index;
  56126. }
  56127. if (performLocalSort) {
  56128. me.needsIndexSort = true;
  56129. Ext.Array.sort(newNodes, me.getSortFn());
  56130. me.needsIndexSort = false;
  56131. } else if (needsIndexSort) {
  56132. Ext.Array.sort(newNodes, me.sortByIndex);
  56133. }
  56134. },
  56135. beginFill: function() {
  56136. var me = this;
  56137. if (!me.fillCount++) {
  56138. me.beginUpdate();
  56139. me.suspendEvent('add', 'update');
  56140. me.suspendAutoSync();
  56141. me.fillArray = [];
  56142. }
  56143. },
  56144. endFill: function(parent, nodes) {
  56145. var me = this,
  56146. fillArray = me.fillArray,
  56147. i, len, index;
  56148. fillArray.push(nodes);
  56149. if (!--me.fillCount) {
  56150. me.resumeAutoSync();
  56151. me.resumeEvent('add', 'update');
  56152. for (i = 0 , len = fillArray.length; i < len; i++) {
  56153. index = me.indexOf(fillArray[i][0]);
  56154. if (index !== -1) {
  56155. me.fireEvent('add', me, fillArray[i], index);
  56156. }
  56157. }
  56158. me.fillArray = null;
  56159. me.endUpdate();
  56160. }
  56161. },
  56162. sortByIndex: function(node1, node2) {
  56163. return node1.data.index - node2.data.index;
  56164. },
  56165. onIdChanged: function(node, oldId, newId) {
  56166. var childNodes = node.childNodes,
  56167. len = childNodes && childNodes.length,
  56168. i;
  56169. this.callParent(arguments);
  56170. delete this.byIdMap[oldId];
  56171. this.byIdMap[newId] = node;
  56172. for (i = 0; i < len; i++) {
  56173. childNodes[i].set('parentId', newId);
  56174. }
  56175. },
  56176. treeify: function(parentNode, records) {
  56177. var me = this,
  56178. loadParentNodeId = parentNode.getId(),
  56179. parentIdProperty = me.getParentIdProperty(),
  56180. len = records.length,
  56181. result = [],
  56182. nodeMap = {},
  56183. i, node, parentId, parent, id, children;
  56184. for (i = 0; i < len; i++) {
  56185. node = records[i];
  56186. node.data.depth = 1;
  56187. nodeMap[node.id] = node;
  56188. }
  56189. for (i = 0; i < len; i++) {
  56190. node = records[i];
  56191. parentId = node.data[parentIdProperty];
  56192. if (!(parentId || parentId === 0) || parentId === loadParentNodeId) {
  56193. result.push(node);
  56194. } else {
  56195. if (!nodeMap[parentId]) {
  56196. Ext.raise('Ext.data.TreeStore, Invalid parentId "' + parentId + '"');
  56197. }
  56198. parent = nodeMap[parentId];
  56199. parent.$children = parent.$children || [];
  56200. parent.$children.push(node);
  56201. node.data.depth = parent.data.depth + 1;
  56202. }
  56203. }
  56204. for (id in nodeMap) {
  56205. node = nodeMap[id];
  56206. children = node.$children;
  56207. if (children) {
  56208. delete node.$children;
  56209. me.setupNodes(children);
  56210. node.appendChild(children);
  56211. }
  56212. me.registerNode(node);
  56213. }
  56214. me.setupNodes(result);
  56215. return result;
  56216. },
  56217. cleanRecords: function(node, records) {
  56218. var nodeHash = {},
  56219. childNodes = node.childNodes,
  56220. i = 0,
  56221. len = childNodes.length,
  56222. out = [],
  56223. rec;
  56224. for (; i < len; ++i) {
  56225. nodeHash[childNodes[i].getId()] = true;
  56226. }
  56227. for (i = 0 , len = records.length; i < len; ++i) {
  56228. rec = records[i];
  56229. if (!nodeHash[rec.getId()]) {
  56230. out.push(rec);
  56231. }
  56232. }
  56233. return out;
  56234. },
  56235. removeAll: function() {
  56236. this.suspendEvents();
  56237. this.setRoot(null);
  56238. this.resumeEvents();
  56239. this.callParent();
  56240. },
  56241. doSort: function(sorterFn) {
  56242. var me = this;
  56243. if (me.getRemoteSort()) {
  56244. me.load();
  56245. } else {
  56246. me.tree.sort(sorterFn, true);
  56247. me.fireEvent('datachanged', me);
  56248. me.fireEvent('refresh', me);
  56249. }
  56250. me.fireEvent('sort', me, me.sorters.getRange());
  56251. },
  56252. filterVisible: function(node) {
  56253. return node.get('visible');
  56254. },
  56255. isVisible: function(node) {
  56256. var parentNode = node.parentNode,
  56257. visible = node.data.visible,
  56258. root = this.getRoot();
  56259. while (visible && parentNode) {
  56260. visible = parentNode.data.expanded && parentNode.data.visible;
  56261. parentNode = parentNode.parentNode;
  56262. }
  56263. return visible && !(node === root && !this.getRootVisible());
  56264. },
  56265. commitChanges: function() {
  56266. var removed = this.removedNodes;
  56267. if (removed) {
  56268. removed.length = 0;
  56269. }
  56270. this.callParent();
  56271. },
  56272. getRootNode: function() {
  56273. return this.getRoot();
  56274. },
  56275. setRootNode: function(root) {
  56276. this.setRoot(root);
  56277. return this.getRoot();
  56278. },
  56279. privates: {
  56280. fireChangeEvent: function(record) {
  56281. return !!this.byIdMap[record.id];
  56282. },
  56283. getRawRemovedRecords: function() {
  56284. return this.removedNodes;
  56285. },
  56286. createOperation: function(type, options) {
  56287. var me = this,
  56288. node = options.node,
  56289. proxy;
  56290. if (me.useModelProxy && node && node !== me.getRootNode()) {
  56291. proxy = node.getProxy();
  56292. }
  56293. if (proxy && proxy !== me.getProxy()) {
  56294. return proxy.createOperation(type, options);
  56295. } else {
  56296. return me.callParent([
  56297. type,
  56298. options
  56299. ]);
  56300. }
  56301. },
  56302. recordCreator: function(data, Model) {
  56303. return new Model(data);
  56304. },
  56305. doFilter: function(node) {
  56306. this.filterNodes(node, this.getFilters().getFilterFn(), true);
  56307. },
  56308. filterNodes: function(node, filterFn, parentVisible) {
  56309. var me = this,
  56310. bottomUpFiltering = me.filterer === 'bottomup',
  56311. match = filterFn(node) && parentVisible || (node.isRoot() && !me.getRootVisible()),
  56312. childNodes = node.childNodes,
  56313. len = childNodes && childNodes.length,
  56314. i, matchingChildren;
  56315. if (len) {
  56316. for (i = 0; i < len; ++i) {
  56317. matchingChildren = me.filterNodes(childNodes[i], filterFn, match || bottomUpFiltering) || matchingChildren;
  56318. }
  56319. if (bottomUpFiltering) {
  56320. match = matchingChildren || match;
  56321. }
  56322. }
  56323. node.set("visible", match, me._silentOptions);
  56324. return match;
  56325. },
  56326. needsLocalFilter: function() {
  56327. return !this.getRemoteFilter() && this.getFilters().length;
  56328. },
  56329. onRemoteFilterSet: function(filters, remoteFilter) {
  56330. var data = this.getData();
  56331. data.setFilters(null);
  56332. if (filters) {
  56333. filters.on('endupdate', this.onFilterEndUpdate, this);
  56334. }
  56335. },
  56336. onRemoteSortSet: function(sorters, remoteSort) {
  56337. var data = this.getData();
  56338. data.setSorters(null);
  56339. if (sorters) {
  56340. sorters.on('endupdate', this.onSorterEndUpdate, this);
  56341. }
  56342. }
  56343. },
  56344. deprecated: {
  56345. 5: {
  56346. properties: {
  56347. tree: null
  56348. }
  56349. }
  56350. }
  56351. });
  56352. Ext.define('Ext.data.Types', {
  56353. singleton: true
  56354. }, function(Types) {
  56355. var SortTypes = Ext.data.SortTypes;
  56356. Ext.apply(Types, {
  56357. stripRe: /[\$,%]/g,
  56358. AUTO: {
  56359. sortType: SortTypes.none,
  56360. type: 'auto'
  56361. },
  56362. STRING: {
  56363. convert: function(v) {
  56364. var defaultValue = this.getAllowNull() ? null : '';
  56365. return (v === undefined || v === null) ? defaultValue : String(v);
  56366. },
  56367. sortType: SortTypes.asUCString,
  56368. type: 'string'
  56369. },
  56370. INT: {
  56371. convert: function(v) {
  56372. if (typeof v === 'number') {
  56373. return parseInt(v, 10);
  56374. }
  56375. return v !== undefined && v !== null && v !== '' ? parseInt(String(v).replace(Types.stripRe, ''), 10) : (this.getAllowNull() ? null : 0);
  56376. },
  56377. sortType: SortTypes.none,
  56378. type: 'int'
  56379. },
  56380. FLOAT: {
  56381. convert: function(v) {
  56382. if (typeof v === 'number') {
  56383. return v;
  56384. }
  56385. return v !== undefined && v !== null && v !== '' ? parseFloat(String(v).replace(Types.stripRe, ''), 10) : (this.getAllowNull() ? null : 0);
  56386. },
  56387. sortType: SortTypes.none,
  56388. type: 'float'
  56389. },
  56390. BOOL: {
  56391. convert: function(v) {
  56392. if (typeof v === 'boolean') {
  56393. return v;
  56394. }
  56395. if (this.getAllowNull() && (v === undefined || v === null || v === '')) {
  56396. return null;
  56397. }
  56398. return v === 'true' || v == 1;
  56399. },
  56400. sortType: SortTypes.none,
  56401. type: 'bool'
  56402. },
  56403. DATE: {
  56404. convert: function(v) {
  56405. var df = this.getDateReadFormat() || this.getDateFormat(),
  56406. parsed;
  56407. if (!v) {
  56408. return null;
  56409. }
  56410. if (v instanceof Date) {
  56411. return v;
  56412. }
  56413. if (df) {
  56414. return Ext.Date.parse(v, df);
  56415. }
  56416. parsed = Date.parse(v);
  56417. return parsed ? new Date(parsed) : null;
  56418. },
  56419. sortType: SortTypes.asDate,
  56420. type: 'date'
  56421. }
  56422. });
  56423. Types.BOOLEAN = Types.BOOL;
  56424. Types.INTEGER = Types.INT;
  56425. Types.NUMBER = Types.FLOAT;
  56426. });
  56427. Ext.define('Ext.data.Validation', {
  56428. extend: Ext.data.Model,
  56429. isValidation: true,
  56430. syncGeneration: 0,
  56431. attach: function(record) {
  56432. this.record = record;
  56433. this.isBase = record.self === Ext.data.Model;
  56434. delete this.data.id;
  56435. },
  56436. getValidation: function() {
  56437. return null;
  56438. },
  56439. isValid: function() {
  56440. var me = this;
  56441. if (me.syncGeneration !== me.record.generation) {
  56442. me.refresh();
  56443. }
  56444. return !me.dirty;
  56445. },
  56446. refresh: function(force) {
  56447. if (this.isBase) {
  56448. return;
  56449. }
  56450. var me = this,
  56451. data = me.data,
  56452. record = me.record,
  56453. fields = record.fields,
  56454. generation = record.generation,
  56455. recordData = record.data,
  56456. sep = record.validationSeparator,
  56457. values = null,
  56458. defaultMessage, currentValue, error, field, item, i, j, jLen, len, msg, val, name;
  56459. if (force || me.syncGeneration !== generation) {
  56460. me.syncGeneration = generation;
  56461. for (i = 0 , len = fields.length; i < len; ++i) {
  56462. field = fields[i];
  56463. name = field.name;
  56464. val = recordData[name];
  56465. defaultMessage = field.defaultInvalidMessage;
  56466. error = 0;
  56467. if (!(name in data)) {
  56468. data[name] = currentValue = true;
  56469. } else
  56470. {
  56471. currentValue = data[name];
  56472. }
  56473. if (field.validate !== Ext.emptyFn) {
  56474. msg = field.validate(val, sep, null, record);
  56475. if (msg !== true) {
  56476. error = msg || defaultMessage;
  56477. }
  56478. }
  56479. if (!error) {
  56480. error = true;
  56481. }
  56482. if (error !== currentValue) {
  56483. (values || (values = {}))[name] = error;
  56484. }
  56485. }
  56486. if (values) {
  56487. me.set(values);
  56488. }
  56489. }
  56490. }
  56491. });
  56492. Ext.define('Ext.dom.Helper', function() {
  56493. var afterbegin = 'afterbegin',
  56494. afterend = 'afterend',
  56495. beforebegin = 'beforebegin',
  56496. beforeend = 'beforeend',
  56497. bbValues = [
  56498. 'BeforeBegin',
  56499. 'previousSibling'
  56500. ],
  56501. aeValues = [
  56502. 'AfterEnd',
  56503. 'nextSibling'
  56504. ],
  56505. bb_ae_PositionHash = {
  56506. beforebegin: bbValues,
  56507. afterend: aeValues
  56508. },
  56509. fullPositionHash = {
  56510. beforebegin: bbValues,
  56511. afterend: aeValues,
  56512. afterbegin: [
  56513. 'AfterBegin',
  56514. 'firstChild'
  56515. ],
  56516. beforeend: [
  56517. 'BeforeEnd',
  56518. 'lastChild'
  56519. ]
  56520. };
  56521. return {
  56522. singleton: true,
  56523. alternateClassName: [
  56524. 'Ext.DomHelper',
  56525. 'Ext.core.DomHelper'
  56526. ],
  56527. emptyTags: /^(?:br|frame|hr|img|input|link|meta|range|spacer|wbr|area|param|col)$/i,
  56528. confRe: /^(?:tag|children|cn|html|tpl|tplData)$/i,
  56529. endRe: /end/i,
  56530. attributeTransform: {
  56531. cls: 'class',
  56532. htmlFor: 'for'
  56533. },
  56534. closeTags: {},
  56535. detachedDiv: document.createElement('div'),
  56536. decamelizeName: function() {
  56537. var camelCaseRe = /([a-z])([A-Z])/g,
  56538. cache = {};
  56539. function decamel(match, p1, p2) {
  56540. return p1 + '-' + p2.toLowerCase();
  56541. }
  56542. return function(s) {
  56543. return cache[s] || (cache[s] = s.replace(camelCaseRe, decamel));
  56544. };
  56545. }(),
  56546. generateMarkup: function(spec, buffer) {
  56547. var me = this,
  56548. specType = typeof spec,
  56549. attr, val, tag, i, closeTags;
  56550. if (specType === "string" || specType === "number") {
  56551. buffer.push(spec);
  56552. } else if (Ext.isArray(spec)) {
  56553. for (i = 0; i < spec.length; i++) {
  56554. if (spec[i]) {
  56555. me.generateMarkup(spec[i], buffer);
  56556. }
  56557. }
  56558. } else {
  56559. tag = spec.tag || 'div';
  56560. buffer.push('<', tag);
  56561. for (attr in spec) {
  56562. if (spec.hasOwnProperty(attr)) {
  56563. val = spec[attr];
  56564. if (val !== undefined && !me.confRe.test(attr)) {
  56565. if (val && val.join) {
  56566. val = val.join(' ');
  56567. }
  56568. if (typeof val === "object") {
  56569. buffer.push(' ', attr, '="');
  56570. me.generateStyles(val, buffer, true).push('"');
  56571. } else {
  56572. buffer.push(' ', me.attributeTransform[attr] || attr, '="', val, '"');
  56573. }
  56574. }
  56575. }
  56576. }
  56577. if (me.emptyTags.test(tag)) {
  56578. buffer.push('/>');
  56579. } else {
  56580. buffer.push('>');
  56581. if ((val = spec.tpl)) {
  56582. val.applyOut(spec.tplData, buffer);
  56583. }
  56584. if ((val = spec.html)) {
  56585. buffer.push(val);
  56586. }
  56587. if ((val = spec.cn || spec.children)) {
  56588. me.generateMarkup(val, buffer);
  56589. }
  56590. closeTags = me.closeTags;
  56591. buffer.push(closeTags[tag] || (closeTags[tag] = '</' + tag + '>'));
  56592. }
  56593. }
  56594. return buffer;
  56595. },
  56596. generateStyles: function(styles, buffer, encode) {
  56597. var a = buffer || [],
  56598. name, val;
  56599. for (name in styles) {
  56600. if (styles.hasOwnProperty(name)) {
  56601. val = styles[name];
  56602. name = this.decamelizeName(name);
  56603. if (encode && Ext.String.hasHtmlCharacters(val)) {
  56604. val = Ext.String.htmlEncode(val);
  56605. }
  56606. a.push(name, ':', val, ';');
  56607. }
  56608. }
  56609. return buffer || a.join('');
  56610. },
  56611. markup: function(spec) {
  56612. if (typeof spec === "string") {
  56613. return spec;
  56614. }
  56615. var buf = this.generateMarkup(spec, []);
  56616. return buf.join('');
  56617. },
  56618. applyStyles: function(el, styles) {
  56619. Ext.fly(el).applyStyles(styles);
  56620. },
  56621. createContextualFragment: function(html) {
  56622. var div = this.detachedDiv,
  56623. fragment = document.createDocumentFragment(),
  56624. length, childNodes;
  56625. div.innerHTML = html;
  56626. childNodes = div.childNodes;
  56627. length = childNodes.length;
  56628. while (length--) {
  56629. fragment.appendChild(childNodes[0]);
  56630. }
  56631. return fragment;
  56632. },
  56633. createDom: function(o) {
  56634. var me = this,
  56635. markup = me.markup(o),
  56636. div = me.detachedDiv,
  56637. child;
  56638. div.innerHTML = markup;
  56639. child = div.firstChild;
  56640. return Ext.supports.ChildContentClearedWhenSettingInnerHTML ? child.cloneNode(true) : child;
  56641. },
  56642. insertHtml: function(where, el, html) {
  56643. var me = this,
  56644. hashVal, range, rangeEl, setStart, frag;
  56645. where = where.toLowerCase();
  56646. if (el.insertAdjacentHTML) {
  56647. if (me.ieInsertHtml) {
  56648. frag = me.ieInsertHtml(where, el, html);
  56649. if (frag) {
  56650. return frag;
  56651. }
  56652. }
  56653. hashVal = fullPositionHash[where];
  56654. if (hashVal) {
  56655. el.insertAdjacentHTML(hashVal[0], html);
  56656. return el[hashVal[1]];
  56657. }
  56658. } else
  56659. {
  56660. if (el.nodeType === 3) {
  56661. where = where === afterbegin ? beforebegin : where;
  56662. where = where === beforeend ? afterend : where;
  56663. }
  56664. range = Ext.supports.CreateContextualFragment ? el.ownerDocument.createRange() : undefined;
  56665. setStart = 'setStart' + (this.endRe.test(where) ? 'After' : 'Before');
  56666. if (bb_ae_PositionHash[where]) {
  56667. if (range) {
  56668. range[setStart](el);
  56669. frag = range.createContextualFragment(html);
  56670. } else {
  56671. frag = this.createContextualFragment(html);
  56672. }
  56673. el.parentNode.insertBefore(frag, where === beforebegin ? el : el.nextSibling);
  56674. return el[(where === beforebegin ? 'previous' : 'next') + 'Sibling'];
  56675. } else {
  56676. rangeEl = (where === afterbegin ? 'first' : 'last') + 'Child';
  56677. if (el.firstChild) {
  56678. if (range) {
  56679. try {
  56680. range[setStart](el[rangeEl]);
  56681. frag = range.createContextualFragment(html);
  56682. } catch (e) {
  56683. frag = this.createContextualFragment(html);
  56684. }
  56685. } else {
  56686. frag = this.createContextualFragment(html);
  56687. }
  56688. if (where === afterbegin) {
  56689. el.insertBefore(frag, el.firstChild);
  56690. } else {
  56691. el.appendChild(frag);
  56692. }
  56693. } else {
  56694. el.innerHTML = html;
  56695. }
  56696. return el[rangeEl];
  56697. }
  56698. }
  56699. Ext.raise({
  56700. sourceClass: 'Ext.DomHelper',
  56701. sourceMethod: 'insertHtml',
  56702. htmlToInsert: html,
  56703. targetElement: el,
  56704. msg: 'Illegal insertion point reached: "' + where + '"'
  56705. });
  56706. },
  56707. insertBefore: function(el, o, returnElement) {
  56708. return this.doInsert(el, o, returnElement, beforebegin);
  56709. },
  56710. insertAfter: function(el, o, returnElement) {
  56711. return this.doInsert(el, o, returnElement, afterend);
  56712. },
  56713. insertFirst: function(el, o, returnElement) {
  56714. return this.doInsert(el, o, returnElement, afterbegin);
  56715. },
  56716. append: function(el, o, returnElement) {
  56717. return this.doInsert(el, o, returnElement, beforeend);
  56718. },
  56719. overwrite: function(el, html, returnElement) {
  56720. var me = this,
  56721. newNode;
  56722. el = Ext.getDom(el);
  56723. html = me.markup(html);
  56724. if (me.ieOverwrite) {
  56725. newNode = me.ieOverwrite(el, html);
  56726. }
  56727. if (!newNode) {
  56728. el.innerHTML = html;
  56729. newNode = el.firstChild;
  56730. }
  56731. return returnElement ? Ext.get(newNode) : newNode;
  56732. },
  56733. doInsert: function(el, o, returnElement, where) {
  56734. var me = this,
  56735. newNode;
  56736. el = el.dom || Ext.getDom(el);
  56737. if ('innerHTML' in el) {
  56738. newNode = me.insertHtml(where, el, me.markup(o));
  56739. } else {
  56740. newNode = me.createDom(o, null);
  56741. if (el.nodeType === 3) {
  56742. where = where === afterbegin ? beforebegin : where;
  56743. where = where === beforeend ? afterend : where;
  56744. }
  56745. if (bb_ae_PositionHash[where]) {
  56746. el.parentNode.insertBefore(newNode, where === beforebegin ? el : el.nextSibling);
  56747. } else if (el.firstChild && where === afterbegin) {
  56748. el.insertBefore(newNode, el.firstChild);
  56749. } else {
  56750. el.appendChild(newNode);
  56751. }
  56752. }
  56753. return returnElement ? Ext.get(newNode) : newNode;
  56754. },
  56755. createTemplate: function(o) {
  56756. var html = this.markup(o);
  56757. return new Ext.Template(html);
  56758. },
  56759. createHtml: function(spec) {
  56760. return this.markup(spec);
  56761. }
  56762. };
  56763. });
  56764. Ext.define('Ext.dom.Query', function() {
  56765. var DQ,
  56766. doc = document,
  56767. cache, simpleCache, valueCache,
  56768. useClassList = !!doc.documentElement.classList,
  56769. useElementPointer = !!doc.documentElement.firstElementChild,
  56770. useChildrenCollection = (function() {
  56771. var d = doc.createElement('div');
  56772. d.innerHTML = '<!-- -->text<!-- -->';
  56773. return d.children && (d.children.length === 0);
  56774. })(),
  56775. nonSpace = /\S/,
  56776. trimRe = /^\s+|\s+$/g,
  56777. tplRe = /\{(\d+)\}/g,
  56778. modeRe = /^(\s?[\/>+~]\s?|\s|$)/,
  56779. tagTokenRe = /^(#)?([\w\-\*\|\\]+)/,
  56780. nthRe = /(\d*)n\+?(\d*)/,
  56781. nthRe2 = /\D/,
  56782. startIdRe = /^\s*#/,
  56783. isIE = window.ActiveXObject ? true : false,
  56784. key = 30803,
  56785. longHex = /\\([0-9a-fA-F]{6})/g,
  56786. shortHex = /\\([0-9a-fA-F]{1,6})\s{0,1}/g,
  56787. nonHex = /\\([^0-9a-fA-F]{1})/g,
  56788. escapes = /\\/g,
  56789. num, hasEscapes,
  56790. supportsColonNsSeparator = (function() {
  56791. var xmlDoc,
  56792. xmlString = '<r><a:b xmlns:a="n"></a:b></r>';
  56793. if (window.DOMParser) {
  56794. xmlDoc = (new DOMParser()).parseFromString(xmlString, "application/xml");
  56795. } else {
  56796. xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
  56797. xmlDoc.loadXML(xmlString);
  56798. }
  56799. return !!xmlDoc.getElementsByTagName('a:b').length;
  56800. })(),
  56801. longHexToChar = function($0, $1) {
  56802. return String.fromCharCode(parseInt($1, 16));
  56803. },
  56804. shortToLongHex = function($0, $1) {
  56805. while ($1.length < 6) {
  56806. $1 = '0' + $1;
  56807. }
  56808. return '\\' + $1;
  56809. },
  56810. charToLongHex = function($0, $1) {
  56811. num = $1.charCodeAt(0).toString(16);
  56812. if (num.length === 1) {
  56813. num = '0' + num;
  56814. }
  56815. return '\\0000' + num;
  56816. },
  56817. unescapeCssSelector = function(selector) {
  56818. return (hasEscapes) ? selector.replace(longHex, longHexToChar) : selector;
  56819. },
  56820. setupEscapes = function(path) {
  56821. hasEscapes = (path.indexOf('\\') > -1);
  56822. if (hasEscapes) {
  56823. path = path.replace(shortHex, shortToLongHex).replace(nonHex, charToLongHex).replace(escapes, '\\\\');
  56824. }
  56825. return path;
  56826. };
  56827. eval("var batch = 30803, child, next, prev, byClassName;");
  56828. child = useChildrenCollection ? function child(parent, index) {
  56829. return parent.children[index];
  56830. } : function child(parent, index) {
  56831. var i = 0,
  56832. n = parent.firstChild;
  56833. while (n) {
  56834. if (n.nodeType == 1) {
  56835. if (++i == index) {
  56836. return n;
  56837. }
  56838. }
  56839. n = n.nextSibling;
  56840. }
  56841. return null;
  56842. };
  56843. next = useElementPointer ? function(n) {
  56844. return n.nextElementSibling;
  56845. } : function(n) {
  56846. while ((n = n.nextSibling) && n.nodeType != 1){}
  56847. return n;
  56848. };
  56849. prev = useElementPointer ? function(n) {
  56850. return n.previousElementSibling;
  56851. } : function(n) {
  56852. while ((n = n.previousSibling) && n.nodeType != 1){}
  56853. return n;
  56854. };
  56855. function children(parent) {
  56856. var n = parent.firstChild,
  56857. nodeIndex = -1,
  56858. nextNode;
  56859. while (n) {
  56860. nextNode = n.nextSibling;
  56861. if (n.nodeType == 3 && !nonSpace.test(n.nodeValue)) {
  56862. parent.removeChild(n);
  56863. } else {
  56864. n.nodeIndex = ++nodeIndex;
  56865. }
  56866. n = nextNode;
  56867. }
  56868. return this;
  56869. }
  56870. byClassName = useClassList ?
  56871. function(nodeSet, cls) {
  56872. cls = unescapeCssSelector(cls);
  56873. if (!cls) {
  56874. return nodeSet;
  56875. }
  56876. var result = [],
  56877. ri = -1,
  56878. i, ci, classList;
  56879. for (i = 0; ci = nodeSet[i]; i++) {
  56880. classList = ci.classList;
  56881. if (classList) {
  56882. if (classList.contains(cls)) {
  56883. result[++ri] = ci;
  56884. }
  56885. } else if ((' ' + ci.className + ' ').indexOf(cls) !== -1) {
  56886. result[++ri] = ci;
  56887. }
  56888. }
  56889. return result;
  56890. } : function(nodeSet, cls) {
  56891. cls = unescapeCssSelector(cls);
  56892. if (!cls) {
  56893. return nodeSet;
  56894. }
  56895. var result = [],
  56896. ri = -1,
  56897. i, ci;
  56898. for (i = 0; ci = nodeSet[i]; i++) {
  56899. if ((' ' + ci.className + ' ').indexOf(cls) !== -1) {
  56900. result[++ri] = ci;
  56901. }
  56902. }
  56903. return result;
  56904. };
  56905. function attrValue(n, attr) {
  56906. if (!n.tagName && typeof n.length != "undefined") {
  56907. n = n[0];
  56908. }
  56909. if (!n) {
  56910. return null;
  56911. }
  56912. if (attr == "for") {
  56913. return n.htmlFor;
  56914. }
  56915. if (attr == "class" || attr == "className") {
  56916. return n.className;
  56917. }
  56918. return n.getAttribute(attr) || n[attr];
  56919. }
  56920. function getNodes(ns, mode, tagName) {
  56921. var result = [],
  56922. ri = -1,
  56923. cs, i, ni, j, ci, cn, utag, n, cj;
  56924. if (!ns) {
  56925. return result;
  56926. }
  56927. tagName = tagName.replace('|', ':') || "*";
  56928. if (typeof ns.getElementsByTagName != "undefined") {
  56929. ns = [
  56930. ns
  56931. ];
  56932. }
  56933. if (!mode) {
  56934. tagName = unescapeCssSelector(tagName);
  56935. if (!supportsColonNsSeparator && DQ.isXml(ns[0]) && tagName.indexOf(':') !== -1) {
  56936. for (i = 0; ni = ns[i]; i++) {
  56937. cs = ni.getElementsByTagName(tagName.split(':').pop());
  56938. for (j = 0; ci = cs[j]; j++) {
  56939. if (ci.tagName === tagName) {
  56940. result[++ri] = ci;
  56941. }
  56942. }
  56943. }
  56944. } else {
  56945. for (i = 0; ni = ns[i]; i++) {
  56946. cs = ni.getElementsByTagName(tagName);
  56947. for (j = 0; ci = cs[j]; j++) {
  56948. result[++ri] = ci;
  56949. }
  56950. }
  56951. }
  56952. }
  56953. else if (mode == "/" || mode == ">") {
  56954. utag = tagName.toUpperCase();
  56955. for (i = 0; ni = ns[i]; i++) {
  56956. cn = ni.childNodes;
  56957. for (j = 0; cj = cn[j]; j++) {
  56958. if (cj.nodeName == utag || cj.nodeName == tagName || tagName == '*') {
  56959. result[++ri] = cj;
  56960. }
  56961. }
  56962. }
  56963. }
  56964. else if (mode == "+") {
  56965. utag = tagName.toUpperCase();
  56966. for (i = 0; n = ns[i]; i++) {
  56967. while ((n = n.nextSibling) && n.nodeType != 1){}
  56968. if (n && (n.nodeName == utag || n.nodeName == tagName || tagName == '*')) {
  56969. result[++ri] = n;
  56970. }
  56971. }
  56972. }
  56973. else if (mode == "~") {
  56974. utag = tagName.toUpperCase();
  56975. for (i = 0; n = ns[i]; i++) {
  56976. while ((n = n.nextSibling)) {
  56977. if (n.nodeName == utag || n.nodeName == tagName || tagName == '*') {
  56978. result[++ri] = n;
  56979. }
  56980. }
  56981. }
  56982. }
  56983. return result;
  56984. }
  56985. function concat(a, b) {
  56986. a.push.apply(a, b);
  56987. return a;
  56988. }
  56989. function byTag(cs, tagName) {
  56990. if (cs.tagName || cs === doc) {
  56991. cs = [
  56992. cs
  56993. ];
  56994. }
  56995. if (!tagName) {
  56996. return cs;
  56997. }
  56998. var result = [],
  56999. ri = -1,
  57000. i, ci;
  57001. tagName = tagName.toLowerCase();
  57002. for (i = 0; ci = cs[i]; i++) {
  57003. if (ci.nodeType == 1 && ci.tagName.toLowerCase() == tagName) {
  57004. result[++ri] = ci;
  57005. }
  57006. }
  57007. return result;
  57008. }
  57009. function byId(cs, id) {
  57010. id = unescapeCssSelector(id);
  57011. if (cs.tagName || cs === doc) {
  57012. cs = [
  57013. cs
  57014. ];
  57015. }
  57016. if (!id) {
  57017. return cs;
  57018. }
  57019. var result = [],
  57020. ri = -1,
  57021. i, ci;
  57022. for (i = 0; ci = cs[i]; i++) {
  57023. if (ci && ci.id == id) {
  57024. result[++ri] = ci;
  57025. return result;
  57026. }
  57027. }
  57028. return result;
  57029. }
  57030. function byAttribute(cs, attr, value, op, custom) {
  57031. var result = [],
  57032. ri = -1,
  57033. useGetStyle = custom == "{",
  57034. fn = DQ.operators[op],
  57035. a, xml, hasXml, i, ci;
  57036. value = unescapeCssSelector(value);
  57037. for (i = 0; ci = cs[i]; i++) {
  57038. if (ci.nodeType === 1) {
  57039. if (!hasXml) {
  57040. xml = DQ.isXml(ci);
  57041. hasXml = true;
  57042. }
  57043. if (!xml) {
  57044. if (useGetStyle) {
  57045. a = DQ.getStyle(ci, attr);
  57046. } else if (attr == "class" || attr == "className") {
  57047. a = ci.className;
  57048. } else if (attr == "for") {
  57049. a = ci.htmlFor;
  57050. } else if (attr == "href") {
  57051. a = ci.getAttribute("href", 2);
  57052. } else {
  57053. a = ci.getAttribute(attr);
  57054. }
  57055. } else {
  57056. a = ci.getAttribute(attr);
  57057. }
  57058. if ((fn && fn(a, value)) || (!fn && a)) {
  57059. result[++ri] = ci;
  57060. }
  57061. }
  57062. }
  57063. return result;
  57064. }
  57065. function byPseudo(cs, name, value) {
  57066. value = unescapeCssSelector(value);
  57067. return DQ.pseudos[name](cs, value);
  57068. }
  57069. function nodupIEXml(cs) {
  57070. var d = ++key,
  57071. r, i, len, c;
  57072. cs[0].setAttribute("_nodup", d);
  57073. r = [
  57074. cs[0]
  57075. ];
  57076. for (i = 1 , len = cs.length; i < len; i++) {
  57077. c = cs[i];
  57078. if (!c.getAttribute("_nodup") != d) {
  57079. c.setAttribute("_nodup", d);
  57080. r[r.length] = c;
  57081. }
  57082. }
  57083. for (i = 0 , len = cs.length; i < len; i++) {
  57084. cs[i].removeAttribute("_nodup");
  57085. }
  57086. return r;
  57087. }
  57088. function nodup(cs) {
  57089. if (!cs) {
  57090. return [];
  57091. }
  57092. var len = cs.length,
  57093. c, i,
  57094. r = cs,
  57095. cj,
  57096. ri = -1,
  57097. d, j;
  57098. if (!len || typeof cs.nodeType != "undefined" || len == 1) {
  57099. return cs;
  57100. }
  57101. if (isIE && typeof cs[0].selectSingleNode != "undefined") {
  57102. return nodupIEXml(cs);
  57103. }
  57104. d = ++key;
  57105. cs[0]._nodup = d;
  57106. for (i = 1; c = cs[i]; i++) {
  57107. if (c._nodup != d) {
  57108. c._nodup = d;
  57109. } else {
  57110. r = [];
  57111. for (j = 0; j < i; j++) {
  57112. r[++ri] = cs[j];
  57113. }
  57114. for (j = i + 1; cj = cs[j]; j++) {
  57115. if (cj._nodup != d) {
  57116. cj._nodup = d;
  57117. r[++ri] = cj;
  57118. }
  57119. }
  57120. return r;
  57121. }
  57122. }
  57123. return r;
  57124. }
  57125. function quickDiffIEXml(c1, c2) {
  57126. var d = ++key,
  57127. r = [],
  57128. i, len;
  57129. for (i = 0 , len = c1.length; i < len; i++) {
  57130. c1[i].setAttribute("_qdiff", d);
  57131. }
  57132. for (i = 0 , len = c2.length; i < len; i++) {
  57133. if (c2[i].getAttribute("_qdiff") != d) {
  57134. r[r.length] = c2[i];
  57135. }
  57136. }
  57137. for (i = 0 , len = c1.length; i < len; i++) {
  57138. c1[i].removeAttribute("_qdiff");
  57139. }
  57140. return r;
  57141. }
  57142. function quickDiff(c1, c2) {
  57143. var len1 = c1.length,
  57144. d = ++key,
  57145. r = [],
  57146. i, len;
  57147. if (!len1) {
  57148. return c2;
  57149. }
  57150. if (isIE && typeof c1[0].selectSingleNode != "undefined") {
  57151. return quickDiffIEXml(c1, c2);
  57152. }
  57153. for (i = 0; i < len1; i++) {
  57154. c1[i]._qdiff = d;
  57155. }
  57156. for (i = 0 , len = c2.length; i < len; i++) {
  57157. if (c2[i]._qdiff != d) {
  57158. r[r.length] = c2[i];
  57159. }
  57160. }
  57161. return r;
  57162. }
  57163. function quickId(ns, mode, root, id) {
  57164. if (ns == root) {
  57165. id = unescapeCssSelector(id);
  57166. var d = root.ownerDocument || root;
  57167. return d.getElementById(id);
  57168. }
  57169. ns = getNodes(ns, mode, "*");
  57170. return byId(ns, id);
  57171. }
  57172. return {
  57173. singleton: true,
  57174. alternateClassName: [
  57175. 'Ext.core.DomQuery',
  57176. 'Ext.DomQuery'
  57177. ],
  57178. _init: function() {
  57179. DQ = this;
  57180. DQ.operators = Ext.Object.chain(Ext.util.Operators);
  57181. DQ._cache = cache = new Ext.util.LruCache({
  57182. maxSize: 200
  57183. });
  57184. DQ._valueCache = valueCache = new Ext.util.LruCache({
  57185. maxSize: 200
  57186. });
  57187. DQ._simpleCache = simpleCache = new Ext.util.LruCache({
  57188. maxSize: 200
  57189. });
  57190. },
  57191. clearCache: function() {
  57192. cache.clear();
  57193. valueCache.clear();
  57194. simpleCache.clear();
  57195. },
  57196. getStyle: function(el, name) {
  57197. return Ext.fly(el, '_DomQuery').getStyle(name);
  57198. },
  57199. compile: function(path, type) {
  57200. type = type || "select";
  57201. var fn = [
  57202. "var f = function(root) {\n var mode; ++batch; var n = root || document;\n"
  57203. ],
  57204. lastPath,
  57205. matchers = DQ.matchers,
  57206. matchersLn = matchers.length,
  57207. modeMatch,
  57208. lmode = path.match(modeRe),
  57209. tokenMatch, matched, j, t, m;
  57210. path = setupEscapes(path);
  57211. if (lmode && lmode[1]) {
  57212. fn[fn.length] = 'mode="' + lmode[1].replace(trimRe, "") + '";';
  57213. path = path.replace(lmode[1], "");
  57214. }
  57215. while (path.substr(0, 1) == "/") {
  57216. path = path.substr(1);
  57217. }
  57218. while (path && lastPath != path) {
  57219. lastPath = path;
  57220. tokenMatch = path.match(tagTokenRe);
  57221. if (type == "select") {
  57222. if (tokenMatch) {
  57223. if (tokenMatch[1] == "#") {
  57224. fn[fn.length] = 'n = quickId(n, mode, root, "' + tokenMatch[2] + '");';
  57225. } else {
  57226. fn[fn.length] = 'n = getNodes(n, mode, "' + tokenMatch[2] + '");';
  57227. }
  57228. path = path.replace(tokenMatch[0], "");
  57229. } else if (path.substr(0, 1) != '@') {
  57230. fn[fn.length] = 'n = getNodes(n, mode, "*");';
  57231. }
  57232. } else
  57233. {
  57234. if (tokenMatch) {
  57235. if (tokenMatch[1] == "#") {
  57236. fn[fn.length] = 'n = byId(n, "' + tokenMatch[2] + '");';
  57237. } else {
  57238. fn[fn.length] = 'n = byTag(n, "' + tokenMatch[2] + '");';
  57239. }
  57240. path = path.replace(tokenMatch[0], "");
  57241. }
  57242. }
  57243. while (!(modeMatch = path.match(modeRe))) {
  57244. matched = false;
  57245. for (j = 0; j < matchersLn; j++) {
  57246. t = matchers[j];
  57247. m = path.match(t.re);
  57248. if (m) {
  57249. fn[fn.length] = t.select.replace(tplRe, function(x, i) {
  57250. return m[i];
  57251. });
  57252. path = path.replace(m[0], "");
  57253. matched = true;
  57254. break;
  57255. }
  57256. }
  57257. if (!matched) {
  57258. Ext.raise({
  57259. sourceClass: 'Ext.DomQuery',
  57260. sourceMethod: 'compile',
  57261. msg: 'Error parsing selector. Parsing failed at "' + path + '"'
  57262. });
  57263. }
  57264. }
  57265. if (modeMatch[1]) {
  57266. fn[fn.length] = 'mode="' + modeMatch[1].replace(trimRe, "") + '";';
  57267. path = path.replace(modeMatch[1], "");
  57268. }
  57269. }
  57270. fn[fn.length] = "return nodup(n);\n}";
  57271. eval(fn.join(""));
  57272. return f;
  57273. },
  57274. jsSelect: function(path, root, type) {
  57275. root = root || doc;
  57276. if (typeof root == "string") {
  57277. root = doc.getElementById(root);
  57278. }
  57279. var paths = Ext.splitAndUnescape(path, ","),
  57280. results = [],
  57281. query, i, len, subPath, result;
  57282. for (i = 0 , len = paths.length; i < len; i++) {
  57283. subPath = paths[i].replace(trimRe, "");
  57284. query = cache.get(subPath);
  57285. if (!query) {
  57286. query = DQ.compile(subPath, type);
  57287. if (!query) {
  57288. Ext.raise({
  57289. sourceClass: 'Ext.DomQuery',
  57290. sourceMethod: 'jsSelect',
  57291. msg: subPath + ' is not a valid selector'
  57292. });
  57293. }
  57294. cache.add(subPath, query);
  57295. } else {
  57296. setupEscapes(subPath);
  57297. }
  57298. result = query(root);
  57299. if (result && result !== doc) {
  57300. results = results.concat(result);
  57301. }
  57302. }
  57303. if (paths.length > 1) {
  57304. return nodup(results);
  57305. }
  57306. return results;
  57307. },
  57308. isXml: function(el) {
  57309. var docEl = (el ? el.ownerDocument || el : 0).documentElement;
  57310. return docEl ? docEl.nodeName !== "HTML" : false;
  57311. },
  57312. select: doc.querySelectorAll ? function(path, root, type, single) {
  57313. root = root || doc;
  57314. if (!DQ.isXml(root)) {
  57315. try {
  57316. if (root.parentNode && (root.nodeType !== 9) && path.indexOf(',') === -1 && !startIdRe.test(path)) {
  57317. path = Ext.makeIdSelector(Ext.id(root)) + ' ' + path;
  57318. root = root.parentNode;
  57319. }
  57320. return single ? [
  57321. root.querySelector(path)
  57322. ] : Ext.Array.toArray(root.querySelectorAll(path));
  57323. } catch (e) {}
  57324. }
  57325. return DQ.jsSelect.call(this, path, root, type);
  57326. } : function(path, root, type) {
  57327. return DQ.jsSelect.call(this, path, root, type);
  57328. },
  57329. selectNode: function(path, root) {
  57330. return Ext.DomQuery.select(path, root, null, true)[0];
  57331. },
  57332. selectValue: function(path, root, defaultValue) {
  57333. path = path.replace(trimRe, "");
  57334. var query = valueCache.get(path),
  57335. n, v;
  57336. if (!query) {
  57337. query = DQ.compile(path, "select");
  57338. valueCache.add(path, query);
  57339. } else {
  57340. setupEscapes(path);
  57341. }
  57342. n = query(root);
  57343. return DQ.getNodeValue(n[0] || n, defaultValue);
  57344. },
  57345. getNodeValue: function(node, defaultValue) {
  57346. if (typeof node.normalize == 'function') {
  57347. node.normalize();
  57348. }
  57349. var firstChild = node && node.firstChild,
  57350. v = firstChild ? firstChild.nodeValue : null;
  57351. if (defaultValue !== undefined && (v == null || v === '')) {
  57352. v = defaultValue;
  57353. }
  57354. return v;
  57355. },
  57356. selectNumber: function(path, root, defaultValue) {
  57357. var v = DQ.selectValue(path, root, defaultValue || 0);
  57358. return parseFloat(v);
  57359. },
  57360. is: function(el, ss) {
  57361. if (typeof el == "string") {
  57362. el = doc.getElementById(el);
  57363. }
  57364. var isArray = Ext.isArray(el),
  57365. result = DQ.filter(isArray ? el : [
  57366. el
  57367. ], ss);
  57368. return isArray ? (result.length == el.length) : (result.length > 0);
  57369. },
  57370. filter: function(els, ss, nonMatches) {
  57371. ss = ss.replace(trimRe, "");
  57372. var query = simpleCache.get(ss),
  57373. result;
  57374. if (!query) {
  57375. query = DQ.compile(ss, "simple");
  57376. simpleCache.add(ss, query);
  57377. } else {
  57378. setupEscapes(ss);
  57379. }
  57380. result = query(els);
  57381. return nonMatches ? quickDiff(result, els) : result;
  57382. },
  57383. matchers: [
  57384. {
  57385. re: /^\.([\w\-\\]+)/,
  57386. select: useClassList ? 'n = byClassName(n, "{1}");' : 'n = byClassName(n, " {1} ");'
  57387. },
  57388. {
  57389. re: /^\:([\w\-]+)(?:\(((?:[^\s>\/]*|.*?))\))?/,
  57390. select: 'n = byPseudo(n, "{1}", "{2}");'
  57391. },
  57392. {
  57393. re: /^(?:([\[\{])(?:@)?([\w\-]+)\s?(?:(=|.=)\s?['"]?(.*?)["']?)?[\]\}])/,
  57394. select: 'n = byAttribute(n, "{2}", "{4}", "{3}", "{1}");'
  57395. },
  57396. {
  57397. re: /^#([\w\-\\]+)/,
  57398. select: 'n = byId(n, "{1}");'
  57399. },
  57400. {
  57401. re: /^@([\w\-\.]+)/,
  57402. select: 'return {firstChild:{nodeValue:attrValue(n, "{1}")}};'
  57403. }
  57404. ],
  57405. pseudos: {
  57406. "first-child": function(c) {
  57407. var r = [],
  57408. ri = -1,
  57409. n, i, ci;
  57410. for (i = 0; (ci = n = c[i]); i++) {
  57411. while ((n = n.previousSibling) && n.nodeType != 1){}
  57412. if (!n) {
  57413. r[++ri] = ci;
  57414. }
  57415. }
  57416. return r;
  57417. },
  57418. "last-child": function(c) {
  57419. var r = [],
  57420. ri = -1,
  57421. n, i, ci;
  57422. for (i = 0; (ci = n = c[i]); i++) {
  57423. while ((n = n.nextSibling) && n.nodeType != 1){}
  57424. if (!n) {
  57425. r[++ri] = ci;
  57426. }
  57427. }
  57428. return r;
  57429. },
  57430. "nth-child": function(c, a) {
  57431. var r = [],
  57432. ri = -1,
  57433. m = nthRe.exec(a == "even" && "2n" || a == "odd" && "2n+1" || !nthRe2.test(a) && "n+" + a || a),
  57434. f = (m[1] || 1) - 0,
  57435. l = m[2] - 0,
  57436. i, n, j, cn, pn;
  57437. for (i = 0; n = c[i]; i++) {
  57438. pn = n.parentNode;
  57439. if (batch != pn._batch) {
  57440. j = 0;
  57441. for (cn = pn.firstChild; cn; cn = cn.nextSibling) {
  57442. if (cn.nodeType == 1) {
  57443. cn.nodeIndex = ++j;
  57444. }
  57445. }
  57446. pn._batch = batch;
  57447. }
  57448. if (f == 1) {
  57449. if (l === 0 || n.nodeIndex == l) {
  57450. r[++ri] = n;
  57451. }
  57452. } else if ((n.nodeIndex + l) % f === 0) {
  57453. r[++ri] = n;
  57454. }
  57455. }
  57456. return r;
  57457. },
  57458. "only-child": function(c) {
  57459. var r = [],
  57460. ri = -1,
  57461. i, ci;
  57462. for (i = 0; ci = c[i]; i++) {
  57463. if (!prev(ci) && !next(ci)) {
  57464. r[++ri] = ci;
  57465. }
  57466. }
  57467. return r;
  57468. },
  57469. "empty": function(c) {
  57470. var r = [],
  57471. ri = -1,
  57472. i, ci, cns, j, cn, empty;
  57473. for (i = 0; ci = c[i]; i++) {
  57474. cns = ci.childNodes;
  57475. j = 0;
  57476. empty = true;
  57477. while (cn = cns[j]) {
  57478. ++j;
  57479. if (cn.nodeType == 1 || cn.nodeType == 3) {
  57480. empty = false;
  57481. break;
  57482. }
  57483. }
  57484. if (empty) {
  57485. r[++ri] = ci;
  57486. }
  57487. }
  57488. return r;
  57489. },
  57490. "contains": function(c, v) {
  57491. var r = [],
  57492. ri = -1,
  57493. i, ci;
  57494. for (i = 0; ci = c[i]; i++) {
  57495. if ((ci.textContent || ci.innerText || ci.text || '').indexOf(v) != -1) {
  57496. r[++ri] = ci;
  57497. }
  57498. }
  57499. return r;
  57500. },
  57501. "nodeValue": function(c, v) {
  57502. var r = [],
  57503. ri = -1,
  57504. i, ci;
  57505. for (i = 0; ci = c[i]; i++) {
  57506. if (ci.firstChild && ci.firstChild.nodeValue == v) {
  57507. r[++ri] = ci;
  57508. }
  57509. }
  57510. return r;
  57511. },
  57512. "checked": function(c) {
  57513. var r = [],
  57514. ri = -1,
  57515. i, ci;
  57516. for (i = 0; ci = c[i]; i++) {
  57517. if (ci.checked === true) {
  57518. r[++ri] = ci;
  57519. }
  57520. }
  57521. return r;
  57522. },
  57523. "not": function(c, ss) {
  57524. return DQ.filter(c, ss, true);
  57525. },
  57526. "any": function(c, selectors) {
  57527. var ss = selectors.split('|'),
  57528. r = [],
  57529. ri = -1,
  57530. s, i, ci, j;
  57531. for (i = 0; ci = c[i]; i++) {
  57532. for (j = 0; s = ss[j]; j++) {
  57533. if (DQ.is(ci, s)) {
  57534. r[++ri] = ci;
  57535. break;
  57536. }
  57537. }
  57538. }
  57539. return r;
  57540. },
  57541. "odd": function(c) {
  57542. return this["nth-child"](c, "odd");
  57543. },
  57544. "even": function(c) {
  57545. return this["nth-child"](c, "even");
  57546. },
  57547. "nth": function(c, a) {
  57548. return c[a - 1] || [];
  57549. },
  57550. "first": function(c) {
  57551. return c[0] || [];
  57552. },
  57553. "last": function(c) {
  57554. return c[c.length - 1] || [];
  57555. },
  57556. "has": function(c, ss) {
  57557. var s = DQ.select,
  57558. r = [],
  57559. ri = -1,
  57560. i, ci;
  57561. for (i = 0; ci = c[i]; i++) {
  57562. if (s(ss, ci).length > 0) {
  57563. r[++ri] = ci;
  57564. }
  57565. }
  57566. return r;
  57567. },
  57568. "next": function(c, ss) {
  57569. var is = DQ.is,
  57570. r = [],
  57571. ri = -1,
  57572. i, ci, n;
  57573. for (i = 0; ci = c[i]; i++) {
  57574. n = next(ci);
  57575. if (n && is(n, ss)) {
  57576. r[++ri] = ci;
  57577. }
  57578. }
  57579. return r;
  57580. },
  57581. "prev": function(c, ss) {
  57582. var is = DQ.is,
  57583. r = [],
  57584. ri = -1,
  57585. i, ci, n;
  57586. for (i = 0; ci = c[i]; i++) {
  57587. n = prev(ci);
  57588. if (n && is(n, ss)) {
  57589. r[++ri] = ci;
  57590. }
  57591. }
  57592. return r;
  57593. },
  57594. focusable: function(candidates) {
  57595. var len = candidates.length,
  57596. results = [],
  57597. i = 0,
  57598. c;
  57599. for (; i < len; i++) {
  57600. c = candidates[i];
  57601. if (Ext.fly(c, '_DomQuery').isFocusable()) {
  57602. results.push(c);
  57603. }
  57604. }
  57605. return results;
  57606. },
  57607. visible: function(candidates, deep) {
  57608. var len = candidates.length,
  57609. results = [],
  57610. i = 0,
  57611. c;
  57612. for (; i < len; i++) {
  57613. c = candidates[i];
  57614. if (Ext.fly(c, '_DomQuery').isVisible(deep)) {
  57615. results.push(c);
  57616. }
  57617. }
  57618. return results;
  57619. },
  57620. isScrolled: function(c) {
  57621. var r = [],
  57622. ri = -1,
  57623. i, ci, s;
  57624. for (i = 0; ci = c[i]; i++) {
  57625. s = Ext.fly(ci, '_DomQuery').getScroll();
  57626. if (s.top > 0 || s.left > 0) {
  57627. r[++ri] = ci;
  57628. }
  57629. }
  57630. return r;
  57631. }
  57632. }
  57633. };
  57634. }, function() {
  57635. this._init();
  57636. });
  57637. Ext.define('Ext.data.reader.Xml', {
  57638. extend: Ext.data.reader.Reader,
  57639. alternateClassName: 'Ext.data.XmlReader',
  57640. alias: 'reader.xml',
  57641. config: {
  57642. record: '',
  57643. namespace: ''
  57644. },
  57645. responseType: 'document',
  57646. createAccessor: function(expr) {
  57647. if (Ext.isEmpty(expr)) {
  57648. return Ext.emptyFn;
  57649. }
  57650. if (Ext.isFunction(expr)) {
  57651. return expr;
  57652. }
  57653. return function(root) {
  57654. return this.getNodeValue(Ext.DomQuery.selectNode(expr, root));
  57655. };
  57656. },
  57657. getNodeValue: function(node) {
  57658. if (node) {
  57659. if (typeof node.normalize === 'function') {
  57660. node.normalize();
  57661. }
  57662. node = node.firstChild;
  57663. if (node) {
  57664. return node.nodeValue;
  57665. }
  57666. }
  57667. return undefined;
  57668. },
  57669. getResponseData: function(response) {
  57670. var xml = response.responseXML,
  57671. error = 'XML data not found in the response';
  57672. if (!xml) {
  57673. Ext.Logger.warn(error);
  57674. return this.createReadError(error);
  57675. }
  57676. return xml;
  57677. },
  57678. getData: function(data) {
  57679. return data.documentElement || data;
  57680. },
  57681. getRoot: function(data) {
  57682. return this.getRootValue(data, this.getRootProperty());
  57683. },
  57684. extractData: function(root, readOptions) {
  57685. var recordName = this.getRecord();
  57686. if (!recordName) {
  57687. Ext.raise('Record is a required parameter');
  57688. }
  57689. if (recordName !== root.nodeName) {
  57690. root = Ext.DomQuery.select(recordName, root);
  57691. } else {
  57692. root = [
  57693. root
  57694. ];
  57695. }
  57696. return this.callParent([
  57697. root,
  57698. readOptions
  57699. ]);
  57700. },
  57701. readRecords: function(doc, readOptions, internalReadOptions) {
  57702. if (Ext.isArray(doc)) {
  57703. doc = doc[0];
  57704. }
  57705. return this.callParent([
  57706. doc,
  57707. readOptions,
  57708. internalReadOptions
  57709. ]);
  57710. },
  57711. createFieldAccessor: function(field) {
  57712. var namespace = this.getNamespace(),
  57713. selector, autoMapping, result;
  57714. if (field.mapping) {
  57715. selector = field.mapping;
  57716. } else {
  57717. selector = (namespace ? namespace + '|' : '') + field.name;
  57718. autoMapping = true;
  57719. }
  57720. if (typeof selector === 'function') {
  57721. result = function(raw, self) {
  57722. return field.mapping(raw, self);
  57723. };
  57724. } else {
  57725. if (autoMapping && !namespace && Ext.supports.XmlQuerySelector) {
  57726. result = function(raw, self) {
  57727. return self.getNodeValue(raw.querySelector(selector));
  57728. };
  57729. }
  57730. if (!result) {
  57731. result = function(raw, self) {
  57732. return self.getNodeValue(Ext.DomQuery.selectNode(selector, raw));
  57733. };
  57734. }
  57735. }
  57736. return result;
  57737. },
  57738. privates: {
  57739. getGroupRoot: function(data) {
  57740. return this.getRootValue(data, this.getGroupRootProperty());
  57741. },
  57742. getRootValue: function(data, prop) {
  57743. var nodeName = data.nodeName;
  57744. if (!prop || (nodeName && nodeName == prop)) {
  57745. return data;
  57746. } else if (typeof prop === 'function') {
  57747. return prop(data);
  57748. } else if (Ext.DomQuery.isXml(data)) {
  57749. return Ext.DomQuery.selectNode(prop, data);
  57750. }
  57751. },
  57752. getSummaryRoot: function(data) {
  57753. return this.getRootValue(data, this.getSummaryRootProperty());
  57754. }
  57755. },
  57756. deprecated: {
  57757. '5.1.1': {
  57758. properties: {
  57759. xmlData: null
  57760. }
  57761. }
  57762. }
  57763. });
  57764. Ext.define('Ext.data.writer.Xml', {
  57765. extend: Ext.data.writer.Writer,
  57766. alternateClassName: 'Ext.data.XmlWriter',
  57767. alias: 'writer.xml',
  57768. config: {
  57769. documentRoot: 'xmlData',
  57770. defaultDocumentRoot: 'xmlData',
  57771. header: '',
  57772. record: 'record'
  57773. },
  57774. selectorRe: /[^>\s]+/g,
  57775. writeRecords: function(request, data) {
  57776. var me = this,
  57777. xml = [],
  57778. i = 0,
  57779. len = data.length,
  57780. root = me.getDocumentRoot(),
  57781. recordName = me.getRecord(),
  57782. record = recordName.match(this.selectorRe),
  57783. recLen = record.length,
  57784. needsRoot = data.length !== 1 && recLen === 1,
  57785. transform;
  57786. transform = this.getTransform();
  57787. if (transform) {
  57788. data = transform(data, request);
  57789. }
  57790. xml.push(me.getHeader() || '');
  57791. if (!root && needsRoot) {
  57792. root = me.getDefaultDocumentRoot();
  57793. }
  57794. if (root) {
  57795. xml.push('<', root, '>');
  57796. }
  57797. for (i = 0; i < recLen - 1; i++) {
  57798. xml.push('<', record[i], '>');
  57799. }
  57800. recordName = record[i];
  57801. for (i = 0; i < len; ++i) {
  57802. this.objectToElement(recordName, data[i], xml);
  57803. }
  57804. for (i = recLen - 2; i > -1; i--) {
  57805. xml.push('</', record[i], '>');
  57806. }
  57807. if (root) {
  57808. xml.push('</', root, '>');
  57809. }
  57810. request.setXmlData(xml.join(''));
  57811. return request;
  57812. },
  57813. objectToElement: function(name, o, output) {
  57814. var key, datum,
  57815. subOutput = [],
  57816. subKeys, subKeyLen, i, subObject, subObjects, lastObject, lastKey;
  57817. if (!output) {
  57818. output = [];
  57819. }
  57820. output.push('<', name);
  57821. for (key in o) {
  57822. datum = o[key];
  57823. if (key[0] === '@') {
  57824. output.push(' ', key.substr(1), '="', datum, '"');
  57825. } else
  57826. {
  57827. if (typeof datum === 'object') {
  57828. this.objectToElement(key, datum, subOutput);
  57829. } else {
  57830. subKeys = key.match(this.selectorRe);
  57831. if ((subKeyLen = subKeys.length) > 1) {
  57832. subObjects = subObjects || {};
  57833. for (subObject = subObjects , i = 0; i < subKeyLen; i++) {
  57834. lastObject = subObject;
  57835. lastKey = subKeys[i];
  57836. subObject = subObject[lastKey] || (subObject[lastKey] = {});
  57837. }
  57838. lastObject[lastKey] = datum;
  57839. } else {
  57840. subOutput.push('<', key, '>', datum, '</', key, '>');
  57841. }
  57842. }
  57843. }
  57844. }
  57845. output.push('>');
  57846. output.push.apply(output, subOutput);
  57847. if (subObjects) {
  57848. for (key in subObjects) {
  57849. datum = subObjects[key];
  57850. this.objectToElement(key, datum, output);
  57851. }
  57852. }
  57853. output.push('</', name, '>');
  57854. return output;
  57855. }
  57856. });
  57857. Ext.define('Ext.data.XmlStore', {
  57858. extend: Ext.data.Store,
  57859. alias: 'store.xml',
  57860. constructor: function(config) {
  57861. config = Ext.apply({
  57862. proxy: {
  57863. type: 'ajax',
  57864. reader: 'xml',
  57865. writer: 'xml'
  57866. }
  57867. }, config);
  57868. this.callParent([
  57869. config
  57870. ]);
  57871. }
  57872. });
  57873. Ext.define('Ext.data.identifier.Negative', {
  57874. extend: Ext.data.identifier.Sequential,
  57875. alias: 'data.identifier.negative',
  57876. config: {
  57877. increment: -1,
  57878. seed: -1
  57879. }
  57880. });
  57881. Ext.define('Ext.data.identifier.Uuid', {
  57882. extend: Ext.data.identifier.Generator,
  57883. alias: 'data.identifier.uuid',
  57884. isUnique: true,
  57885. config: {
  57886. id: null
  57887. },
  57888. constructor: function(config) {
  57889. this.callParent([
  57890. config
  57891. ]);
  57892. this.reconfigure(config);
  57893. },
  57894. reconfigure: function(config) {
  57895. var cls = this.self;
  57896. this.generate = (config && config.version === 1) ? cls.createSequential(config.salt, config.timestamp, config.clockSeq) : cls.createRandom();
  57897. },
  57898. clone: null,
  57899. statics: {
  57900. createRandom: function() {
  57901. var pattern = 'xxxxxxxx-xxxx-4xxx-Rxxx-xMxxxxxxxxxx'.split(''),
  57902. hex = '0123456789abcdef'.split(''),
  57903. length = pattern.length,
  57904. parts = [];
  57905. return function() {
  57906. for (var r, c,
  57907. i = 0; i < length; ++i) {
  57908. c = pattern[i];
  57909. if (c !== '-' && c !== '4') {
  57910. r = Math.random() * 16;
  57911. r = (c === 'R') ? (r & 3 | 8) : (r | ((c === 'M') ? 1 : 0));
  57912. c = hex[r];
  57913. }
  57914. parts[i] = c;
  57915. }
  57916. return parts.join('');
  57917. };
  57918. },
  57919. createSequential: function(salt, time, clockSeq) {
  57920. var parts = [],
  57921. twoPow32 = Math.pow(2, 32),
  57922. saltLo = salt.lo,
  57923. saltHi = salt.hi,
  57924. timeLo = time.lo,
  57925. timeHi = time.hi,
  57926. toHex = function(value, length) {
  57927. var ret = value.toString(16).toLowerCase();
  57928. if (ret.length > length) {
  57929. ret = ret.substring(ret.length - length);
  57930. }
  57931. else if (ret.length < length) {
  57932. ret = Ext.String.leftPad(ret, length, '0');
  57933. }
  57934. return ret;
  57935. };
  57936. if (typeof salt === 'number') {
  57937. saltHi = Math.floor(salt / twoPow32);
  57938. saltLo = Math.floor(salt - saltHi * twoPow32);
  57939. }
  57940. if (typeof time === 'number') {
  57941. timeHi = Math.floor(time / twoPow32);
  57942. timeLo = Math.floor(time - timeHi * twoPow32);
  57943. }
  57944. saltHi |= 256;
  57945. parts[3] = toHex(128 | ((clockSeq >>> 8) & 63), 2) + toHex(clockSeq & 255, 2);
  57946. parts[4] = toHex(saltHi, 4) + toHex(saltLo, 8);
  57947. return function() {
  57948. parts[0] = toHex(timeLo, 8);
  57949. parts[1] = toHex(timeHi & 65535, 4);
  57950. parts[2] = toHex(((timeHi >>> 16) & 4095) | (1 << 12), 4);
  57951. ++timeLo;
  57952. if (timeLo >= twoPow32) {
  57953. timeLo = 0;
  57954. ++timeHi;
  57955. }
  57956. return parts.join('-');
  57957. };
  57958. }
  57959. }
  57960. }, function() {
  57961. this.Global = new this({
  57962. id: 'uuid'
  57963. });
  57964. });
  57965. Ext.define('Ext.data.proxy.WebStorage', {
  57966. extend: Ext.data.proxy.Client,
  57967. alternateClassName: 'Ext.data.WebStorageProxy',
  57968. config: {
  57969. id: undefined
  57970. },
  57971. constructor: function(config) {
  57972. this.callParent(arguments);
  57973. this.cache = {};
  57974. if (this.getStorageObject() === undefined) {
  57975. Ext.raise("Local Storage is not supported in this browser, please use another type of data proxy");
  57976. }
  57977. if (this.getId() === undefined) {
  57978. Ext.raise("No unique id was provided to the local storage proxy. See Ext.data.proxy.LocalStorage documentation for details");
  57979. }
  57980. this.initialize();
  57981. },
  57982. create: function(operation) {
  57983. var me = this,
  57984. records = operation.getRecords(),
  57985. length = records.length,
  57986. ids = me.getIds(),
  57987. id, record, i, identifier;
  57988. if (me.isHierarchical === undefined) {
  57989. me.isHierarchical = !!records[0].isNode;
  57990. if (me.isHierarchical) {
  57991. me.getStorageObject().setItem(me.getTreeKey(), true);
  57992. }
  57993. }
  57994. for (i = 0; i < length; i++) {
  57995. record = records[i];
  57996. if (record.phantom) {
  57997. identifier = record.identifier;
  57998. if (identifier && identifier.isUnique) {
  57999. id = record.getId();
  58000. } else {
  58001. id = me.getNextId();
  58002. }
  58003. } else {
  58004. id = record.getId();
  58005. }
  58006. me.setRecord(record, id);
  58007. record.commit();
  58008. ids.push(id);
  58009. }
  58010. me.setIds(ids);
  58011. operation.setSuccessful(true);
  58012. },
  58013. read: function(operation) {
  58014. var me = this,
  58015. allRecords,
  58016. records = [],
  58017. success = true,
  58018. Model = me.getModel(),
  58019. validCount = 0,
  58020. recordCreator = operation.getRecordCreator(),
  58021. filters, sorters, limit, filterLen, valid, record, ids, length, data, id, i, j;
  58022. if (me.isHierarchical) {
  58023. records = me.getTreeData();
  58024. } else {
  58025. ids = me.getIds();
  58026. length = ids.length;
  58027. id = operation.getId();
  58028. if (id) {
  58029. data = me.getRecord(id);
  58030. if (data !== null) {
  58031. record = recordCreator ? recordCreator(data, Model) : new Model(data);
  58032. }
  58033. if (record) {
  58034. records.push(record);
  58035. } else {
  58036. success = false;
  58037. }
  58038. } else {
  58039. sorters = operation.getSorters();
  58040. filters = operation.getFilters();
  58041. limit = operation.getLimit();
  58042. allRecords = [];
  58043. for (i = 0; i < length; i++) {
  58044. data = me.getRecord(ids[i]);
  58045. record = recordCreator ? recordCreator(data, Model) : new Model(data);
  58046. allRecords.push(record);
  58047. }
  58048. if (sorters) {
  58049. Ext.Array.sort(allRecords, Ext.util.Sorter.createComparator(sorters));
  58050. }
  58051. for (i = operation.getStart() || 0; i < length; i++) {
  58052. record = allRecords[i];
  58053. valid = true;
  58054. if (filters) {
  58055. for (j = 0 , filterLen = filters.length; j < filterLen; j++) {
  58056. valid = filters[j].filter(record);
  58057. }
  58058. }
  58059. if (valid) {
  58060. records.push(record);
  58061. validCount++;
  58062. }
  58063. if (limit && validCount === limit) {
  58064. break;
  58065. }
  58066. }
  58067. }
  58068. }
  58069. if (success) {
  58070. operation.setResultSet(new Ext.data.ResultSet({
  58071. records: records,
  58072. total: records.length,
  58073. loaded: true
  58074. }));
  58075. operation.setSuccessful(true);
  58076. } else {
  58077. operation.setException('Unable to load records');
  58078. }
  58079. },
  58080. update: function(operation) {
  58081. var records = operation.getRecords(),
  58082. length = records.length,
  58083. ids = this.getIds(),
  58084. record, id, i;
  58085. for (i = 0; i < length; i++) {
  58086. record = records[i];
  58087. this.setRecord(record);
  58088. record.commit();
  58089. id = record.getId();
  58090. if (id !== undefined && Ext.Array.indexOf(ids, id) === -1) {
  58091. ids.push(id);
  58092. }
  58093. }
  58094. this.setIds(ids);
  58095. operation.setSuccessful(true);
  58096. },
  58097. erase: function(operation) {
  58098. var me = this,
  58099. records = operation.getRecords(),
  58100. ids = me.getIds(),
  58101. idLength = ids.length,
  58102. newIds = [],
  58103. removedHash = {},
  58104. i = records.length,
  58105. id;
  58106. for (; i--; ) {
  58107. Ext.apply(removedHash, me.removeRecord(records[i]));
  58108. }
  58109. for (i = 0; i < idLength; i++) {
  58110. id = ids[i];
  58111. if (!removedHash[id]) {
  58112. newIds.push(id);
  58113. }
  58114. }
  58115. me.setIds(newIds);
  58116. operation.setSuccessful(true);
  58117. },
  58118. getRecord: function(id) {
  58119. var me = this,
  58120. cache = me.cache,
  58121. data = !cache[id] ? Ext.decode(me.getStorageObject().getItem(me.getRecordKey(id))) : cache[id];
  58122. if (!data) {
  58123. return null;
  58124. }
  58125. cache[id] = data;
  58126. data[me.getModel().prototype.idProperty] = id;
  58127. return Ext.merge({}, data);
  58128. },
  58129. setRecord: function(record, id) {
  58130. if (id) {
  58131. record.set('id', id, {
  58132. commit: true
  58133. });
  58134. } else {
  58135. id = record.getId();
  58136. }
  58137. var me = this,
  58138. rawData = record.getData(),
  58139. data = {},
  58140. model = me.getModel(),
  58141. fields = model.getFields(),
  58142. length = fields.length,
  58143. i = 0,
  58144. field, name, obj, key, value;
  58145. for (; i < length; i++) {
  58146. field = fields[i];
  58147. name = field.name;
  58148. if (field.persist) {
  58149. value = rawData[name];
  58150. if (field.isDateField && field.dateFormat && Ext.isDate(value)) {
  58151. value = Ext.Date.format(value, field.dateFormat);
  58152. } else if (field.serialize) {
  58153. value = field.serialize(value, record);
  58154. }
  58155. data[name] = value;
  58156. }
  58157. }
  58158. delete data[model.prototype.idProperty];
  58159. if (record.isNode && record.get('depth') === 1) {
  58160. delete data.parentId;
  58161. }
  58162. obj = me.getStorageObject();
  58163. key = me.getRecordKey(id);
  58164. me.cache[id] = data;
  58165. obj.removeItem(key);
  58166. obj.setItem(key, Ext.encode(data));
  58167. },
  58168. removeRecord: function(record) {
  58169. var me = this,
  58170. id = record.getId(),
  58171. records = {},
  58172. i, childNodes;
  58173. records[id] = record;
  58174. me.getStorageObject().removeItem(me.getRecordKey(id));
  58175. delete me.cache[id];
  58176. if (record.childNodes) {
  58177. childNodes = record.childNodes;
  58178. for (i = childNodes.length; i--; ) {
  58179. Ext.apply(records, me.removeRecord(childNodes[i]));
  58180. }
  58181. }
  58182. return records;
  58183. },
  58184. getRecordKey: function(id) {
  58185. if (id.isModel) {
  58186. id = id.getId();
  58187. }
  58188. return Ext.String.format("{0}-{1}", this.getId(), id);
  58189. },
  58190. getRecordCounterKey: function() {
  58191. return Ext.String.format("{0}-counter", this.getId());
  58192. },
  58193. getTreeKey: function() {
  58194. return Ext.String.format("{0}-tree", this.getId());
  58195. },
  58196. getIds: function() {
  58197. var me = this,
  58198. ids = (me.getStorageObject().getItem(me.getId()) || "").split(","),
  58199. length = ids.length,
  58200. isString = this.getIdField().isStringField,
  58201. i;
  58202. if (length === 1 && ids[0] === "") {
  58203. ids = [];
  58204. } else {
  58205. for (i = 0; i < length; i++) {
  58206. ids[i] = isString ? ids[i] : +ids[i];
  58207. }
  58208. }
  58209. return ids;
  58210. },
  58211. getIdField: function() {
  58212. return this.getModel().prototype.idField;
  58213. },
  58214. setIds: function(ids) {
  58215. var obj = this.getStorageObject(),
  58216. str = ids.join(","),
  58217. id = this.getId();
  58218. obj.removeItem(id);
  58219. if (!Ext.isEmpty(str)) {
  58220. obj.setItem(id, str);
  58221. }
  58222. },
  58223. getNextId: function() {
  58224. var me = this,
  58225. obj = me.getStorageObject(),
  58226. key = me.getRecordCounterKey(),
  58227. isString = me.getIdField().isStringField,
  58228. id;
  58229. id = me.idGenerator.generate();
  58230. obj.setItem(key, id);
  58231. if (isString) {
  58232. id = id + '';
  58233. }
  58234. return id;
  58235. },
  58236. getTreeData: function() {
  58237. var me = this,
  58238. ids = me.getIds(),
  58239. length = ids.length,
  58240. records = [],
  58241. recordHash = {},
  58242. root = [],
  58243. i = 0,
  58244. Model = me.getModel(),
  58245. idProperty = Model.prototype.idProperty,
  58246. rootLength, record, parent, parentId, children, id;
  58247. for (; i < length; i++) {
  58248. id = ids[i];
  58249. record = me.getRecord(id);
  58250. records.push(record);
  58251. recordHash[id] = record;
  58252. if (!record.parentId) {
  58253. root.push(record);
  58254. }
  58255. }
  58256. rootLength = root.length;
  58257. Ext.Array.sort(records, me.sortByParentId);
  58258. for (i = rootLength; i < length; i++) {
  58259. record = records[i];
  58260. parentId = record.parentId;
  58261. if (!parent || parent[idProperty] !== parentId) {
  58262. parent = recordHash[parentId];
  58263. parent.children = children = [];
  58264. }
  58265. children.push(record);
  58266. }
  58267. for (i = length; i--; ) {
  58268. record = records[i];
  58269. if (!record.children && !record.leaf) {
  58270. record.loaded = true;
  58271. }
  58272. }
  58273. for (i = rootLength; i--; ) {
  58274. record = root[i];
  58275. root[i] = new Model(record);
  58276. }
  58277. return root;
  58278. },
  58279. sortByParentId: function(node1, node2) {
  58280. return (node1.parentId || 0) - (node2.parentId || 0);
  58281. },
  58282. initialize: function() {
  58283. var me = this,
  58284. storageObject = me.getStorageObject(),
  58285. lastId = +storageObject.getItem(me.getRecordCounterKey()),
  58286. id = me.getId();
  58287. storageObject.setItem(id, storageObject.getItem(id) || "");
  58288. if (storageObject.getItem(me.getTreeKey())) {
  58289. me.isHierarchical = true;
  58290. }
  58291. me.idGenerator = new Ext.data.identifier.Sequential({
  58292. seed: lastId ? lastId + 1 : 1
  58293. });
  58294. },
  58295. clear: function() {
  58296. var me = this,
  58297. obj = me.getStorageObject(),
  58298. ids = me.getIds(),
  58299. len = ids.length,
  58300. i;
  58301. for (i = 0; i < len; i++) {
  58302. obj.removeItem(me.getRecordKey(ids[i]));
  58303. }
  58304. obj.removeItem(me.getRecordCounterKey());
  58305. obj.removeItem(me.getTreeKey());
  58306. obj.removeItem(me.getId());
  58307. me.cache = {};
  58308. },
  58309. getStorageObject: function() {
  58310. Ext.raise("The getStorageObject function has not been defined in your Ext.data.proxy.WebStorage subclass");
  58311. }
  58312. });
  58313. Ext.define('Ext.data.proxy.LocalStorage', {
  58314. extend: Ext.data.proxy.WebStorage,
  58315. alias: 'proxy.localstorage',
  58316. alternateClassName: 'Ext.data.LocalStorageProxy',
  58317. getStorageObject: function() {
  58318. return window.localStorage;
  58319. }
  58320. });
  58321. Ext.define('Ext.data.proxy.Rest', {
  58322. extend: Ext.data.proxy.Ajax,
  58323. alternateClassName: 'Ext.data.RestProxy',
  58324. alias: 'proxy.rest',
  58325. defaultActionMethods: {
  58326. create: 'POST',
  58327. read: 'GET',
  58328. update: 'PUT',
  58329. destroy: 'DELETE'
  58330. },
  58331. slashRe: /\/$/,
  58332. periodRe: /\.$/,
  58333. config: {
  58334. appendId: true,
  58335. format: null,
  58336. batchActions: false,
  58337. actionMethods: {
  58338. create: 'POST',
  58339. read: 'GET',
  58340. update: 'PUT',
  58341. destroy: 'DELETE'
  58342. }
  58343. },
  58344. buildUrl: function(request) {
  58345. var me = this,
  58346. operation = request.getOperation(),
  58347. records = operation.getRecords(),
  58348. record = records ? records[0] : null,
  58349. format = me.getFormat(),
  58350. url = me.getUrl(request),
  58351. id, params;
  58352. if (record && !record.phantom) {
  58353. id = record.getId();
  58354. } else {
  58355. id = operation.getId();
  58356. }
  58357. if (me.getAppendId() && me.isValidId(id)) {
  58358. if (!url.match(me.slashRe)) {
  58359. url += '/';
  58360. }
  58361. url += encodeURIComponent(id);
  58362. params = request.getParams();
  58363. if (params) {
  58364. delete params[me.getIdParam()];
  58365. }
  58366. }
  58367. if (format) {
  58368. if (!url.match(me.periodRe)) {
  58369. url += '.';
  58370. }
  58371. url += format;
  58372. }
  58373. request.setUrl(url);
  58374. return me.callParent([
  58375. request
  58376. ]);
  58377. },
  58378. isValidId: function(id) {
  58379. return id || id === 0;
  58380. }
  58381. });
  58382. Ext.define('Ext.data.proxy.SessionStorage', {
  58383. extend: Ext.data.proxy.WebStorage,
  58384. alias: 'proxy.sessionstorage',
  58385. alternateClassName: 'Ext.data.SessionStorageProxy',
  58386. getStorageObject: function() {
  58387. return window.sessionStorage;
  58388. }
  58389. });
  58390. Ext.define('Ext.data.summary.Base', {
  58391. mixins: [
  58392. Ext.mixin.Factoryable
  58393. ],
  58394. alias: 'data.summary.base',
  58395. isAggregator: true,
  58396. factoryConfig: {
  58397. defaultType: 'base',
  58398. cacheable: true
  58399. },
  58400. constructor: function(config) {
  58401. var calculate = config && config.calculate;
  58402. if (calculate) {
  58403. config = Ext.apply({}, config);
  58404. delete config.calculate;
  58405. this.calculate = calculate;
  58406. }
  58407. this.initConfig(config);
  58408. },
  58409. extractValue: function(record, property, root) {
  58410. var ret;
  58411. if (record) {
  58412. if (root) {
  58413. record = record[root];
  58414. }
  58415. ret = record[property];
  58416. }
  58417. return ret;
  58418. }
  58419. }, function() {
  58420. Ext.Factory.on('dataSummary', function(factory, config) {
  58421. if (typeof config === 'function') {
  58422. return factory({
  58423. calculate: config
  58424. });
  58425. }
  58426. });
  58427. });
  58428. Ext.define('Ext.data.summary.Sum', {
  58429. extend: Ext.data.summary.Base,
  58430. alias: 'data.summary.sum',
  58431. calculate: function(records, property, root, begin, end) {
  58432. var n = end - begin,
  58433. i, sum, v;
  58434. for (i = 0; i < n; ++i) {
  58435. v = this.extractValue(records[begin + i], property, root);
  58436. sum = i ? sum + v : v;
  58437. }
  58438. return sum;
  58439. }
  58440. });
  58441. Ext.define('Ext.data.summary.Average', {
  58442. extend: Ext.data.summary.Sum,
  58443. alias: 'data.summary.average',
  58444. calculate: function(records, property, root, begin, end) {
  58445. var len = end - begin,
  58446. value;
  58447. if (len > 0) {
  58448. value = this.callParent([
  58449. records,
  58450. property,
  58451. root,
  58452. begin,
  58453. end
  58454. ]) / len;
  58455. }
  58456. return value;
  58457. }
  58458. });
  58459. Ext.define('Ext.data.summary.Count', {
  58460. extend: Ext.data.summary.Base,
  58461. alias: 'data.summary.count',
  58462. calculate: function(records, property, root, begin, end) {
  58463. return end - begin;
  58464. }
  58465. });
  58466. Ext.define('Ext.data.summary.Max', {
  58467. extend: Ext.data.summary.Base,
  58468. alias: 'data.summary.max',
  58469. calculate: function(records, property, root, begin, end) {
  58470. var max = this.extractValue(records[begin], property, root),
  58471. i, v;
  58472. for (i = begin; i < end; ++i) {
  58473. v = this.extractValue(records[i], property, root);
  58474. if (v > max) {
  58475. max = v;
  58476. }
  58477. }
  58478. return max;
  58479. }
  58480. });
  58481. Ext.define('Ext.data.summary.Min', {
  58482. extend: Ext.data.summary.Base,
  58483. alias: 'data.summary.min',
  58484. calculate: function(records, property, root, begin, end) {
  58485. var min = this.extractValue(records[begin], property, root),
  58486. i, v;
  58487. for (i = begin; i < end; ++i) {
  58488. v = this.extractValue(records[i], property, root);
  58489. if (v < min) {
  58490. min = v;
  58491. }
  58492. }
  58493. return min;
  58494. }
  58495. });
  58496. Ext.define('Ext.data.validator.AbstractDate', {
  58497. extend: Ext.data.validator.Validator,
  58498. config: {
  58499. message: null,
  58500. format: ''
  58501. },
  58502. applyFormat: function(format) {
  58503. if (!format) {
  58504. format = this.getDefaultFormat();
  58505. }
  58506. if (!Ext.isArray(format)) {
  58507. format = [
  58508. format
  58509. ];
  58510. }
  58511. return format;
  58512. },
  58513. parse: function(value) {
  58514. if (Ext.isDate(value)) {
  58515. return value;
  58516. }
  58517. var me = this,
  58518. format = me.getFormat(),
  58519. len = format.length,
  58520. ret = null,
  58521. i;
  58522. for (i = 0; i < len && !ret; ++i) {
  58523. ret = Ext.Date.parse(value, format[i], true);
  58524. }
  58525. return ret;
  58526. },
  58527. validate: function(value) {
  58528. return this.parse(value) ? true : this.getMessage();
  58529. }
  58530. });
  58531. Ext.define('Ext.data.validator.Bound', {
  58532. extend: Ext.data.validator.Validator,
  58533. alias: 'data.validator.bound',
  58534. type: 'bound',
  58535. config: {
  58536. min: undefined,
  58537. max: undefined,
  58538. emptyMessage: 'Must be present',
  58539. minOnlyMessage: 'Value must be greater than {0}',
  58540. maxOnlyMessage: 'Value must be less than {0}',
  58541. bothMessage: 'Value must be between {0} and {1}'
  58542. },
  58543. resetMessages: function() {
  58544. this._bothMsg = this._minMsg = this._maxMsg = null;
  58545. },
  58546. updateMin: function() {
  58547. this.resetMessages();
  58548. },
  58549. updateMax: function() {
  58550. this.resetMessages();
  58551. },
  58552. updateMinOnlyMessage: function() {
  58553. this.resetMessages();
  58554. },
  58555. updateMaxOnlyMessage: function() {
  58556. this.resetMessages();
  58557. },
  58558. updateBothMessage: function() {
  58559. this.resetMessages();
  58560. },
  58561. validate: function(value) {
  58562. var me = this,
  58563. min = me.getMin(),
  58564. max = me.getMax(),
  58565. hasMin = (min != null),
  58566. hasMax = (max != null),
  58567. msg = this.validateValue(value);
  58568. if (msg !== true) {
  58569. return msg;
  58570. }
  58571. value = me.getValue(value);
  58572. if (hasMin && hasMax) {
  58573. if (value < min || value > max) {
  58574. msg = me._bothMsg || (me._bothMsg = Ext.String.format(me.getBothMessage(), min, max));
  58575. }
  58576. } else if (hasMin) {
  58577. if (value < min) {
  58578. msg = me._minMsg || (me._minMsg = Ext.String.format(me.getMinOnlyMessage(), min));
  58579. }
  58580. } else if (hasMax) {
  58581. if (value > max) {
  58582. msg = me._maxMsg || (me._maxMsg = Ext.String.format(me.getMaxOnlyMessage(), max));
  58583. }
  58584. }
  58585. return msg;
  58586. },
  58587. validateValue: function(value) {
  58588. if (value === undefined || value === null) {
  58589. return this.getEmptyMessage();
  58590. }
  58591. return true;
  58592. },
  58593. getValue: Ext.identityFn
  58594. });
  58595. Ext.define('Ext.data.validator.Format', {
  58596. extend: Ext.data.validator.Validator,
  58597. alias: 'data.validator.format',
  58598. type: 'format',
  58599. config: {
  58600. message: 'Is in the wrong format',
  58601. matcher: undefined
  58602. },
  58603. constructor: function() {
  58604. this.callParent(arguments);
  58605. if (!this.getMatcher()) {
  58606. Ext.raise('validator.Format must be configured with a matcher');
  58607. }
  58608. },
  58609. validate: function(value) {
  58610. var matcher = this.getMatcher(),
  58611. result = matcher && matcher.test(value);
  58612. return result ? result : this.getMessage();
  58613. }
  58614. });
  58615. Ext.define('Ext.data.validator.CIDRv4', {
  58616. extend: Ext.data.validator.Format,
  58617. alias: 'data.validator.cidrv4',
  58618. type: 'cidrv4',
  58619. message: 'Is not a valid CIDR block',
  58620. 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]))$/
  58621. });
  58622. Ext.define('Ext.data.validator.CIDRv6', {
  58623. extend: Ext.data.validator.Format,
  58624. alias: 'data.validator.cidrv6',
  58625. type: 'cidrv6',
  58626. message: 'Is not a valid CIDR block',
  58627. 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]))?$/
  58628. });
  58629. Ext.define('Ext.data.validator.Number', {
  58630. extend: Ext.data.validator.Validator,
  58631. alias: 'data.validator.number',
  58632. type: 'number',
  58633. config: {
  58634. decimalSeparator: undefined,
  58635. message: 'Is not a valid number',
  58636. thousandSeparator: undefined
  58637. },
  58638. constructor: function(config) {
  58639. this.callParent([
  58640. config
  58641. ]);
  58642. this.rebuildMatcher();
  58643. },
  58644. applyDecimalSeparator: function(v) {
  58645. return v === undefined ? Ext.util.Format.decimalSeparator : v;
  58646. },
  58647. updateDecimalSeparator: function() {
  58648. this.rebuildMatcher();
  58649. },
  58650. applyThousandSeparator: function(v) {
  58651. return v === undefined ? Ext.util.Format.thousandSeparator : v;
  58652. },
  58653. updateThousandSeparator: function() {
  58654. this.rebuildMatcher();
  58655. },
  58656. parse: function(v) {
  58657. var sep = this.getDecimalSeparator(),
  58658. N = Ext.Number;
  58659. if (typeof v === 'string') {
  58660. if (!this.matcher.test(v)) {
  58661. return null;
  58662. }
  58663. v = this.parseValue(v);
  58664. }
  58665. return sep ? N.parseFloat(v) : N.parseInt(v);
  58666. },
  58667. validate: function(value) {
  58668. return this.parse(value) === null ? this.getMessage() : true;
  58669. },
  58670. privates: {
  58671. getMatcherText: function(preventSign) {
  58672. var t = this.getThousandSeparator(),
  58673. d = this.getDecimalSeparator(),
  58674. s = '(?:';
  58675. if (t) {
  58676. t = Ext.String.escapeRegex(t);
  58677. s += '(?:\\d{1,3}(' + t + '\\d{3})*)|';
  58678. }
  58679. s += '\\d*)';
  58680. if (d) {
  58681. d = Ext.String.escapeRegex(d);
  58682. s += '(?:' + d + '\\d*)?';
  58683. }
  58684. if (!preventSign) {
  58685. s = this.getSignPart() + s;
  58686. }
  58687. return s;
  58688. },
  58689. getSignPart: function() {
  58690. return '(\\+|\\-)?';
  58691. },
  58692. parseValue: function(v) {
  58693. var thousandMatcher = this.thousandMatcher,
  58694. decimal;
  58695. if (thousandMatcher) {
  58696. v = v.replace(thousandMatcher, '');
  58697. }
  58698. decimal = this.getDecimalSeparator();
  58699. if (decimal && decimal !== '.') {
  58700. v = v.replace(decimal, '.');
  58701. }
  58702. return v;
  58703. },
  58704. rebuildMatcher: function() {
  58705. var me = this,
  58706. sep;
  58707. if (!me.isConfiguring) {
  58708. sep = me.getThousandSeparator();
  58709. me.matcher = new RegExp('^' + me.getMatcherText() + '$');
  58710. if (sep) {
  58711. me.thousandMatcher = sep ? new RegExp(Ext.String.escapeRegex(sep), 'g') : null;
  58712. }
  58713. }
  58714. }
  58715. }
  58716. });
  58717. Ext.define('Ext.data.validator.Currency', {
  58718. extend: Ext.data.validator.Number,
  58719. alias: 'data.validator.currency',
  58720. type: 'currency',
  58721. config: {
  58722. symbolAtEnd: undefined,
  58723. spacer: undefined,
  58724. symbol: undefined
  58725. },
  58726. message: 'Is not a valid currency amount',
  58727. applySymbolAtEnd: function(value) {
  58728. return value === undefined ? Ext.util.Format.currencyAtEnd : value;
  58729. },
  58730. updateSymbolAtEnd: function() {
  58731. this.rebuildMatcher();
  58732. },
  58733. applySpacer: function(value) {
  58734. return value === undefined ? Ext.util.Format.currencySpacer : value;
  58735. },
  58736. updateSpacer: function() {
  58737. this.rebuildMatcher();
  58738. },
  58739. applySymbol: function(value) {
  58740. return value === undefined ? Ext.util.Format.currencySign : value;
  58741. },
  58742. updateSymbol: function() {
  58743. this.rebuildMatcher();
  58744. },
  58745. privates: {
  58746. getMatcherText: function() {
  58747. var me = this,
  58748. ret = me.callParent([
  58749. true
  58750. ]),
  58751. symbolPart = me.getSymbolMatcher();
  58752. if (me.getSymbolAtEnd()) {
  58753. ret += symbolPart;
  58754. } else {
  58755. ret = symbolPart + ret;
  58756. }
  58757. return me.getSignPart() + ret;
  58758. },
  58759. getSymbolMatcher: function() {
  58760. var symbol = Ext.String.escapeRegex(this.getSymbol()),
  58761. spacer = Ext.String.escapeRegex(this.getSpacer() || ''),
  58762. s = this.getSymbolAtEnd() ? (spacer + symbol) : (symbol + spacer);
  58763. return '(?:' + s + ')?';
  58764. },
  58765. parseValue: function(v) {
  58766. v = v.replace(this.currencyMatcher, this.atEnd ? '' : '$1');
  58767. return this.callParent([
  58768. v
  58769. ]);
  58770. },
  58771. rebuildMatcher: function() {
  58772. var me = this,
  58773. symbolPart, atEnd, sign;
  58774. me.callParent();
  58775. if (!me.isConfiguring) {
  58776. atEnd = me.getSymbolAtEnd();
  58777. symbolPart = me.getSymbolMatcher();
  58778. sign = me.getSignPart();
  58779. me.atEnd = atEnd;
  58780. me.currencyMatcher = new RegExp(atEnd ? (symbolPart + '$') : ('^' + sign + symbolPart));
  58781. }
  58782. }
  58783. }
  58784. });
  58785. Ext.define('Ext.data.validator.CurrencyUS', {
  58786. extend: Ext.data.validator.Currency,
  58787. alias: 'data.validator.currency-us',
  58788. type: 'currency-us',
  58789. thousandSeparator: ',',
  58790. decimalSeparator: '.',
  58791. symbol: '$',
  58792. spacer: '',
  58793. symbolAtEnd: false
  58794. });
  58795. Ext.define('Ext.data.validator.Date', {
  58796. extend: Ext.data.validator.AbstractDate,
  58797. alias: 'data.validator.date',
  58798. type: 'date',
  58799. isDateValidator: true,
  58800. message: 'Is not a valid date',
  58801. privates: {
  58802. getDefaultFormat: function() {
  58803. return [
  58804. Ext.Date.defaultFormat,
  58805. 'm/d/Y',
  58806. 'n/j/Y',
  58807. 'n/j/y',
  58808. 'm/j/y',
  58809. 'n/d/y',
  58810. 'm/j/Y',
  58811. 'n/d/Y',
  58812. 'm-d-y',
  58813. 'n-d-y',
  58814. 'm-d-Y',
  58815. 'mdy',
  58816. 'mdY',
  58817. 'Y-m-d'
  58818. ];
  58819. }
  58820. }
  58821. });
  58822. Ext.define('Ext.data.validator.DateTime', {
  58823. extend: Ext.data.validator.AbstractDate,
  58824. alias: 'data.validator.datetime',
  58825. type: 'datetime',
  58826. isDateTimeValidator: true,
  58827. message: 'Is not a valid date and time',
  58828. privates: {
  58829. getDefaultFormat: function() {
  58830. var D = Ext.Date;
  58831. return D.defaultFormat + ' ' + D.defaultTimeFormat;
  58832. }
  58833. }
  58834. });
  58835. Ext.define('Ext.data.validator.Email', {
  58836. extend: Ext.data.validator.Format,
  58837. alias: 'data.validator.email',
  58838. type: 'email',
  58839. message: 'Is not a valid email address',
  58840. matcher: /^(")?(?:[^\."])(?:(?:[\.])?(?:[\w\-!#$%&'*+\/=?\^_`{|}~]))*\1@(\w[\-\w]*\.){1,5}([A-Za-z]){2,6}$/
  58841. });
  58842. Ext.define('Ext.data.validator.List', {
  58843. extend: Ext.data.validator.Validator,
  58844. alias: 'data.validator.list',
  58845. type: 'list',
  58846. config: {
  58847. list: null,
  58848. message: null
  58849. },
  58850. inclusion: null,
  58851. validate: function(value) {
  58852. var contains = Ext.Array.contains(this.getList(), value),
  58853. inclusion = this.inclusion,
  58854. exclusion = !inclusion,
  58855. result;
  58856. result = (inclusion && contains) || (exclusion && !contains);
  58857. return result || this.getMessage();
  58858. }
  58859. });
  58860. Ext.define('Ext.data.validator.Exclusion', {
  58861. extend: Ext.data.validator.List,
  58862. alias: 'data.validator.exclusion',
  58863. type: 'exclusion',
  58864. message: 'Is a value that has been excluded',
  58865. constructor: function() {
  58866. this.callParent(arguments);
  58867. if (!this.getList()) {
  58868. Ext.raise('validator.Exclusion requires a list');
  58869. }
  58870. },
  58871. inclusion: false
  58872. });
  58873. Ext.define('Ext.data.validator.IPAddress', {
  58874. extend: Ext.data.validator.Format,
  58875. alias: 'data.validator.ipaddress',
  58876. type: 'ipaddress',
  58877. message: 'Is not a valid IP address',
  58878. matcher: new RegExp('^(' +
  58879. '((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]?)' + '|' +
  58880. '((([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])))' + ')$')
  58881. });
  58882. Ext.define('Ext.data.validator.Inclusion', {
  58883. extend: Ext.data.validator.List,
  58884. alias: 'data.validator.inclusion',
  58885. type: 'inclusion',
  58886. message: 'Is not in the list of acceptable values',
  58887. constructor: function() {
  58888. this.callParent(arguments);
  58889. if (!this.getList()) {
  58890. Ext.raise('validator.Inclusion requires a list');
  58891. }
  58892. },
  58893. inclusion: true
  58894. });
  58895. Ext.define('Ext.data.validator.Length', {
  58896. extend: Ext.data.validator.Bound,
  58897. alias: 'data.validator.length',
  58898. type: 'length',
  58899. minOnlyMessage: 'Length must be at least {0}',
  58900. maxOnlyMessage: 'Length must be no more than {0}',
  58901. bothMessage: 'Length must be between {0} and {1}',
  58902. getValue: function(v) {
  58903. return String(v).length;
  58904. }
  58905. });
  58906. Ext.define('Ext.data.validator.Presence', {
  58907. extend: Ext.data.validator.Validator,
  58908. alias: 'data.validator.presence',
  58909. type: 'presence',
  58910. isPresence: true,
  58911. config: {
  58912. message: 'Must be present',
  58913. allowEmpty: false
  58914. },
  58915. validate: function(value) {
  58916. var valid = !(value === undefined || value === null);
  58917. if (valid && !this.getAllowEmpty()) {
  58918. valid = value !== '';
  58919. }
  58920. return valid ? true : this.getMessage();
  58921. }
  58922. });
  58923. Ext.define('Ext.data.validator.NotNull', {
  58924. extend: Ext.data.validator.Presence,
  58925. alias: 'data.validator.notnull',
  58926. type: 'notnull',
  58927. allowEmpty: true
  58928. });
  58929. Ext.define('Ext.data.validator.Phone', {
  58930. extend: Ext.data.validator.Format,
  58931. alias: 'data.validator.phone',
  58932. type: 'phone',
  58933. message: 'Is not a valid phone number',
  58934. matcher: new RegExp('^ *' +
  58935. '(?:' + '\\+?' +
  58936. '(\\d{1,3})' +
  58937. '[- .]?' + ')?' +
  58938. '(?:' + '(?:' + '(\\d{3})' +
  58939. '|' + '\\((\\d{3})\\)' +
  58940. ')?' +
  58941. '[- .]?' + ')' +
  58942. '(?:' + '([2-9]\\d{2})' +
  58943. '[- .]?' + ')' +
  58944. '(\\d{4})' +
  58945. '(?: *(?:e?xt?) *(\\d*))?' + ' *$')
  58946. });
  58947. Ext.define('Ext.data.validator.Range', {
  58948. extend: Ext.data.validator.Bound,
  58949. alias: 'data.validator.range',
  58950. type: 'range',
  58951. minOnlyMessage: 'Must be at least {0}',
  58952. maxOnlyMessage: 'Must be no more than than {0}',
  58953. bothMessage: 'Must be between {0} and {1}',
  58954. config: {
  58955. nanMessage: 'Must be numeric'
  58956. },
  58957. validateValue: function(value) {
  58958. var msg = this.callParent([
  58959. value
  58960. ]);
  58961. if (msg === true && isNaN(value)) {
  58962. msg = this.getNanMessage();
  58963. }
  58964. return msg;
  58965. }
  58966. });
  58967. Ext.define('Ext.data.validator.Time', {
  58968. extend: Ext.data.validator.AbstractDate,
  58969. alias: 'data.validator.time',
  58970. type: 'time',
  58971. isTimeValidator: true,
  58972. message: 'Is not a valid time',
  58973. privates: {
  58974. getDefaultFormat: function() {
  58975. return Ext.Date.defaultTimeFormat;
  58976. }
  58977. }
  58978. });
  58979. Ext.define('Ext.data.validator.Url', {
  58980. extend: Ext.data.validator.Format,
  58981. alias: 'data.validator.url',
  58982. type: 'url',
  58983. message: 'Is not a valid URL',
  58984. matcher: /^(http:\/\/|https:\/\/|ftp:\/\/|\/\/)([-a-zA-Z0-9@:%_\+.~#?&//=])+$/
  58985. });
  58986. Ext.define('Ext.data.virtual.Group', {
  58987. isVirtualGroup: true,
  58988. firstRecords: null,
  58989. id: '',
  58990. summaryRecord: null,
  58991. constructor: function(key) {
  58992. this.id = key;
  58993. this.firstRecords = [];
  58994. },
  58995. first: function() {
  58996. return this.firstRecords[0] || null;
  58997. },
  58998. getGroupKey: function() {
  58999. return this.id;
  59000. },
  59001. getSummaryRecord: function() {
  59002. return this.summaryRecord;
  59003. }
  59004. });
  59005. Ext.define('Ext.data.virtual.Page', {
  59006. isVirtualPage: true,
  59007. begin: 0,
  59008. end: 0,
  59009. error: null,
  59010. locked: null,
  59011. number: 0,
  59012. operation: null,
  59013. pageMap: null,
  59014. records: null,
  59015. state: null,
  59016. constructor: function(config) {
  59017. var me = this,
  59018. pageSize;
  59019. Ext.apply(me, config);
  59020. pageSize = me.pageMap.store.getPageSize();
  59021. me.begin = me.number * pageSize;
  59022. me.end = me.begin + pageSize;
  59023. me.locks = {
  59024. active: 0,
  59025. prefetch: 0
  59026. };
  59027. },
  59028. destroy: function() {
  59029. var me = this,
  59030. operation = me.operation;
  59031. me.state = 'destroyed';
  59032. if (operation) {
  59033. operation.abort();
  59034. }
  59035. me.callParent();
  59036. },
  59037. adjustLock: function(kind, delta) {
  59038. var me = this,
  59039. locks = me.locks,
  59040. pageMap = me.pageMap,
  59041. locked = null,
  59042. lockedWas = me.locked;
  59043. if (!(kind in locks)) {
  59044. Ext.raise('Bad lock type (expected "active" or "prefetch"): "' + kind + '"');
  59045. }
  59046. if (delta !== 1 && delta !== -1) {
  59047. Ext.raise('Invalid lock count delta (should be 1 or -1): ' + delta);
  59048. }
  59049. locks[kind] += delta;
  59050. if (locks.active) {
  59051. locked = 'active';
  59052. } else if (locks.prefetch) {
  59053. locked = 'prefetch';
  59054. }
  59055. if (locked !== lockedWas) {
  59056. me.locked = locked;
  59057. if (pageMap) {
  59058. pageMap.onPageLockChange(me, locked, lockedWas);
  59059. }
  59060. }
  59061. },
  59062. clearRecords: function(out, by) {
  59063. var me = this,
  59064. begin = me.begin,
  59065. records = me.records,
  59066. i, n;
  59067. if (records) {
  59068. n = records.length;
  59069. if (by) {
  59070. for (i = 0; i < n; ++i) {
  59071. delete out[records[i][by]];
  59072. }
  59073. } else {
  59074. for (i = 0; i < n; ++i) {
  59075. delete out[begin + i];
  59076. }
  59077. }
  59078. }
  59079. },
  59080. fillRecords: function(out, by, withIndex) {
  59081. var me = this,
  59082. records = me.records,
  59083. begin = me.begin,
  59084. i, n, record;
  59085. if (records) {
  59086. n = records.length;
  59087. if (by) {
  59088. for (i = 0; i < n; ++i) {
  59089. record = records[i];
  59090. out[record[by]] = withIndex ? begin + i : record;
  59091. }
  59092. } else {
  59093. for (i = 0; i < n; ++i) {
  59094. out[begin + i] = records[i];
  59095. }
  59096. }
  59097. }
  59098. },
  59099. isInitial: function() {
  59100. return this.state === null;
  59101. },
  59102. isLoaded: function() {
  59103. return this.state === 'loaded';
  59104. },
  59105. isLoading: function() {
  59106. return this.state === 'loading';
  59107. },
  59108. load: function() {
  59109. var me = this,
  59110. operation;
  59111. me.state = 'loading';
  59112. operation = me.pageMap.store.loadVirtualPage(me, me.onLoad, me);
  59113. if (me.state === 'loading') {
  59114. me.operation = operation;
  59115. }
  59116. },
  59117. privates: {
  59118. onLoad: function(operation) {
  59119. var me = this;
  59120. me.operation = null;
  59121. if (!me.destroyed) {
  59122. if (!(me.error = operation.getError())) {
  59123. me.records = operation.getRecords();
  59124. me.state = 'loaded';
  59125. } else {
  59126. me.state = 'error';
  59127. }
  59128. me.pageMap.onPageLoad(me);
  59129. }
  59130. }
  59131. }
  59132. });
  59133. Ext.define('Ext.data.virtual.PageMap', {
  59134. isVirtualPageMap: true,
  59135. config: {
  59136. cacheSize: 10,
  59137. concurrentLoading: 1,
  59138. pageCount: null
  59139. },
  59140. generation: 0,
  59141. store: null,
  59142. constructor: function(config) {
  59143. var me = this;
  59144. me.prefetchSortFn = me.prefetchSortFn.bind(me);
  59145. me.initConfig(config);
  59146. me.clear();
  59147. },
  59148. destroy: function() {
  59149. this.clear(true);
  59150. this.callParent();
  59151. },
  59152. canSatisfy: function(range) {
  59153. var end = this.getPageIndex(range.end),
  59154. pageCount = this.getPageCount();
  59155. return pageCount === null || end < pageCount;
  59156. },
  59157. clear: function(destroy) {
  59158. var me = this,
  59159. alive = !destroy || null,
  59160. pages = me.pages,
  59161. pg;
  59162. ++me.generation;
  59163. me.byId = alive && {};
  59164. me.byInternalId = alive && {};
  59165. me.cache = alive && [];
  59166. me.indexMap = alive && {};
  59167. me.pages = alive && {};
  59168. me.loading = alive && [];
  59169. me.loadQueues = alive && {
  59170. active: [],
  59171. prefetch: []
  59172. };
  59173. if (pages) {
  59174. for (pg in pages) {
  59175. me.destroyPage(pages[pg]);
  59176. }
  59177. }
  59178. },
  59179. getPage: function(number, autoCreate) {
  59180. var me = this,
  59181. pageCount = me.getPageCount(),
  59182. pages = me.pages,
  59183. page;
  59184. if (pageCount === null || number < pageCount) {
  59185. page = pages[number];
  59186. if (!page && autoCreate !== false) {
  59187. pages[number] = page = new Ext.data.virtual.Page({
  59188. pageMap: me,
  59189. number: number
  59190. });
  59191. }
  59192. } else
  59193. {
  59194. Ext.raise('Invalid page number ' + number + ' when limit is ' + pageCount);
  59195. }
  59196. return page || null;
  59197. },
  59198. getPageIndex: function(index) {
  59199. if (index.isEntity) {
  59200. index = this.indexOf(index);
  59201. }
  59202. return Math.floor(index / this.store.getPageSize());
  59203. },
  59204. getPageOf: function(index, autoCreate) {
  59205. var pageSize = this.store.getPageSize(),
  59206. n = Math.floor(index / pageSize);
  59207. return this.getPage(n, autoCreate);
  59208. },
  59209. getPages: function(begin, end) {
  59210. var pageSize = this.store.getPageSize(),
  59211. first = Math.floor(begin / pageSize),
  59212. last = Math.ceil(end / pageSize),
  59213. ret = {},
  59214. n;
  59215. for (n = first; n < last; ++n) {
  59216. ret[n] = this.getPage(n);
  59217. }
  59218. return ret;
  59219. },
  59220. flushNextLoad: function() {
  59221. var me = this,
  59222. queueTimer = me.queueTimer;
  59223. if (queueTimer) {
  59224. Ext.unasap(queueTimer);
  59225. }
  59226. me.loadNext();
  59227. },
  59228. indexOf: function(record) {
  59229. var ret = this.indexMap[record.internalId];
  59230. return (ret || ret === 0) ? ret : -1;
  59231. },
  59232. getByInternalId: function(internalId) {
  59233. var index = this.indexMap[internalId],
  59234. page;
  59235. if (index || index === 0) {
  59236. page = this.pages[Math.floor(index / this.store.getPageSize())];
  59237. if (page) {
  59238. return page.records[index - page.begin];
  59239. }
  59240. }
  59241. },
  59242. updatePageCount: function(pageCount, oldPageCount) {
  59243. var pages = this.pages,
  59244. pageNumber, page;
  59245. if (oldPageCount === null || pageCount < oldPageCount) {
  59246. for (pageNumber in pages) {
  59247. page = pages[pageNumber];
  59248. if (page.number >= pageCount) {
  59249. this.clearPage(page);
  59250. this.destroyPage(page);
  59251. }
  59252. }
  59253. }
  59254. },
  59255. privates: {
  59256. queueTimer: null,
  59257. clearPage: function(page, fromCache) {
  59258. var me = this,
  59259. A = Ext.Array,
  59260. loadQueues = me.loadQueues;
  59261. delete me.pages[page.number];
  59262. page.clearRecords(me.byId, 'id');
  59263. page.clearRecords(me.byInternalId, 'internalId');
  59264. page.clearRecords(me.indexMap, 'internalId');
  59265. A.remove(loadQueues.active, page);
  59266. A.remove(loadQueues.prefetch, page);
  59267. if (!fromCache) {
  59268. Ext.Array.remove(me.cache, page);
  59269. }
  59270. },
  59271. destroyPage: function(page) {
  59272. this.store.onPageDestroy(page);
  59273. page.destroy();
  59274. },
  59275. loadNext: function() {
  59276. var me = this,
  59277. concurrency = me.getConcurrentLoading(),
  59278. loading = me.loading,
  59279. loadQueues = me.loadQueues,
  59280. page;
  59281. me.queueTimer = null;
  59282. while (loading.length < concurrency) {
  59283. if (!(page = loadQueues.active.shift() || loadQueues.prefetch.shift())) {
  59284. break;
  59285. }
  59286. loading.push(page);
  59287. page.load();
  59288. }
  59289. },
  59290. onPageLoad: function(page) {
  59291. var me = this,
  59292. store = me.store,
  59293. activeRanges = store.activeRanges,
  59294. n = activeRanges.length,
  59295. i;
  59296. Ext.Array.remove(me.loading, page);
  59297. if (!page.error) {
  59298. page.fillRecords(me.byId, 'id');
  59299. page.fillRecords(me.byInternalId, 'internalId');
  59300. page.fillRecords(me.indexMap, 'internalId', true);
  59301. store.onPageDataAcquired(page);
  59302. for (i = 0; i < n; ++i) {
  59303. activeRanges[i].onPageLoad(page);
  59304. }
  59305. }
  59306. me.flushNextLoad();
  59307. },
  59308. onPageLockChange: function(page, state, oldState) {
  59309. var me = this,
  59310. cache = me.cache,
  59311. loadQueues = me.loadQueues,
  59312. store = me.store,
  59313. cacheSize, concurrency;
  59314. if (page.isInitial()) {
  59315. if (oldState) {
  59316. Ext.Array.remove(loadQueues[oldState], page);
  59317. }
  59318. if (state) {
  59319. loadQueues[state].push(page);
  59320. concurrency = me.getConcurrentLoading();
  59321. if (!me.queueTimer && me.loading.length < concurrency) {
  59322. me.queueTimer = Ext.asap(me.loadNext, me);
  59323. }
  59324. }
  59325. }
  59326. if (state) {
  59327. if (!oldState) {
  59328. Ext.Array.remove(cache, page);
  59329. }
  59330. } else {
  59331. cache.push(page);
  59332. for (cacheSize = me.getCacheSize(); cache.length > cacheSize; ) {
  59333. page = cache.shift();
  59334. me.clearPage(page, true);
  59335. store.onPageEvicted(page);
  59336. me.destroyPage(page);
  59337. }
  59338. }
  59339. },
  59340. prefetchSortFn: function(a, b) {
  59341. a = a.number;
  59342. b = b.number;
  59343. var M = Math,
  59344. firstPage = this.sortFirstPage,
  59345. lastPage = this.sortLastPage,
  59346. direction = this.sortDirection,
  59347. aDir = a < firstPage,
  59348. bDir = b < firstPage,
  59349. ret;
  59350. a = aDir ? M.abs(firstPage - a) : M.abs(lastPage - a);
  59351. b = bDir ? M.abs(firstPage - b) : M.abs(lastPage - b);
  59352. if (a === b) {
  59353. ret = aDir ? direction : -direction;
  59354. } else {
  59355. ret = a - b;
  59356. }
  59357. return ret;
  59358. },
  59359. prioritizePrefetch: function(direction, firstPage, lastPage) {
  59360. var me = this;
  59361. me.sortDirection = direction;
  59362. me.sortFirstPage = firstPage;
  59363. me.sortLastPage = lastPage;
  59364. me.loadQueues.prefetch.sort(me.prefetchSortFn);
  59365. }
  59366. }
  59367. });
  59368. Ext.define('Ext.data.virtual.Range', {
  59369. extend: Ext.data.Range,
  59370. isVirtualRange: true,
  59371. callback: null,
  59372. prefetch: false,
  59373. scope: null,
  59374. direction: 1,
  59375. constructor: function(config) {
  59376. this.adjustingPages = [];
  59377. this.callParent([
  59378. config
  59379. ]);
  59380. },
  59381. reset: function() {
  59382. var me = this;
  59383. me.records = {};
  59384. me.activePages = me.prefetchPages = null;
  59385. },
  59386. privates: {
  59387. adjustPageLocks: function(kind, adjustment) {
  59388. var me = this,
  59389. pages = me.adjustingPages,
  59390. n = pages.length,
  59391. i;
  59392. if (n > 1) {
  59393. pages.sort(me.direction < 0 ? me.pageSortBackFn : me.pageSortFwdFn);
  59394. }
  59395. for (i = 0; i < n; ++i) {
  59396. pages[i].adjustLock(kind, adjustment);
  59397. }
  59398. pages.length = 0;
  59399. },
  59400. doGoto: function() {
  59401. var me = this,
  59402. begin = me.begin,
  59403. end = me.end,
  59404. prefetch = me.prefetch,
  59405. records = me.records,
  59406. store = me.store,
  59407. pageMap = store.pageMap,
  59408. limit = store.totalCount,
  59409. beginWas = me.lastBegin,
  59410. endWas = me.lastEnd,
  59411. activePagesWas = me.activePages,
  59412. prefetchPagesWas = me.prefetchPages,
  59413. beginBufferZone = me.trailingBufferZone,
  59414. endBufferZone = me.leadingBufferZone,
  59415. adjustingPages = me.adjustingPages,
  59416. activePages, page, pg, direction, prefetchBegin, prefetchEnd, prefetchPages;
  59417. adjustingPages.length = 0;
  59418. if ((begin > beginWas && end < endWas) || (begin < beginWas && end > endWas)) {
  59419. direction = me.direction;
  59420. } else {
  59421. direction = (begin < beginWas) ? -1 : ((begin > beginWas) ? 1 : me.direction);
  59422. }
  59423. if (direction < 0) {
  59424. pg = beginBufferZone;
  59425. beginBufferZone = endBufferZone;
  59426. endBufferZone = pg;
  59427. }
  59428. me.direction = direction;
  59429. me.activePages = activePages = pageMap.getPages(begin, end);
  59430. if (prefetch) {
  59431. me.prefetchBegin = prefetchBegin = Math.max(0, begin - beginBufferZone);
  59432. if (limit === null) {
  59433. limit = Number.MAX_VALUE;
  59434. }
  59435. me.prefetchEnd = prefetchEnd = Math.min(limit, end + endBufferZone);
  59436. me.prefetchPages = prefetchPages = pageMap.getPages(prefetchBegin, prefetchEnd);
  59437. }
  59438. for (pg in activePages) {
  59439. page = activePages[pg];
  59440. if (prefetchPages) {
  59441. delete prefetchPages[pg];
  59442. }
  59443. if (activePagesWas && pg in activePagesWas) {
  59444. delete activePagesWas[pg];
  59445. } else {
  59446. page.adjustLock('active', 1);
  59447. page.fillRecords(records);
  59448. }
  59449. }
  59450. if (prefetchPages) {
  59451. for (pg in prefetchPages) {
  59452. if (prefetchPagesWas && pg in prefetchPagesWas) {
  59453. delete prefetchPagesWas[pg];
  59454. } else {
  59455. prefetchPages[pg].adjustLock('prefetch', 1);
  59456. }
  59457. }
  59458. }
  59459. if (prefetchPagesWas) {
  59460. for (pg in prefetchPagesWas) {
  59461. adjustingPages.push(prefetchPagesWas[pg]);
  59462. }
  59463. if (adjustingPages.length) {
  59464. me.adjustPageLocks('prefetch', -1);
  59465. }
  59466. }
  59467. if (activePagesWas) {
  59468. for (pg in activePagesWas) {
  59469. adjustingPages.push(page = activePagesWas[pg]);
  59470. page.clearRecords(records);
  59471. }
  59472. if (adjustingPages.length) {
  59473. me.adjustPageLocks('active', -1);
  59474. }
  59475. }
  59476. if (prefetchPages) {
  59477. pageMap.prioritizePrefetch(direction, pageMap.getPageIndex(begin), pageMap.getPageIndex(end - 1));
  59478. }
  59479. me.lastBegin = begin;
  59480. me.lastEnd = end;
  59481. },
  59482. onPageDestroy: function(page) {
  59483. var n = page.number,
  59484. activePages = this.activePages,
  59485. prefetchPages = this.prefetchPages;
  59486. if (activePages) {
  59487. delete activePages[n];
  59488. }
  59489. if (prefetchPages) {
  59490. delete prefetchPages[n];
  59491. }
  59492. },
  59493. onPageLoad: function(page) {
  59494. var me = this,
  59495. callback = me.callback,
  59496. first, last;
  59497. if (me.activePages[page.number]) {
  59498. page.fillRecords(me.records);
  59499. if (callback) {
  59500. first = Math.max(me.begin, page.begin);
  59501. last = Math.min(me.end, page.end);
  59502. Ext.callback(callback, me.scope, [
  59503. me,
  59504. first,
  59505. last
  59506. ]);
  59507. }
  59508. }
  59509. },
  59510. pageSortBackFn: function(page1, page2) {
  59511. return page2.number - page1.number;
  59512. },
  59513. pageSortFwdFn: function(page1, page2) {
  59514. return page1.number - page2.number;
  59515. },
  59516. refresh: function() {
  59517. this.records = this.records || {};
  59518. },
  59519. reload: function() {
  59520. var me = this,
  59521. begin = me.begin,
  59522. end = me.end;
  59523. me.begin = me.end = 0;
  59524. me.direction = 1;
  59525. me.prefetchPages = me.activePages = null;
  59526. me.goto(begin, end);
  59527. }
  59528. }
  59529. });
  59530. Ext.define('Ext.data.virtual.Store', {
  59531. extend: Ext.data.ProxyStore,
  59532. alias: 'store.virtual',
  59533. isVirtualStore: true,
  59534. config: {
  59535. data: null,
  59536. totalCount: null,
  59537. leadingBufferZone: 200,
  59538. trailingBufferZone: 50
  59539. },
  59540. remoteSort: true,
  59541. remoteFilter: true,
  59542. sortOnLoad: false,
  59543. trackRemoved: false,
  59544. constructor: function(config) {
  59545. var me = this;
  59546. me.sortByPage = me.sortByPage.bind(me);
  59547. me.activeRanges = [];
  59548. me.pageMap = new Ext.data.virtual.PageMap({
  59549. store: me
  59550. });
  59551. me.callParent([
  59552. config
  59553. ]);
  59554. },
  59555. doDestroy: function() {
  59556. this.pageMap.destroy();
  59557. this.callParent();
  59558. },
  59559. applyGrouper: function(grouper) {
  59560. this.group(grouper);
  59561. return this.grouper;
  59562. },
  59563. contains: function(record) {
  59564. return this.indexOf(record) > -1;
  59565. },
  59566. createActiveRange: function(config) {
  59567. var range = Ext.apply({
  59568. leadingBufferZone: this.getLeadingBufferZone(),
  59569. trailingBufferZone: this.getTrailingBufferZone(),
  59570. store: this
  59571. }, config);
  59572. return new Ext.data.virtual.Range(range);
  59573. },
  59574. getAt: function(index) {
  59575. var page = this.pageMap.getPageOf(index,
  59576. false),
  59577. ret;
  59578. if (page && page.records) {
  59579. ret = page.records[index - page.begin];
  59580. }
  59581. return ret || null;
  59582. },
  59583. getById: function(id) {
  59584. return this.pageMap.byId[id] || null;
  59585. },
  59586. getCount: function() {
  59587. return this.totalCount || 0;
  59588. },
  59589. getGrouper: function() {
  59590. return this.grouper;
  59591. },
  59592. getGroups: function() {
  59593. var me = this,
  59594. groups = me.groupCollection;
  59595. if (!groups) {
  59596. me.groupCollection = groups = new Ext.util.Collection();
  59597. }
  59598. return groups;
  59599. },
  59600. getSummaryRecord: function() {
  59601. return this.summaryRecord || null;
  59602. },
  59603. isGrouped: function() {
  59604. return !!this.grouper;
  59605. },
  59606. group: function(grouper, direction) {
  59607. var me = this;
  59608. grouper = grouper || null;
  59609. if (grouper) {
  59610. if (typeof grouper === 'string') {
  59611. grouper = {
  59612. property: grouper,
  59613. direction: direction || 'ASC'
  59614. };
  59615. }
  59616. if (!grouper.isGrouper) {
  59617. grouper = new Ext.util.Grouper(grouper);
  59618. }
  59619. grouper.setRoot('data');
  59620. me.getGroups().getSorters().splice(0, 1, {
  59621. property: 'id',
  59622. direction: grouper.getDirection()
  59623. });
  59624. }
  59625. me.grouper = grouper;
  59626. if (!me.isConfiguring) {
  59627. me.reload();
  59628. me.fireEvent('groupchange', me, grouper);
  59629. }
  59630. },
  59631. getByInternalId: function(internalId) {
  59632. return this.pageMap.getByInternalId(internalId);
  59633. },
  59634. indexOf: function(record) {
  59635. return this.pageMap.indexOf(record);
  59636. },
  59637. indexOfId: function(id) {
  59638. var rec = this.getById(id);
  59639. return rec ? this.indexOf(rec) : -1;
  59640. },
  59641. load: function(options) {
  59642. if (typeof options === 'function') {
  59643. options = {
  59644. callback: options
  59645. };
  59646. }
  59647. var me = this,
  59648. page = (options && options.page) || 1,
  59649. pageSize = me.getPageSize(),
  59650. operation = me.createOperation('read', Ext.apply({
  59651. start: (page - 1) * pageSize,
  59652. limit: pageSize,
  59653. page: page,
  59654. filters: me.getFilters().items,
  59655. sorters: me.getSorters().items,
  59656. grouper: me.getGrouper()
  59657. }, options));
  59658. operation.execute();
  59659. return operation;
  59660. },
  59661. reload: function(options) {
  59662. if (typeof options === 'function') {
  59663. options = {
  59664. callback: options
  59665. };
  59666. }
  59667. var me = this;
  59668. if (me.fireEvent('beforereload') === false) {
  59669. return null;
  59670. }
  59671. options = Ext.apply({
  59672. internalScope: me,
  59673. internalCallback: me.handleReload,
  59674. page: 1
  59675. }, options);
  59676. me.pageMap.clear();
  59677. me.getGroups().clear();
  59678. return me.load(options);
  59679. },
  59680. removeAll: function() {
  59681. var activeRanges = this.activeRanges,
  59682. i;
  59683. this.pageMap.clear();
  59684. for (i = activeRanges.length; i-- > 0; ) {
  59685. activeRanges[i].reset();
  59686. }
  59687. },
  59688. applyProxy: function(proxy) {
  59689. proxy = this.callParent([
  59690. proxy
  59691. ]);
  59692. if (proxy && proxy.setEnablePaging) {
  59693. proxy.setEnablePaging(true);
  59694. }
  59695. return proxy;
  59696. },
  59697. createFiltersCollection: function() {
  59698. return new Ext.util.FilterCollection();
  59699. },
  59700. createSortersCollection: function() {
  59701. return new Ext.util.SorterCollection();
  59702. },
  59703. onFilterEndUpdate: function() {
  59704. var me = this,
  59705. filters = me.getFilters(false);
  59706. if (!me.isConfiguring) {
  59707. me.reload();
  59708. me.fireEvent('filterchange', me, filters.getRange());
  59709. }
  59710. },
  59711. onSorterEndUpdate: function() {
  59712. var me = this,
  59713. sorters = me.getSorters().getRange(),
  59714. fire = !me.isConfiguring;
  59715. if (fire) {
  59716. me.fireEvent('beforesort', me, sorters);
  59717. }
  59718. if (fire) {
  59719. me.reload();
  59720. me.fireEvent('sort', me, sorters);
  59721. }
  59722. },
  59723. updatePageSize: function(pageSize) {
  59724. var totalCount = this.totalCount;
  59725. if (totalCount !== null) {
  59726. this.pageMap.setPageCount(Math.ceil(totalCount / pageSize));
  59727. }
  59728. },
  59729. updateTotalCount: function(totalCount, oldTotalCount) {
  59730. var me = this,
  59731. pageMap = me.pageMap;
  59732. me.totalCount = totalCount;
  59733. pageMap.setPageCount(Math.ceil(totalCount / me.getPageSize()));
  59734. me.fireEvent('totalcountchange', me, totalCount, oldTotalCount);
  59735. },
  59736. add: function() {
  59737. Ext.raise('Virtual stores do not support the add() method');
  59738. },
  59739. insert: function() {
  59740. Ext.raise('Virtual stores do not support the insert() method');
  59741. },
  59742. filter: function() {
  59743. if (!this.getRemoteFilter()) {
  59744. Ext.raise('Virtual stores do not support local filtering');
  59745. }
  59746. this.callParent(arguments);
  59747. },
  59748. filterBy: function() {
  59749. Ext.raise('Virtual stores do not support local filtering');
  59750. },
  59751. loadData: function() {
  59752. Ext.raise('Virtual stores do not support the loadData() method');
  59753. },
  59754. applyData: function() {
  59755. Ext.raise('Virtual stores do not support direct data loading');
  59756. },
  59757. updateRemoteFilter: function(remoteFilter, oldRemoteFilter) {
  59758. if (remoteFilter === false) {
  59759. Ext.raise('Virtual stores are always remotely filtered.');
  59760. }
  59761. this.callParent([
  59762. remoteFilter,
  59763. oldRemoteFilter
  59764. ]);
  59765. },
  59766. updateRemoteSort: function(remoteSort, oldRemoteSort) {
  59767. if (remoteSort === false) {
  59768. Ext.raise('Virtual stores are always remotely sorted.');
  59769. }
  59770. this.callParent([
  59771. remoteSort,
  59772. oldRemoteSort
  59773. ]);
  59774. },
  59775. updateTrackRemoved: function(value) {
  59776. if (value !== false) {
  59777. Ext.raise('Virtual stores do not support trackRemoved.');
  59778. }
  59779. this.callParent(arguments);
  59780. },
  59781. privates: {
  59782. attachSummaryData: function(resultSet) {
  59783. var me = this,
  59784. summary = resultSet.getSummaryData(),
  59785. grouper, len, i, data, rec;
  59786. if (summary) {
  59787. me.summaryRecord = summary;
  59788. }
  59789. summary = resultSet.getGroupData();
  59790. if (summary) {
  59791. grouper = me.getGrouper();
  59792. if (grouper) {
  59793. me.groupSummaryData = data = {};
  59794. for (i = 0 , len = summary.length; i < len; ++i) {
  59795. rec = summary[i];
  59796. data[grouper.getGroupString(rec)] = rec;
  59797. }
  59798. }
  59799. }
  59800. },
  59801. handleReload: function(op) {
  59802. var me = this,
  59803. activeRanges = me.activeRanges,
  59804. len = activeRanges.length,
  59805. pageMap = me.pageMap,
  59806. i, range;
  59807. if (op.wasSuccessful()) {
  59808. me.readTotalCount(op.getResultSet());
  59809. me.fireEvent('reload', me, op);
  59810. for (i = 0; i < len; ++i) {
  59811. range = activeRanges[i];
  59812. if (pageMap.canSatisfy(range)) {
  59813. range.reload();
  59814. }
  59815. }
  59816. }
  59817. },
  59818. loadVirtualPage: function(page, callback, scope) {
  59819. var me = this,
  59820. pageMapGeneration = me.pageMap.generation;
  59821. return me.load({
  59822. page: page.number + 1,
  59823. internalCallback: function(op) {
  59824. var resultSet = op.getResultSet();
  59825. if (pageMapGeneration === me.pageMap.generation) {
  59826. if (op.wasSuccessful()) {
  59827. me.readTotalCount(resultSet);
  59828. me.attachSummaryData(resultSet);
  59829. }
  59830. callback.call(scope || page, op);
  59831. me.groupSummaryData = null;
  59832. }
  59833. }
  59834. });
  59835. },
  59836. lockGroups: function(grouper, page) {
  59837. var groups = this.getGroups(),
  59838. groupInfo = page.groupInfo = {},
  59839. records = page.records,
  59840. len = records.length,
  59841. groupSummaryData = this.groupSummaryData,
  59842. pageMap = this.pageMap,
  59843. n = page.number,
  59844. group, i, groupKey, summaryRec, rec, firstRecords, first;
  59845. for (i = 0; i < len; ++i) {
  59846. rec = records[i];
  59847. groupKey = grouper.getGroupString(rec);
  59848. if (!groupInfo[groupKey]) {
  59849. groupInfo[groupKey] = rec;
  59850. group = groups.get(groupKey);
  59851. if (!group) {
  59852. group = new Ext.data.virtual.Group(groupKey);
  59853. groups.add(group);
  59854. }
  59855. firstRecords = group.firstRecords;
  59856. first = firstRecords[0];
  59857. if (first && n < pageMap.getPageIndex(first)) {
  59858. firstRecords.unshift(rec);
  59859. } else {
  59860. firstRecords.push(rec);
  59861. }
  59862. summaryRec = groupSummaryData && groupSummaryData[groupKey];
  59863. if (summaryRec) {
  59864. group.summaryRecord = summaryRec;
  59865. }
  59866. }
  59867. }
  59868. },
  59869. onPageDataAcquired: function(page) {
  59870. var grouper = this.getGrouper();
  59871. if (grouper) {
  59872. this.lockGroups(grouper, page);
  59873. }
  59874. },
  59875. onPageDestroy: function(page) {
  59876. var ranges = this.activeRanges,
  59877. len = ranges.length,
  59878. i;
  59879. for (i = 0; i < len; ++i) {
  59880. ranges[i].onPageDestroy(page);
  59881. }
  59882. },
  59883. onPageEvicted: function(page) {
  59884. var grouper = this.getGrouper();
  59885. if (grouper) {
  59886. this.releaseGroups(grouper, page);
  59887. }
  59888. },
  59889. readTotalCount: function(resultSet) {
  59890. var total = resultSet.getRemoteTotal();
  59891. if (!isNaN(total)) {
  59892. this.setTotalCount(total);
  59893. }
  59894. },
  59895. releaseGroups: function(grouper, page) {
  59896. var groups = this.getGroups(),
  59897. groupInfo = page.groupInfo,
  59898. first, firstRecords, key, group;
  59899. for (key in groupInfo) {
  59900. first = groupInfo[key];
  59901. group = groups.get(key);
  59902. firstRecords = group.firstRecords;
  59903. if (firstRecords.length === 1) {
  59904. groups.remove(group);
  59905. } else if (firstRecords[0] === first) {
  59906. firstRecords.shift();
  59907. firstRecords.sort(this.sortByPage);
  59908. } else {
  59909. Ext.Array.remove(firstRecords, first);
  59910. }
  59911. }
  59912. },
  59913. sortByPage: function(rec1, rec2) {
  59914. var map = this.pageMap;
  59915. return map.getPageIndex(rec1) - map.getPageIndex(rec2);
  59916. }
  59917. }
  59918. });
  59919. Ext.define('Ext.direct.Event', {
  59920. alias: 'direct.event',
  59921. status: true,
  59922. constructor: function(config) {
  59923. Ext.apply(this, config);
  59924. },
  59925. getName: function() {
  59926. return this.name;
  59927. },
  59928. getData: function() {
  59929. return this.data;
  59930. }
  59931. });
  59932. Ext.define('Ext.direct.RemotingEvent', {
  59933. extend: Ext.direct.Event,
  59934. alias: 'direct.rpc',
  59935. getTransaction: function() {
  59936. var me = this;
  59937. return me.transaction || Ext.direct.Manager.getTransaction(me.tid);
  59938. }
  59939. });
  59940. Ext.define('Ext.direct.ExceptionEvent', {
  59941. extend: Ext.direct.RemotingEvent,
  59942. alias: 'direct.exception',
  59943. status: false
  59944. });
  59945. Ext.define('Ext.direct.JsonProvider', {
  59946. extend: Ext.direct.Provider,
  59947. alias: 'direct.jsonprovider',
  59948. parseResponse: function(response) {
  59949. var text = response && response.responseText;
  59950. if (text != null) {
  59951. if (Ext.isObject(text) || Ext.isArray(text)) {
  59952. return text;
  59953. }
  59954. return Ext.decode(text);
  59955. }
  59956. return null;
  59957. },
  59958. createEvents: function(response) {
  59959. var me = this,
  59960. data = null,
  59961. events = [],
  59962. event, i, len;
  59963. try {
  59964. data = me.parseResponse(response);
  59965. } catch (e) {
  59966. event = new Ext.direct.ExceptionEvent({
  59967. parsingError: true,
  59968. data: e,
  59969. xhr: response,
  59970. code: Ext.direct.Manager.exceptions.PARSE,
  59971. message: 'Error parsing json response: \n\n ' + e
  59972. });
  59973. return [
  59974. event
  59975. ];
  59976. }
  59977. if (Ext.isArray(data)) {
  59978. for (i = 0 , len = data.length; i < len; ++i) {
  59979. events.push(me.createEvent(data[i]));
  59980. }
  59981. } else if (Ext.isObject(data)) {
  59982. events.push(me.createEvent(data));
  59983. }
  59984. return events;
  59985. },
  59986. createEvent: function(response) {
  59987. if (typeof response !== 'object' || !('type' in response)) {
  59988. return new Ext.direct.ExceptionEvent({
  59989. data: response,
  59990. code: Ext.direct.Manager.exceptions.DATA,
  59991. message: 'Invalid data: event type is not specified'
  59992. });
  59993. }
  59994. return Ext.create('direct.' + response.type, response);
  59995. }
  59996. });
  59997. Ext.define('Ext.util.TaskRunner', {
  59998. fireIdleEvent: null,
  59999. interval: 10,
  60000. timerId: null,
  60001. constructor: function(interval) {
  60002. var me = this;
  60003. if (typeof interval === 'number') {
  60004. me.interval = interval;
  60005. } else if (interval) {
  60006. Ext.apply(me, interval);
  60007. }
  60008. me.tasks = [];
  60009. me.timerFn = me.onTick.bind(me);
  60010. },
  60011. newTask: function(config) {
  60012. var task = new Ext.util.TaskRunner.Task(config);
  60013. task.manager = this;
  60014. if (Ext.Timer.track) {
  60015. task.creator = new Error().stack;
  60016. }
  60017. return task;
  60018. },
  60019. start: function(task) {
  60020. var me = this,
  60021. now = Ext.Date.now();
  60022. if (!task.pending) {
  60023. me.tasks.push(task);
  60024. task.pending = true;
  60025. }
  60026. task.stopped = false;
  60027. task.taskStartTime = now;
  60028. task.taskRunTime = task.fireOnStart !== false ? 0 : task.taskStartTime;
  60029. task.taskRunCount = 0;
  60030. if (!me.firing) {
  60031. if (task.fireOnStart !== false) {
  60032. me.startTimer(0, now);
  60033. } else {
  60034. me.startTimer(task.interval, now);
  60035. }
  60036. }
  60037. return task;
  60038. },
  60039. stop: function(task, andRemove) {
  60040. var me = this,
  60041. tasks = me.tasks,
  60042. pendingCount = 0,
  60043. i;
  60044. if (!task.stopped) {
  60045. task.stopped = true;
  60046. task.pending = false;
  60047. if (task.onStop) {
  60048. task.onStop.call(task.scope || task, task);
  60049. }
  60050. }
  60051. if (andRemove) {
  60052. Ext.Array.remove(tasks, task);
  60053. }
  60054. for (i = 0; !pendingCount && i < tasks.length; i++) {
  60055. if (!tasks[i].stopped) {
  60056. pendingCount++;
  60057. }
  60058. }
  60059. if (!pendingCount) {
  60060. Ext.undefer(me.timerId);
  60061. me.timerId = null;
  60062. }
  60063. return task;
  60064. },
  60065. stopAll: function(andRemove) {
  60066. var me = this;
  60067. Ext.each(this.tasks, function(task) {
  60068. me.stop(task, andRemove);
  60069. }, null, true);
  60070. },
  60071. firing: false,
  60072. nextExpires: 1.0E99,
  60073. onTick: function() {
  60074. var me = this,
  60075. tasks = me.tasks,
  60076. fireIdleEvent = me.fireIdleEvent,
  60077. now = Ext.Date.now(),
  60078. nextExpires = 1.0E99,
  60079. len = tasks.length,
  60080. expires, newTasks, i, task, rt, remove, args;
  60081. var timer = Ext.Timer.get(me.timerId);
  60082. if (timer) {
  60083. timer.tasks = [];
  60084. }
  60085. me.timerId = null;
  60086. me.firing = true;
  60087. for (i = 0; i < len || i < (len = tasks.length); ++i) {
  60088. task = tasks[i];
  60089. if (!(remove = task.stopped)) {
  60090. expires = task.taskRunTime + task.interval;
  60091. if (expires <= now) {
  60092. rt = 1;
  60093. if (fireIdleEvent === null && task.fireIdleEvent !== false) {
  60094. fireIdleEvent = true;
  60095. }
  60096. task.taskRunCount++;
  60097. if (task.args) {
  60098. args = task.addCountToArgs ? task.args.concat([
  60099. task.taskRunCount
  60100. ]) : task.args;
  60101. } else {
  60102. args = [
  60103. task.taskRunCount
  60104. ];
  60105. }
  60106. if (timer) {
  60107. timer.tasks.push(task);
  60108. }
  60109. if (me.disableTryCatch) {
  60110. rt = task.run.apply(task.scope || task, args);
  60111. } else {
  60112. try {
  60113. rt = task.run.apply(task.scope || task, args);
  60114. } catch (taskError) {
  60115. try {
  60116. Ext.log({
  60117. fn: task.run,
  60118. prefix: 'Error while running task',
  60119. stack: taskError.stack,
  60120. msg: taskError,
  60121. level: 'error'
  60122. });
  60123. if (task.onError) {
  60124. rt = task.onError.call(task.scope || task, task, taskError);
  60125. }
  60126. } catch (ignore) {}
  60127. }
  60128. }
  60129. task.taskRunTime = now;
  60130. if (rt === false || task.taskRunCount === task.repeat) {
  60131. me.stop(task);
  60132. remove = true;
  60133. } else {
  60134. remove = task.stopped;
  60135. expires = now + task.interval;
  60136. }
  60137. }
  60138. if (!remove && task.duration && task.duration <= (now - task.taskStartTime)) {
  60139. me.stop(task);
  60140. remove = true;
  60141. }
  60142. }
  60143. if (remove) {
  60144. task.pending = false;
  60145. if (!newTasks) {
  60146. newTasks = tasks.slice(0, i);
  60147. }
  60148. } else
  60149. {
  60150. if (newTasks) {
  60151. newTasks.push(task);
  60152. }
  60153. if (nextExpires > expires) {
  60154. nextExpires = expires;
  60155. }
  60156. }
  60157. }
  60158. if (newTasks) {
  60159. me.tasks = newTasks;
  60160. }
  60161. me.firing = false;
  60162. if (me.tasks.length) {
  60163. me.startTimer(nextExpires - now, Ext.Date.now());
  60164. }
  60165. if (fireIdleEvent === null) {
  60166. fireIdleEvent = false;
  60167. }
  60168. Ext._suppressIdle = !fireIdleEvent;
  60169. },
  60170. startTimer: function(timeout, now) {
  60171. var me = this,
  60172. expires = now + timeout,
  60173. timerId = me.timerId;
  60174. if (timerId && me.nextExpires - expires > me.interval) {
  60175. timerId = Ext.undefer(timerId);
  60176. }
  60177. if (!timerId) {
  60178. if (timeout < me.interval) {
  60179. timeout = me.interval;
  60180. }
  60181. me.timerId = Ext.defer(me.timerFn, timeout);
  60182. me.nextExpires = expires;
  60183. var timer = Ext.Timer.get(me.timerId);
  60184. if (timer) {
  60185. timer.runner = me;
  60186. }
  60187. }
  60188. }
  60189. },
  60190. function() {
  60191. var me = this,
  60192. proto = me.prototype;
  60193. proto.destroy = proto.stopAll;
  60194. me.Task = new Ext.Class({
  60195. isTask: true,
  60196. stopped: true,
  60197. fireOnStart: false,
  60198. constructor: function(config) {
  60199. Ext.apply(this, config);
  60200. },
  60201. restart: function(interval) {
  60202. if (interval !== undefined) {
  60203. this.interval = interval;
  60204. }
  60205. this.manager.start(this);
  60206. },
  60207. start: function(interval) {
  60208. if (this.stopped) {
  60209. this.restart(interval);
  60210. }
  60211. },
  60212. stop: function(andRemove) {
  60213. this.manager.stop(this, andRemove);
  60214. },
  60215. destroy: function() {
  60216. this.stop(true);
  60217. }
  60218. });
  60219. proto = me.Task.prototype;
  60220. proto.destroy = proto.stop;
  60221. });
  60222. Ext.define('Ext.direct.PollingProvider', {
  60223. extend: Ext.direct.JsonProvider,
  60224. alias: 'direct.pollingprovider',
  60225. type: 'polling',
  60226. interval: 3000,
  60227. constructor: function(config) {
  60228. var me = this;
  60229. me.callParent([
  60230. config
  60231. ]);
  60232. me.pollTask = Ext.TaskManager.newTask({
  60233. run: me.runPoll,
  60234. interval: me.interval,
  60235. scope: me
  60236. });
  60237. },
  60238. destroy: function() {
  60239. this.pollTask.stop(true);
  60240. this.callParent();
  60241. },
  60242. doConnect: function() {
  60243. var me = this,
  60244. url = me.url,
  60245. pollFn = me.pollFn;
  60246. if (pollFn && Ext.isString(pollFn)) {
  60247. var fnName = pollFn;
  60248. me.pollFn = pollFn = Ext.direct.Manager.parseMethod(pollFn);
  60249. if (!Ext.isFunction(pollFn)) {
  60250. Ext.raise("Cannot resolve Ext Direct API method " + fnName + " for PollingProvider");
  60251. }
  60252. }
  60253. else if (Ext.isFunction(url)) {
  60254. Ext.log.warn('Using a function for url is deprecated, use pollFn instead.');
  60255. me.pollFn = pollFn = url;
  60256. me.url = url = null;
  60257. }
  60258. if (url || pollFn) {
  60259. me.setInterval(me.interval);
  60260. me.pollTask.start();
  60261. }
  60262. },
  60263. doDisconnect: function() {
  60264. if (this.pollTask) {
  60265. this.pollTask.stop();
  60266. }
  60267. },
  60268. getInterval: function() {
  60269. return this.pollTask && this.pollTask.interval;
  60270. },
  60271. setInterval: function(interval) {
  60272. var me = this,
  60273. pollTask = me.pollTask;
  60274. if (interval < 100) {
  60275. Ext.raise("Attempting to configure PollProvider " + me.id + " with interval that is less than 100ms.");
  60276. }
  60277. me.interval = pollTask.interval = interval;
  60278. if (me.isConnected()) {
  60279. pollTask.restart(interval);
  60280. }
  60281. },
  60282. runPoll: function() {
  60283. var me = this,
  60284. url = me.url,
  60285. pollFn = me.pollFn,
  60286. baseParams = me.baseParams,
  60287. args, request;
  60288. if (me.fireEvent('beforepoll', me) !== false) {
  60289. if (pollFn) {
  60290. args = pollFn.directCfg.method.getArgs({
  60291. params: baseParams !== undefined ? baseParams : {},
  60292. callback: me.onPollFn,
  60293. scope: me
  60294. });
  60295. pollFn.apply(window, args);
  60296. } else {
  60297. request = {
  60298. url: url,
  60299. callback: me.onData,
  60300. scope: me,
  60301. params: baseParams,
  60302. headers: me.getHeaders()
  60303. };
  60304. if (me.timeout != null) {
  60305. request.timeout = me.timeout;
  60306. }
  60307. me.sendAjaxRequest(request);
  60308. }
  60309. me.fireEvent('poll', me);
  60310. }
  60311. },
  60312. onData: function(opt, success, response) {
  60313. var me = this,
  60314. i, len, events, event;
  60315. if (success) {
  60316. events = me.createEvents(response);
  60317. for (i = 0 , len = events.length; i < len; ++i) {
  60318. event = events[i];
  60319. me.fireEvent('data', me, event);
  60320. if (!event.status) {
  60321. me.fireEvent('exception', me, event);
  60322. }
  60323. }
  60324. } else {
  60325. event = new Ext.direct.ExceptionEvent({
  60326. data: null,
  60327. code: Ext.direct.Manager.exceptions.TRANSPORT,
  60328. message: 'Unable to connect to the server.',
  60329. xhr: response
  60330. });
  60331. me.fireEvent('data', me, event);
  60332. me.fireEvent('exception', me, event);
  60333. }
  60334. me.callParent([
  60335. opt,
  60336. success,
  60337. response
  60338. ]);
  60339. },
  60340. onPollFn: function(result, event, success, options) {
  60341. this.onData(null, success, {
  60342. responseText: result
  60343. });
  60344. },
  60345. inheritableStatics: {
  60346. checkConfig: function(config) {
  60347. return config && config.type === 'polling' && (config.url || config.pollFn);
  60348. }
  60349. }
  60350. });
  60351. Ext.define('Ext.direct.RemotingMethod', {
  60352. constructor: function(config) {
  60353. var me = this,
  60354. params = config.params,
  60355. len = config.len,
  60356. metadataCfg = config.metadata,
  60357. metadata = {},
  60358. name, pLen, p, param;
  60359. me.name = config.name;
  60360. me.disableBatching = config.batched != null ? !config.batched : false;
  60361. if (config.formHandler) {
  60362. me.formHandler = config.formHandler;
  60363. } else if (Ext.isNumeric(len)) {
  60364. me.len = len;
  60365. me.ordered = true;
  60366. } else {
  60367. me.named = true;
  60368. me.strict = config.strict !== undefined ? config.strict : true;
  60369. me.params = {};
  60370. pLen = params && params.length;
  60371. for (p = 0; p < pLen; p++) {
  60372. param = params[p];
  60373. name = Ext.isObject(param) ? param.name : param;
  60374. me.params[name] = true;
  60375. }
  60376. }
  60377. if (metadataCfg) {
  60378. params = metadataCfg.params;
  60379. len = metadataCfg.len;
  60380. if (Ext.isNumeric(len)) {
  60381. if (len === 0) {
  60382. Ext.raise('metadata.len cannot be 0 ' + 'for Ext Direct method ' + me.name);
  60383. }
  60384. metadata.ordered = true;
  60385. metadata.len = len;
  60386. } else if (Ext.isArray(params)) {
  60387. metadata.named = true;
  60388. metadata.params = {};
  60389. for (p = 0 , pLen = params.length; p < pLen; p++) {
  60390. param = params[p];
  60391. metadata.params[param] = true;
  60392. }
  60393. metadata.strict = metadataCfg.strict !== undefined ? metadataCfg.strict : true;
  60394. } else
  60395. {
  60396. Ext.raise('metadata is neither named nor ordered ' + 'for Ext Direct method ' + me.name);
  60397. }
  60398. me.metadata = metadata;
  60399. }
  60400. },
  60401. getArgs: function(config) {
  60402. var me = this,
  60403. params = config.params,
  60404. paramOrder = config.paramOrder,
  60405. paramsAsArray = config.paramsAsArray,
  60406. metadata = config.metadata,
  60407. options = config.options,
  60408. args = [],
  60409. flatten, i, len;
  60410. if (me.ordered) {
  60411. if (me.len > 0) {
  60412. if (paramOrder) {
  60413. flatten = config.paramsAsArray && me.len === 1 && (paramOrder.length > 1 || Ext.isArray(params));
  60414. if (flatten) {
  60415. if (Ext.isArray(params)) {
  60416. for (i = 0 , len = params.length; i < len; i++) {
  60417. args.push(me.convertParams(params[i], paramOrder, paramOrder.length, true));
  60418. }
  60419. } else {
  60420. args = me.convertParams(params, paramOrder, paramOrder.length, true);
  60421. }
  60422. if (!params.allowSingle || args.length > 1) {
  60423. args = [
  60424. args
  60425. ];
  60426. }
  60427. } else {
  60428. args = me.convertParams(params, paramOrder, me.len, false);
  60429. }
  60430. } else {
  60431. args.push(params);
  60432. }
  60433. }
  60434. } else {
  60435. args.push(params);
  60436. }
  60437. args.push(config.callback, config.scope || window);
  60438. if (options || metadata) {
  60439. options = Ext.apply({}, options);
  60440. if (metadata) {
  60441. options.metadata = metadata;
  60442. }
  60443. args.push(options);
  60444. }
  60445. return args;
  60446. },
  60447. convertParams: function(params, paramOrder, count, flatten) {
  60448. var ret = [],
  60449. paramName, i, len;
  60450. for (i = 0 , len = count; i < len; i++) {
  60451. paramName = paramOrder[i];
  60452. ret.push(params[paramName]);
  60453. }
  60454. if (flatten) {
  60455. return ret.length === 0 ? undefined : ret.length === 1 ? ret[0] : ret;
  60456. } else {
  60457. return ret;
  60458. }
  60459. },
  60460. getCallData: function(args) {
  60461. var me = this,
  60462. data = null,
  60463. len = me.len,
  60464. params = me.params,
  60465. strict = me.strict,
  60466. form, callback, scope, name, options, metadata;
  60467. if (me.ordered) {
  60468. callback = args[len];
  60469. scope = args[len + 1];
  60470. options = args[len + 2];
  60471. if (len !== 0) {
  60472. data = args.slice(0, len);
  60473. }
  60474. } else if (me.formHandler) {
  60475. form = args[0];
  60476. callback = args[1];
  60477. scope = args[2];
  60478. options = args[3];
  60479. } else {
  60480. data = Ext.apply({}, args[0]);
  60481. callback = args[1];
  60482. scope = args[2];
  60483. options = args[3];
  60484. if (strict) {
  60485. for (name in data) {
  60486. if (data.hasOwnProperty(name) && !params[name]) {
  60487. delete data[name];
  60488. }
  60489. }
  60490. }
  60491. }
  60492. if (me.metadata && options && options.metadata) {
  60493. if (me.metadata.ordered) {
  60494. if (!Ext.isArray(options.metadata)) {
  60495. Ext.raise('options.metadata is not an Array ' + 'for Ext Direct method ' + me.name);
  60496. } else if (options.metadata.length < me.metadata.len) {
  60497. Ext.raise('Not enough parameters in options.metadata ' + 'for Ext Direct method ' + me.name);
  60498. }
  60499. metadata = options.metadata.slice(0, me.metadata.len);
  60500. } else {
  60501. if (!Ext.isObject(options.metadata)) {
  60502. Ext.raise('options.metadata is not an Object ' + 'for Ext Direct method ' + me.name);
  60503. }
  60504. metadata = Ext.apply({}, options.metadata);
  60505. if (me.metadata.strict) {
  60506. for (name in metadata) {
  60507. if (metadata.hasOwnProperty(name) && !me.metadata.params[name]) {
  60508. delete metadata[name];
  60509. }
  60510. }
  60511. }
  60512. for (name in me.metadata.params) {
  60513. if (!metadata.hasOwnProperty(name)) {
  60514. Ext.raise('Named parameter ' + name + ' is missing ' + 'in options.metadata for Ext Direct method ' + me.name);
  60515. }
  60516. }
  60517. }
  60518. delete options.metadata;
  60519. }
  60520. return {
  60521. form: form,
  60522. data: data,
  60523. metadata: metadata,
  60524. callback: callback,
  60525. scope: scope,
  60526. options: options
  60527. };
  60528. }
  60529. });
  60530. Ext.define('Ext.direct.Transaction', {
  60531. alias: 'direct.transaction',
  60532. statics: {
  60533. TRANSACTION_ID: 0
  60534. },
  60535. constructor: function(config) {
  60536. var me = this;
  60537. Ext.apply(me, config);
  60538. me.id = me.tid = ++me.self.TRANSACTION_ID;
  60539. me.retryCount = 0;
  60540. },
  60541. send: function() {
  60542. var me = this;
  60543. me.provider.queueTransaction(me);
  60544. },
  60545. retry: function() {
  60546. var me = this;
  60547. me.retryCount++;
  60548. me.send();
  60549. },
  60550. getProvider: function() {
  60551. return this.provider;
  60552. }
  60553. });
  60554. Ext.define('Ext.direct.RemotingProvider', {
  60555. extend: Ext.direct.JsonProvider,
  60556. alias: 'direct.remotingprovider',
  60557. type: 'remoting',
  60558. enableBuffer: 10,
  60559. bufferLimit: Number.MAX_VALUE,
  60560. maxRetries: 1,
  60561. constructor: function(config) {
  60562. var me = this;
  60563. me.callParent([
  60564. config
  60565. ]);
  60566. me.namespace = (Ext.isString(me.namespace)) ? Ext.ns(me.namespace) : me.namespace || Ext.global;
  60567. me.callBuffer = [];
  60568. },
  60569. destroy: function() {
  60570. if (this.callTask) {
  60571. this.callTask.cancel();
  60572. }
  60573. this.callParent();
  60574. },
  60575. connect: function() {
  60576. var me = this;
  60577. if (!me.url) {
  60578. Ext.raise('Error initializing RemotingProvider "' + me.id + '", no url configured.');
  60579. }
  60580. me.callParent();
  60581. },
  60582. doConnect: function() {
  60583. if (!this.apiCreated) {
  60584. this.initAPI();
  60585. this.apiCreated = true;
  60586. }
  60587. },
  60588. getNamespace: function(root, action) {
  60589. var parts, ns, i, len;
  60590. root = root || Ext.global;
  60591. parts = action.toString().split('.');
  60592. for (i = 0 , len = parts.length; i < len; i++) {
  60593. ns = parts[i];
  60594. root = root[ns];
  60595. if (typeof root === 'undefined') {
  60596. return root;
  60597. }
  60598. }
  60599. return root;
  60600. },
  60601. createNamespaces: function(root, action) {
  60602. var parts, ns, i, len;
  60603. root = root || Ext.global;
  60604. parts = action.toString().split('.');
  60605. for (i = 0 , len = parts.length; i < len; i++) {
  60606. ns = parts[i];
  60607. root[ns] = root[ns] || {};
  60608. root = root[ns];
  60609. }
  60610. return root;
  60611. },
  60612. initAPI: function() {
  60613. var me = this,
  60614. actions = me.actions,
  60615. namespace = me.namespace,
  60616. Manager = Ext.direct.Manager,
  60617. action, cls, methods, i, len, method, handler;
  60618. for (action in actions) {
  60619. if (actions.hasOwnProperty(action)) {
  60620. if (me.disableNestedActions) {
  60621. cls = namespace[action];
  60622. if (!cls) {
  60623. cls = namespace[action] = {};
  60624. }
  60625. } else {
  60626. cls = me.getNamespace(namespace, action);
  60627. if (!cls) {
  60628. cls = me.createNamespaces(namespace, action);
  60629. }
  60630. }
  60631. methods = actions[action];
  60632. for (i = 0 , len = methods.length; i < len; ++i) {
  60633. method = new Ext.direct.RemotingMethod(methods[i]);
  60634. cls[method.name] = handler = me.createHandler(action, method);
  60635. Manager.registerMethod(handler.$name, handler);
  60636. }
  60637. }
  60638. }
  60639. },
  60640. createHandler: function(action, method) {
  60641. var me = this,
  60642. handler;
  60643. handler = function() {
  60644. me.invokeFunction(action, method, Array.prototype.slice.call(arguments, 0));
  60645. };
  60646. handler.name = handler.$name = action + '.' + method.name;
  60647. handler.$directFn = true;
  60648. handler.directCfg = handler.$directCfg = {
  60649. action: action,
  60650. method: method
  60651. };
  60652. return handler;
  60653. },
  60654. invokeFunction: function(action, method, args) {
  60655. var me = this,
  60656. transaction, form, isUpload, postParams;
  60657. transaction = me.configureTransaction(action, method, args);
  60658. if (me.fireEvent('beforecall', me, transaction, method) !== false) {
  60659. Ext.direct.Manager.addTransaction(transaction);
  60660. if (transaction.isForm) {
  60661. form = transaction.form;
  60662. isUpload = String(form.getAttribute("enctype")).toLowerCase() === 'multipart/form-data';
  60663. postParams = {
  60664. extTID: transaction.id,
  60665. extAction: action,
  60666. extMethod: method.name,
  60667. extType: 'rpc',
  60668. extUpload: String(isUpload)
  60669. };
  60670. if (transaction.metadata) {
  60671. postParams.extMetadata = Ext.JSON.encode(transaction.metadata);
  60672. }
  60673. Ext.apply(transaction, {
  60674. form: form,
  60675. isUpload: isUpload,
  60676. params: postParams
  60677. });
  60678. }
  60679. me.queueTransaction(transaction);
  60680. me.fireEvent('call', me, transaction, method);
  60681. }
  60682. },
  60683. configureTransaction: function(action, method, args, isForm) {
  60684. var data, cb, scope, options, params;
  60685. data = method.getCallData(args);
  60686. cb = data.callback;
  60687. scope = data.scope;
  60688. options = data.options;
  60689. if (cb && !Ext.isFunction(cb)) {
  60690. Ext.raise("Callback argument is not a function " + "for Ext Direct method " + action + "." + method.name);
  60691. }
  60692. cb = cb && scope ? cb.bind(scope) : cb;
  60693. params = Ext.apply({}, {
  60694. provider: this,
  60695. args: args,
  60696. action: action,
  60697. method: method.name,
  60698. form: data.form,
  60699. data: data.data,
  60700. metadata: data.metadata,
  60701. callbackOptions: options,
  60702. callback: cb,
  60703. isForm: !!method.formHandler,
  60704. disableBatching: method.disableBatching
  60705. });
  60706. if (options && options.timeout != null) {
  60707. params.timeout = options.timeout;
  60708. }
  60709. return new Ext.direct.Transaction(params);
  60710. },
  60711. queueTransaction: function(transaction) {
  60712. var me = this,
  60713. callBuffer = me.callBuffer,
  60714. enableBuffer = me.enableBuffer;
  60715. if (transaction.isForm || enableBuffer === false || transaction.disableBatching || transaction.timeout != null) {
  60716. me.sendTransaction(transaction);
  60717. return;
  60718. }
  60719. callBuffer.push(transaction);
  60720. if (enableBuffer && callBuffer.length < me.bufferLimit) {
  60721. if (!me.callTask) {
  60722. me.callTask = new Ext.util.DelayedTask(me.combineAndSend, me);
  60723. }
  60724. me.callTask.delay(Ext.isNumber(enableBuffer) ? enableBuffer : 10);
  60725. } else {
  60726. me.combineAndSend();
  60727. }
  60728. },
  60729. combineAndSend: function() {
  60730. var me = this,
  60731. buffer = me.callBuffer,
  60732. len = buffer.length;
  60733. if (len > 0) {
  60734. me.sendTransaction(len === 1 ? buffer[0] : buffer);
  60735. me.callBuffer = [];
  60736. }
  60737. },
  60738. sendTransaction: function(transaction) {
  60739. var me = this,
  60740. request, callData, params,
  60741. enableUrlEncode = me.enableUrlEncode,
  60742. payload, i, len;
  60743. request = {
  60744. url: me.url,
  60745. callback: me.onData,
  60746. scope: me,
  60747. transaction: transaction,
  60748. headers: me.getHeaders()
  60749. };
  60750. if (transaction.timeout != null) {
  60751. request.timeout = transaction.timeout;
  60752. } else if (me.timeout != null) {
  60753. request.timeout = me.timeout;
  60754. }
  60755. if (transaction.isForm) {
  60756. Ext.apply(request, {
  60757. params: transaction.params,
  60758. form: transaction.form,
  60759. isUpload: transaction.isUpload
  60760. });
  60761. } else {
  60762. if (Ext.isArray(transaction)) {
  60763. callData = [];
  60764. for (i = 0 , len = transaction.length; i < len; ++i) {
  60765. payload = me.getPayload(transaction[i]);
  60766. callData.push(payload);
  60767. }
  60768. } else {
  60769. callData = me.getPayload(transaction);
  60770. }
  60771. if (enableUrlEncode) {
  60772. params = {};
  60773. params[Ext.isString(enableUrlEncode) ? enableUrlEncode : 'data'] = Ext.encode(callData);
  60774. request.params = params;
  60775. } else {
  60776. request.jsonData = callData;
  60777. }
  60778. }
  60779. return me.sendAjaxRequest(request);
  60780. },
  60781. getPayload: function(transaction) {
  60782. var result = {
  60783. action: transaction.action,
  60784. method: transaction.method,
  60785. data: transaction.data,
  60786. type: 'rpc',
  60787. tid: transaction.id
  60788. };
  60789. if (transaction.metadata) {
  60790. result.metadata = transaction.metadata;
  60791. }
  60792. return result;
  60793. },
  60794. onData: function(options, success, response) {
  60795. var me = this,
  60796. i, len, events, event, transaction, transactions;
  60797. if (me.destroying || me.destroyed) {
  60798. return;
  60799. }
  60800. events = success && me.createEvents(response);
  60801. success = events && events.length && !events[0].parsingError;
  60802. if (success) {
  60803. for (i = 0 , len = events.length; i < len; ++i) {
  60804. event = events[i];
  60805. me.fireEvent('data', me, event);
  60806. transaction = me.getTransaction(event);
  60807. if (transaction) {
  60808. if (me.fireEvent('beforecallback', me, event, transaction) !== false) {
  60809. me.runCallback(transaction, event, true);
  60810. }
  60811. Ext.direct.Manager.removeTransaction(transaction);
  60812. }
  60813. }
  60814. } else {
  60815. transactions = [].concat(options.transaction);
  60816. event = events[0] || new Ext.direct.ExceptionEvent({
  60817. data: null,
  60818. transaction: transaction,
  60819. code: Ext.direct.Manager.exceptions.TRANSPORT,
  60820. message: 'Unable to connect to the server.',
  60821. xhr: response
  60822. });
  60823. for (i = 0 , len = transactions.length; i < len; ++i) {
  60824. transaction = me.getTransaction(transactions[i]);
  60825. if (transaction && transaction.retryCount < me.maxRetries) {
  60826. transaction.retry();
  60827. } else {
  60828. me.fireEvent('data', me, event);
  60829. me.fireEvent('exception', me, event);
  60830. if (transaction && me.fireEvent('beforecallback', me, event, transaction) !== false) {
  60831. me.runCallback(transaction, event, false);
  60832. }
  60833. Ext.direct.Manager.removeTransaction(transaction);
  60834. }
  60835. }
  60836. }
  60837. me.callParent([
  60838. options,
  60839. success,
  60840. response
  60841. ]);
  60842. },
  60843. getTransaction: function(options) {
  60844. return options && options.tid ? Ext.direct.Manager.getTransaction(options.tid) : null;
  60845. },
  60846. runCallback: function(transaction, event) {
  60847. var success = !!event.status,
  60848. funcName = success ? 'success' : 'failure',
  60849. callback, options, result;
  60850. if (transaction && transaction.callback) {
  60851. callback = transaction.callback;
  60852. options = transaction.callbackOptions;
  60853. result = typeof event.result !== 'undefined' ? event.result : event.data;
  60854. if (Ext.isFunction(callback)) {
  60855. callback(result, event, success, options);
  60856. } else {
  60857. Ext.callback(callback[funcName], callback.scope, [
  60858. result,
  60859. event,
  60860. success,
  60861. options
  60862. ]);
  60863. Ext.callback(callback.callback, callback.scope, [
  60864. result,
  60865. event,
  60866. success,
  60867. options
  60868. ]);
  60869. }
  60870. }
  60871. },
  60872. inheritableStatics: {
  60873. checkConfig: function(config) {
  60874. return config && config.type === 'remoting' && config.url && Ext.isArray(config.actions);
  60875. }
  60876. }
  60877. });
  60878. Ext.define('Ext.dom.Fly', {
  60879. extend: Ext.dom.Element,
  60880. alternateClassName: 'Ext.dom.Element.Fly',
  60881. validNodeTypes: {
  60882. 1: 1,
  60883. 9: 1,
  60884. 11: 1
  60885. },
  60886. isFly: true,
  60887. constructor: function(dom) {
  60888. this.dom = dom;
  60889. this.el = this;
  60890. },
  60891. attach: function(dom) {
  60892. var me = this,
  60893. data;
  60894. if (!dom) {
  60895. return me.detach();
  60896. }
  60897. me.dom = Ext.getDom(dom);
  60898. if (!Ext.cache[dom.id]) {
  60899. data = me.peekData();
  60900. if (data) {
  60901. data.isSynchronized = false;
  60902. }
  60903. }
  60904. return me;
  60905. },
  60906. detach: function() {
  60907. return (this.dom = null);
  60908. },
  60909. addListener:
  60910. function() {
  60911. Ext.raise("Cannot use addListener() on Ext.dom.Fly instances. " + "Please use Ext.get() to retrieve an Ext.dom.Element instance instead.");
  60912. } ||
  60913. null,
  60914. removeListener:
  60915. function() {
  60916. Ext.raise("Cannot use removeListener() on Ext.dom.Fly instances. " + "Please use Ext.get() to retrieve an Ext.dom.Element instance instead.");
  60917. } ||
  60918. null
  60919. }, function(Fly) {
  60920. var flyweights = {},
  60921. detachedBodyEl;
  60922. Fly.cache = flyweights;
  60923. Ext.fly = function(dom, named) {
  60924. var fly = null,
  60925. fn = Ext.fly,
  60926. nodeType, data;
  60927. named = named || (fn.caller && (fn.caller.$name || fn.caller.name)) || '_global';
  60928. dom = Ext.getDom(dom);
  60929. if (dom) {
  60930. nodeType = dom.nodeType;
  60931. if (Fly.prototype.validNodeTypes[nodeType] || (!nodeType && (dom.window == dom))) {
  60932. fly = Ext.cache[dom.id];
  60933. if (!fly || fly.dom !== dom) {
  60934. if (named === 'constructor') {
  60935. named = '$constructor';
  60936. }
  60937. fly = flyweights[named] || (flyweights[named] = new Fly());
  60938. fly.dom = dom;
  60939. data = fly.peekData();
  60940. if (data) {
  60941. data.isSynchronized = false;
  60942. }
  60943. }
  60944. }
  60945. }
  60946. return fly;
  60947. };
  60948. Ext.getDetachedBody = function() {
  60949. if (!detachedBodyEl) {
  60950. Ext.detachedBodyEl = detachedBodyEl = new Fly(document.createElement('div'));
  60951. detachedBodyEl.isDetachedBody = true;
  60952. }
  60953. return detachedBodyEl;
  60954. };
  60955. });
  60956. Ext.define('Ext.dom.CompositeElementLite', {
  60957. alternateClassName: [
  60958. 'Ext.CompositeElementLite'
  60959. ],
  60960. isComposite: true,
  60961. isLite: true,
  60962. statics: {
  60963. importElementMethods: function() {
  60964. var Element = Ext.dom.Element,
  60965. prototype = this.prototype;
  60966. Ext.Object.each(Element.prototype, function(name, member) {
  60967. if (typeof member === 'function' && !prototype[name]) {
  60968. prototype[name] = function() {
  60969. return this.invoke(name, arguments);
  60970. };
  60971. }
  60972. });
  60973. }
  60974. },
  60975. constructor: function(elements, skipValidation) {
  60976. if (skipValidation) {
  60977. this.elements = elements || [];
  60978. } else {
  60979. this.elements = [];
  60980. this.add(elements);
  60981. }
  60982. },
  60983. getElement: function(el) {
  60984. var fly = this._fly || (this._fly = new Ext.dom.Fly());
  60985. return fly.attach(el);
  60986. },
  60987. transformElement: function(el) {
  60988. return Ext.getDom(el);
  60989. },
  60990. getCount: function() {
  60991. return this.elements.length;
  60992. },
  60993. add: function(els, root) {
  60994. var elements = this.elements,
  60995. i, ln;
  60996. if (!els) {
  60997. return this;
  60998. }
  60999. if (typeof els == "string") {
  61000. els = Ext.fly(root || document).query(els);
  61001. } else if (els.isComposite) {
  61002. els = els.elements;
  61003. } else if (!Ext.isIterable(els)) {
  61004. els = [
  61005. els
  61006. ];
  61007. }
  61008. for (i = 0 , ln = els.length; i < ln; ++i) {
  61009. elements.push(this.transformElement(els[i]));
  61010. }
  61011. return this;
  61012. },
  61013. invoke: function(fn, args) {
  61014. var me = this,
  61015. elements = me.elements,
  61016. ln = elements.length,
  61017. prototype, element, i;
  61018. if (i !== 0) {
  61019. prototype = (me.isLite ? Ext.dom.Fly : Ext.dom.Element).prototype;
  61020. for (i = 0; i < ln; i++) {
  61021. element = elements[i];
  61022. if (element) {
  61023. prototype[fn].apply(me.getElement(element), args);
  61024. }
  61025. }
  61026. }
  61027. return me;
  61028. },
  61029. item: function(index) {
  61030. var el = this.elements[index],
  61031. out = null;
  61032. if (el) {
  61033. out = this.getElement(el);
  61034. }
  61035. return out;
  61036. },
  61037. slice: function(start, end) {
  61038. return Ext.Array.slice(this.elements, start, end);
  61039. },
  61040. each: function(fn, scope) {
  61041. var me = this,
  61042. els = me.elements,
  61043. len = els.length,
  61044. i, e;
  61045. for (i = 0; i < len; i++) {
  61046. e = els[i];
  61047. if (e) {
  61048. e = this.getElement(e);
  61049. if (fn.call(scope || e, e, me, i) === false) {
  61050. break;
  61051. }
  61052. }
  61053. }
  61054. return me;
  61055. },
  61056. fill: function(els) {
  61057. var me = this;
  61058. me.elements = [];
  61059. me.add(els);
  61060. return me;
  61061. },
  61062. insert: function(index, nodes) {
  61063. Ext.Array.insert(this.elements, index, nodes);
  61064. },
  61065. filter: function(selector) {
  61066. var me = this,
  61067. els = me.elements,
  61068. len = els.length,
  61069. out = [],
  61070. i = 0,
  61071. isFunc = typeof selector == 'function',
  61072. add, el;
  61073. for (; i < len; i++) {
  61074. el = els[i];
  61075. add = false;
  61076. if (el) {
  61077. el = me.getElement(el);
  61078. if (isFunc) {
  61079. add = selector.call(el, el, me, i) !== false;
  61080. } else {
  61081. add = el.is(selector);
  61082. }
  61083. if (add) {
  61084. out.push(me.transformElement(el));
  61085. }
  61086. }
  61087. }
  61088. me.elements = out;
  61089. return me;
  61090. },
  61091. indexOf: function(el) {
  61092. return Ext.Array.indexOf(this.elements, this.transformElement(el));
  61093. },
  61094. replaceElement: function(el, replacement, domReplace) {
  61095. var index = !isNaN(el) ? el : this.indexOf(el),
  61096. d;
  61097. if (index > -1) {
  61098. replacement = Ext.getDom(replacement);
  61099. if (domReplace) {
  61100. d = this.elements[index];
  61101. d.parentNode.insertBefore(replacement, d);
  61102. Ext.removeNode(d);
  61103. }
  61104. Ext.Array.splice(this.elements, index, 1, replacement);
  61105. }
  61106. return this;
  61107. },
  61108. clear: function(removeDom) {
  61109. var me = this,
  61110. els = me.elements,
  61111. i = els.length - 1;
  61112. if (removeDom) {
  61113. for (; i >= 0; i--) {
  61114. Ext.removeNode(els[i]);
  61115. }
  61116. }
  61117. this.elements = [];
  61118. },
  61119. addElements: function(els, root) {
  61120. if (!els) {
  61121. return this;
  61122. }
  61123. if (typeof els === "string") {
  61124. els = Ext.dom.Element.selectorFunction(els, root);
  61125. }
  61126. var yels = this.elements,
  61127. eLen = els.length,
  61128. e;
  61129. for (e = 0; e < eLen; e++) {
  61130. yels.push(Ext.get(els[e]));
  61131. }
  61132. return this;
  61133. },
  61134. first: function() {
  61135. return this.item(0);
  61136. },
  61137. last: function() {
  61138. return this.item(this.getCount() - 1);
  61139. },
  61140. contains: function(el) {
  61141. return this.indexOf(el) != -1;
  61142. },
  61143. removeElement: function(keys, removeDom) {
  61144. keys = [].concat(keys);
  61145. var me = this,
  61146. elements = me.elements,
  61147. kLen = keys.length,
  61148. val, el, k;
  61149. for (k = 0; k < kLen; k++) {
  61150. val = keys[k];
  61151. if ((el = (elements[val] || elements[val = me.indexOf(val)]))) {
  61152. if (removeDom) {
  61153. if (el.dom) {
  61154. el.destroy();
  61155. } else {
  61156. Ext.removeNode(el);
  61157. }
  61158. }
  61159. Ext.Array.erase(elements, val, 1);
  61160. }
  61161. }
  61162. return me;
  61163. },
  61164. destroy: function() {
  61165. this.invoke('destroy', arguments);
  61166. this.callParent();
  61167. }
  61168. }, function(CompositeElementLite) {
  61169. var prototype = CompositeElementLite.prototype;
  61170. CompositeElementLite.importElementMethods();
  61171. prototype.on = prototype.addListener;
  61172. });
  61173. Ext.define('Ext.dom.CompositeElement', {
  61174. alternateClassName: 'Ext.CompositeElement',
  61175. extend: Ext.dom.CompositeElementLite,
  61176. isLite: false,
  61177. getElement: function(el) {
  61178. return el;
  61179. },
  61180. transformElement: function(el) {
  61181. return Ext.get(el);
  61182. }
  61183. });
  61184. Ext.define('Ext.dom.GarbageCollector', {
  61185. singleton: true,
  61186. interval: 30000,
  61187. constructor: function() {
  61188. var me = this;
  61189. me.lastTime = Ext.now();
  61190. me.onTick = me.onTick.bind(me);
  61191. me.onTick.$skipTimerCheck = true;
  61192. me.resume();
  61193. },
  61194. collect: function() {
  61195. var me = this,
  61196. cache = Ext.cache,
  61197. eid, dom, el, t, isGarbage, tagName;
  61198. var collectedIds = [];
  61199. for (eid in cache) {
  61200. if (!cache.hasOwnProperty(eid)) {
  61201. continue;
  61202. }
  61203. el = cache[eid];
  61204. if (el.skipGarbageCollection) {
  61205. continue;
  61206. }
  61207. dom = el.dom;
  61208. if (!dom) {
  61209. Ext.raise('Missing DOM node in element garbage collection: ' + eid);
  61210. }
  61211. try {
  61212. isGarbage = Ext.isGarbage(dom);
  61213. } catch (e) {
  61214. delete cache[eid];
  61215. collectedIds.push('#' + el.id);
  61216. continue;
  61217. }
  61218. if (isGarbage) {
  61219. isGarbage = false;
  61220. if (el && el.dom) {
  61221. tagName = el.dom.tagName;
  61222. el.collect();
  61223. collectedIds.push((tagName ? tagName : '') + '#' + el.id);
  61224. }
  61225. }
  61226. }
  61227. if (Ext.isIE9m) {
  61228. t = {};
  61229. for (eid in cache) {
  61230. if (cache.hasOwnProperty(eid)) {
  61231. t[eid] = cache[eid];
  61232. }
  61233. }
  61234. Ext.cache = Ext.dom.Element.cache = t;
  61235. }
  61236. me.lastTime = Ext.now();
  61237. return collectedIds;
  61238. },
  61239. onTick: function() {
  61240. this.timerId = null;
  61241. if (Ext.enableGarbageCollector) {
  61242. this.collect();
  61243. }
  61244. this.resume();
  61245. },
  61246. pause: function() {
  61247. var timerId = this.timerId;
  61248. if (timerId) {
  61249. this.timerId = null;
  61250. Ext.undefer(timerId);
  61251. }
  61252. },
  61253. resume: function() {
  61254. var me = this,
  61255. lastTime = me.lastTime;
  61256. if (Ext.enableGarbageCollector && (Ext.now() - lastTime) > me.interval) {
  61257. me.collect();
  61258. }
  61259. if (!me.timerId) {
  61260. me.timerId = Ext.defer(me.onTick, me.interval);
  61261. }
  61262. }
  61263. });
  61264. Ext.define('Ext.dom.TouchAction', {
  61265. singleton: true,
  61266. lastTouchStartTime: 0,
  61267. minMoveDistance: 8,
  61268. spaceRe: /\s+/,
  61269. preventSingle: null,
  61270. preventMulti: null,
  61271. disabledOverflowDom: null,
  61272. panXCls: Ext.baseCSSPrefix + 'touch-action-pan-x',
  61273. panYCls: Ext.baseCSSPrefix + 'touch-action-pan-y',
  61274. cssValues: [
  61275. 'none',
  61276. 'pan-x',
  61277. 'pan-y',
  61278. 'pan-x pan-y',
  61279. 'pinch-zoom',
  61280. 'pan-x pinch-zoom',
  61281. 'pan-y pinch-zoom',
  61282. 'pan-x pan-y pinch-zoom',
  61283. 'double-tap-zoom',
  61284. 'pan-x double-tap-zoom',
  61285. 'pan-y double-tap-zoom',
  61286. 'pan-x pan-y double-tap-zoom',
  61287. 'pinch-zoom double-tap-zoom',
  61288. 'pan-x pinch-zoom double-tap-zoom',
  61289. 'pan-y pinch-zoom double-tap-zoom',
  61290. ''
  61291. ],
  61292. objectValues: [
  61293. {
  61294. panX: false,
  61295. panY: false,
  61296. pinchZoom: false,
  61297. doubleTapZoom: false
  61298. },
  61299. {
  61300. panX: true,
  61301. panY: false,
  61302. pinchZoom: false,
  61303. doubleTapZoom: false
  61304. },
  61305. {
  61306. panX: false,
  61307. panY: true,
  61308. pinchZoom: false,
  61309. doubleTapZoom: false
  61310. },
  61311. {
  61312. panX: true,
  61313. panY: true,
  61314. pinchZoom: false,
  61315. doubleTapZoom: false
  61316. },
  61317. {
  61318. panX: false,
  61319. panY: false,
  61320. pinchZoom: true,
  61321. doubleTapZoom: false
  61322. },
  61323. {
  61324. panX: true,
  61325. panY: false,
  61326. pinchZoom: true,
  61327. doubleTapZoom: false
  61328. },
  61329. {
  61330. panX: false,
  61331. panY: true,
  61332. pinchZoom: true,
  61333. doubleTapZoom: false
  61334. },
  61335. {
  61336. panX: true,
  61337. panY: true,
  61338. pinchZoom: true,
  61339. doubleTapZoom: false
  61340. },
  61341. {
  61342. panX: false,
  61343. panY: false,
  61344. pinchZoom: false,
  61345. doubleTapZoom: true
  61346. },
  61347. {
  61348. panX: true,
  61349. panY: false,
  61350. pinchZoom: false,
  61351. doubleTapZoom: true
  61352. },
  61353. {
  61354. panX: false,
  61355. panY: true,
  61356. pinchZoom: false,
  61357. doubleTapZoom: true
  61358. },
  61359. {
  61360. panX: true,
  61361. panY: true,
  61362. pinchZoom: false,
  61363. doubleTapZoom: true
  61364. },
  61365. {
  61366. panX: false,
  61367. panY: false,
  61368. pinchZoom: true,
  61369. doubleTapZoom: true
  61370. },
  61371. {
  61372. panX: true,
  61373. panY: false,
  61374. pinchZoom: true,
  61375. doubleTapZoom: true
  61376. },
  61377. {
  61378. panX: false,
  61379. panY: true,
  61380. pinchZoom: true,
  61381. doubleTapZoom: true
  61382. },
  61383. {
  61384. panX: true,
  61385. panY: true,
  61386. pinchZoom: true,
  61387. doubleTapZoom: true
  61388. }
  61389. ],
  61390. attributeName: 'data-extTouchAction',
  61391. constructor: function() {
  61392. var me = this,
  61393. supports = Ext.supports;
  61394. if (supports.TouchAction) {
  61395. me.cssProp = 'touch-action';
  61396. } else if (supports.MSPointerEvents) {
  61397. me.cssProp = '-ms-touch-action';
  61398. }
  61399. if (supports.TouchEvents) {
  61400. Ext.getWin().on({
  61401. touchstart: 'onTouchStart',
  61402. touchmove: 'onTouchMove',
  61403. touchend: 'onTouchEnd',
  61404. scope: me,
  61405. delegated: false,
  61406. translate: false,
  61407. capture: true,
  61408. priority: 5000
  61409. });
  61410. Ext.on({
  61411. scroll: 'onScroll',
  61412. scope: me,
  61413. destroyable: true
  61414. });
  61415. }
  61416. if (Ext.isFunction(Object.freeze)) {
  61417. var objectValues = me.objectValues;
  61418. for (var i = 0,
  61419. ln = objectValues.length; i < ln; i++) {
  61420. Object.freeze(objectValues[i]);
  61421. }
  61422. }
  61423. },
  61424. containsTargets: function(dom, e) {
  61425. var contains = true,
  61426. event = e.browserEvent,
  61427. touches = e.type === 'touchend' ? event.changedTouches : event.touches,
  61428. i, ln;
  61429. for (i = 0 , ln = touches.length; i < ln; i++) {
  61430. if (!dom.contains(touches[i].target)) {
  61431. contains = false;
  61432. break;
  61433. }
  61434. }
  61435. return contains;
  61436. },
  61437. disableOverflow: function(dom, vertical) {
  61438. var me = this,
  61439. overflowName = vertical ? 'overflow-y' : 'overflow-x',
  61440. overflowStyle, cls;
  61441. if (!me.disabledOverflowDom && !Ext.isiOS && !Ext.getScrollbarSize().width) {
  61442. me.disabledOverflowDom = dom;
  61443. cls = vertical ? me.panXCls : me.panYCls;
  61444. while (dom) {
  61445. overflowStyle = Ext.fly(dom).getStyle(overflowName);
  61446. if (overflowStyle === 'auto' || overflowStyle === 'scroll') {
  61447. Ext.fly(dom).addCls(cls);
  61448. }
  61449. dom = dom.parentNode;
  61450. }
  61451. }
  61452. },
  61453. get: function(dom) {
  61454. var flags = dom.getAttribute(this.attributeName),
  61455. ret = null;
  61456. if (flags != null) {
  61457. ret = this.objectValues[flags];
  61458. }
  61459. return ret;
  61460. },
  61461. getFlags: function(touchAction) {
  61462. var flags;
  61463. if (typeof touchAction === 'number') {
  61464. flags = touchAction;
  61465. } else {
  61466. flags = 0;
  61467. if (touchAction.panX !== false) {
  61468. flags |= 1;
  61469. }
  61470. if (touchAction.panY !== false) {
  61471. flags |= 2;
  61472. }
  61473. if (touchAction.pinchZoom !== false) {
  61474. flags |= 4;
  61475. }
  61476. if (touchAction.doubleTapZoom !== false) {
  61477. flags |= 8;
  61478. }
  61479. }
  61480. return flags;
  61481. },
  61482. isScrollable: function(el, vertical, forward) {
  61483. var overflowStyle = Ext.fly(el).getStyle(vertical ? 'overflow-y' : 'overflow-x'),
  61484. isScrollable = (overflowStyle === 'auto' || overflowStyle === 'scroll');
  61485. if (isScrollable) {
  61486. if (vertical) {
  61487. isScrollable = forward ? (el.scrollTop + el.clientHeight) < el.scrollHeight : el.scrollTop > 0;
  61488. } else {
  61489. isScrollable = forward ? (el.scrollLeft + el.clientWidth) < el.scrollWidth : el.scrollLeft > 0;
  61490. }
  61491. }
  61492. return isScrollable;
  61493. },
  61494. lookupFlags: function(dom) {
  61495. return parseInt((dom.getAttribute && dom.getAttribute(this.attributeName)) || 15, 10);
  61496. },
  61497. onScroll: function() {
  61498. this.scrollOccurred = true;
  61499. this.isDoubleTap = false;
  61500. },
  61501. onTouchEnd: function(e) {
  61502. var me = this,
  61503. dom = e.target,
  61504. touchCount, flags, doubleTapZoom;
  61505. touchCount = e.browserEvent.touches.length;
  61506. if (touchCount === 0) {
  61507. if (me.isDoubleTap) {
  61508. while (dom) {
  61509. flags = me.lookupFlags(dom);
  61510. if (flags != null) {
  61511. doubleTapZoom = flags & 8;
  61512. if (!doubleTapZoom) {
  61513. e.preventDefault();
  61514. }
  61515. }
  61516. dom = dom.parentNode;
  61517. }
  61518. }
  61519. me.isDoubleTap = false;
  61520. me.preventSingle = null;
  61521. me.preventMulti = null;
  61522. me.resetOverflow();
  61523. }
  61524. },
  61525. onTouchMove: function(e) {
  61526. var me = this,
  61527. prevent = null,
  61528. dom = e.target,
  61529. flags, touchCount, panX, panY, point, startPoint, isVertical, scale, distance, deltaX, deltaY, preventSingle, preventMulti;
  61530. preventSingle = me.preventSingle;
  61531. preventMulti = me.preventMulti;
  61532. touchCount = e.browserEvent.touches.length;
  61533. if ((touchCount === 1 && (preventSingle === false)) || (preventMulti === false)) {
  61534. return;
  61535. }
  61536. if ((touchCount > 1 && (preventMulti === true)) || (touchCount === 1 && (preventSingle === true))) {
  61537. prevent = true;
  61538. } else {
  61539. if (touchCount === 1) {
  61540. point = e.getPoint();
  61541. startPoint = me.startPoint;
  61542. scale = Ext.Element.getViewportScale();
  61543. distance = point.getDistanceTo(me.startPoint) * scale;
  61544. deltaX = point.x - startPoint.x;
  61545. deltaY = point.y - startPoint.y;
  61546. isVertical = Math.abs(deltaY) >= Math.abs(deltaX);
  61547. }
  61548. while (dom && (dom.nodeType === 1)) {
  61549. flags = me.lookupFlags(dom);
  61550. if (flags & 0) {
  61551. prevent = true;
  61552. } else if (touchCount === 1) {
  61553. panX = !!(flags & 1);
  61554. panY = !!(flags & 2);
  61555. if (panX && panY) {
  61556. prevent = false;
  61557. } else if (!panX && !panY) {
  61558. prevent = true;
  61559. } else if (distance >= me.minMoveDistance) {
  61560. prevent = !!((panX && isVertical) || (panY && !isVertical));
  61561. }
  61562. if (!prevent && me.isScrollable(dom, isVertical, (isVertical ? deltaY : deltaX) < 0)) {
  61563. break;
  61564. }
  61565. } else if (me.containsTargets(dom, e)) {
  61566. prevent = !(flags & 4);
  61567. } else {
  61568. prevent = false;
  61569. }
  61570. if (prevent) {
  61571. break;
  61572. }
  61573. dom = dom.parentNode;
  61574. }
  61575. }
  61576. if (touchCount === 1) {
  61577. me.preventSingle = prevent;
  61578. } else if (touchCount > 1) {
  61579. me.preventMulti = prevent;
  61580. }
  61581. if (prevent) {
  61582. e.preventDefault();
  61583. }
  61584. },
  61585. onTouchStart: function(e) {
  61586. var me = this,
  61587. time, flags, dom, panX, panY;
  61588. if (e.browserEvent.touches.length === 1) {
  61589. time = e.time;
  61590. if (!me.scrollOccurred && ((time - me.lastTouchStartTime) <= 500)) {
  61591. me.isDoubleTap = true;
  61592. }
  61593. me.lastTouchStartTime = time;
  61594. me.scrollOccurred = false;
  61595. me.startPoint = e.getPoint();
  61596. dom = e.target;
  61597. while (dom) {
  61598. flags = me.lookupFlags(dom);
  61599. if (flags != null) {
  61600. panX = !!(flags & 1);
  61601. panY = !!(flags & 2);
  61602. if (panX !== panY) {
  61603. me.disableOverflow(dom, panX);
  61604. break;
  61605. }
  61606. }
  61607. dom = dom.parentNode;
  61608. }
  61609. } else {
  61610. me.isDoubleTap = false;
  61611. }
  61612. },
  61613. resetOverflow: function() {
  61614. var me = this,
  61615. dom = me.disabledOverflowDom;
  61616. while (dom) {
  61617. Ext.fly(dom).removeCls([
  61618. me.panXCls,
  61619. me.panYCls
  61620. ]);
  61621. dom = dom.parentNode;
  61622. }
  61623. me.disabledOverflowDom = null;
  61624. },
  61625. set: function(dom, value) {
  61626. var me = this,
  61627. cssProp = me.cssProp,
  61628. flags = me.getFlags(value),
  61629. supportedFlags = (flags & Ext.supports.TouchAction),
  61630. attributeName = me.attributeName;
  61631. if (cssProp) {
  61632. Ext.fly(dom).setStyle(cssProp, me.cssValues[supportedFlags]);
  61633. }
  61634. if (flags === 15) {
  61635. dom.removeAttribute(attributeName);
  61636. } else {
  61637. dom.setAttribute(attributeName, flags);
  61638. }
  61639. }
  61640. });
  61641. Ext.define('Ext.drag.Constraint', {
  61642. alias: 'drag.constraint.base',
  61643. mixins: [
  61644. Ext.mixin.Factoryable
  61645. ],
  61646. factoryConfig: {
  61647. defaultType: 'base',
  61648. type: 'drag.constraint'
  61649. },
  61650. config: {
  61651. element: null,
  61652. horizontal: null,
  61653. region: null,
  61654. snap: null,
  61655. source: null,
  61656. vertical: null,
  61657. x: null,
  61658. y: null
  61659. },
  61660. constructor: function(config) {
  61661. this.initConfig(config);
  61662. },
  61663. applyElement: function(element) {
  61664. if (element && typeof element !== 'boolean') {
  61665. element = Ext.get(element);
  61666. }
  61667. return element || null;
  61668. },
  61669. applySnap: function(snap) {
  61670. if (typeof snap === 'number') {
  61671. snap = {
  61672. x: snap,
  61673. y: snap
  61674. };
  61675. }
  61676. return snap;
  61677. },
  61678. constrain: function(xy, info) {
  61679. var me = this,
  61680. x = xy[0],
  61681. y = xy[1],
  61682. constrainInfo = me.constrainInfo,
  61683. initial = constrainInfo.initial,
  61684. constrainX = constrainInfo.x,
  61685. constrainY = constrainInfo.y,
  61686. snap = constrainInfo.snap,
  61687. min, max;
  61688. if (!constrainInfo.vertical) {
  61689. if (snap && snap.x) {
  61690. if (snap.xFn) {
  61691. x = snap.x.call(me, info, x);
  61692. } else {
  61693. x = me.doSnap(x, initial.x, snap.x);
  61694. }
  61695. }
  61696. if (constrainX) {
  61697. min = constrainX[0];
  61698. max = constrainX[1];
  61699. if (min !== null && x < min) {
  61700. x = min;
  61701. }
  61702. if (max !== null && x > max) {
  61703. x = max;
  61704. }
  61705. }
  61706. } else {
  61707. x = initial.x;
  61708. }
  61709. if (!constrainInfo.horizontal) {
  61710. if (snap && snap.y) {
  61711. if (snap.yFn) {
  61712. y = snap.y.call(me, info, y);
  61713. } else {
  61714. y = me.doSnap(y, initial.y, snap.y);
  61715. }
  61716. }
  61717. if (constrainY) {
  61718. min = constrainY[0];
  61719. max = constrainY[1];
  61720. if (min !== null && y < min) {
  61721. y = min;
  61722. }
  61723. if (max !== null && y > max) {
  61724. y = max;
  61725. }
  61726. }
  61727. } else {
  61728. y = initial.y;
  61729. }
  61730. return [
  61731. x,
  61732. y
  61733. ];
  61734. },
  61735. destroy: function() {
  61736. this.setSource(null);
  61737. this.setElement(null);
  61738. this.callParent();
  61739. },
  61740. privates: {
  61741. constrainValue: function(a, b, resolver) {
  61742. var val = null,
  61743. aNull = a === null,
  61744. bNull = b === null;
  61745. if (!(aNull && bNull)) {
  61746. if (aNull) {
  61747. val = b;
  61748. } else if (bNull) {
  61749. val = a;
  61750. } else {
  61751. val = resolver(a, b);
  61752. }
  61753. }
  61754. return val;
  61755. },
  61756. doSnap: function(position, initial, snap) {
  61757. if (!snap) {
  61758. return position;
  61759. }
  61760. var ratio = (position - initial) / snap,
  61761. floor = Math.floor(ratio);
  61762. if (ratio - floor <= 0.5) {
  61763. ratio = floor;
  61764. } else {
  61765. ratio = floor + 1;
  61766. }
  61767. return initial + (snap * ratio);
  61768. },
  61769. onDragStart: function(info) {
  61770. var me = this,
  61771. snap = me.getSnap(),
  61772. vertical = !!me.getVertical(),
  61773. horizontal = !!me.getHorizontal(),
  61774. element = me.getElement(),
  61775. region = me.getRegion(),
  61776. proxy = info.proxy,
  61777. proxyEl = proxy.element,
  61778. x = me.getX(),
  61779. y = me.getY(),
  61780. minX = null,
  61781. maxX = null,
  61782. minY = null,
  61783. maxY = null,
  61784. rminX = null,
  61785. rmaxX = null,
  61786. rminY = null,
  61787. rmaxY = null,
  61788. pos, size;
  61789. if (element) {
  61790. if (typeof element === 'boolean') {
  61791. element = me.getSource().getElement().parent();
  61792. }
  61793. if (info.local) {
  61794. pos = element.getStyle('position');
  61795. if (pos === 'relative' || pos === 'absolute') {
  61796. size = element.getSize();
  61797. region = new Ext.util.Region(0, size.width, size.height, 0);
  61798. } else {
  61799. region = element.getRegion(true, true);
  61800. }
  61801. } else {
  61802. region = element.getRegion(true);
  61803. }
  61804. }
  61805. if (region) {
  61806. if (!vertical) {
  61807. rminX = region.left;
  61808. rmaxX = region.right - (proxyEl ? proxy.width : 0);
  61809. }
  61810. if (!horizontal) {
  61811. rminY = region.top;
  61812. rmaxY = region.bottom - (proxyEl ? proxy.height : 0);
  61813. }
  61814. }
  61815. if (!vertical && (region || x)) {
  61816. if (x) {
  61817. minX = x[0];
  61818. maxX = x[1];
  61819. }
  61820. if (minX !== null || maxX !== null || rminX !== null || rmaxX !== null) {
  61821. minX = me.constrainValue(minX, rminX, Math.max);
  61822. maxX = me.constrainValue(maxX, rmaxX, Math.min);
  61823. x = [
  61824. minX,
  61825. maxX
  61826. ];
  61827. }
  61828. }
  61829. if (!horizontal && (region || y)) {
  61830. if (y) {
  61831. minY = y[0];
  61832. maxY = y[1];
  61833. }
  61834. if (minY !== null || maxY !== null || rminY !== null || rmaxY !== null) {
  61835. minY = me.constrainValue(minY, rminY, Math.max);
  61836. maxY = me.constrainValue(maxY, rmaxY, Math.min);
  61837. y = [
  61838. minY,
  61839. maxY
  61840. ];
  61841. }
  61842. }
  61843. if (snap) {
  61844. snap = {
  61845. x: snap.x,
  61846. xFn: typeof snap.x === 'function',
  61847. y: snap.y,
  61848. yFn: typeof snap.y === 'function'
  61849. };
  61850. }
  61851. me.constrainInfo = {
  61852. initial: info.element.initial,
  61853. vertical: vertical,
  61854. horizontal: horizontal,
  61855. x: x,
  61856. y: y,
  61857. snap: snap
  61858. };
  61859. }
  61860. }
  61861. });
  61862. Ext.define('Ext.drag.Info', {
  61863. constructor: function(source, e) {
  61864. if (!source) {
  61865. return;
  61866. }
  61867. var me = this,
  61868. local = source.getLocal(),
  61869. el, proxyEl, proxy, x, xy, y, pageXY, elPageXY;
  61870. me.source = source;
  61871. me.local = local;
  61872. xy = me.getEventXY(e);
  61873. pageXY = e.getXY();
  61874. el = source.getElement();
  61875. elPageXY = el.getXY();
  61876. xy = local ? el.getLocalXY() : elPageXY;
  61877. x = xy[0];
  61878. y = xy[1];
  61879. me.initialEvent = e;
  61880. me.eventTarget = e.target;
  61881. me.cursor = {
  61882. current: {
  61883. x: x,
  61884. y: y
  61885. },
  61886. delta: {
  61887. x: 0,
  61888. y: 0
  61889. },
  61890. initial: {
  61891. x: pageXY[0],
  61892. y: pageXY[1]
  61893. },
  61894. offset: {
  61895. x: pageXY[0] - elPageXY[0],
  61896. y: pageXY[1] - elPageXY[1]
  61897. }
  61898. };
  61899. me.element = {
  61900. current: {
  61901. x: x,
  61902. y: y
  61903. },
  61904. delta: {
  61905. x: 0,
  61906. y: 0
  61907. },
  61908. initial: {
  61909. x: x,
  61910. y: y
  61911. }
  61912. };
  61913. me.proxy = {
  61914. instance: source.getProxy(),
  61915. current: {
  61916. x: x,
  61917. y: y
  61918. },
  61919. delta: {
  61920. x: 0,
  61921. y: 0
  61922. },
  61923. initial: {
  61924. x: x,
  61925. y: y
  61926. },
  61927. element: el,
  61928. isUnderCursor: false,
  61929. isElement: true
  61930. };
  61931. me.types = [];
  61932. me.data = {};
  61933. source.describe(me);
  61934. proxy = me.proxy;
  61935. proxyEl = proxy.instance.setupElement(me);
  61936. proxy.isElement = proxyEl === source.getElement();
  61937. proxy.element = proxyEl;
  61938. if (proxyEl) {
  61939. proxy.width = proxyEl.getWidth();
  61940. proxy.height = proxyEl.getHeight();
  61941. }
  61942. if (proxy.isElement) {
  61943. el = me.element;
  61944. el.current = proxy.current;
  61945. el.delta = proxy.delta;
  61946. }
  61947. me.needsCursorCheck = proxy.element && source.manager && source.manager.pointerBug;
  61948. },
  61949. cursor: null,
  61950. element: null,
  61951. eventTarget: null,
  61952. files: null,
  61953. isNative: false,
  61954. proxy: null,
  61955. source: null,
  61956. target: null,
  61957. types: null,
  61958. valid: false,
  61959. clearData: function(type) {
  61960. Ext.Array.remove(this.types, type);
  61961. delete this.data[type];
  61962. },
  61963. clone: function() {
  61964. var me = this,
  61965. ret = new Ext.drag.Info();
  61966. ret.cursor = Ext.merge({}, me.cursor);
  61967. ret.data = Ext.apply({}, me.data);
  61968. ret.element = Ext.merge({}, me.element);
  61969. ret.eventTarget = me.eventTarget;
  61970. ret.proxy = Ext.merge({}, me.proxy);
  61971. ret.source = me.source;
  61972. ret.target = me.target;
  61973. ret.types = Ext.Array.clone(me.types);
  61974. ret.valid = me.valid;
  61975. return ret;
  61976. },
  61977. getData: function(type) {
  61978. var me = this,
  61979. data = me.data,
  61980. dt = me.dataTransfer,
  61981. ret;
  61982. if (dt) {
  61983. ret = dt.getData(type);
  61984. } else {
  61985. if (!me.finalized) {
  61986. Ext.raise('Unable to call getData until the drop is complete');
  61987. }
  61988. ret = data[type];
  61989. if (typeof ret === 'function') {
  61990. data[type] = ret = ret.call(me.source, me);
  61991. }
  61992. if (!ret && ret !== 0) {
  61993. ret = '';
  61994. }
  61995. }
  61996. return Ext.Promise.resolve(ret);
  61997. },
  61998. setData: function(type, value) {
  61999. Ext.Array.include(this.types, type);
  62000. this.data[type] = value;
  62001. },
  62002. destroy: function() {
  62003. var me = this;
  62004. me.eventTarget = me.data = me.proxy = me.targetMap = me.targetMap = me.types = me.elementMap = me.possibleTargets = me.target = null;
  62005. me.callParent();
  62006. },
  62007. privates: {
  62008. data: null,
  62009. dataTransfer: null,
  62010. elementMap: null,
  62011. possibleTargets: null,
  62012. targetMap: null,
  62013. copyNativeData: function(target, e) {
  62014. var dt = e.browserEvent.dataTransfer;
  62015. this.target = target;
  62016. this.dataTransfer = dt;
  62017. this.files = dt.files;
  62018. },
  62019. finalize: function() {
  62020. var me = this,
  62021. target = me.target;
  62022. me.finalized = true;
  62023. if (target) {
  62024. target.info = null;
  62025. target.handleDrop(me);
  62026. }
  62027. },
  62028. getAlignXY: function(x, y) {
  62029. var me = this,
  62030. source = me.source,
  62031. cursorOffset = me.cursor.offset,
  62032. proxy = source.getProxy(),
  62033. proxyEl = me.proxy.element,
  62034. constrain = source.getConstrain(),
  62035. xy = [
  62036. x,
  62037. y
  62038. ];
  62039. if (proxyEl) {
  62040. if (me.proxy.isElement) {
  62041. xy[0] -= cursorOffset.x;
  62042. xy[1] -= cursorOffset.y;
  62043. } else {
  62044. xy = proxy.adjustCursorOffset(me, xy);
  62045. }
  62046. if (constrain) {
  62047. xy = constrain.constrain(xy, me);
  62048. }
  62049. }
  62050. return xy;
  62051. },
  62052. getEventXY: function(e) {
  62053. var xy = e.getXY(),
  62054. source = this.source;
  62055. if (this.local) {
  62056. xy = source.convertToLocalXY(xy);
  62057. }
  62058. return xy;
  62059. },
  62060. onNativeDragEnter: function(target, e) {
  62061. var me = this;
  62062. me.valid = target.accepts(me);
  62063. target.info = me;
  62064. me.copyNativeData(target, e);
  62065. },
  62066. onNativeDragLeave: function(target, e) {
  62067. var me = this;
  62068. if (me.target === target) {
  62069. target.info = null;
  62070. me.valid = false;
  62071. me.target = me.dataTransfer = me.files = null;
  62072. }
  62073. },
  62074. onNativeDragMove: function(target, e) {
  62075. this.copyNativeData(target, e);
  62076. },
  62077. onNativeDrop: function(target, e) {
  62078. this.copyNativeData(target, e);
  62079. target.info = null;
  62080. },
  62081. setActive: function(target) {
  62082. var me = this,
  62083. source = me.source,
  62084. current = me.target,
  62085. changed = current !== target;
  62086. if (current && changed) {
  62087. current.handleDragLeave(me);
  62088. current.info = null;
  62089. }
  62090. me.target = target;
  62091. if (target) {
  62092. if (changed) {
  62093. me.valid = !!me.possibleTargets[target.getId()] && target.accepts(me) !== false;
  62094. target.handleDragEnter(me);
  62095. target.info = me;
  62096. }
  62097. target.handleDragMove(me);
  62098. } else {
  62099. me.valid = false;
  62100. }
  62101. if (changed) {
  62102. source.getProxy().update(me);
  62103. }
  62104. },
  62105. update: function(event, beforeStart) {
  62106. var me = this,
  62107. xy = me.getEventXY(event),
  62108. x = xy[0],
  62109. y = xy[1],
  62110. alignXY = me.getAlignXY(x, y),
  62111. alignX = alignXY[0],
  62112. alignY = alignXY[1],
  62113. proxyData = me.proxy,
  62114. cursor = me.cursor,
  62115. current = cursor.current,
  62116. delta = cursor.delta,
  62117. initial = cursor.initial,
  62118. proxy = proxyData.instance;
  62119. current.x = x;
  62120. current.y = y;
  62121. delta.x = x - initial.x;
  62122. delta.y = y - initial.y;
  62123. current = proxyData.current;
  62124. delta = proxyData.delta;
  62125. initial = proxyData.initial;
  62126. current.x = alignX;
  62127. current.y = alignY;
  62128. delta.x = alignX - initial.x;
  62129. delta.y = alignY - initial.y;
  62130. if (me.needsCursorCheck) {
  62131. proxyData.isUnderCursor = !(x < alignX || y < alignY || x > proxyData.width + alignX || y > proxyData.height + alignY);
  62132. }
  62133. if (!beforeStart && proxy) {
  62134. proxy.setXY(me, alignXY);
  62135. }
  62136. }
  62137. }
  62138. });
  62139. Ext.define('Ext.drag.Item', {
  62140. mixins: [
  62141. Ext.mixin.Observable,
  62142. Ext.mixin.Identifiable
  62143. ],
  62144. config: {
  62145. autoDestroy: true,
  62146. component: null,
  62147. element: null,
  62148. groups: null
  62149. },
  62150. constructor: function(config) {
  62151. this.mixins.observable.constructor.call(this, config);
  62152. },
  62153. isDisabled: function() {
  62154. return this.disabled;
  62155. },
  62156. disable: function() {
  62157. this.disabled = true;
  62158. },
  62159. enable: function() {
  62160. this.disabled = false;
  62161. },
  62162. updateComponent: function(comp, was) {
  62163. var el;
  62164. if (comp) {
  62165. el = comp.el;
  62166. } else if (was && was.el === this.getElement()) {
  62167. el = null;
  62168. } else {
  62169. return;
  62170. }
  62171. this.setElement(el);
  62172. },
  62173. applyElement: function(element) {
  62174. return element ? Ext.get(element) : null;
  62175. },
  62176. updateElement: function() {
  62177. this.setupListeners();
  62178. },
  62179. applyGroups: function(group) {
  62180. if (typeof group === 'string') {
  62181. group = [
  62182. group
  62183. ];
  62184. }
  62185. return group;
  62186. },
  62187. destroy: function() {
  62188. var me = this,
  62189. el = me.getElement();
  62190. me.destroying = true;
  62191. me.setElement(null);
  62192. if (el && me.getAutoDestroy()) {
  62193. el.destroy();
  62194. }
  62195. me.callParent();
  62196. me.destroying = false;
  62197. },
  62198. privates: {
  62199. disabled: false,
  62200. convertToLocalXY: function(xy) {
  62201. var c = this.getComponent();
  62202. if (c) {
  62203. xy = c.convertToLocalXY(xy);
  62204. } else {
  62205. xy = this.getElement().translateXY(xy[0], xy[1]);
  62206. xy = [
  62207. xy.x,
  62208. xy.y
  62209. ];
  62210. }
  62211. return xy;
  62212. },
  62213. getElListeners: Ext.privateFn,
  62214. setupListeners: function(element) {
  62215. var me = this,
  62216. elListeners = me.elListeners;
  62217. element = element || me.getElement();
  62218. if (elListeners) {
  62219. elListeners.destroy();
  62220. me.elListeners = null;
  62221. }
  62222. if (element) {
  62223. me.elListeners = element.on(Ext.apply({
  62224. scope: me,
  62225. destroyable: true
  62226. }, me.getElListeners()));
  62227. }
  62228. }
  62229. }
  62230. });
  62231. Ext.define('Ext.drag.Manager', {
  62232. singleton: true,
  62233. dragCls: Ext.baseCSSPrefix + 'drag-body',
  62234. pointerBug: Ext.isTouch || (!Ext.supports.CSSPointerEvents || Ext.isIE10m || Ext.isOpera),
  62235. constructor: function() {
  62236. this.targets = {};
  62237. this.nativeTargets = [];
  62238. Ext.onReady(this.init, this);
  62239. },
  62240. init: function() {
  62241. Ext.getDoc().on({
  62242. scope: this,
  62243. dragenter: {
  62244. capture: true,
  62245. fn: 'onNativeDragEnter'
  62246. },
  62247. dragleave: 'onNativeDragLeave',
  62248. dragover: 'onNativeDragOver',
  62249. drop: 'onNativeDrop'
  62250. });
  62251. },
  62252. destroy: function() {
  62253. var me = this,
  62254. targets = me.targets,
  62255. key;
  62256. me.destroying = true;
  62257. for (key in targets) {
  62258. targets[key].destroy();
  62259. }
  62260. me.targets = null;
  62261. me.callParent();
  62262. me.destroying = false;
  62263. },
  62264. privates: {
  62265. elementFromPoint: function(x, y) {
  62266. if (Ext.rootInheritedState.rtl) {
  62267. x = Ext.Element.getViewportWidth() - x;
  62268. }
  62269. return Ext.dom.Element.fromPagePoint(x, y, true);
  62270. },
  62271. getAtPoint: function(info) {
  62272. var current = info.cursor.current,
  62273. elementMap = info.elementMap,
  62274. isUnderCursor = info.proxy.isUnderCursor,
  62275. proxyEl = this.pointerBug && isUnderCursor ? info.proxy.element.dom : null,
  62276. target, el;
  62277. if (proxyEl) {
  62278. proxyEl.style.visibility = 'hidden';
  62279. }
  62280. el = this.elementFromPoint(current.x, current.y);
  62281. if (proxyEl) {
  62282. proxyEl.style.visibility = 'visible';
  62283. }
  62284. while (el) {
  62285. target = elementMap[el.id];
  62286. if (target) {
  62287. return target;
  62288. }
  62289. el = el.parentNode;
  62290. }
  62291. return null;
  62292. },
  62293. getNativeDragInfo: function(e) {
  62294. var info = this.nativeDragInfo;
  62295. if (!info) {
  62296. this.nativeDragInfo = info = new Ext.drag.Info();
  62297. info.isNative = true;
  62298. }
  62299. return info;
  62300. },
  62301. onDragCancel: function() {
  62302. Ext.getBody().removeCls(this.dragCls);
  62303. },
  62304. onDragEnd: function(info, e) {
  62305. info.finalize();
  62306. Ext.getBody().removeCls(this.dragCls);
  62307. },
  62308. onDragMove: function(info, e) {
  62309. this.processDrag(info);
  62310. },
  62311. onDragStart: function(info, e) {
  62312. var me = this,
  62313. source = info.source,
  62314. targets = me.targets,
  62315. groups = source.getGroups(),
  62316. targetMap = {},
  62317. possibleTargets = {},
  62318. elementMap = {},
  62319. id, target, targetGroups, groupMap, groupOk, len, i;
  62320. elementMap = {};
  62321. possibleTargets = {};
  62322. if (groups) {
  62323. groupMap = Ext.Array.toMap(groups);
  62324. }
  62325. for (id in targets) {
  62326. target = targets[id];
  62327. if (!target.isDisabled()) {
  62328. groupOk = false;
  62329. targetGroups = target.getGroups();
  62330. if (!groupMap && !targetGroups) {
  62331. groupOk = true;
  62332. } else if (groupMap && targetGroups) {
  62333. for (i = 0 , len = targetGroups.length; i < len; ++i) {
  62334. if (groupMap[targetGroups[i]]) {
  62335. groupOk = true;
  62336. break;
  62337. }
  62338. }
  62339. }
  62340. if (groupOk) {
  62341. possibleTargets[id] = target;
  62342. }
  62343. }
  62344. targetMap[id] = target;
  62345. elementMap[target.getElement().id] = target;
  62346. }
  62347. info.possibleTargets = possibleTargets;
  62348. info.targetMap = targetMap;
  62349. info.elementMap = elementMap;
  62350. Ext.getBody().addCls(me.dragCls);
  62351. me.processDrag(info);
  62352. },
  62353. onNativeDragEnter: function(e) {
  62354. var nativeTargets = this.nativeTargets,
  62355. target = e.target;
  62356. e.preventDefault();
  62357. if (nativeTargets[nativeTargets.length - 1] !== target) {
  62358. nativeTargets.push(target);
  62359. }
  62360. },
  62361. onNativeDragLeave: function(e) {
  62362. var nativeTargets = this.nativeTargets;
  62363. Ext.Array.remove(nativeTargets, e.target);
  62364. if (nativeTargets.length === 0) {
  62365. this.nativeDragInfo = null;
  62366. }
  62367. },
  62368. onNativeDragOver: function(e) {
  62369. e.preventDefault();
  62370. },
  62371. onNativeDrop: function(e) {
  62372. e.preventDefault();
  62373. this.nativeTargets.length = 0;
  62374. this.nativeDragInfo = null;
  62375. },
  62376. processDrag: function(info) {
  62377. info.setActive(this.getAtPoint(info));
  62378. },
  62379. register: function(target) {
  62380. this.targets[target.getId()] = target;
  62381. },
  62382. unregister: function(target) {
  62383. if (this.destroying) {
  62384. return;
  62385. }
  62386. delete this.targets[target.getId()];
  62387. }
  62388. }
  62389. });
  62390. Ext.define('Ext.drag.Source', {
  62391. extend: Ext.drag.Item,
  62392. defaultIdPrefix: 'source-',
  62393. config: {
  62394. activateOnLongPress: false,
  62395. activeCls: null,
  62396. constrain: null,
  62397. handle: null,
  62398. local: null,
  62399. proxy: 'original',
  62400. revert: false
  62401. },
  62402. dragging: false,
  62403. constructor: function(config) {
  62404. var describe = config && config.describe;
  62405. if (describe) {
  62406. this.describe = describe;
  62407. config = Ext.apply({}, config);
  62408. delete config.describe;
  62409. }
  62410. this.callParent([
  62411. config
  62412. ]);
  62413. this.manager = Ext.drag['Manager'];
  62414. },
  62415. describe: Ext.emptyFn,
  62416. isDragging: function() {
  62417. return this.dragging;
  62418. },
  62419. beforeDragStart: Ext.emptyFn,
  62420. onDragCancel: Ext.emptyFn,
  62421. onDragEnd: Ext.emptyFn,
  62422. onDragMove: Ext.emptyFn,
  62423. onDragStart: Ext.emptyFn,
  62424. applyActivateOnLongPress: function(activateOnLongPress) {
  62425. if (typeof activateOnLongPress === 'string') {
  62426. activateOnLongPress = [
  62427. activateOnLongPress
  62428. ];
  62429. }
  62430. return activateOnLongPress;
  62431. },
  62432. updateActivateOnLongPress: function(activateOnLongPress) {
  62433. if (!this.isConfiguring) {
  62434. this.setupListeners();
  62435. }
  62436. },
  62437. updateActiveCls: function(cls, oldCls) {
  62438. if (this.dragging) {
  62439. var el = this.getElement();
  62440. el.replaceCls(oldCls, cls);
  62441. }
  62442. },
  62443. applyConstrain: function(constrain) {
  62444. if (constrain && !constrain.$isClass) {
  62445. if (constrain.isRegion) {
  62446. constrain = {
  62447. region: constrain
  62448. };
  62449. } else if (constrain.isElement || !Ext.isObject(constrain)) {
  62450. constrain = {
  62451. element: constrain
  62452. };
  62453. }
  62454. constrain = Ext.apply({
  62455. source: this
  62456. }, constrain);
  62457. constrain = Ext.Factory.dragConstraint(constrain);
  62458. }
  62459. return constrain;
  62460. },
  62461. updateElement: function(element, oldElement) {
  62462. if (oldElement && !oldElement.destroyed) {
  62463. oldElement.un('dragstart', 'stopNativeDrag', this);
  62464. }
  62465. if (element && !this.getHandle()) {
  62466. element.setTouchAction({
  62467. panX: false,
  62468. panY: false
  62469. });
  62470. element.on('dragstart', 'stopNativeDrag', this, {
  62471. translate: false,
  62472. delegated: false
  62473. });
  62474. }
  62475. this.callParent([
  62476. element,
  62477. oldElement
  62478. ]);
  62479. },
  62480. updateHandle: function() {
  62481. if (!this.isConfiguring) {
  62482. this.setupListeners();
  62483. }
  62484. },
  62485. applyProxy: function(proxy) {
  62486. if (proxy) {
  62487. proxy = Ext.Factory.dragproxy(proxy);
  62488. }
  62489. return proxy;
  62490. },
  62491. updateProxy: function(proxy, oldProxy) {
  62492. if (oldProxy) {
  62493. oldProxy.destroy();
  62494. }
  62495. if (proxy) {
  62496. proxy.setSource(this);
  62497. }
  62498. },
  62499. resolveListenerScope: function() {
  62500. var ownerCmp = this.ownerCmp,
  62501. a = arguments;
  62502. if (ownerCmp) {
  62503. return ownerCmp.resolveListenerScope.apply(ownerCmp, a);
  62504. }
  62505. return this.callParent(a);
  62506. },
  62507. destroy: function() {
  62508. var me = this;
  62509. me.manager = me.initialEvent = null;
  62510. me.setConstrain(null);
  62511. me.setProxy(null);
  62512. me.callParent();
  62513. },
  62514. privates: {
  62515. draggingCls: Ext.baseCSSPrefix + 'drag-dragging',
  62516. info: null,
  62517. revertCls: Ext.baseCSSPrefix + 'drag-revert',
  62518. canActivateOnLongPress: function(e) {
  62519. var activate = this.getActivateOnLongPress();
  62520. return !!(activate && (activate === true || Ext.Array.contains(activate, e.pointerType)));
  62521. },
  62522. dragCleanup: function(info) {
  62523. var me = this,
  62524. cls = me.getActiveCls(),
  62525. proxy = me.getProxy(),
  62526. el = me.getElement(),
  62527. proxyEl = info ? info.proxy.element : null;
  62528. if (cls) {
  62529. el.removeCls(cls);
  62530. }
  62531. if (proxyEl) {
  62532. proxyEl.removeCls(me.draggingCls);
  62533. }
  62534. proxy.cleanup(info);
  62535. me.dragging = false;
  62536. me.initialEvent = me.info = null;
  62537. },
  62538. getElListeners: function() {
  62539. var o = {
  62540. touchstart: 'handleTouchStart',
  62541. dragstart: 'handleDragStart',
  62542. drag: 'handleDragMove',
  62543. dragend: 'handleDragEnd',
  62544. dragcancel: 'handleDragCancel'
  62545. },
  62546. handle = this.getHandle();
  62547. if (handle) {
  62548. o.dragstart = {
  62549. fn: o.dragstart,
  62550. delegate: handle
  62551. };
  62552. }
  62553. if (this.getActivateOnLongPress()) {
  62554. o.longpress = 'handleLongPress';
  62555. }
  62556. return o;
  62557. },
  62558. handleDragCancel: function(e) {
  62559. var me = this,
  62560. info = me.info,
  62561. manager = me.manager;
  62562. if (manager) {
  62563. manager.onDragCancel(info, e);
  62564. }
  62565. me.onDragCancel(info);
  62566. if (me.hasListeners.dragcancel) {
  62567. me.fireEvent('dragcancel', me, info, e);
  62568. }
  62569. Ext.fireEvent('dragcancel', me, info, e);
  62570. me.dragCleanup(info);
  62571. },
  62572. handleDragEnd: function(e) {
  62573. if (!this.dragging) {
  62574. return;
  62575. }
  62576. var me = this,
  62577. manager = me.manager,
  62578. revert = me.getRevert(),
  62579. info = me.info,
  62580. proxy = info.proxy;
  62581. info.update(e);
  62582. if (manager) {
  62583. manager.onDragEnd(info, e);
  62584. }
  62585. me.onDragEnd(info);
  62586. if (me.hasListeners.dragend) {
  62587. me.fireEvent('dragend', me, info, e);
  62588. }
  62589. Ext.fireEvent('dragend', me, info, e);
  62590. proxy = proxy.instance;
  62591. if (revert && proxy) {
  62592. proxy.dragRevert(info, me.revertCls, revert, function() {
  62593. me.dragCleanup(info);
  62594. });
  62595. } else {
  62596. me.dragCleanup(info);
  62597. }
  62598. },
  62599. handleDragMove: function(e) {
  62600. var me = this,
  62601. info = me.info,
  62602. manager = me.manager;
  62603. if (!me.dragging) {
  62604. return;
  62605. }
  62606. e.stopPropagation();
  62607. e.claimGesture();
  62608. info.update(e);
  62609. if (manager) {
  62610. manager.onDragMove(info, e);
  62611. }
  62612. me.onDragMove(info);
  62613. if (me.hasListeners.dragmove) {
  62614. me.fireEvent('dragmove', me, info, e);
  62615. }
  62616. },
  62617. handleDragStart: function(e) {
  62618. var me = this,
  62619. hasListeners = me.hasListeners,
  62620. manager = me.manager,
  62621. constrain = me.getConstrain(),
  62622. initialEvent = me.initialEvent,
  62623. el, cls, info, cancel, proxyEl;
  62624. if (me.preventStart(e)) {
  62625. return false;
  62626. }
  62627. if (hasListeners.initdragconstraints) {
  62628. me.fireEvent('initdragconstraints', me, e);
  62629. }
  62630. me.info = info = new Ext.drag.Info(me, initialEvent);
  62631. me.setup(info);
  62632. if (constrain) {
  62633. constrain.onDragStart(info);
  62634. }
  62635. info.update(e, true);
  62636. cancel = me.beforeDragStart(info) === false;
  62637. if (!cancel && hasListeners.beforedragstart) {
  62638. cancel = me.fireEvent('beforedragstart', me, info, e) === false;
  62639. }
  62640. if (cancel) {
  62641. me.dragCleanup();
  62642. return false;
  62643. }
  62644. e.claimGesture();
  62645. me.dragging = true;
  62646. cls = me.getActiveCls();
  62647. el = me.getElement();
  62648. if (cls) {
  62649. el.addCls(cls);
  62650. }
  62651. proxyEl = info.proxy.element;
  62652. if (proxyEl) {
  62653. proxyEl.addCls(me.draggingCls);
  62654. }
  62655. info.update(e);
  62656. if (manager) {
  62657. manager.onDragStart(info, e);
  62658. }
  62659. me.onDragStart(info);
  62660. if (hasListeners.dragstart) {
  62661. me.fireEvent('dragstart', me, info, e);
  62662. }
  62663. Ext.fireEvent('dragstart', me, info, e);
  62664. },
  62665. handleLongPress: function(e) {
  62666. if (!this.isDisabled() && this.canActivateOnLongPress(e)) {
  62667. this.initialEvent = e;
  62668. e.startDrag();
  62669. }
  62670. },
  62671. handleTouchStart: function(e) {
  62672. if (!this.isDisabled()) {
  62673. this.initialEvent = e;
  62674. }
  62675. },
  62676. preventStart: function(e) {
  62677. return this.isDisabled() || (!e.longpress && this.canActivateOnLongPress(e));
  62678. },
  62679. setup: Ext.privateFn,
  62680. stopNativeDrag: function(e) {
  62681. e.preventDefault();
  62682. }
  62683. }
  62684. });
  62685. Ext.define('Ext.drag.Target', {
  62686. extend: Ext.drag.Item,
  62687. defaultIdPrefix: 'target-',
  62688. config: {
  62689. invalidCls: '',
  62690. validCls: ''
  62691. },
  62692. constructor: function(config) {
  62693. var me = this,
  62694. accepts = config && config.accepts;
  62695. if (accepts) {
  62696. me.accepts = accepts;
  62697. config = Ext.apply({}, config);
  62698. delete config.accepts;
  62699. }
  62700. me.callParent([
  62701. config
  62702. ]);
  62703. Ext.drag.Manager.register(me);
  62704. },
  62705. accepts: function(info) {
  62706. return true;
  62707. },
  62708. disable: function() {
  62709. this.callParent();
  62710. this.setupListeners(null);
  62711. },
  62712. enable: function() {
  62713. this.callParent();
  62714. this.setupListeners();
  62715. },
  62716. beforeDrop: Ext.emptyFn,
  62717. onDrop: Ext.emptyFn,
  62718. onDragEnter: Ext.emptyFn,
  62719. onDragLeave: Ext.emptyFn,
  62720. onDragMove: Ext.emptyFn,
  62721. updateInvalidCls: function(invalidCls, oldInvalidCls) {
  62722. var info = this.info;
  62723. this.doUpdateCls(info && !info.valid, invalidCls, oldInvalidCls);
  62724. },
  62725. updateValidCls: function(validCls, oldValidCls) {
  62726. var info = this.info;
  62727. this.doUpdateCls(info && info.valid, validCls, oldValidCls);
  62728. },
  62729. destroy: function() {
  62730. Ext.drag.Manager.unregister(this);
  62731. this.callParent();
  62732. },
  62733. privates: {
  62734. doUpdateCls: function(needsAdd, cls, oldCls) {
  62735. var el = this.getElement();
  62736. if (oldCls) {
  62737. el.removeCls(oldCls);
  62738. }
  62739. if (cls && needsAdd) {
  62740. el.addCls(cls);
  62741. }
  62742. },
  62743. getElListeners: function() {
  62744. return {
  62745. dragenter: 'handleNativeDragEnter',
  62746. dragleave: 'handleNativeDragLeave',
  62747. dragover: 'handleNativeDragMove',
  62748. drop: 'handleNativeDrop'
  62749. };
  62750. },
  62751. handleDrop: function(info) {
  62752. var me = this,
  62753. hasListeners = me.hasListeners,
  62754. valid = info.valid;
  62755. me.getElement().removeCls([
  62756. me.getInvalidCls(),
  62757. me.getValidCls()
  62758. ]);
  62759. if (valid && me.beforeDrop(info) !== false) {
  62760. if (hasListeners.beforedrop && me.fireEvent('beforedrop', me, info) === false) {
  62761. return false;
  62762. }
  62763. me.onDrop(info);
  62764. if (hasListeners.drop) {
  62765. me.fireEvent('drop', me, info);
  62766. }
  62767. } else {
  62768. return false;
  62769. }
  62770. },
  62771. handleDragEnter: function(info) {
  62772. var me = this,
  62773. cls = info.valid ? me.getValidCls() : me.getInvalidCls();
  62774. if (cls) {
  62775. me.getElement().addCls(cls);
  62776. }
  62777. me.onDragEnter(info);
  62778. if (me.hasListeners.dragenter) {
  62779. me.fireEvent('dragenter', me, info);
  62780. }
  62781. },
  62782. handleDragLeave: function(info) {
  62783. var me = this;
  62784. me.getElement().removeCls([
  62785. me.getInvalidCls(),
  62786. me.getValidCls()
  62787. ]);
  62788. me.onDragLeave(info);
  62789. if (me.hasListeners.dragleave) {
  62790. me.fireEvent('dragleave', me, info);
  62791. }
  62792. },
  62793. handleDragMove: function(info) {
  62794. var me = this;
  62795. me.onDragMove(info);
  62796. if (me.hasListeners.dragmove) {
  62797. me.fireEvent('dragmove', me, info);
  62798. }
  62799. },
  62800. handleNativeDragEnter: function(e) {
  62801. var me = this,
  62802. info = Ext.drag.Manager.getNativeDragInfo(e);
  62803. info.onNativeDragEnter(me, e);
  62804. if (me.hasListeners.dragenter) {
  62805. me.fireEvent('dragenter', me, info);
  62806. }
  62807. },
  62808. handleNativeDragLeave: function(e) {
  62809. var me = this,
  62810. info = Ext.drag.Manager.getNativeDragInfo(e);
  62811. info.onNativeDragLeave(me, e);
  62812. if (me.hasListeners.dragleave) {
  62813. me.fireEvent('dragleave', me, info);
  62814. }
  62815. },
  62816. handleNativeDragMove: function(e) {
  62817. var me = this,
  62818. info = Ext.drag.Manager.getNativeDragInfo(e);
  62819. info.onNativeDragMove(me, e);
  62820. if (me.hasListeners.dragmove) {
  62821. me.fireEvent('dragmove', me, info);
  62822. }
  62823. },
  62824. handleNativeDrop: function(e) {
  62825. var me = this,
  62826. hasListeners = me.hasListeners,
  62827. info = Ext.drag.Manager.getNativeDragInfo(e),
  62828. valid = info.valid;
  62829. info.onNativeDrop(me, e);
  62830. if (valid) {
  62831. if (hasListeners.beforedrop && me.fireEvent('beforedrop', me, info) === false) {
  62832. return;
  62833. }
  62834. if (hasListeners.drop) {
  62835. me.fireEvent('drop', me, info);
  62836. }
  62837. }
  62838. }
  62839. }
  62840. });
  62841. Ext.define('Ext.drag.proxy.None', {
  62842. mixins: [
  62843. Ext.mixin.Factoryable
  62844. ],
  62845. alias: 'drag.proxy.none',
  62846. factoryConfig: {
  62847. aliasPrefix: 'drag.proxy.',
  62848. type: 'dragproxy'
  62849. },
  62850. config: {
  62851. source: null
  62852. },
  62853. constructor: function(config) {
  62854. var getElement = config && config.getElement;
  62855. if (getElement) {
  62856. this.getElement = getElement;
  62857. config = Ext.apply({}, config);
  62858. delete config.getElement;
  62859. }
  62860. this.initConfig(config);
  62861. },
  62862. cleanup: Ext.emptyFn,
  62863. dragRevert: function(info, revertCls, options, callback) {
  62864. var positionable = this.getPositionable(info),
  62865. initial = info.proxy.initial;
  62866. positionable.addCls(revertCls);
  62867. positionable.setXY([
  62868. initial.x,
  62869. initial.y
  62870. ], Ext.apply({
  62871. callback: function() {
  62872. positionable.removeCls(revertCls);
  62873. callback();
  62874. }
  62875. }, options));
  62876. },
  62877. getElement: function() {
  62878. return null;
  62879. },
  62880. getPositionable: function() {
  62881. return this.element;
  62882. },
  62883. setXY: function(info, xy, animation) {
  62884. var positionable = this.getPositionable(info);
  62885. if (positionable) {
  62886. positionable.setXY(xy, animation);
  62887. }
  62888. },
  62889. update: Ext.emptyFn,
  62890. privates: {
  62891. setupElement: function(info) {
  62892. return (this.element = this.getElement(info));
  62893. },
  62894. adjustCursorOffset: function(info, pos) {
  62895. return pos;
  62896. }
  62897. }
  62898. });
  62899. Ext.define('Ext.drag.proxy.Original', {
  62900. extend: Ext.drag.proxy.None,
  62901. alias: 'drag.proxy.original',
  62902. getElement: function(info) {
  62903. return info.source.getElement();
  62904. },
  62905. getPositionable: function(info) {
  62906. var source = info.source;
  62907. return source.getComponent() || source.getElement();
  62908. }
  62909. });
  62910. Ext.define('Ext.drag.proxy.Placeholder', {
  62911. extend: Ext.drag.proxy.None,
  62912. alias: 'drag.proxy.placeholder',
  62913. config: {
  62914. cls: '',
  62915. cursorOffset: [
  62916. 12,
  62917. 20
  62918. ],
  62919. html: null,
  62920. invalidCls: '',
  62921. validCls: ''
  62922. },
  62923. placeholderCls: Ext.baseCSSPrefix + 'drag-proxy-placeholder',
  62924. cleanup: function() {
  62925. this.element = Ext.destroy(this.element);
  62926. },
  62927. getElement: function() {
  62928. var el = Ext.getBody().createChild({
  62929. cls: this.getCls(),
  62930. html: this.getHtml()
  62931. });
  62932. el.addCls(this.placeholderCls);
  62933. el.setTouchAction({
  62934. panX: false,
  62935. panY: false
  62936. });
  62937. return el;
  62938. },
  62939. update: function(info) {
  62940. var el = this.element,
  62941. invalidCls = this.getInvalidCls(),
  62942. validCls = this.getValidCls(),
  62943. valid = info.valid;
  62944. if (info.target) {
  62945. el.replaceCls(valid ? invalidCls : validCls, valid ? validCls : invalidCls);
  62946. } else {
  62947. el.removeCls([
  62948. invalidCls,
  62949. validCls
  62950. ]);
  62951. }
  62952. },
  62953. updateCls: function(cls, oldCls) {
  62954. var el = this.element;
  62955. if (el) {
  62956. if (oldCls) {
  62957. el.removeCls(oldCls);
  62958. }
  62959. if (cls) {
  62960. el.addCls(cls);
  62961. }
  62962. }
  62963. },
  62964. updateHtml: function(html) {
  62965. var el = this.element;
  62966. if (el) {
  62967. el.setHtml(html || '');
  62968. }
  62969. },
  62970. updateInvalidCls: function(invalidCls, oldInvalidCls) {
  62971. this.doUpdateCls(invalidCls, oldInvalidCls);
  62972. },
  62973. updateValidCls: function(validCls, oldValidCls) {
  62974. this.doUpdateCls(validCls, oldValidCls);
  62975. },
  62976. destroy: function() {
  62977. this.element = Ext.destroy(this.element);
  62978. this.callParent();
  62979. },
  62980. privates: {
  62981. adjustCursorOffset: function(info, xy) {
  62982. var offset = this.getCursorOffset();
  62983. if (offset) {
  62984. xy[0] += (offset[0] || 0);
  62985. xy[1] += (offset[1] || 0);
  62986. }
  62987. return xy;
  62988. },
  62989. doUpdateCls: function(cls, oldCls) {
  62990. var el = this.element,
  62991. hasCls;
  62992. if (el) {
  62993. if (oldCls) {
  62994. hasCls = cls && el.hasCls(oldCls);
  62995. el.removeCls(oldCls);
  62996. }
  62997. if (cls && hasCls) {
  62998. el.addCls(cls);
  62999. }
  63000. }
  63001. }
  63002. }
  63003. });
  63004. Ext.define('Ext.event.gesture.Recognizer', {
  63005. mixins: [
  63006. Ext.mixin.Identifiable
  63007. ],
  63008. priority: 0,
  63009. handledEvents: [],
  63010. isStarted: false,
  63011. config: {
  63012. onRecognized: Ext.emptyFn,
  63013. callbackScope: null
  63014. },
  63015. constructor: function(config) {
  63016. this.initConfig(config);
  63017. Ext.event.publisher.Gesture.instance.registerRecognizer(this);
  63018. },
  63019. onStart: Ext.emptyFn,
  63020. onEnd: Ext.emptyFn,
  63021. onTouchStart: Ext.emptyFn,
  63022. onTouchMove: Ext.emptyFn,
  63023. onTouchEnd: function() {
  63024. return this.reset();
  63025. },
  63026. onTouchCancel: function(e) {
  63027. return this.cancel(e);
  63028. },
  63029. fire: function(eventName, e, info, isCancel) {
  63030. this.getOnRecognized().call(this.getCallbackScope(), this, eventName, e, info, isCancel);
  63031. },
  63032. cancel: function(e) {
  63033. if (this.isStarted) {
  63034. this.onCancel(e);
  63035. }
  63036. return this.reset();
  63037. },
  63038. onCancel: Ext.emptyFn,
  63039. reset: function() {
  63040. this.isStarted = false;
  63041. return false;
  63042. }
  63043. });
  63044. Ext.define('Ext.event.gesture.SingleTouch', {
  63045. extend: Ext.event.gesture.Recognizer,
  63046. isSingleTouch: true,
  63047. onTouchStart: function(e) {
  63048. if (e.touches.length > 1) {
  63049. return this.cancel(e);
  63050. }
  63051. }
  63052. });
  63053. Ext.define('Ext.event.gesture.DoubleTap', {
  63054. extend: Ext.event.gesture.SingleTouch,
  63055. priority: 300,
  63056. config: {
  63057. moveDistance: 8,
  63058. tapDistance: 24,
  63059. maxDuration: 300
  63060. },
  63061. handledEvents: [
  63062. 'singletap',
  63063. 'doubletap'
  63064. ],
  63065. singleTapTimer: null,
  63066. startTime: 0,
  63067. lastTapTime: 0,
  63068. onTouchStart: function(e) {
  63069. var me = this,
  63070. ret = me.callParent([
  63071. e
  63072. ]),
  63073. lastStartPoint;
  63074. if (ret !== false) {
  63075. me.isStarted = true;
  63076. lastStartPoint = me.lastStartPoint = e.changedTouches[0].point;
  63077. me.startPoint = me.startPoint || lastStartPoint;
  63078. me.startTime = e.time;
  63079. Ext.undefer(me.singleTapTimer);
  63080. }
  63081. return ret;
  63082. },
  63083. onTouchMove: function(e) {
  63084. var me = this,
  63085. point = e.changedTouches[0].point,
  63086. scale = Ext.Element.getViewportScale(),
  63087. distance = Math.round(Math.abs(point.getDistanceTo(me.lastStartPoint) * scale));
  63088. if (distance >= me.getMoveDistance()) {
  63089. return me.cancel(e);
  63090. }
  63091. },
  63092. onTouchEnd: function(e) {
  63093. var me = this,
  63094. maxDuration = me.getMaxDuration(),
  63095. time = e.time,
  63096. target = e.target,
  63097. lastTapTime = me.lastTapTime,
  63098. lastTarget = me.lastTarget,
  63099. point = e.changedTouches[0].point,
  63100. duration, scale, distance;
  63101. me.lastTapTime = time;
  63102. me.lastTarget = target;
  63103. if (lastTapTime) {
  63104. duration = time - lastTapTime;
  63105. if (duration <= maxDuration) {
  63106. scale = Ext.Element.getViewportScale();
  63107. distance = Math.round(Math.abs(point.getDistanceTo(me.startPoint) * scale));
  63108. if (distance <= me.getTapDistance()) {
  63109. if (target !== lastTarget) {
  63110. return me.cancel(e);
  63111. }
  63112. me.lastTarget = null;
  63113. me.lastTapTime = 0;
  63114. me.fire('doubletap', e, {
  63115. touch: e.changedTouches[0],
  63116. duration: duration
  63117. });
  63118. return me.callParent([
  63119. e
  63120. ]);
  63121. }
  63122. }
  63123. }
  63124. if (time - me.startTime > maxDuration) {
  63125. me.fire('singletap', e);
  63126. me.reset();
  63127. } else {
  63128. me.setSingleTapTimer(e);
  63129. }
  63130. },
  63131. setSingleTapTimer: function(e) {
  63132. var me = this;
  63133. me.singleTapTimer = Ext.defer(function() {
  63134. me.fire('singletap', e);
  63135. me.reset();
  63136. }, me.getMaxDuration());
  63137. },
  63138. reset: function() {
  63139. var me = this;
  63140. Ext.undefer(me.singleTapTimer);
  63141. me.startTime = me.lastTapTime = 0;
  63142. me.lastStartPoint = me.startPoint = me.singleTapTimer = null;
  63143. return me.callParent();
  63144. }
  63145. }, function(DoubleTap) {
  63146. var gestures = Ext.manifest.gestures;
  63147. DoubleTap.instance = new DoubleTap(gestures && gestures.doubleTap);
  63148. });
  63149. Ext.define('Ext.event.gesture.Drag', {
  63150. extend: Ext.event.gesture.SingleTouch,
  63151. priority: 100,
  63152. startPoint: null,
  63153. previousPoint: null,
  63154. lastPoint: null,
  63155. handledEvents: [
  63156. 'dragstart',
  63157. 'drag',
  63158. 'dragend',
  63159. 'dragcancel'
  63160. ],
  63161. config: {
  63162. minDistance: 8
  63163. },
  63164. constructor: function() {
  63165. this.callParent(arguments);
  63166. this.initInfo();
  63167. },
  63168. initInfo: function() {
  63169. this.info = {
  63170. touch: null,
  63171. previous: {
  63172. x: 0,
  63173. y: 0
  63174. },
  63175. x: 0,
  63176. y: 0,
  63177. delta: {
  63178. x: 0,
  63179. y: 0
  63180. },
  63181. absDelta: {
  63182. x: 0,
  63183. y: 0
  63184. },
  63185. flick: {
  63186. velocity: {
  63187. x: 0,
  63188. y: 0
  63189. }
  63190. },
  63191. direction: {
  63192. x: 0,
  63193. y: 0
  63194. },
  63195. time: 0,
  63196. previousTime: {
  63197. x: 0,
  63198. y: 0
  63199. },
  63200. longpress: false
  63201. };
  63202. },
  63203. onTouchStart: function(e) {
  63204. var me = this,
  63205. ret = me.callParent([
  63206. e
  63207. ]);
  63208. if (ret !== false) {
  63209. me.startTime = e.time;
  63210. me.startPoint = e.changedTouches[0].point;
  63211. }
  63212. return ret;
  63213. },
  63214. tryDragStart: function(e) {
  63215. var me = this,
  63216. point = e.changedTouches[0].point,
  63217. minDistance = me.getMinDistance(),
  63218. scale = Ext.Element.getViewportScale(),
  63219. distance = Math.round(Math.abs(point.getDistanceTo(me.startPoint) * scale));
  63220. if (distance >= minDistance) {
  63221. me.doDragStart(e);
  63222. }
  63223. },
  63224. doDragStart: function(e, isLongPress) {
  63225. var me = this,
  63226. touch = e.changedTouches[0],
  63227. point = touch.point,
  63228. info = me.info,
  63229. time;
  63230. if (isLongPress) {
  63231. time = Ext.now();
  63232. me.startTime = time;
  63233. me.startPoint = point;
  63234. info.longpress = true;
  63235. } else {
  63236. time = e.time;
  63237. }
  63238. me.isStarted = true;
  63239. me.previousPoint = me.lastPoint = point;
  63240. me.resetInfo('x', e, touch);
  63241. me.resetInfo('y', e, touch);
  63242. info.time = time;
  63243. me.fire('dragstart', e, info);
  63244. },
  63245. onTouchMove: function(e) {
  63246. var me = this,
  63247. touch, point;
  63248. if (!me.startPoint) {
  63249. return;
  63250. }
  63251. if (!me.isStarted) {
  63252. me.tryDragStart(e);
  63253. }
  63254. if (!me.isStarted) {
  63255. return;
  63256. }
  63257. touch = e.changedTouches[0];
  63258. point = touch.point;
  63259. if (me.lastPoint) {
  63260. me.previousPoint = me.lastPoint;
  63261. }
  63262. me.lastPoint = point;
  63263. me.lastMoveEvent = e;
  63264. me.updateInfo('x', e, touch);
  63265. me.updateInfo('y', e, touch);
  63266. me.info.time = e.time;
  63267. me.fire('drag', e, me.info);
  63268. },
  63269. onAxisDragEnd: function(axis, info) {
  63270. var duration = info.time - info.previousTime[axis];
  63271. if (duration > 0) {
  63272. info.flick.velocity[axis] = (info[axis] - info.previous[axis]) / duration;
  63273. }
  63274. },
  63275. resetInfo: function(axis, e, touch) {
  63276. var me = this,
  63277. value = me.lastPoint[axis],
  63278. startValue = me.startPoint[axis],
  63279. delta = value - startValue,
  63280. capAxis = axis.toUpperCase(),
  63281. info = me.info;
  63282. info.touch = touch;
  63283. info.delta[axis] = delta;
  63284. info.absDelta[axis] = Math.abs(delta);
  63285. info.previousTime[axis] = me.startTime;
  63286. info.previous[axis] = startValue;
  63287. info[axis] = value;
  63288. info.direction[axis] = 0;
  63289. info['start' + capAxis] = me.startPoint[axis];
  63290. info['previous' + capAxis] = info.previous[axis];
  63291. info['page' + capAxis] = info[axis];
  63292. info['delta' + capAxis] = info.delta[axis];
  63293. info['absDelta' + capAxis] = info.absDelta[axis];
  63294. info['previousDelta' + capAxis] = 0;
  63295. info.startTime = me.startTime;
  63296. },
  63297. updateInfo: function(axis, e, touch) {
  63298. var me = this,
  63299. value = me.lastPoint[axis],
  63300. previousValue = me.previousPoint[axis],
  63301. startValue = me.startPoint[axis],
  63302. delta = value - startValue,
  63303. info = me.info,
  63304. direction = info.direction,
  63305. capAxis = axis.toUpperCase(),
  63306. previousFlick = info.previous[axis];
  63307. info.touch = touch;
  63308. info.delta[axis] = delta;
  63309. info.absDelta[axis] = Math.abs(delta);
  63310. if (value !== previousFlick && value !== info[axis]) {
  63311. info.previous[axis] = info[axis];
  63312. info.previousTime[axis] = info.time;
  63313. }
  63314. info[axis] = value;
  63315. if (value > previousValue) {
  63316. direction[axis] = 1;
  63317. } else if (value < previousValue) {
  63318. direction[axis] = -1;
  63319. }
  63320. info['start' + capAxis] = startValue;
  63321. info['previous' + capAxis] = info.previous[axis];
  63322. info['page' + capAxis] = info[axis];
  63323. info['delta' + capAxis] = info.delta[axis];
  63324. info['absDelta' + capAxis] = info.absDelta[axis];
  63325. info['previousDelta' + capAxis] = info.previous[axis] - startValue;
  63326. info.startTime = me.startTime;
  63327. },
  63328. onTouchEnd: function(e) {
  63329. var me = this,
  63330. touch, point, info;
  63331. if (me.isStarted) {
  63332. touch = e.changedTouches[0];
  63333. point = touch.point;
  63334. info = me.info;
  63335. me.lastPoint = point;
  63336. me.updateInfo('x', e, touch);
  63337. me.updateInfo('y', e, touch);
  63338. info.time = e.time;
  63339. me.onAxisDragEnd('x', info);
  63340. me.onAxisDragEnd('y', info);
  63341. me.fire('dragend', e, info);
  63342. }
  63343. return this.callParent([
  63344. e
  63345. ]);
  63346. },
  63347. onCancel: function(e) {
  63348. var me = this,
  63349. touch = e.changedTouches[0],
  63350. info = me.info;
  63351. if (!e.touches.length) {
  63352. me.lastPoint = touch.point;
  63353. }
  63354. me.updateInfo('x', e, touch);
  63355. me.updateInfo('y', e, touch);
  63356. info.time = e.time;
  63357. me.fire('dragcancel', e, info, true);
  63358. },
  63359. reset: function() {
  63360. var me = this;
  63361. me.lastPoint = me.startPoint = me.previousPoint = me.lastPoint = me.lastMoveEvent = null;
  63362. me.initInfo();
  63363. return me.callParent();
  63364. }
  63365. }, function(Drag) {
  63366. var gestures = Ext.manifest.gestures;
  63367. Drag.instance = new Drag(gestures && gestures.drag);
  63368. });
  63369. Ext.define('Ext.event.gesture.Swipe', {
  63370. extend: Ext.event.gesture.SingleTouch,
  63371. priority: 600,
  63372. handledEvents: [
  63373. 'swipestart',
  63374. 'swipe',
  63375. 'swipecancel'
  63376. ],
  63377. config: {
  63378. minDistance: 80,
  63379. maxOffset: 35,
  63380. maxDuration: 1000
  63381. },
  63382. onTouchStart: function(e) {
  63383. var me = this,
  63384. ret = me.callParent([
  63385. e
  63386. ]),
  63387. touch;
  63388. if (ret !== false) {
  63389. touch = e.changedTouches[0];
  63390. me.startTime = e.time;
  63391. me.isHorizontal = true;
  63392. me.isVertical = true;
  63393. me.startX = touch.pageX;
  63394. me.startY = touch.pageY;
  63395. }
  63396. return ret;
  63397. },
  63398. onTouchMove: function(e) {
  63399. var me = this,
  63400. touch = e.changedTouches[0],
  63401. x = touch.pageX,
  63402. y = touch.pageY,
  63403. deltaX = x - me.startX,
  63404. deltaY = y - me.startY,
  63405. absDeltaX = Math.abs(x - me.startX),
  63406. absDeltaY = Math.abs(y - me.startY),
  63407. duration = e.time - me.startTime,
  63408. minDistance, direction, distance;
  63409. if ((absDeltaX === 0 && absDeltaY === 0) || (duration > me.getMaxDuration())) {
  63410. return me.cancel(e);
  63411. }
  63412. if (me.isHorizontal && absDeltaY > me.getMaxOffset()) {
  63413. me.isHorizontal = false;
  63414. }
  63415. if (me.isVertical && absDeltaX > me.getMaxOffset()) {
  63416. me.isVertical = false;
  63417. }
  63418. if (!me.isVertical || !me.isHorizontal) {
  63419. minDistance = me.getMinDistance();
  63420. if (me.isHorizontal && absDeltaX < minDistance) {
  63421. direction = (deltaX < 0) ? 'left' : 'right';
  63422. distance = absDeltaX;
  63423. } else if (me.isVertical && absDeltaY < minDistance) {
  63424. direction = (deltaY < 0) ? 'up' : 'down';
  63425. distance = absDeltaY;
  63426. }
  63427. }
  63428. if (!me.isHorizontal && !me.isVertical) {
  63429. return me.cancel(e);
  63430. }
  63431. if (direction && !me.isStarted) {
  63432. me.isStarted = true;
  63433. me.fire('swipestart', e, {
  63434. touch: touch,
  63435. direction: direction,
  63436. distance: distance,
  63437. duration: duration
  63438. });
  63439. }
  63440. },
  63441. onTouchEnd: function(e) {
  63442. var me = this,
  63443. touch, x, y, deltaX, deltaY, absDeltaX, absDeltaY, minDistance, duration, direction, distance;
  63444. if (me.onTouchMove(e) !== false) {
  63445. touch = e.changedTouches[0];
  63446. x = touch.pageX;
  63447. y = touch.pageY;
  63448. deltaX = x - me.startX;
  63449. deltaY = y - me.startY;
  63450. absDeltaX = Math.abs(deltaX);
  63451. absDeltaY = Math.abs(deltaY);
  63452. minDistance = me.getMinDistance();
  63453. duration = e.time - me.startTime;
  63454. if (me.isVertical && absDeltaY < minDistance) {
  63455. me.isVertical = false;
  63456. }
  63457. if (me.isHorizontal && absDeltaX < minDistance) {
  63458. me.isHorizontal = false;
  63459. }
  63460. if (me.isHorizontal) {
  63461. direction = (deltaX < 0) ? 'left' : 'right';
  63462. distance = absDeltaX;
  63463. } else if (me.isVertical) {
  63464. direction = (deltaY < 0) ? 'up' : 'down';
  63465. distance = absDeltaY;
  63466. }
  63467. me.fire('swipe', e, {
  63468. touch: touch,
  63469. direction: direction,
  63470. distance: distance,
  63471. duration: duration
  63472. });
  63473. }
  63474. return this.callParent([
  63475. e
  63476. ]);
  63477. },
  63478. onCancel: function(e) {
  63479. this.fire('swipecancel', e, null, true);
  63480. },
  63481. reset: function() {
  63482. var me = this;
  63483. me.startTime = me.isHorizontal = me.isVertical = me.startX = me.startY = null;
  63484. return me.callParent();
  63485. }
  63486. }, function(Swipe) {
  63487. var gestures = Ext.manifest.gestures;
  63488. Swipe.instance = new Swipe(gestures && gestures.swipe);
  63489. });
  63490. Ext.define('Ext.event.gesture.EdgeSwipe', {
  63491. extend: Ext.event.gesture.Swipe,
  63492. priority: 500,
  63493. handledEvents: [
  63494. 'edgeswipe',
  63495. 'edgeswipestart',
  63496. 'edgeswipeend',
  63497. 'edgeswipecancel'
  63498. ],
  63499. config: {
  63500. minDistance: 60
  63501. },
  63502. onTouchStart: function(e) {
  63503. var me = this,
  63504. ret = me.callParent([
  63505. e
  63506. ]),
  63507. touch;
  63508. if (ret !== false) {
  63509. touch = e.changedTouches[0];
  63510. me.direction = null;
  63511. me.isHorizontal = true;
  63512. me.isVertical = true;
  63513. me.startX = touch.pageX;
  63514. me.startY = touch.pageY;
  63515. }
  63516. return ret;
  63517. },
  63518. onTouchMove: function(e) {
  63519. var me = this,
  63520. touch = e.changedTouches[0],
  63521. x = touch.pageX,
  63522. y = touch.pageY,
  63523. deltaX = x - me.startX,
  63524. deltaY = y - me.startY,
  63525. absDeltaY = Math.abs(y - me.startY),
  63526. absDeltaX = Math.abs(x - me.startX),
  63527. minDistance = me.getMinDistance(),
  63528. maxOffset = me.getMaxOffset(),
  63529. duration = e.time - me.startTime,
  63530. elementWidth = Ext.Viewport && Ext.Element.getViewportWidth(),
  63531. elementHeight = Ext.Viewport && Ext.Element.getViewportHeight(),
  63532. direction, distance;
  63533. if (me.isVertical && absDeltaX > maxOffset) {
  63534. me.isVertical = false;
  63535. }
  63536. if (me.isHorizontal && absDeltaY > maxOffset) {
  63537. me.isHorizontal = false;
  63538. }
  63539. if (me.isVertical && me.isHorizontal) {
  63540. if (absDeltaY > absDeltaX) {
  63541. me.isHorizontal = false;
  63542. } else {
  63543. me.isVertical = false;
  63544. }
  63545. }
  63546. if (me.isHorizontal) {
  63547. direction = (deltaX < 0) ? 'left' : 'right';
  63548. distance = deltaX;
  63549. } else if (me.isVertical) {
  63550. direction = (deltaY < 0) ? 'up' : 'down';
  63551. distance = deltaY;
  63552. }
  63553. direction = me.direction || (me.direction = direction);
  63554. if (direction === 'up') {
  63555. distance = deltaY * -1;
  63556. } else if (direction === 'left') {
  63557. distance = deltaX * -1;
  63558. }
  63559. me.distance = distance;
  63560. if (!distance) {
  63561. return me.cancel(e);
  63562. }
  63563. if (!me.isStarted) {
  63564. if ((direction === 'right' && me.startX > minDistance) || (direction === 'down' && me.startY > minDistance) || (direction === 'left' && (elementWidth - me.startX) > minDistance) || (direction === 'up' && (elementHeight - me.startY) > minDistance)) {
  63565. return me.cancel(e);
  63566. }
  63567. me.isStarted = true;
  63568. me.startTime = e.time;
  63569. me.fire('edgeswipestart', e, {
  63570. touch: touch,
  63571. direction: direction,
  63572. distance: distance,
  63573. duration: duration
  63574. });
  63575. } else {
  63576. me.fire('edgeswipe', e, {
  63577. touch: touch,
  63578. direction: direction,
  63579. distance: distance,
  63580. duration: duration
  63581. });
  63582. }
  63583. },
  63584. onTouchEnd: function(e) {
  63585. var me = this,
  63586. duration;
  63587. if (me.onTouchMove(e) !== false) {
  63588. duration = e.time - me.startTime;
  63589. me.fire('edgeswipeend', e, {
  63590. touch: e.changedTouches[0],
  63591. direction: me.direction,
  63592. distance: me.distance,
  63593. duration: duration
  63594. });
  63595. }
  63596. return this.reset();
  63597. },
  63598. onCancel: function(e) {
  63599. this.fire('edgeswipecancel', e, {
  63600. touch: e.changedTouches[0]
  63601. }, true);
  63602. },
  63603. reset: function() {
  63604. var me = this;
  63605. me.direction = me.isHorizontal = me.isVertical = me.startX = me.startY = me.startTime = me.distance = null;
  63606. return me.callParent();
  63607. }
  63608. }, function(EdgeSwipe) {
  63609. var gestures = Ext.manifest.gestures;
  63610. EdgeSwipe.instance = new EdgeSwipe(gestures && gestures.edgeSwipe);
  63611. });
  63612. Ext.define('Ext.event.gesture.LongPress', {
  63613. extend: Ext.event.gesture.SingleTouch,
  63614. priority: 400,
  63615. config: {
  63616. moveDistance: 8,
  63617. minDuration: 1000
  63618. },
  63619. handledEvents: [
  63620. 'longpress',
  63621. 'taphold'
  63622. ],
  63623. onTouchStart: function(e) {
  63624. var me = this,
  63625. ret = me.callParent([
  63626. e
  63627. ]);
  63628. if (ret !== false) {
  63629. me.startPoint = e.changedTouches[0].point;
  63630. me.setLongPressTimer(e);
  63631. }
  63632. return ret;
  63633. },
  63634. setLongPressTimer: function(e) {
  63635. var me = this;
  63636. Ext.undefer(me.timer);
  63637. me.timer = Ext.defer(me.fireLongPress, me.getMinDuration(), me, [
  63638. e
  63639. ]);
  63640. },
  63641. onTouchMove: function(e) {
  63642. var me = this,
  63643. point = e.changedTouches[0].point,
  63644. scale = Ext.Element.getViewportScale(),
  63645. distance = Math.round(Math.abs(point.getDistanceTo(me.startPoint) * scale));
  63646. if (distance >= me.getMoveDistance()) {
  63647. return me.cancel(e);
  63648. }
  63649. },
  63650. reset: function() {
  63651. var me = this;
  63652. me.timer = me.startPoint = Ext.undefer(me.timer);
  63653. return me.callParent();
  63654. },
  63655. fireLongPress: function(e) {
  63656. var me = this,
  63657. info = {
  63658. touch: e.changedTouches[0],
  63659. duration: me.getMinDuration(),
  63660. startDrag: me.startDrag
  63661. };
  63662. this.fire('taphold', e, info);
  63663. this.fire('longpress', e, info);
  63664. this.reset();
  63665. },
  63666. startDrag: function() {
  63667. var dragRecognizer = Ext.event.gesture.Drag.instance,
  63668. touchStartEvent = this.parentEvent;
  63669. dragRecognizer.doDragStart(touchStartEvent, true);
  63670. Ext.event.publisher.Gesture.instance.claimRecognizer(dragRecognizer, touchStartEvent);
  63671. }
  63672. }, function(LongPress) {
  63673. var gestures = Ext.manifest.gestures;
  63674. LongPress.instance = new LongPress(gestures && gestures.longPress);
  63675. });
  63676. Ext.define('Ext.event.gesture.MultiTouch', {
  63677. extend: Ext.event.gesture.Recognizer,
  63678. requiredTouchesCount: 2,
  63679. isTracking: false,
  63680. isMultiTouch: true,
  63681. onTouchStart: function(e) {
  63682. var me = this,
  63683. requiredTouchesCount = me.requiredTouchesCount,
  63684. touches = e.touches,
  63685. touchesCount = touches.length;
  63686. if (touchesCount === requiredTouchesCount) {
  63687. me.isTracking = true;
  63688. } else if (touchesCount > requiredTouchesCount) {
  63689. return me.cancel(e);
  63690. }
  63691. },
  63692. reset: function() {
  63693. this.isTracking = false;
  63694. return this.callParent();
  63695. }
  63696. });
  63697. Ext.define('Ext.event.gesture.Pinch', {
  63698. extend: Ext.event.gesture.MultiTouch,
  63699. priority: 700,
  63700. handledEvents: [
  63701. 'pinchstart',
  63702. 'pinch',
  63703. 'pinchend',
  63704. 'pinchcancel'
  63705. ],
  63706. startDistance: 0,
  63707. lastTouches: null,
  63708. onTouchMove: function(e) {
  63709. var me = this,
  63710. touches, firstPoint, secondPoint, distance;
  63711. if (me.isTracking) {
  63712. touches = e.touches;
  63713. firstPoint = touches[0].point;
  63714. secondPoint = touches[1].point;
  63715. distance = firstPoint.getDistanceTo(secondPoint);
  63716. if (distance === 0) {
  63717. return;
  63718. }
  63719. if (!me.isStarted) {
  63720. me.isStarted = true;
  63721. me.startDistance = distance;
  63722. me.fire('pinchstart', e, {
  63723. touches: touches,
  63724. distance: distance,
  63725. scale: 1
  63726. });
  63727. } else {
  63728. me.fire('pinch', e, {
  63729. touches: touches,
  63730. distance: distance,
  63731. scale: distance / me.startDistance
  63732. });
  63733. }
  63734. }
  63735. },
  63736. onTouchEnd: function(e) {
  63737. if (this.isStarted) {
  63738. this.fire('pinchend', e);
  63739. }
  63740. return this.callParent([
  63741. e
  63742. ]);
  63743. },
  63744. onCancel: function(e) {
  63745. this.fire('pinchcancel', e, null, true);
  63746. },
  63747. reset: function() {
  63748. this.lastTouches = null;
  63749. this.startDistance = 0;
  63750. return this.callParent();
  63751. }
  63752. }, function(Pinch) {
  63753. var gestures = Ext.manifest.gestures;
  63754. Pinch.instance = new Pinch(gestures && gestures.pinch);
  63755. });
  63756. Ext.define('Ext.event.gesture.Rotate', {
  63757. extend: Ext.event.gesture.MultiTouch,
  63758. priority: 800,
  63759. handledEvents: [
  63760. 'rotatestart',
  63761. 'rotate',
  63762. 'rotateend',
  63763. 'rotatecancel'
  63764. ],
  63765. startAngle: 0,
  63766. lastTouches: null,
  63767. lastAngle: null,
  63768. onTouchMove: function(e) {
  63769. var me = this,
  63770. touches, lastAngle, firstPoint, secondPoint, angle, nextAngle, previousAngle, diff;
  63771. if (me.isTracking) {
  63772. touches = e.touches;
  63773. lastAngle = me.lastAngle;
  63774. firstPoint = touches[0].point;
  63775. secondPoint = touches[1].point;
  63776. angle = firstPoint.getAngleTo(secondPoint);
  63777. if (lastAngle !== null) {
  63778. diff = Math.abs(lastAngle - angle);
  63779. nextAngle = angle + 360;
  63780. previousAngle = angle - 360;
  63781. if (Math.abs(nextAngle - lastAngle) < diff) {
  63782. angle = nextAngle;
  63783. } else if (Math.abs(previousAngle - lastAngle) < diff) {
  63784. angle = previousAngle;
  63785. }
  63786. }
  63787. me.lastAngle = angle;
  63788. if (!me.isStarted) {
  63789. me.isStarted = true;
  63790. me.startAngle = angle;
  63791. me.fire('rotatestart', e, {
  63792. touches: touches,
  63793. angle: angle,
  63794. rotation: 0
  63795. });
  63796. } else {
  63797. me.fire('rotate', e, {
  63798. touches: touches,
  63799. angle: angle,
  63800. rotation: angle - me.startAngle
  63801. });
  63802. }
  63803. me.lastTouches = Ext.Array.clone(touches);
  63804. }
  63805. },
  63806. onTouchEnd: function(e) {
  63807. if (this.isStarted) {
  63808. this.fire('rotateend', e);
  63809. }
  63810. return this.callParent([
  63811. e
  63812. ]);
  63813. },
  63814. onCancel: function(e) {
  63815. this.fire('rotatecancel', e, null, true);
  63816. },
  63817. reset: function() {
  63818. var me = this;
  63819. me.lastTouches = me.lastAngle = me.startAngle = null;
  63820. return this.callParent();
  63821. }
  63822. }, function(Rotate) {
  63823. var gestures = Ext.manifest.gestures;
  63824. Rotate.instance = new Rotate(gestures && gestures.rotate);
  63825. });
  63826. Ext.define('Ext.event.gesture.Tap', {
  63827. extend: Ext.event.gesture.SingleTouch,
  63828. priority: 200,
  63829. handledEvents: [
  63830. 'tap',
  63831. 'tapcancel'
  63832. ],
  63833. config: {
  63834. moveDistance: 8
  63835. },
  63836. onTouchStart: function(e) {
  63837. var me = this,
  63838. ret = me.callParent([
  63839. e
  63840. ]);
  63841. if (ret !== false) {
  63842. me.isStarted = true;
  63843. me.startPoint = e.changedTouches[0].point;
  63844. }
  63845. return ret;
  63846. },
  63847. onTouchMove: function(e) {
  63848. var me = this,
  63849. point = e.changedTouches[0].point,
  63850. scale = Ext.Element.getViewportScale(),
  63851. distance = Math.round(Math.abs(point.getDistanceTo(me.startPoint) * scale));
  63852. if (distance >= me.getMoveDistance()) {
  63853. return me.cancel(e);
  63854. }
  63855. },
  63856. onTouchEnd: function(e) {
  63857. this.fire('tap', e, {
  63858. touch: e.changedTouches[0]
  63859. });
  63860. return this.callParent([
  63861. e
  63862. ]);
  63863. },
  63864. onCancel: function(e) {
  63865. this.fire('tapcancel', e, {
  63866. touch: e.changedTouches[0]
  63867. }, true);
  63868. },
  63869. reset: function() {
  63870. this.startPoint = null;
  63871. return this.callParent();
  63872. }
  63873. }, function(Tap) {
  63874. var gestures = Ext.manifest.gestures;
  63875. Tap.instance = new Tap(gestures && gestures.tap);
  63876. });
  63877. Ext.define('Ext.event.publisher.Focus', {
  63878. extend: Ext.event.publisher.Dom,
  63879. type: 'focus',
  63880. handledEvents: [
  63881. 'focusenter',
  63882. 'focusleave',
  63883. 'focusmove'
  63884. ],
  63885. handledDomEvents: [
  63886. 'focusin',
  63887. 'focusout'
  63888. ],
  63889. publishDelegatedDomEvent: function(e) {
  63890. var me = this,
  63891. relatedTarget = e.relatedTarget;
  63892. if (me.$suppressEvents) {
  63893. return;
  63894. }
  63895. if (e.type === 'focusout') {
  63896. if (relatedTarget == null) {
  63897. me.processFocusIn(e, e.target, document.body);
  63898. }
  63899. } else {
  63900. if (relatedTarget == null || !relatedTarget.tagName) {
  63901. relatedTarget = document.body;
  63902. }
  63903. me.processFocusIn(e, relatedTarget, e.target);
  63904. }
  63905. },
  63906. processFocusIn: function(e, fromElement, toElement) {
  63907. var me = this,
  63908. commonAncestor, node,
  63909. targets = [],
  63910. focusFly = me.focusFly,
  63911. backwards, event, focusEnterEvent;
  63912. if ((fromElement && focusFly.attach(fromElement).isFocusSuspended()) || (toElement && focusFly.attach(toElement).isFocusSuspended())) {
  63913. return;
  63914. }
  63915. if (toElement.compareDocumentPosition) {
  63916. backwards = !!(toElement.compareDocumentPosition(fromElement) & 4);
  63917. }
  63918. for (node = fromElement , commonAncestor = Ext.dom.Element.getCommonAncestor(toElement, fromElement, true); node && node !== commonAncestor; node = node.parentNode) {
  63919. targets.push(node);
  63920. }
  63921. if (targets.length) {
  63922. event = me.createSyntheticEvent('focusleave', e, fromElement, toElement, fromElement, toElement, backwards);
  63923. me.publish(event, targets);
  63924. if (event.stopped) {
  63925. return;
  63926. }
  63927. }
  63928. targets.length = 0;
  63929. for (node = toElement; node && node !== commonAncestor; node = node.parentNode) {
  63930. targets.push(node);
  63931. }
  63932. focusEnterEvent = me.createSyntheticEvent('focusenter', e, toElement, fromElement, fromElement, toElement, backwards);
  63933. if (targets.length) {
  63934. me.publish(focusEnterEvent, targets);
  63935. if (focusEnterEvent.stopped) {
  63936. return;
  63937. }
  63938. }
  63939. targets = me.getPropagatingTargets(commonAncestor);
  63940. if (targets.length) {
  63941. event = me.createSyntheticEvent('focusmove', e, toElement, fromElement, fromElement, toElement, backwards);
  63942. me.publish(event, targets);
  63943. if (event.stopped) {
  63944. return;
  63945. }
  63946. }
  63947. if (Ext.GlobalEvents.hasListeners.focus) {
  63948. Ext.GlobalEvents.fireEvent('focus', {
  63949. event: focusEnterEvent,
  63950. toElement: toElement,
  63951. fromElement: fromElement,
  63952. backwards: backwards
  63953. });
  63954. }
  63955. },
  63956. createSyntheticEvent: function(eventName, browserEvent, target, relatedTarget, fromElement, toElement, backwards) {
  63957. var event = new Ext.event.Event(browserEvent);
  63958. event.type = eventName;
  63959. event.relatedTarget = relatedTarget;
  63960. event.target = target;
  63961. event.fromElement = fromElement;
  63962. event.toElement = toElement;
  63963. event.backwards = backwards;
  63964. return event;
  63965. }
  63966. }, function(Focus) {
  63967. var focusTimeout;
  63968. Focus.prototype.focusFly = new Ext.dom.Fly();
  63969. Focus.instance = new Focus();
  63970. if (!Ext.supports.FocusinFocusoutEvents) {
  63971. this.override({
  63972. handledDomEvents: [
  63973. 'focus',
  63974. 'blur'
  63975. ],
  63976. publishDelegatedDomEvent: function(e) {
  63977. var me = this,
  63978. targetIsElement;
  63979. me.callSuper([
  63980. e
  63981. ]);
  63982. targetIsElement = e.target !== window && e.target !== document;
  63983. if (e.type === 'blur') {
  63984. if (!targetIsElement) {
  63985. if (e.explicitOriginalTarget === Focus.previousActiveElement) {
  63986. if (e.target === window) {
  63987. Ext.undefer(focusTimeout);
  63988. focusTimeout = 0;
  63989. me.processFocusIn(e, Focus.previousActiveElement, document.body);
  63990. Focus.previousActiveElement = null;
  63991. }
  63992. }
  63993. } else {
  63994. focusTimeout = Ext.defer(function() {
  63995. focusTimeout = 0;
  63996. me.processFocusIn(e, e.target, document.body);
  63997. Focus.previousActiveElement = null;
  63998. }, 1);
  63999. if (targetIsElement && Ext.cache[e.target.id]) {
  64000. Ext.cache[e.target.id].focusinTimeout = focusTimeout;
  64001. }
  64002. }
  64003. Focus.previousActiveElement = targetIsElement ? e.target : null;
  64004. } else {
  64005. Ext.undefer(focusTimeout);
  64006. focusTimeout = 0;
  64007. me.processFocusIn(e, Focus.previousActiveElement || document.body, targetIsElement ? e.target : document.body);
  64008. }
  64009. }
  64010. });
  64011. Ext.define(null, {
  64012. override: 'Ext.dom.Element',
  64013. destroy: function() {
  64014. if (this.focusinTimeout) {
  64015. Ext.undefer(this.focusinTimeout);
  64016. this.focusinTimeout = null;
  64017. }
  64018. this.callParent();
  64019. }
  64020. });
  64021. }
  64022. });
  64023. Ext.define('Ext.field.InputMask', function(InputMask) {
  64024. return {
  64025. cachedConfig: {
  64026. blank: '_',
  64027. characters: {
  64028. '*': '[A-Za-z0-9]',
  64029. 'a': '[a-z]',
  64030. 'A': '[A-Z]',
  64031. '0': '[0-9]',
  64032. '9': '[0-9]'
  64033. },
  64034. ignoreCase: true
  64035. },
  64036. config: {
  64037. pattern: null
  64038. },
  64039. _cached: false,
  64040. _lastEditablePos: null,
  64041. _mask: null,
  64042. statics: {
  64043. active: {},
  64044. from: function(value, existing) {
  64045. var active = InputMask.active,
  64046. ret;
  64047. if (value === null) {
  64048. ret = null;
  64049. } else if (typeof value !== 'string') {
  64050. if (existing && !existing._cached) {
  64051. ret = existing;
  64052. ret.setConfig(value);
  64053. } else {
  64054. ret = new InputMask(value);
  64055. }
  64056. } else if (!(ret = active[value])) {
  64057. if (!(ret = InputMask.cache.remove(value))) {
  64058. ret = new InputMask({
  64059. pattern: value
  64060. });
  64061. }
  64062. active[value] = ret;
  64063. ret._cached = 1;
  64064. } else
  64065. {
  64066. ++ret._cached;
  64067. }
  64068. return ret;
  64069. }
  64070. },
  64071. constructor: function(config) {
  64072. this.initConfig(config);
  64073. },
  64074. release: function() {
  64075. var me = this,
  64076. cache = InputMask.cache,
  64077. key;
  64078. if (me._cached && !--me._cached) {
  64079. key = me.getPattern();
  64080. if (InputMask.active[key] !== me) {
  64081. Ext.raise('Invalid call to InputMask#release (not active)');
  64082. }
  64083. if (cache.map[key]) {
  64084. Ext.raise('Invalid call to InputMask#release (already cached)');
  64085. }
  64086. delete InputMask.active[key];
  64087. cache.add(key, me);
  64088. cache.trim(cache.maxSize);
  64089. }
  64090. else if (me._cached === 0) {
  64091. Ext.raise('Invalid call to InputMask#release (already released)');
  64092. }
  64093. },
  64094. clearRange: function(value, start, len) {
  64095. var me = this,
  64096. blank = me.getBlank(),
  64097. end = start + len,
  64098. n = value.length,
  64099. s = '',
  64100. i, mask, prefixLen;
  64101. if (!blank) {
  64102. prefixLen = me._prefix.length;
  64103. for (i = 0; i < n; ++i) {
  64104. if (i < prefixLen || i < start || i >= end) {
  64105. s += value[i];
  64106. }
  64107. }
  64108. s = me.formatValue(s);
  64109. } else {
  64110. mask = me.getPattern();
  64111. for (i = 0; i < n; ++i) {
  64112. if (i < start || i >= end) {
  64113. s += value[i];
  64114. } else if (me.isFixedChar(i)) {
  64115. s += mask[i];
  64116. } else {
  64117. s += blank;
  64118. }
  64119. }
  64120. }
  64121. return s;
  64122. },
  64123. formatValue: function(value) {
  64124. var me = this,
  64125. blank = me.getBlank(),
  64126. i, length, mask, prefix, s;
  64127. if (!blank) {
  64128. prefix = me._prefix;
  64129. length = prefix.length;
  64130. s = this.insertRange('', value, 0);
  64131. for (i = s.length; i > length && me.isFixedChar(i - 1); ) {
  64132. --i;
  64133. }
  64134. s = (i < length) ? prefix : s.slice(0, i - 1);
  64135. } else if (value) {
  64136. s = me.formatValue('');
  64137. s = me.insertRange(s, value, 0);
  64138. } else {
  64139. mask = me.getPattern();
  64140. s = '';
  64141. for (i = 0 , length = mask.length; i < length; ++i) {
  64142. if (me.isFixedChar(i)) {
  64143. s += mask[i];
  64144. } else {
  64145. s += blank;
  64146. }
  64147. }
  64148. }
  64149. return s;
  64150. },
  64151. getEditPosLeft: function(pos) {
  64152. for (var i = pos; i >= 0; --i) {
  64153. if (!this.isFixedChar(i)) {
  64154. return i;
  64155. }
  64156. }
  64157. return null;
  64158. },
  64159. getEditPosRight: function(pos) {
  64160. var mask = this._mask,
  64161. len = mask.length,
  64162. i;
  64163. for (i = pos; i < len; ++i) {
  64164. if (!this.isFixedChar(i)) {
  64165. return i;
  64166. }
  64167. }
  64168. return null;
  64169. },
  64170. getFilledLength: function(value) {
  64171. var me = this,
  64172. blank = me.getBlank(),
  64173. c, i;
  64174. if (!blank) {
  64175. return value.length;
  64176. }
  64177. for (i = value && value.length; i-- > 0; ) {
  64178. c = value[i];
  64179. if (!me.isFixedChar(i) && me.isAllowedChar(c, i)) {
  64180. break;
  64181. }
  64182. }
  64183. return ++i || me._prefix.length;
  64184. },
  64185. getSubLength: function(value, substr, pos) {
  64186. var me = this,
  64187. mask = me.getPattern(),
  64188. k = 0,
  64189. maskLen = mask.length,
  64190. substrLen = substr.length,
  64191. i;
  64192. for (i = pos; i < maskLen && k < substrLen; ) {
  64193. if (!me.isFixedChar(i) || mask[i] === substr[k]) {
  64194. if (me.isAllowedChar(substr[k++], i, true)) {
  64195. ++i;
  64196. }
  64197. } else {
  64198. ++i;
  64199. }
  64200. }
  64201. return i - pos;
  64202. },
  64203. insertRange: function(value, substr, pos) {
  64204. var me = this,
  64205. mask = me.getPattern(),
  64206. blank = me.getBlank(),
  64207. filled = me.isFilled(value),
  64208. prefixLen = me._prefix.length,
  64209. maskLen = mask.length,
  64210. substrLen = substr.length,
  64211. s = value,
  64212. ch, fixed, i, k;
  64213. if (!blank && pos > s.length) {
  64214. s += mask.slice(s.length, pos);
  64215. }
  64216. for (i = pos , k = 0; i < maskLen && k < substrLen; ) {
  64217. fixed = me.isFixedChar(i);
  64218. if (!fixed || mask[i] === substr[k]) {
  64219. ch = substr[k++];
  64220. if (me.isAllowedChar(ch, i, true)) {
  64221. if (i < s.length) {
  64222. if (blank || filled || i < prefixLen) {
  64223. s = s.slice(0, i) + ch + s.slice(i + 1);
  64224. } else {
  64225. s = me.formatValue(s.substr(0, i) + ch + s.substr(i));
  64226. }
  64227. } else if (!blank) {
  64228. s += ch;
  64229. }
  64230. ++i;
  64231. }
  64232. } else {
  64233. if (!blank && i >= s.length) {
  64234. s += mask[i];
  64235. } else if (blank && fixed && substr[k] === blank) {
  64236. ++k;
  64237. }
  64238. ++i;
  64239. }
  64240. }
  64241. return s;
  64242. },
  64243. isAllowedChar: function(character, pos, allowBlankChar) {
  64244. var me = this,
  64245. mask = me.getPattern(),
  64246. c, characters, rule;
  64247. if (me.isFixedChar(pos)) {
  64248. return mask[pos] === character;
  64249. }
  64250. c = mask[pos];
  64251. characters = me.getCharacters();
  64252. rule = characters[c];
  64253. return !rule || rule.test(character || '') || (allowBlankChar && character === me.getBlank());
  64254. },
  64255. isEmpty: function(value) {
  64256. for (var i = 0,
  64257. len = value.length; i < len; ++i) {
  64258. if (!this.isFixedChar(i) && this.isAllowedChar(value[i], i)) {
  64259. return false;
  64260. }
  64261. }
  64262. return true;
  64263. },
  64264. isFilled: function(value) {
  64265. return this.getFilledLength(value) === this._mask.length;
  64266. },
  64267. isFixedChar: function(pos) {
  64268. return Ext.Array.indexOf(this._fixedCharPositions, pos) > -1;
  64269. },
  64270. setCaretToEnd: function(field, value) {
  64271. var filledLen = this.getFilledLength(value),
  64272. pos = this.getEditPosRight(filledLen);
  64273. if (pos !== null) {
  64274. Ext.raf(function() {
  64275. if (!field.destroyed) {
  64276. field.setCaretPos(pos);
  64277. Ext.raf(function() {
  64278. if (!field.destroyed) {
  64279. field.setCaretPos(pos);
  64280. }
  64281. });
  64282. }
  64283. });
  64284. }
  64285. },
  64286. onBlur: function(field, value) {
  64287. if (field.getAutoHideInputMask() !== false) {
  64288. if (this.isEmpty(value)) {
  64289. field.maskProcessed = true;
  64290. field.setValue('');
  64291. }
  64292. }
  64293. },
  64294. onFocus: function(field, value) {
  64295. if (field.getAutoHideInputMask() !== false) {
  64296. if (!value) {
  64297. field.maskProcessed = true;
  64298. field.setValue(this._mask);
  64299. }
  64300. }
  64301. this.setCaretToEnd(field, value);
  64302. },
  64303. onChange: function(field, value, oldValue) {
  64304. var me = this,
  64305. s;
  64306. if (field.maskProcessed || value === oldValue) {
  64307. field.maskProcessed = false;
  64308. return true;
  64309. }
  64310. if (value) {
  64311. s = me.formatValue(value);
  64312. field.maskProcessed = true;
  64313. field.setValue(s);
  64314. }
  64315. },
  64316. processAutocomplete: function(field, value) {
  64317. var me = this,
  64318. s;
  64319. if (value) {
  64320. if (value.length > me._mask.length) {
  64321. value = value.substr(0, me._mask.length);
  64322. }
  64323. s = me.formatValue(value);
  64324. field.maskProcessed = true;
  64325. field.inputElement.dom.value = s;
  64326. field.setValue(s);
  64327. this.setCaretToEnd(field, value);
  64328. }
  64329. },
  64330. showEmptyMask: function(field, adjustCaret) {
  64331. var s = this.formatValue();
  64332. field.maskProcessed = true;
  64333. field.setValue(s);
  64334. if (adjustCaret) {
  64335. this.setCaretToEnd(field);
  64336. }
  64337. },
  64338. onKeyDown: function(field, value, event) {
  64339. if (event.ctrlKey || event.metaKey) {
  64340. return;
  64341. }
  64342. var me = this,
  64343. key = event.keyCode === event.DELETE,
  64344. del = key === 'Delete',
  64345. handled = del || (event.keyCode === event.BACKSPACE),
  64346. s = value,
  64347. caret, editPos, len, prefixLen, textSelection, start;
  64348. if (handled) {
  64349. caret = field.getCaretPos();
  64350. prefixLen = me._prefix.length;
  64351. textSelection = field.getTextSelection();
  64352. start = textSelection[0];
  64353. len = textSelection[1] - start;
  64354. if (len) {
  64355. s = me.clearRange(value, start, len);
  64356. } else if (caret < prefixLen || (!del && caret === prefixLen)) {
  64357. caret = prefixLen;
  64358. } else {
  64359. editPos = del ? me.getEditPosRight(caret) : me.getEditPosLeft(caret - 1);
  64360. if (editPos !== null) {
  64361. s = me.clearRange(value, editPos, 1);
  64362. caret = editPos;
  64363. }
  64364. }
  64365. if (s !== value) {
  64366. field.maskProcessed = true;
  64367. field.setValue(s);
  64368. }
  64369. event.preventDefault();
  64370. field.setCaretPos(caret);
  64371. }
  64372. },
  64373. onKeyPress: function(field, value, event) {
  64374. var me = this,
  64375. key = event.keyCode,
  64376. ch = event.getChar(),
  64377. mask = me.getPattern(),
  64378. prefixLen = me._prefix.length,
  64379. s = value,
  64380. caretPos, pos, start, textSelection;
  64381. if (key === event.ENTER || key === event.TAB || event.ctrlKey || event.metaKey) {
  64382. return;
  64383. }
  64384. caretPos = field.getCaretPos();
  64385. textSelection = field.getTextSelection();
  64386. if (me.isFixedChar(caretPos) && mask[caretPos] === ch) {
  64387. s = me.insertRange(s, ch, caretPos);
  64388. ++caretPos;
  64389. } else {
  64390. pos = me.getEditPosRight(caretPos);
  64391. if (pos !== null && me.isAllowedChar(ch, pos)) {
  64392. start = textSelection[0];
  64393. s = me.clearRange(s, start, textSelection[1] - start);
  64394. s = me.insertRange(s, ch, pos);
  64395. caretPos = pos + 1;
  64396. }
  64397. }
  64398. if (s !== value) {
  64399. field.maskProcessed = true;
  64400. field.setValue(s);
  64401. }
  64402. event.preventDefault();
  64403. if (caretPos < me._lastEditablePos && caretPos > prefixLen) {
  64404. caretPos = me.getEditPosRight(caretPos);
  64405. }
  64406. field.setCaretPos(caretPos);
  64407. },
  64408. onPaste: function(field, value, event) {
  64409. var text,
  64410. clipdData = event.browserEvent.clipboardData;
  64411. if (clipdData && clipdData.getData) {
  64412. text = clipdData.getData('text/plain');
  64413. } else if (Ext.global.clipboardData && Ext.global.clipboardData.getData) {
  64414. text = Ext.global.clipboardData.getData('Text');
  64415. }
  64416. if (text) {
  64417. this.paste(field, value, text, field.getTextSelection());
  64418. }
  64419. event.preventDefault();
  64420. },
  64421. paste: function(field, value, text, selection) {
  64422. var me = this,
  64423. caretPos = selection[0],
  64424. len = selection[1] - caretPos,
  64425. s = len ? me.clearRange(value, caretPos, len) : value,
  64426. textLen = me.getSubLength(s, text, caretPos);
  64427. s = me.insertRange(s, text, caretPos);
  64428. caretPos += textLen;
  64429. caretPos = me.getEditPosRight(caretPos) || caretPos;
  64430. if (s !== value) {
  64431. field.maskProcessed = true;
  64432. field.setValue(s);
  64433. }
  64434. field.setCaretPos(caretPos);
  64435. },
  64436. syncPattern: function(field) {
  64437. var fieldValue = field.getValue(),
  64438. s;
  64439. if (field.getAutoHideInputMask() === false) {
  64440. if (!fieldValue) {
  64441. this.showEmptyMask(field);
  64442. } else {
  64443. s = this.formatValue(fieldValue);
  64444. field.maskProcessed = true;
  64445. field.setValue(s);
  64446. }
  64447. } else {
  64448. if (fieldValue) {
  64449. s = this.formatValue(fieldValue);
  64450. field.maskProcessed = true;
  64451. field.setValue(s);
  64452. }
  64453. }
  64454. },
  64455. applyCharacters: function(map) {
  64456. var ret = {},
  64457. flags = this.getIgnoreCase() ? 'i' : '',
  64458. c, v;
  64459. for (c in map) {
  64460. v = map[c];
  64461. if (typeof v === 'string') {
  64462. v = new RegExp(v, flags);
  64463. }
  64464. ret[c] = v;
  64465. }
  64466. return ret;
  64467. },
  64468. updatePattern: function(mask) {
  64469. var me = this,
  64470. characters = me.getCharacters(),
  64471. lastEditablePos = 0,
  64472. n = mask && mask.length,
  64473. blank = me.getBlank(),
  64474. fixedPosArr = [],
  64475. prefix = '',
  64476. str = '',
  64477. c, i;
  64478. for (i = 0; i < n; ++i) {
  64479. c = mask[i];
  64480. if (!characters[c]) {
  64481. fixedPosArr.push(str.length);
  64482. str += c;
  64483. } else {
  64484. lastEditablePos = str.length + 1;
  64485. str += blank;
  64486. }
  64487. }
  64488. me._lastEditablePos = lastEditablePos;
  64489. me._mask = str;
  64490. me._fixedCharPositions = fixedPosArr;
  64491. for (i = 0; i < str.length && me.isFixedChar(i); ++i) {
  64492. prefix += str[i];
  64493. }
  64494. me._prefix = prefix;
  64495. }
  64496. };
  64497. }, function(InputMask) {
  64498. InputMask.cache = new Ext.util.LRU();
  64499. InputMask.cache.maxSize = 100;
  64500. });
  64501. Ext.define('Ext.fx.runner.Css', {
  64502. extend: Ext.Evented,
  64503. prefixedProperties: {
  64504. 'transform': true,
  64505. 'transform-origin': true,
  64506. 'perspective': true,
  64507. 'transform-style': true,
  64508. 'transition': true,
  64509. 'transition-property': true,
  64510. 'transition-duration': true,
  64511. 'transition-timing-function': true,
  64512. 'transition-delay': true,
  64513. 'animation': true,
  64514. 'animation-name': true,
  64515. 'animation-duration': true,
  64516. 'animation-iteration-count': true,
  64517. 'animation-direction': true,
  64518. 'animation-timing-function': true,
  64519. 'animation-delay': true
  64520. },
  64521. lengthProperties: {
  64522. 'top': true,
  64523. 'right': true,
  64524. 'bottom': true,
  64525. 'left': true,
  64526. 'width': true,
  64527. 'height': true,
  64528. 'max-height': true,
  64529. 'max-width': true,
  64530. 'min-height': true,
  64531. 'min-width': true,
  64532. 'margin-bottom': true,
  64533. 'margin-left': true,
  64534. 'margin-right': true,
  64535. 'margin-top': true,
  64536. 'padding-bottom': true,
  64537. 'padding-left': true,
  64538. 'padding-right': true,
  64539. 'padding-top': true,
  64540. 'border-bottom-width': true,
  64541. 'border-left-width': true,
  64542. 'border-right-width': true,
  64543. 'border-spacing': true,
  64544. 'border-top-width': true,
  64545. 'border-width': true,
  64546. 'outline-width': true,
  64547. 'letter-spacing': true,
  64548. 'line-height': true,
  64549. 'text-indent': true,
  64550. 'word-spacing': true,
  64551. 'font-size': true,
  64552. 'translate': true,
  64553. 'translateX': true,
  64554. 'translateY': true,
  64555. 'translateZ': true,
  64556. 'translate3d': true,
  64557. 'x': true,
  64558. 'y': true
  64559. },
  64560. durationProperties: {
  64561. 'transition-duration': true,
  64562. 'transition-delay': true,
  64563. 'animation-duration': true,
  64564. 'animation-delay': true
  64565. },
  64566. angleProperties: {
  64567. rotate: true,
  64568. rotateX: true,
  64569. rotateY: true,
  64570. rotateZ: true,
  64571. skew: true,
  64572. skewX: true,
  64573. skewY: true
  64574. },
  64575. DEFAULT_UNIT_LENGTH: 'px',
  64576. DEFAULT_UNIT_ANGLE: 'deg',
  64577. DEFAULT_UNIT_DURATION: 'ms',
  64578. customProperties: {
  64579. x: true,
  64580. y: true
  64581. },
  64582. formattedNameCache: {
  64583. 'x': 'left',
  64584. 'y': 'top'
  64585. },
  64586. transformMethods3d: [
  64587. 'translateX',
  64588. 'translateY',
  64589. 'translateZ',
  64590. 'rotate',
  64591. 'rotateX',
  64592. 'rotateY',
  64593. 'rotateZ',
  64594. 'skewX',
  64595. 'skewY',
  64596. 'scaleX',
  64597. 'scaleY',
  64598. 'scaleZ'
  64599. ],
  64600. transformMethodsNo3d: [
  64601. 'translateX',
  64602. 'translateY',
  64603. 'rotate',
  64604. 'skewX',
  64605. 'skewY',
  64606. 'scaleX',
  64607. 'scaleY'
  64608. ],
  64609. constructor: function() {
  64610. var me = this;
  64611. me.transformMethods = Ext.feature.has.Css3dTransforms ? me.transformMethods3d : me.transformMethodsNo3d;
  64612. me.vendorPrefix = Ext.browser.getStyleDashPrefix();
  64613. me.ruleStylesCache = {};
  64614. me.callParent();
  64615. },
  64616. getStyleSheet: function() {
  64617. var styleSheet = this.styleSheet,
  64618. styleElement, styleSheets;
  64619. if (!styleSheet) {
  64620. styleElement = document.createElement('style');
  64621. styleElement.type = 'text/css';
  64622. (document.head || document.getElementsByTagName('head')[0]).appendChild(styleElement);
  64623. styleSheets = document.styleSheets;
  64624. this.styleSheet = styleSheet = styleSheets[styleSheets.length - 1];
  64625. }
  64626. return styleSheet;
  64627. },
  64628. applyRules: function(selectors) {
  64629. var styleSheet = this.getStyleSheet(),
  64630. ruleStylesCache = this.ruleStylesCache,
  64631. rules = styleSheet.cssRules,
  64632. selector, properties, ruleStyle, ruleStyleCache, rulesLength, name, value;
  64633. for (selector in selectors) {
  64634. properties = selectors[selector];
  64635. ruleStyle = ruleStylesCache[selector];
  64636. if (ruleStyle === undefined) {
  64637. rulesLength = rules.length;
  64638. styleSheet.insertRule(selector + '{}', rulesLength);
  64639. ruleStyle = ruleStylesCache[selector] = rules.item(rulesLength).style;
  64640. }
  64641. ruleStyleCache = ruleStyle.$cache;
  64642. if (!ruleStyleCache) {
  64643. ruleStyleCache = ruleStyle.$cache = {};
  64644. }
  64645. for (name in properties) {
  64646. value = this.formatValue(properties[name], name);
  64647. name = this.formatName(name);
  64648. if (ruleStyleCache[name] !== value) {
  64649. ruleStyleCache[name] = value;
  64650. if (value === null) {
  64651. ruleStyle.removeProperty(name);
  64652. } else {
  64653. ruleStyle.setProperty(name, value);
  64654. }
  64655. }
  64656. }
  64657. }
  64658. return this;
  64659. },
  64660. applyStyles: function(styles) {
  64661. var id, element, elementStyle, properties, name, value;
  64662. for (id in styles) {
  64663. if (styles.hasOwnProperty(id)) {
  64664. this.activeElement = element = document.getElementById(id);
  64665. if (!element) {
  64666. continue;
  64667. }
  64668. elementStyle = element.style;
  64669. properties = styles[id];
  64670. for (name in properties) {
  64671. if (properties.hasOwnProperty(name)) {
  64672. value = this.formatValue(properties[name], name);
  64673. name = this.formatName(name);
  64674. if (value === null) {
  64675. elementStyle.removeProperty(name);
  64676. } else {
  64677. elementStyle.setProperty(name, value);
  64678. }
  64679. }
  64680. }
  64681. }
  64682. }
  64683. this.activeElement = null;
  64684. return this;
  64685. },
  64686. formatName: function(name) {
  64687. var cache = this.formattedNameCache,
  64688. formattedName = cache[name];
  64689. if (!formattedName) {
  64690. if ((Ext.os.is.Tizen || !Ext.feature.has.CssTransformNoPrefix) && this.prefixedProperties[name]) {
  64691. formattedName = this.vendorPrefix + name;
  64692. } else {
  64693. formattedName = name;
  64694. }
  64695. cache[name] = formattedName;
  64696. }
  64697. return formattedName;
  64698. },
  64699. formatValue: function(value, name) {
  64700. var type = typeof value,
  64701. defaultLengthUnit = this.DEFAULT_UNIT_LENGTH,
  64702. isCustom = this.customProperties[name],
  64703. transformMethods, method, i, ln, transformValues, values;
  64704. if (value === null) {
  64705. return '';
  64706. }
  64707. if (type === 'string') {
  64708. if (this.lengthProperties[name]) {
  64709. if (!Ext.dom.Element.hasUnit(value)) {
  64710. value = value + defaultLengthUnit;
  64711. if (isCustom) {
  64712. value = this.getCustomValue(value, name);
  64713. }
  64714. }
  64715. }
  64716. return value;
  64717. } else if (type === 'number') {
  64718. if (value === 0) {
  64719. return '0';
  64720. }
  64721. if (this.lengthProperties[name]) {
  64722. value = value + defaultLengthUnit;
  64723. if (isCustom) {
  64724. value = this.getCustomValue(value, name);
  64725. }
  64726. return value;
  64727. }
  64728. if (this.angleProperties[name]) {
  64729. return value + this.DEFAULT_UNIT_ANGLE;
  64730. }
  64731. if (this.durationProperties[name]) {
  64732. return value + this.DEFAULT_UNIT_DURATION;
  64733. }
  64734. } else if (name === 'transform') {
  64735. transformMethods = this.transformMethods;
  64736. transformValues = [];
  64737. for (i = 0 , ln = transformMethods.length; i < ln; i++) {
  64738. method = transformMethods[i];
  64739. transformValues.push(method + '(' + this.formatValue(value[method], method) + ')');
  64740. }
  64741. return transformValues.join(' ');
  64742. } else if (Ext.isArray(value)) {
  64743. values = [];
  64744. for (i = 0 , ln = value.length; i < ln; i++) {
  64745. values.push(this.formatValue(value[i], name));
  64746. }
  64747. return (values.length > 0) ? values.join(', ') : 'none';
  64748. }
  64749. return value;
  64750. },
  64751. getCustomValue: function(value, name) {
  64752. var el = Ext.fly(this.activeElement);
  64753. if (name === 'x') {
  64754. value = el.translateXY(parseInt(value, 10)).x;
  64755. } else if (name === 'y') {
  64756. value = el.translateXY(null, parseInt(value, 10)).y;
  64757. }
  64758. return value + this.DEFAULT_UNIT_LENGTH;
  64759. }
  64760. });
  64761. Ext.define('Ext.fx.runner.CssTransition', {
  64762. extend: Ext.fx.runner.Css,
  64763. alternateClassName: 'Ext.Animator',
  64764. singleton: true,
  64765. listenersAttached: false,
  64766. constructor: function() {
  64767. this.runningAnimationsData = {};
  64768. this.transitionQueue = {
  64769. toData: {},
  64770. transitionData: {}
  64771. };
  64772. return this.callParent(arguments);
  64773. },
  64774. attachListeners: function() {
  64775. this.listenersAttached = true;
  64776. Ext.getWin().on('transitionend', 'onTransitionEnd', this);
  64777. },
  64778. onTransitionEnd: function(e) {
  64779. var target = e.target,
  64780. id = target.id;
  64781. if (id && this.runningAnimationsData.hasOwnProperty(id)) {
  64782. this.refreshRunningAnimationsData(Ext.get(target), [
  64783. e.browserEvent.propertyName
  64784. ]);
  64785. }
  64786. },
  64787. getElementId: function(element) {
  64788. return element.getId ? element.getId() : element.id;
  64789. },
  64790. onAnimationEnd: function(element, data, animation, isInterrupted, isReplaced) {
  64791. var id = this.getElementId(element),
  64792. runningData = this.runningAnimationsData[id],
  64793. endRules = {},
  64794. endData = {},
  64795. runningNameMap, toPropertyNames, i, ln, name;
  64796. animation.un('stop', 'onAnimationStop', this);
  64797. if (runningData) {
  64798. runningNameMap = runningData.nameMap;
  64799. }
  64800. endRules[id] = endData;
  64801. if (data.onBeforeEnd) {
  64802. data.onBeforeEnd.call(data.scope || this, element, isInterrupted);
  64803. }
  64804. animation.fireEvent('animationbeforeend', animation, element, isInterrupted);
  64805. this.fireEvent('animationbeforeend', this, animation, element, isInterrupted);
  64806. if (isReplaced || (!isInterrupted && !data.preserveEndState)) {
  64807. toPropertyNames = data.toPropertyNames;
  64808. for (i = 0 , ln = toPropertyNames.length; i < ln; i++) {
  64809. name = toPropertyNames[i];
  64810. if (runningNameMap && !runningNameMap.hasOwnProperty(name)) {
  64811. endData[name] = null;
  64812. }
  64813. }
  64814. }
  64815. if (data.after) {
  64816. Ext.merge(endData, data.after);
  64817. }
  64818. this.applyStyles(endRules);
  64819. if (data.onEnd) {
  64820. data.onEnd.call(data.scope || this, element, isInterrupted);
  64821. }
  64822. animation.fireEvent('animationend', animation, element, isInterrupted);
  64823. this.fireEvent('animationend', this, animation, element, isInterrupted);
  64824. Ext.AnimationQueue.stop(Ext.emptyFn, animation);
  64825. },
  64826. onAllAnimationsEnd: function(element) {
  64827. var id = this.getElementId(element),
  64828. transitionQueue = this.transitionQueue,
  64829. endRules = {};
  64830. delete this.runningAnimationsData[id];
  64831. endRules[id] = {
  64832. 'transition-property': null,
  64833. 'transition-duration': null,
  64834. 'transition-timing-function': null,
  64835. 'transition-delay': null
  64836. };
  64837. delete transitionQueue.toData[id];
  64838. delete transitionQueue.transitionData[id];
  64839. this.applyStyles(endRules);
  64840. this.fireEvent('animationallend', this, element);
  64841. },
  64842. hasRunningAnimations: function(element) {
  64843. var id = this.getElementId(element),
  64844. runningAnimationsData = this.runningAnimationsData;
  64845. return runningAnimationsData.hasOwnProperty(id) && runningAnimationsData[id].sessions.length > 0;
  64846. },
  64847. refreshRunningAnimationsData: function(element, propertyNames, interrupt, replace) {
  64848. var id = this.getElementId(element),
  64849. runningAnimationsData = this.runningAnimationsData,
  64850. runningData = runningAnimationsData[id];
  64851. if (!runningData) {
  64852. return;
  64853. }
  64854. var nameMap = runningData.nameMap,
  64855. nameList = runningData.nameList,
  64856. sessions = runningData.sessions,
  64857. ln, j, subLn, name, i, session, map, list,
  64858. hasCompletedSession = false;
  64859. interrupt = Boolean(interrupt);
  64860. replace = Boolean(replace);
  64861. if (!sessions) {
  64862. return this;
  64863. }
  64864. ln = sessions.length;
  64865. if (ln === 0) {
  64866. return this;
  64867. }
  64868. if (replace) {
  64869. runningData.nameMap = {};
  64870. nameList.length = 0;
  64871. for (i = 0; i < ln; i++) {
  64872. session = sessions[i];
  64873. this.onAnimationEnd(element, session.data, session.animation, interrupt, replace);
  64874. }
  64875. sessions.length = 0;
  64876. } else {
  64877. for (i = 0; i < ln; i++) {
  64878. session = sessions[i];
  64879. map = session.map;
  64880. list = session.list;
  64881. for (j = 0 , subLn = propertyNames.length; j < subLn; j++) {
  64882. name = propertyNames[j];
  64883. if (map[name]) {
  64884. delete map[name];
  64885. Ext.Array.remove(list, name);
  64886. session.length--;
  64887. if (--nameMap[name] == 0) {
  64888. delete nameMap[name];
  64889. Ext.Array.remove(nameList, name);
  64890. }
  64891. }
  64892. }
  64893. if (session.length == 0) {
  64894. sessions.splice(i, 1);
  64895. i--;
  64896. ln--;
  64897. hasCompletedSession = true;
  64898. this.onAnimationEnd(element, session.data, session.animation, interrupt);
  64899. }
  64900. }
  64901. }
  64902. if (!replace && !interrupt && sessions.length == 0 && hasCompletedSession) {
  64903. this.onAllAnimationsEnd(element);
  64904. }
  64905. },
  64906. getRunningData: function(id) {
  64907. var runningAnimationsData = this.runningAnimationsData;
  64908. if (!runningAnimationsData.hasOwnProperty(id)) {
  64909. runningAnimationsData[id] = {
  64910. nameMap: {},
  64911. nameList: [],
  64912. sessions: []
  64913. };
  64914. }
  64915. return runningAnimationsData[id];
  64916. },
  64917. getTestElement: function() {
  64918. var me = this,
  64919. testElement = me.testElement,
  64920. iframe = me.iframe,
  64921. iframeDocument, iframeStyle;
  64922. if (testElement) {
  64923. if (testElement.ownerDocument.defaultView !== iframe.contentWindow) {
  64924. iframeDocument = iframe.contentDocument;
  64925. iframeDocument.body.appendChild(testElement);
  64926. me.testElementComputedStyle = iframeDocument.defaultView.getComputedStyle(testElement);
  64927. }
  64928. } else {
  64929. iframe = me.iframe = document.createElement('iframe');
  64930. iframe.setAttribute('data-sticky', true);
  64931. iframe.setAttribute('tabIndex', -1);
  64932. iframeStyle = iframe.style;
  64933. iframeStyle.setProperty('visibility', 'hidden', 'important');
  64934. iframeStyle.setProperty('width', '0px', 'important');
  64935. iframeStyle.setProperty('height', '0px', 'important');
  64936. iframeStyle.setProperty('position', 'absolute', 'important');
  64937. iframeStyle.setProperty('border', '0px', 'important');
  64938. iframeStyle.setProperty('zIndex', '-1000', 'important');
  64939. document.body.appendChild(iframe);
  64940. iframeDocument = iframe.contentDocument;
  64941. iframeDocument.open();
  64942. iframeDocument.writeln('</body>');
  64943. iframeDocument.close();
  64944. me.testElement = testElement = iframeDocument.createElement('div');
  64945. testElement.style.setProperty('position', 'absolute', 'important');
  64946. iframeDocument.body.appendChild(testElement);
  64947. me.testElementComputedStyle = iframeDocument.defaultView.getComputedStyle(testElement);
  64948. }
  64949. return testElement;
  64950. },
  64951. getCssStyleValue: function(name, value) {
  64952. var testElement = this.getTestElement(),
  64953. computedStyle = this.testElementComputedStyle,
  64954. style = testElement.style;
  64955. style.setProperty(name, value);
  64956. if (Ext.browser.is.Firefox) {
  64957. testElement.offsetHeight;
  64958. }
  64959. value = computedStyle.getPropertyValue(name);
  64960. style.removeProperty(name);
  64961. return value;
  64962. },
  64963. run: function(animations) {
  64964. var me = this,
  64965. ret = [],
  64966. isLengthPropertyMap = me.lengthProperties,
  64967. fromData = {},
  64968. toData = me.transitionQueue.toData,
  64969. data = {},
  64970. transitionData = me.transitionQueue.transitionData,
  64971. 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;
  64972. if (!me.listenersAttached) {
  64973. me.attachListeners();
  64974. }
  64975. animations = Ext.Array.from(animations);
  64976. for (i = 0 , ln = animations.length; i < ln; i++) {
  64977. animation = animations[i];
  64978. animation = Ext.factory(animation, Ext.fx.Animation);
  64979. ret.push(animation);
  64980. me.activeElement = element = animation.getElement();
  64981. Ext.AnimationQueue.start(Ext.emptyFn, animation);
  64982. computedStyle = window.getComputedStyle(element.dom);
  64983. elementId = me.getElementId(element);
  64984. data[elementId] = data = Ext.merge({}, animation.getData());
  64985. onBeforeStart = animation.getOnBeforeStart();
  64986. if (onBeforeStart) {
  64987. onBeforeStart.call(animation.scope || me, element);
  64988. }
  64989. animation.fireEvent('animationstart', animation, data);
  64990. me.fireEvent('animationstart', me, animation, data);
  64991. before = data.before;
  64992. from = data.from;
  64993. to = data.to;
  64994. data.fromPropertyNames = fromPropertyNames = [];
  64995. data.toPropertyNames = toPropertyNames = [];
  64996. for (name in to) {
  64997. if (to.hasOwnProperty(name)) {
  64998. to[name] = toFormattedValue = me.formatValue(to[name], name);
  64999. formattedName = me.formatName(name);
  65000. isLengthProperty = isLengthPropertyMap.hasOwnProperty(name);
  65001. if (!isLengthProperty) {
  65002. toFormattedValue = me.getCssStyleValue(formattedName, toFormattedValue);
  65003. }
  65004. if (from.hasOwnProperty(name)) {
  65005. from[name] = fromFormattedValue = me.formatValue(from[name], name);
  65006. if (!isLengthProperty) {
  65007. fromFormattedValue = me.getCssStyleValue(formattedName, fromFormattedValue);
  65008. }
  65009. if (toFormattedValue !== fromFormattedValue) {
  65010. fromPropertyNames.push(formattedName);
  65011. toPropertyNames.push(formattedName);
  65012. }
  65013. } else {
  65014. computedValue = computedStyle.getPropertyValue(formattedName);
  65015. if (toFormattedValue !== computedValue) {
  65016. toPropertyNames.push(formattedName);
  65017. }
  65018. }
  65019. }
  65020. }
  65021. propertiesLength = toPropertyNames.length;
  65022. if (propertiesLength === 0) {
  65023. me.onAnimationEnd(element, data, animation);
  65024. continue;
  65025. }
  65026. runningData = me.getRunningData(elementId);
  65027. runningSessions = runningData.sessions;
  65028. if (runningSessions.length > 0) {
  65029. me.refreshRunningAnimationsData(element, Ext.Array.merge(fromPropertyNames, toPropertyNames), true, data.replacePrevious);
  65030. }
  65031. runningNameMap = runningData.nameMap;
  65032. runningNameList = runningData.nameList;
  65033. sessionNameMap = {};
  65034. for (j = 0; j < propertiesLength; j++) {
  65035. name = toPropertyNames[j];
  65036. sessionNameMap[name] = true;
  65037. if (!runningNameMap.hasOwnProperty(name)) {
  65038. runningNameMap[name] = 1;
  65039. runningNameList.push(name);
  65040. } else {
  65041. runningNameMap[name]++;
  65042. }
  65043. }
  65044. runningSession = {
  65045. element: element,
  65046. map: sessionNameMap,
  65047. list: toPropertyNames.slice(),
  65048. length: propertiesLength,
  65049. data: data,
  65050. animation: animation
  65051. };
  65052. runningSessions.push(runningSession);
  65053. animation.on('stop', 'onAnimationStop', me);
  65054. elementData = Ext.apply({}, before);
  65055. Ext.apply(elementData, from);
  65056. if (runningNameList.length > 0) {
  65057. fromPropertyNames = Ext.Array.difference(runningNameList, fromPropertyNames);
  65058. toPropertyNames = Ext.Array.merge(fromPropertyNames, toPropertyNames);
  65059. elementData['transition-property'] = fromPropertyNames;
  65060. }
  65061. fromData[elementId] = elementData;
  65062. toData[elementId] = Ext.apply({}, to);
  65063. transitionData[elementId] = {
  65064. 'transition-property': toPropertyNames,
  65065. 'transition-duration': data.duration,
  65066. 'transition-timing-function': data.easing,
  65067. 'transition-delay': data.delay
  65068. };
  65069. animation.startTime = Date.now();
  65070. }
  65071. me.activeElement = null;
  65072. message = me.$className;
  65073. me.applyStyles(fromData);
  65074. doApplyTo = function(e) {
  65075. if (e.data === message && e.source === window) {
  65076. window.removeEventListener('message', doApplyTo, false);
  65077. me.applyStyles(me.transitionQueue.toData);
  65078. }
  65079. };
  65080. if (!me.messageTimerId) {
  65081. messageTimerFn = function() {
  65082. var messageFollowupFn;
  65083. me.messageTimerId = null;
  65084. if (Ext.isIE) {
  65085. me.applyStyles(me.transitionQueue.transitionData);
  65086. if (!me.messageFollowupId) {
  65087. messageFollowupFn = function() {
  65088. me.messageFollowupId = null;
  65089. window.addEventListener('message', doApplyTo, false);
  65090. window.postMessage(message, '*');
  65091. };
  65092. messageFollowupFn.$skipTimerCheck = true;
  65093. me.messageFollowupId = Ext.raf(messageFollowupFn);
  65094. }
  65095. } else {
  65096. Ext.merge(me.transitionQueue.toData, me.transitionQueue.transitionData);
  65097. window.addEventListener('message', doApplyTo, false);
  65098. window.postMessage(message, '*');
  65099. }
  65100. };
  65101. messageTimerFn.$skipTimerCheck = true;
  65102. me.messageTimerId = Ext.raf(messageTimerFn);
  65103. }
  65104. return ret;
  65105. },
  65106. onAnimationStop: function(animation) {
  65107. var me = this,
  65108. runningAnimationsData = me.runningAnimationsData,
  65109. activeAnimations = 0,
  65110. stoppedAnimations = 0,
  65111. id, runningData, sessions, i, ln, session;
  65112. for (id in runningAnimationsData) {
  65113. if (runningAnimationsData.hasOwnProperty(id)) {
  65114. runningData = runningAnimationsData[id];
  65115. sessions = runningData.sessions;
  65116. activeAnimations++;
  65117. for (i = 0 , ln = sessions.length; i < ln; i++) {
  65118. session = sessions[i];
  65119. if (session.animation === animation) {
  65120. me.refreshRunningAnimationsData(session.element, session.list.slice(), false);
  65121. if (animation.destroying) {
  65122. stoppedAnimations++;
  65123. }
  65124. }
  65125. }
  65126. }
  65127. }
  65128. if (activeAnimations === stoppedAnimations) {
  65129. if (me.messageFollowupId) {
  65130. Ext.unraf(me.messageFollowupId);
  65131. me.messageFollowupId = null;
  65132. }
  65133. if (me.messageTimerId) {
  65134. Ext.unraf(me.messageTimerId);
  65135. me.messageTimerId = null;
  65136. }
  65137. Ext.apply(me.transitionQueue, {
  65138. toData: {},
  65139. transitionData: {}
  65140. });
  65141. }
  65142. }
  65143. });
  65144. Ext.define('Ext.fx.Runner', {
  65145. constructor: function() {
  65146. return new Ext.fx.runner.CssTransition();
  65147. }
  65148. });
  65149. Ext.define('Ext.fx.animation.Cube', {
  65150. extend: Ext.fx.animation.Abstract,
  65151. alias: 'animation.cube',
  65152. config: {
  65153. before: {},
  65154. after: {},
  65155. direction: 'right',
  65156. out: false
  65157. },
  65158. getData: function() {
  65159. var to = this.getTo(),
  65160. from = this.getFrom(),
  65161. before = this.getBefore(),
  65162. after = this.getAfter(),
  65163. out = this.getOut(),
  65164. direction = this.getDirection(),
  65165. el = this.getElement(),
  65166. elW = el.getWidth(),
  65167. elH = el.getHeight(),
  65168. origin = out ? '100% 100%' : '0% 0%',
  65169. fromOpacity = 1,
  65170. toOpacity = 1,
  65171. transformFrom = {
  65172. rotateY: 0,
  65173. translateZ: 0
  65174. },
  65175. transformTo = {
  65176. rotateY: 0,
  65177. translateZ: 0
  65178. };
  65179. if (direction == "left" || direction == "right") {
  65180. if (out) {
  65181. toOpacity = 0.5;
  65182. transformTo.translateZ = elW;
  65183. transformTo.rotateY = -90;
  65184. } else {
  65185. fromOpacity = 0.5;
  65186. transformFrom.translateZ = elW;
  65187. transformFrom.rotateY = 90;
  65188. }
  65189. }
  65190. before['transform-origin'] = origin;
  65191. after['transform-origin'] = null;
  65192. to.set('transform', transformTo);
  65193. from.set('transform', transformFrom);
  65194. from.set('opacity', fromOpacity);
  65195. to.set('opacity', toOpacity);
  65196. return this.callParent(arguments);
  65197. }
  65198. });
  65199. Ext.define('Ext.fx.animation.Wipe', {
  65200. extend: Ext.fx.Animation,
  65201. alternateClassName: 'Ext.fx.animation.WipeIn',
  65202. config: {
  65203. easing: 'ease-out',
  65204. direction: 'right',
  65205. out: false
  65206. },
  65207. refresh: function() {
  65208. var me = this,
  65209. el = me.getElement(),
  65210. elBox = el.dom.getBoundingClientRect(),
  65211. elWidth = elBox.width,
  65212. elHeight = elBox.height,
  65213. from = me.getFrom(),
  65214. to = me.getTo(),
  65215. out = me.getOut(),
  65216. direction = me.getDirection(),
  65217. maskFromX = 0,
  65218. maskFromY = 0,
  65219. maskToX = 0,
  65220. maskToY = 0,
  65221. mask, tmp;
  65222. switch (direction) {
  65223. case 'up':
  65224. if (out) {
  65225. mask = '-webkit-gradient(linear, left top, left bottom, from(#000), to(transparent), color-stop(33%, #000), color-stop(66%, transparent))';
  65226. maskFromY = elHeight * 3 + 'px';
  65227. maskToY = elHeight + 'px';
  65228. } else {
  65229. mask = '-webkit-gradient(linear, left top, left bottom, from(transparent), to(#000), color-stop(66%, #000), color-stop(33%, transparent))';
  65230. maskFromY = -elHeight * 2 + 'px';
  65231. maskToY = 0;
  65232. };
  65233. break;
  65234. case 'down':
  65235. if (out) {
  65236. mask = '-webkit-gradient(linear, left top, left bottom, from(transparent), to(#000), color-stop(66%, #000), color-stop(33%, transparent))';
  65237. maskFromY = -elHeight * 2 + 'px';
  65238. maskToY = 0;
  65239. } else {
  65240. mask = '-webkit-gradient(linear, left top, left bottom, from(#000), to(transparent), color-stop(33%, #000), color-stop(66%, transparent))';
  65241. maskFromY = elHeight * 3 + 'px';
  65242. maskToY = elHeight + 'px';
  65243. };
  65244. break;
  65245. case 'right':
  65246. if (out) {
  65247. mask = '-webkit-gradient(linear, right top, left top, from(#000), to(transparent), color-stop(33%, #000), color-stop(66%, transparent))';
  65248. maskFromX = -elWidth * 2 + 'px';
  65249. maskToX = 0;
  65250. } else {
  65251. mask = '-webkit-gradient(linear, right top, left top, from(transparent), to(#000), color-stop(66%, #000), color-stop(33%, transparent))';
  65252. maskToX = -elWidth * 2 + 'px';
  65253. };
  65254. break;
  65255. case 'left':
  65256. if (out) {
  65257. mask = '-webkit-gradient(linear, right top, left top, from(transparent), to(#000), color-stop(66%, #000), color-stop(33%, transparent))';
  65258. maskToX = -elWidth * 2 + 'px';
  65259. } else {
  65260. mask = '-webkit-gradient(linear, right top, left top, from(#000), to(transparent), color-stop(33%, #000), color-stop(66%, transparent))';
  65261. maskFromX = -elWidth * 2 + 'px';
  65262. maskToX = 0;
  65263. };
  65264. break;
  65265. }
  65266. if (!out) {
  65267. tmp = maskFromY;
  65268. maskFromY = maskToY;
  65269. maskToY = tmp;
  65270. tmp = maskFromX;
  65271. maskFromX = maskToX;
  65272. maskToX = tmp;
  65273. }
  65274. from.set('mask-image', mask);
  65275. from.set('mask-size', elWidth * 3 + 'px ' + elHeight * 3 + 'px');
  65276. from.set('mask-position-x', maskFromX);
  65277. from.set('mask-position-y', maskFromY);
  65278. to.set('mask-position-x', maskToX);
  65279. to.set('mask-position-y', maskToY);
  65280. }
  65281. });
  65282. Ext.define('Ext.fx.animation.WipeOut', {
  65283. extend: Ext.fx.animation.Wipe,
  65284. config: {
  65285. out: true
  65286. }
  65287. });
  65288. Ext.define('Ext.fx.easing.Bounce', {
  65289. extend: Ext.fx.easing.Abstract,
  65290. config: {
  65291. springTension: 0.3,
  65292. acceleration: 30,
  65293. startVelocity: 0
  65294. },
  65295. getValue: function() {
  65296. var deltaTime = Ext.Date.now() - this.getStartTime(),
  65297. theta = (deltaTime / this.getAcceleration()),
  65298. powTime = theta * Math.pow(Math.E, -this.getSpringTension() * theta);
  65299. return this.getStartValue() + (this.getStartVelocity() * powTime);
  65300. }
  65301. });
  65302. Ext.define('Ext.fx.easing.Momentum', {
  65303. extend: Ext.fx.easing.Abstract,
  65304. config: {
  65305. acceleration: 30,
  65306. friction: 0,
  65307. startVelocity: 0
  65308. },
  65309. alpha: 0,
  65310. updateFriction: function(friction) {
  65311. var theta = Math.log(1 - (friction / 10));
  65312. this.theta = theta;
  65313. this.alpha = theta / this.getAcceleration();
  65314. },
  65315. updateStartVelocity: function(velocity) {
  65316. this.velocity = velocity * this.getAcceleration();
  65317. },
  65318. updateAcceleration: function(acceleration) {
  65319. this.velocity = this.getStartVelocity() * acceleration;
  65320. this.alpha = this.theta / acceleration;
  65321. },
  65322. getValue: function() {
  65323. return this.getStartValue() - this.velocity * (1 - this.getFrictionFactor()) / this.theta;
  65324. },
  65325. getFrictionFactor: function() {
  65326. var deltaTime = Ext.Date.now() - this.getStartTime();
  65327. return Math.exp(deltaTime * this.alpha);
  65328. },
  65329. getVelocity: function() {
  65330. return this.getFrictionFactor() * this.velocity;
  65331. }
  65332. });
  65333. Ext.define('Ext.fx.easing.BoundMomentum', {
  65334. extend: Ext.fx.easing.Abstract,
  65335. config: {
  65336. momentum: null,
  65337. bounce: null,
  65338. minMomentumValue: 0,
  65339. maxMomentumValue: 0,
  65340. minVelocity: 0.01,
  65341. startVelocity: 0
  65342. },
  65343. applyMomentum: function(config, currentEasing) {
  65344. return Ext.factory(config, Ext.fx.easing.Momentum, currentEasing);
  65345. },
  65346. applyBounce: function(config, currentEasing) {
  65347. return Ext.factory(config, Ext.fx.easing.Bounce, currentEasing);
  65348. },
  65349. updateStartTime: function(startTime) {
  65350. this.getMomentum().setStartTime(startTime);
  65351. this.callParent(arguments);
  65352. },
  65353. updateStartVelocity: function(startVelocity) {
  65354. this.getMomentum().setStartVelocity(startVelocity);
  65355. },
  65356. updateStartValue: function(startValue) {
  65357. this.getMomentum().setStartValue(startValue);
  65358. },
  65359. reset: function() {
  65360. this.lastValue = null;
  65361. this.isBouncingBack = false;
  65362. this.isOutOfBound = false;
  65363. return this.callParent(arguments);
  65364. },
  65365. getValue: function() {
  65366. var momentum = this.getMomentum(),
  65367. bounce = this.getBounce(),
  65368. startVelocity = momentum.getStartVelocity(),
  65369. direction = startVelocity > 0 ? 1 : -1,
  65370. minValue = this.getMinMomentumValue(),
  65371. maxValue = this.getMaxMomentumValue(),
  65372. boundedValue = (direction == 1) ? maxValue : minValue,
  65373. lastValue = this.lastValue,
  65374. value, velocity;
  65375. if (startVelocity === 0) {
  65376. return this.getStartValue();
  65377. }
  65378. if (!this.isOutOfBound) {
  65379. value = momentum.getValue();
  65380. velocity = momentum.getVelocity();
  65381. if (Math.abs(velocity) < this.getMinVelocity()) {
  65382. this.isEnded = true;
  65383. }
  65384. if (value >= minValue && value <= maxValue) {
  65385. return value;
  65386. }
  65387. this.isOutOfBound = true;
  65388. bounce.setStartTime(Ext.Date.now()).setStartVelocity(velocity).setStartValue(boundedValue);
  65389. }
  65390. value = bounce.getValue();
  65391. if (!this.isEnded) {
  65392. if (!this.isBouncingBack) {
  65393. if (lastValue !== null) {
  65394. if ((direction == 1 && value < lastValue) || (direction == -1 && value > lastValue)) {
  65395. this.isBouncingBack = true;
  65396. }
  65397. }
  65398. } else {
  65399. if (Math.round(value) == boundedValue) {
  65400. this.isEnded = true;
  65401. }
  65402. }
  65403. }
  65404. this.lastValue = value;
  65405. return value;
  65406. }
  65407. });
  65408. Ext.define('Ext.fx.easing.EaseIn', {
  65409. extend: Ext.fx.easing.Linear,
  65410. alias: 'easing.ease-in',
  65411. config: {
  65412. exponent: 4,
  65413. duration: 1500
  65414. },
  65415. getValue: function() {
  65416. var deltaTime = Ext.Date.now() - this.getStartTime(),
  65417. duration = this.getDuration(),
  65418. startValue = this.getStartValue(),
  65419. endValue = this.getEndValue(),
  65420. distance = this.distance,
  65421. theta = deltaTime / duration,
  65422. thetaEnd = Math.pow(theta, this.getExponent()),
  65423. currentValue = startValue + (thetaEnd * distance);
  65424. if (deltaTime >= duration) {
  65425. this.isEnded = true;
  65426. return endValue;
  65427. }
  65428. return currentValue;
  65429. }
  65430. });
  65431. Ext.define('Ext.fx.easing.EaseOut', {
  65432. extend: Ext.fx.easing.Linear,
  65433. alias: 'easing.ease-out',
  65434. config: {
  65435. exponent: 4,
  65436. duration: 1500
  65437. },
  65438. getValue: function() {
  65439. var deltaTime = Ext.Date.now() - this.getStartTime(),
  65440. duration = this.getDuration(),
  65441. startValue = this.getStartValue(),
  65442. endValue = this.getEndValue(),
  65443. distance = this.distance,
  65444. theta = deltaTime / duration,
  65445. thetaC = 1 - theta,
  65446. thetaEnd = 1 - Math.pow(thetaC, this.getExponent()),
  65447. currentValue = startValue + (thetaEnd * distance);
  65448. if (deltaTime >= duration) {
  65449. this.isEnded = true;
  65450. return endValue;
  65451. }
  65452. return currentValue;
  65453. }
  65454. });
  65455. Ext.define('Ext.fx.easing.Easing', {
  65456. constructor: function(easing) {
  65457. return Ext.factory(easing, Ext.fx.easing.Linear, null, 'easing');
  65458. }
  65459. });
  65460. Ext.define('Ext.fx.runner.CssAnimation', {
  65461. extend: Ext.fx.runner.Css,
  65462. constructor: function() {
  65463. this.runningAnimationsMap = {};
  65464. this.elementEndStates = {};
  65465. this.animationElementMap = {};
  65466. this.keyframesRulesCache = {};
  65467. this.uniqueId = 0;
  65468. return this.callParent(arguments);
  65469. },
  65470. attachListeners: function() {
  65471. this.listenersAttached = true;
  65472. Ext.getWin().on({
  65473. animationstart: 'onAnimationStart',
  65474. animationend: 'onAnimationEnd',
  65475. scope: this
  65476. });
  65477. },
  65478. onAnimationStart: function(e) {
  65479. var name = e.browserEvent.animationName,
  65480. elementId = this.animationElementMap[name],
  65481. animation = this.runningAnimationsMap[elementId][name],
  65482. elementEndStates = this.elementEndStates,
  65483. elementEndState = elementEndStates[elementId],
  65484. data = {};
  65485. if (elementEndState) {
  65486. delete elementEndStates[elementId];
  65487. data[elementId] = elementEndState;
  65488. this.applyStyles(data);
  65489. }
  65490. if (animation.before) {
  65491. data[elementId] = animation.before;
  65492. this.applyStyles(data);
  65493. }
  65494. },
  65495. onAnimationEnd: function(e) {
  65496. var element = e.target,
  65497. name = e.browserEvent.animationName,
  65498. animationElementMap = this.animationElementMap,
  65499. elementId = animationElementMap[name],
  65500. runningAnimationsMap = this.runningAnimationsMap,
  65501. runningAnimations = runningAnimationsMap[elementId],
  65502. animation = runningAnimations[name];
  65503. if (animation.onBeforeEnd) {
  65504. animation.onBeforeEnd.call(animation.scope || this, element);
  65505. }
  65506. if (animation.onEnd) {
  65507. animation.onEnd.call(animation.scope || this, element);
  65508. }
  65509. delete animationElementMap[name];
  65510. delete runningAnimations[name];
  65511. this.removeKeyframesRule(name);
  65512. },
  65513. generateAnimationId: function() {
  65514. return 'animation-' + (++this.uniqueId);
  65515. },
  65516. run: function(animations) {
  65517. var data = {},
  65518. elementEndStates = this.elementEndStates,
  65519. animationElementMap = this.animationElementMap,
  65520. runningAnimationsMap = this.runningAnimationsMap,
  65521. runningAnimations, states, elementId, animationId, i, ln, animation, name, runningAnimation, names, durations, easings, delays, directions, iterations;
  65522. if (!this.listenersAttached) {
  65523. this.attachListeners();
  65524. }
  65525. animations = Ext.Array.from(animations);
  65526. for (i = 0 , ln = animations.length; i < ln; i++) {
  65527. animation = animations[i];
  65528. animation = Ext.factory(animation, Ext.fx.Animation);
  65529. elementId = animation.getElement().getId();
  65530. animationId = animation.getName() || this.generateAnimationId();
  65531. animationElementMap[animationId] = elementId;
  65532. animation = animation.getData();
  65533. states = animation.states;
  65534. this.addKeyframesRule(animationId, states);
  65535. runningAnimations = runningAnimationsMap[elementId];
  65536. if (!runningAnimations) {
  65537. runningAnimations = runningAnimationsMap[elementId] = {};
  65538. }
  65539. runningAnimations[animationId] = animation;
  65540. names = [];
  65541. durations = [];
  65542. easings = [];
  65543. delays = [];
  65544. directions = [];
  65545. iterations = [];
  65546. for (name in runningAnimations) {
  65547. if (runningAnimations.hasOwnProperty(name)) {
  65548. runningAnimation = runningAnimations[name];
  65549. names.push(name);
  65550. durations.push(runningAnimation.duration);
  65551. easings.push(runningAnimation.easing);
  65552. delays.push(runningAnimation.delay);
  65553. directions.push(runningAnimation.direction);
  65554. iterations.push(runningAnimation.iteration);
  65555. }
  65556. }
  65557. data[elementId] = {
  65558. 'animation-name': names,
  65559. 'animation-duration': durations,
  65560. 'animation-timing-function': easings,
  65561. 'animation-delay': delays,
  65562. 'animation-direction': directions,
  65563. 'animation-iteration-count': iterations
  65564. };
  65565. if (animation.preserveEndState) {
  65566. elementEndStates[elementId] = states['100%'];
  65567. }
  65568. }
  65569. this.applyStyles(data);
  65570. },
  65571. addKeyframesRule: function(name, keyframes) {
  65572. var percentage, properties, keyframesRule, styleSheet, rules, styles, rulesLength, key, value;
  65573. styleSheet = this.getStyleSheet();
  65574. rules = styleSheet.cssRules;
  65575. rulesLength = rules.length;
  65576. styleSheet.insertRule('@' + this.vendorPrefix + 'keyframes ' + name + '{}', rulesLength);
  65577. keyframesRule = rules[rulesLength];
  65578. for (percentage in keyframes) {
  65579. properties = keyframes[percentage];
  65580. rules = keyframesRule.cssRules;
  65581. rulesLength = rules.length;
  65582. styles = [];
  65583. for (key in properties) {
  65584. value = this.formatValue(properties[key], key);
  65585. key = this.formatName(key);
  65586. styles.push(key + ':' + value);
  65587. }
  65588. keyframesRule.insertRule(percentage + '{' + styles.join(';') + '}', rulesLength);
  65589. }
  65590. return this;
  65591. },
  65592. removeKeyframesRule: function(name) {
  65593. var styleSheet = this.getStyleSheet(),
  65594. rules = styleSheet.cssRules,
  65595. i, ln, rule;
  65596. for (i = 0 , ln = rules.length; i < ln; i++) {
  65597. rule = rules[i];
  65598. if (rule.name === name) {
  65599. styleSheet.removeRule(i);
  65600. break;
  65601. }
  65602. }
  65603. return this;
  65604. }
  65605. });
  65606. Ext.define('Ext.list.AbstractTreeItem', {
  65607. extend: Ext.Widget,
  65608. isTreeListItem: true,
  65609. cachedConfig: {
  65610. expandable: false,
  65611. expanded: false,
  65612. iconCls: '',
  65613. leaf: true,
  65614. loading: false,
  65615. selected: false,
  65616. selectedParent: false
  65617. },
  65618. config: {
  65619. iconClsProperty: 'iconCls',
  65620. indent: null,
  65621. owner: null,
  65622. node: null,
  65623. over: null,
  65624. parentItem: null,
  65625. text: {
  65626. lazy: true,
  65627. $value: ''
  65628. },
  65629. textProperty: 'text'
  65630. },
  65631. updateNode: function(node) {
  65632. if (node) {
  65633. var me = this,
  65634. map = me.itemMap,
  65635. childNodes, owner, len, i, item, child;
  65636. me.element.dom.setAttribute('data-recordId', node.internalId);
  65637. if (!map) {
  65638. childNodes = node.childNodes;
  65639. owner = me.getOwner();
  65640. me.itemMap = map = {};
  65641. for (i = 0 , len = childNodes.length; i < len; ++i) {
  65642. child = childNodes[i];
  65643. if (child.data.visible) {
  65644. item = owner.createItem(child, me);
  65645. map[child.internalId] = item;
  65646. me.insertItem(item, null);
  65647. }
  65648. }
  65649. }
  65650. me.setExpanded(node.isExpanded());
  65651. me.doNodeUpdate(node);
  65652. }
  65653. },
  65654. updateSelected: function(selected) {
  65655. if (!this.isConfiguring) {
  65656. var parent = this.getParentItem();
  65657. while (parent && !parent.isRootListItem) {
  65658. parent.setSelectedParent(selected);
  65659. parent = parent.getParentItem();
  65660. }
  65661. }
  65662. },
  65663. collapse: function() {
  65664. this.getNode().collapse();
  65665. },
  65666. expand: function() {
  65667. this.getNode().expand();
  65668. },
  65669. getToolElement: Ext.emptyFn,
  65670. insertItem: Ext.emptyFn,
  65671. isExpanded: function() {
  65672. return this.getExpanded();
  65673. },
  65674. isSelectionEvent: Ext.emptyFn,
  65675. isToggleEvent: Ext.emptyFn,
  65676. nodeCollapse: function(node, collapsingForExpand) {
  65677. var me = this,
  65678. owner = me.getOwner(),
  65679. animation = me.preventAnimation ? null : owner.getAnimation();
  65680. me.nodeCollapseBegin(animation, collapsingForExpand);
  65681. if (!animation) {
  65682. me.nodeCollapseEnd(collapsingForExpand);
  65683. }
  65684. },
  65685. nodeCollapseBegin: function(animation, collapsingForExpand) {
  65686. var me = this,
  65687. owner = me.getOwner();
  65688. me.setExpanded(false);
  65689. owner.fireEvent('itemcollapse', owner, me);
  65690. },
  65691. nodeCollapseEnd: function(collapsingForExpand) {
  65692. if (!collapsingForExpand && !this.destroying) {
  65693. this.getOwner().updateLayout();
  65694. }
  65695. },
  65696. nodeExpand: function(node) {
  65697. var me = this,
  65698. owner = me.getOwner(),
  65699. floated = me.getFloated(),
  65700. animation = !floated && owner.getAnimation();
  65701. me.nodeExpandBegin(animation);
  65702. if (!animation) {
  65703. me.nodeExpandEnd();
  65704. }
  65705. },
  65706. nodeExpandBegin: function(animation) {
  65707. var me = this,
  65708. owner = me.getOwner();
  65709. me.setExpanded(true);
  65710. owner.fireEvent('itemexpand', owner, me);
  65711. },
  65712. nodeExpandEnd: function() {
  65713. if (!this.destroying) {
  65714. this.getOwner().updateLayout();
  65715. }
  65716. },
  65717. nodeInsert: function(node, refNode) {
  65718. var me = this,
  65719. owner = me.getOwner(),
  65720. map = me.itemMap,
  65721. id = node.internalId,
  65722. item = owner.getItem(node),
  65723. refItem = null,
  65724. oldParent;
  65725. if (item) {
  65726. oldParent = item.getParentItem();
  65727. oldParent.removeItem(item);
  65728. if (oldParent !== me) {
  65729. oldParent.doUpdateExpandable();
  65730. item.setParentItem(me);
  65731. }
  65732. } else {
  65733. item = me.getOwner().createItem(node, me);
  65734. }
  65735. map[id] = item;
  65736. if (refNode) {
  65737. refItem = map[refNode.internalId];
  65738. }
  65739. me.insertItem(item, refItem);
  65740. me.doUpdateExpandable();
  65741. owner.fireEvent('iteminsert', owner, me, item, refItem);
  65742. owner.updateLayout();
  65743. },
  65744. nodeRemove: function(node) {
  65745. var me = this,
  65746. map = me.itemMap,
  65747. owner = me.getOwner(),
  65748. id = node.internalId,
  65749. item = map[id];
  65750. if (item) {
  65751. delete map[id];
  65752. me.removeItem(item);
  65753. item.destroy();
  65754. me.doUpdateExpandable();
  65755. owner.fireEvent('itemremove', owner, me, item);
  65756. owner.updateLayout();
  65757. }
  65758. },
  65759. nodeUpdate: function(node, modifiedFieldNames) {
  65760. this.doNodeUpdate(node);
  65761. },
  65762. onClick: function(e) {
  65763. var me = this,
  65764. owner = me.getOwner(),
  65765. node = me.getNode(),
  65766. info = {
  65767. event: e,
  65768. item: me,
  65769. node: node,
  65770. tree: owner,
  65771. select: node.get('selectable') !== false && me.isSelectionEvent(e),
  65772. toggle: me.isToggleEvent(e)
  65773. };
  65774. if (owner.fireEvent('itemclick', owner, info) !== false) {
  65775. if (info.toggle) {
  65776. me.toggleExpanded();
  65777. e.preventDefault();
  65778. }
  65779. if (info.select) {
  65780. owner.setSelection(me.getNode());
  65781. }
  65782. }
  65783. },
  65784. removeItem: Ext.emptyFn,
  65785. destroy: function() {
  65786. var me = this,
  65787. map = me.itemMap,
  65788. owner = me.getOwner(),
  65789. key;
  65790. if (map) {
  65791. for (key in map) {
  65792. map[key].destroy();
  65793. }
  65794. me.itemMap = null;
  65795. }
  65796. if (owner) {
  65797. owner.removeItem(me.getNode());
  65798. }
  65799. me.setNode(null);
  65800. me.setParentItem(null);
  65801. me.setOwner(null);
  65802. me.callParent();
  65803. },
  65804. privates: {
  65805. doNodeUpdate: function(node, modifiedFieldNames) {
  65806. var me = this,
  65807. textProperty = this.getTextProperty(),
  65808. iconClsProperty = this.getIconClsProperty();
  65809. if (textProperty) {
  65810. me.setText(node.data[textProperty]);
  65811. }
  65812. if (iconClsProperty) {
  65813. me.setIconCls(node.data[iconClsProperty]);
  65814. }
  65815. me.setLoading(node.isLoading());
  65816. me.setLeaf(node.isLeaf());
  65817. me.doUpdateExpandable();
  65818. },
  65819. doUpdateExpandable: function() {
  65820. var node = this.getNode();
  65821. this.setExpandable(node.isExpandable());
  65822. },
  65823. toggleExpanded: function() {
  65824. if (this.isExpanded()) {
  65825. this.collapse();
  65826. } else {
  65827. this.expand();
  65828. }
  65829. },
  65830. updateIndent: function(value) {
  65831. var items = this.itemMap,
  65832. id;
  65833. for (id in items) {
  65834. items[id].setIndent(value);
  65835. }
  65836. },
  65837. updateOwner: function(owner) {
  65838. this.parent = owner;
  65839. }
  65840. }
  65841. });
  65842. Ext.define('Ext.list.RootTreeItem', {
  65843. extend: Ext.list.AbstractTreeItem,
  65844. isRootListItem: true,
  65845. element: {
  65846. reference: 'element',
  65847. tag: 'ul',
  65848. cls: Ext.baseCSSPrefix + 'treelist-root-container'
  65849. },
  65850. insertItem: function(item, refItem) {
  65851. if (refItem) {
  65852. item.element.insertBefore(refItem.element);
  65853. } else {
  65854. this.element.appendChild(item.element);
  65855. }
  65856. },
  65857. isToggleEvent: function(e) {
  65858. return false;
  65859. }
  65860. });
  65861. Ext.define('Ext.mixin.ItemRippler', {
  65862. mixinId: 'itemrippler',
  65863. config: {
  65864. itemRipple: null
  65865. },
  65866. shouldRippleItem: function(item, e) {
  65867. var itemRipple, ripple;
  65868. if (e.getTarget(this.noItemRippleSelector, this.element)) {
  65869. return false;
  65870. }
  65871. itemRipple = item && this.getItemRipple();
  65872. if (itemRipple && item.isWidget) {
  65873. ripple = item.shouldRipple(e);
  65874. if (ripple) {
  65875. itemRipple = Ext.apply({}, itemRipple, ripple);
  65876. }
  65877. }
  65878. return itemRipple;
  65879. },
  65880. rippleItem: function(item, e) {
  65881. if (!item) {
  65882. return;
  65883. }
  65884. var me = this,
  65885. start = e.type.match(me.rippleStateRe),
  65886. itemRipple = me.shouldRippleItem(item, e),
  65887. release = itemRipple && itemRipple.release,
  65888. isRelease = release === true,
  65889. el = item.isWidget ? item.el : item,
  65890. pos, delta, rs, rippledItems;
  65891. if (itemRipple && start && isRelease) {
  65892. me.$rippleStart = e.getXY();
  65893. }
  65894. if (itemRipple && el && ((!start && isRelease) || (start && release !== true))) {
  65895. rippledItems = me.$rippledItems || (me.$rippledItems = []);
  65896. rs = me.$rippleStart;
  65897. if (rs) {
  65898. pos = e.getXY();
  65899. delta = Math.sqrt(Math.pow((pos[0] - rs[0]), 2) + Math.pow((pos[1] - rs[1]), 2));
  65900. if (delta <= 8) {
  65901. el.ripple(e, itemRipple);
  65902. rippledItems.push(el);
  65903. }
  65904. } else {
  65905. el.ripple(e, itemRipple);
  65906. rippledItems.push(el);
  65907. }
  65908. me.$rippleStart = null;
  65909. }
  65910. },
  65911. destroyAllRipples: function() {
  65912. for (var items = this.$rippledItems; items && items.length; ) {
  65913. items.pop().destroyAllRipples();
  65914. }
  65915. },
  65916. privates: {
  65917. noItemRippleSelector: '.' + Ext.baseCSSPrefix + 'item-no-ripple, ' + '.' + Ext.baseCSSPrefix + 'item-no-tap',
  65918. rippleStateRe: /start|down/
  65919. }
  65920. });
  65921. Ext.define('Ext.list.TreeItem', {
  65922. extend: Ext.list.AbstractTreeItem,
  65923. xtype: 'treelistitem',
  65924. collapsedCls: Ext.baseCSSPrefix + 'treelist-item-collapsed',
  65925. expandedCls: Ext.baseCSSPrefix + 'treelist-item-expanded',
  65926. floatedToolCls: Ext.baseCSSPrefix + 'treelist-item-tool-floated',
  65927. leafCls: Ext.baseCSSPrefix + 'treelist-item-leaf',
  65928. expandableCls: Ext.baseCSSPrefix + 'treelist-item-expandable',
  65929. hideIconCls: Ext.baseCSSPrefix + 'treelist-item-hide-icon',
  65930. loadingCls: Ext.baseCSSPrefix + 'treelist-item-loading',
  65931. selectedCls: Ext.baseCSSPrefix + 'treelist-item-selected',
  65932. selectedParentCls: Ext.baseCSSPrefix + 'treelist-item-selected-parent',
  65933. withIconCls: Ext.baseCSSPrefix + 'treelist-item-with-icon',
  65934. hoverCls: Ext.baseCSSPrefix + 'treelist-item-over',
  65935. rowHoverCls: Ext.baseCSSPrefix + 'treelist-row-over',
  65936. isTreeListItem: true,
  65937. config: {
  65938. rowCls: null
  65939. },
  65940. rowClsProperty: 'rowCls',
  65941. element: {
  65942. reference: 'element',
  65943. tag: 'li',
  65944. cls: Ext.baseCSSPrefix + 'treelist-item',
  65945. children: [
  65946. {
  65947. reference: 'rowElement',
  65948. cls: Ext.baseCSSPrefix + 'treelist-row',
  65949. children: [
  65950. {
  65951. reference: 'wrapElement',
  65952. cls: Ext.baseCSSPrefix + 'treelist-item-wrap',
  65953. children: [
  65954. {
  65955. reference: 'iconElement',
  65956. cls: Ext.baseCSSPrefix + 'treelist-item-icon'
  65957. },
  65958. {
  65959. reference: 'textElement',
  65960. cls: Ext.baseCSSPrefix + 'treelist-item-text'
  65961. },
  65962. {
  65963. reference: 'expanderElement',
  65964. cls: Ext.baseCSSPrefix + 'treelist-item-expander'
  65965. }
  65966. ]
  65967. }
  65968. ]
  65969. },
  65970. {
  65971. reference: 'itemContainer',
  65972. tag: 'ul',
  65973. cls: Ext.baseCSSPrefix + 'treelist-container'
  65974. },
  65975. {
  65976. reference: 'toolElement',
  65977. cls: Ext.baseCSSPrefix + 'treelist-item-tool'
  65978. }
  65979. ]
  65980. },
  65981. constructor: function(config) {
  65982. this.callParent([
  65983. config
  65984. ]);
  65985. var toolDom = this.toolElement.dom;
  65986. toolDom.parentNode.removeChild(toolDom);
  65987. },
  65988. getToolElement: function() {
  65989. return this.toolElement;
  65990. },
  65991. insertItem: function(item, refItem) {
  65992. if (refItem) {
  65993. item.element.insertBefore(refItem.element);
  65994. } else {
  65995. this.itemContainer.appendChild(item.element);
  65996. }
  65997. },
  65998. isSelectionEvent: function(e) {
  65999. var owner = this.getOwner();
  66000. return (!this.isToggleEvent(e) || !owner.getExpanderOnly() || owner.getSelectOnExpander());
  66001. },
  66002. isToggleEvent: function(e) {
  66003. var isExpand = false;
  66004. if (this.getOwner().getExpanderOnly()) {
  66005. isExpand = e.target === this.expanderElement.dom;
  66006. } else {
  66007. isExpand = !this.itemContainer.contains(e.target);
  66008. }
  66009. return isExpand;
  66010. },
  66011. nodeCollapseBegin: function(animation, collapsingForExpand) {
  66012. var me = this,
  66013. itemContainer = me.itemContainer,
  66014. height;
  66015. if (me.expanding) {
  66016. me.stopAnimation(me.expanding);
  66017. }
  66018. height = animation && itemContainer.getHeight();
  66019. me.callParent([
  66020. animation,
  66021. collapsingForExpand
  66022. ]);
  66023. if (animation) {
  66024. itemContainer.dom.style.display = 'block';
  66025. me.collapsingForExpand = collapsingForExpand;
  66026. me.collapsing = this.runAnimation(Ext.merge({
  66027. from: {
  66028. height: height
  66029. },
  66030. to: {
  66031. height: 0
  66032. },
  66033. callback: me.nodeCollapseDone,
  66034. scope: me
  66035. }, animation));
  66036. }
  66037. },
  66038. nodeCollapseDone: function(animation) {
  66039. var me = this,
  66040. itemContainer = me.itemContainer;
  66041. if (!me.destroying && !me.destroyed) {
  66042. me.collapsing = null;
  66043. itemContainer.dom.style.display = '';
  66044. itemContainer.setHeight(null);
  66045. me.nodeCollapseEnd(me.collapsingForExpand);
  66046. }
  66047. },
  66048. nodeExpandBegin: function(animation) {
  66049. var me = this,
  66050. itemContainer = me.itemContainer,
  66051. height;
  66052. if (me.collapsing) {
  66053. me.stopAnimation(me.collapsing);
  66054. }
  66055. me.callParent([
  66056. animation
  66057. ]);
  66058. if (animation) {
  66059. height = itemContainer.getHeight();
  66060. itemContainer.setHeight(0);
  66061. me.expanding = me.runAnimation(Ext.merge({
  66062. to: {
  66063. height: height
  66064. },
  66065. callback: me.nodeExpandDone,
  66066. scope: me
  66067. }, animation));
  66068. }
  66069. },
  66070. nodeExpandDone: function() {
  66071. this.expanding = null;
  66072. this.itemContainer.setHeight(null);
  66073. this.nodeExpandEnd();
  66074. },
  66075. removeItem: function(item) {
  66076. this.itemContainer.removeChild(item.element);
  66077. },
  66078. updateNode: function(node, oldNode) {
  66079. this.syncIndent();
  66080. this.callParent([
  66081. node,
  66082. oldNode
  66083. ]);
  66084. },
  66085. updateExpandable: function(expandable) {
  66086. var node = this.getNode();
  66087. this.updateExpandCls();
  66088. if (node) {
  66089. node.set('expandable', expandable);
  66090. }
  66091. },
  66092. updateExpanded: function(expanded) {
  66093. var node = this.getNode();
  66094. this.updateExpandCls();
  66095. if (node) {
  66096. node.set('expanded', expanded);
  66097. }
  66098. },
  66099. updateIconCls: function(iconCls, oldIconCls) {
  66100. var me = this,
  66101. el = me.element;
  66102. me.doIconCls(me.iconElement, iconCls, oldIconCls);
  66103. me.doIconCls(me.toolElement, iconCls, oldIconCls);
  66104. el.toggleCls(me.withIconCls, !!iconCls);
  66105. el.toggleCls(me.hideIconCls, iconCls === null);
  66106. },
  66107. updateLeaf: function(leaf) {
  66108. this.element.toggleCls(this.leafCls, leaf);
  66109. },
  66110. updateLoading: function(loading) {
  66111. this.element.toggleCls(this.loadingCls, loading);
  66112. },
  66113. updateOver: function(over) {
  66114. var me = this;
  66115. me.element.toggleCls(me.hoverCls, !!over);
  66116. me.rowElement.toggleCls(me.rowHoverCls, over > 1);
  66117. },
  66118. updateRowCls: function(value, oldValue) {
  66119. this.rowElement.replaceCls(oldValue, value);
  66120. },
  66121. updateSelected: function(selected, oldSelected) {
  66122. var me = this,
  66123. cls = me.selectedCls,
  66124. tool = me.getToolElement();
  66125. me.callParent([
  66126. selected,
  66127. oldSelected
  66128. ]);
  66129. me.element.toggleCls(cls, selected);
  66130. if (tool) {
  66131. tool.toggleCls(cls, selected);
  66132. }
  66133. },
  66134. updateSelectedParent: function(selectedParent) {
  66135. var me = this;
  66136. me.element.toggleCls(me.selectedParentCls, selectedParent);
  66137. var tool = me.getToolElement();
  66138. if (tool) {
  66139. tool.toggleCls(me.selectedCls, selectedParent);
  66140. }
  66141. },
  66142. updateText: function(text) {
  66143. this.textElement.update(text);
  66144. },
  66145. privates: {
  66146. doNodeUpdate: function(node) {
  66147. this.callParent([
  66148. node
  66149. ]);
  66150. this.setRowCls(node && node.data[this.rowClsProperty]);
  66151. },
  66152. doIconCls: function(element, iconCls, oldIconCls) {
  66153. if (oldIconCls) {
  66154. element.removeCls(oldIconCls);
  66155. }
  66156. if (iconCls) {
  66157. element.addCls(iconCls);
  66158. }
  66159. },
  66160. syncIndent: function() {
  66161. var me = this,
  66162. indent = me.getIndent(),
  66163. node = me.getNode(),
  66164. depth;
  66165. if (node) {
  66166. depth = node.data.depth - 1;
  66167. me.wrapElement.dom.style.marginLeft = (depth * indent) + 'px';
  66168. }
  66169. },
  66170. updateExpandCls: function() {
  66171. if (!this.updatingExpandCls) {
  66172. var me = this,
  66173. expandable = me.getExpandable(),
  66174. element = me.element,
  66175. expanded = me.getExpanded(),
  66176. expandedCls = me.expandedCls,
  66177. collapsedCls = me.collapsedCls;
  66178. me.updatingExpandCls = true;
  66179. element.toggleCls(me.expandableCls, expandable);
  66180. if (expandable) {
  66181. element.toggleCls(expandedCls, expanded);
  66182. element.toggleCls(collapsedCls, !expanded);
  66183. } else {
  66184. element.removeCls([
  66185. expandedCls,
  66186. collapsedCls
  66187. ]);
  66188. }
  66189. me.updatingExpandCls = false;
  66190. }
  66191. },
  66192. updateIndent: function(value, oldValue) {
  66193. this.syncIndent();
  66194. this.callParent([
  66195. value,
  66196. oldValue
  66197. ]);
  66198. }
  66199. }
  66200. }, function(TreeItem) {
  66201. TreeItem.prototype.floatedCls = [
  66202. Ext.Widget.prototype.floatedCls,
  66203. Ext.baseCSSPrefix + 'treelist-item-floated'
  66204. ];
  66205. });
  66206. Ext.define('Ext.list.Tree', {
  66207. extend: Ext.Gadget,
  66208. xtype: 'treelist',
  66209. mixins: [
  66210. Ext.mixin.ItemRippler
  66211. ],
  66212. expanderFirstCls: Ext.baseCSSPrefix + 'treelist-expander-first',
  66213. expanderOnlyCls: Ext.baseCSSPrefix + 'treelist-expander-only',
  66214. highlightPathCls: Ext.baseCSSPrefix + 'treelist-highlight-path',
  66215. microCls: Ext.baseCSSPrefix + 'treelist-micro',
  66216. uiPrefix: Ext.baseCSSPrefix + 'treelist-',
  66217. element: {
  66218. reference: 'element',
  66219. cls: Ext.baseCSSPrefix + 'treelist ' + Ext.baseCSSPrefix + 'unselectable',
  66220. listeners: {
  66221. click: 'onClick',
  66222. touchstart: 'onTouchStart',
  66223. touchend: 'onTouchEnd',
  66224. mouseenter: 'onMouseEnter',
  66225. mouseleave: 'onMouseLeave',
  66226. mouseover: 'onMouseOver'
  66227. },
  66228. children: [
  66229. {
  66230. reference: 'toolsElement',
  66231. cls: Ext.baseCSSPrefix + 'treelist-toolstrip',
  66232. listeners: {
  66233. click: 'onToolStripClick',
  66234. mouseover: 'onToolStripMouseOver'
  66235. }
  66236. }
  66237. ]
  66238. },
  66239. cachedConfig: {
  66240. animation: {
  66241. duration: 500,
  66242. easing: 'ease'
  66243. },
  66244. expanderFirst: true,
  66245. expanderOnly: true
  66246. },
  66247. config: {
  66248. floatLeafItems: false,
  66249. defaults: {
  66250. xtype: 'treelistitem'
  66251. },
  66252. highlightPath: null,
  66253. iconSize: null,
  66254. indent: null,
  66255. micro: false,
  66256. overItem: null,
  66257. selection: null,
  66258. selectOnExpander: false,
  66259. singleExpand: null,
  66260. store: null,
  66261. ui: null
  66262. },
  66263. twoWayBindable: {
  66264. selection: 1
  66265. },
  66266. publishes: {
  66267. selection: 1
  66268. },
  66269. defaultBindProperty: 'store',
  66270. constructor: function(config) {
  66271. this.callParent([
  66272. config
  66273. ]);
  66274. this.publishState('selection', this.getSelection());
  66275. },
  66276. destroy: function() {
  66277. var me = this;
  66278. me.unfloatAll();
  66279. me.activeFloater = null;
  66280. me.setSelection(null);
  66281. me.setStore(null);
  66282. me.callParent();
  66283. },
  66284. updateOverItem: function(over, wasOver) {
  66285. var map = {},
  66286. state = 2,
  66287. c, node;
  66288. for (c = over; c; c = this.getItem(node.parentNode)) {
  66289. node = c.getNode();
  66290. map[node.internalId] = true;
  66291. c.setOver(state);
  66292. state = 1;
  66293. }
  66294. if (wasOver && !wasOver.destroyed) {
  66295. for (c = wasOver; c; c = this.getItem(node.parentNode)) {
  66296. node = c.getNode();
  66297. if (map[node.internalId]) {
  66298. break;
  66299. }
  66300. c.setOver(0);
  66301. }
  66302. }
  66303. },
  66304. applyMicro: function(micro) {
  66305. return Boolean(micro);
  66306. },
  66307. applySelection: function(selection, oldSelection) {
  66308. var store = this.getStore();
  66309. if (!store) {
  66310. selection = null;
  66311. }
  66312. if (store && selection !== null && !(selection instanceof Ext.data.Model)) {
  66313. selection = store.getNodeById(selection);
  66314. }
  66315. if (selection && selection.get('selectable') === false) {
  66316. selection = oldSelection;
  66317. }
  66318. return selection;
  66319. },
  66320. updateSelection: function(selection, oldSelection) {
  66321. var me = this,
  66322. item, parent;
  66323. if (!me.destroying) {
  66324. item = me.getItem(oldSelection);
  66325. if (item) {
  66326. item.setSelected(false);
  66327. }
  66328. item = me.getItem(selection);
  66329. if (item) {
  66330. item.setSelected(true);
  66331. while (parent = item.getParentItem()) {
  66332. parent.setExpanded(true);
  66333. item = parent;
  66334. }
  66335. }
  66336. me.fireEvent('selectionchange', me, selection);
  66337. }
  66338. },
  66339. applyStore: function(store) {
  66340. return store && Ext.StoreManager.lookup(store, 'tree');
  66341. },
  66342. updateStore: function(store, oldStore) {
  66343. var me = this,
  66344. root;
  66345. if (oldStore) {
  66346. if (!oldStore.destroyed) {
  66347. if (oldStore.getAutoDestroy()) {
  66348. oldStore.destroy();
  66349. } else {
  66350. me.storeListeners.destroy();
  66351. }
  66352. }
  66353. me.removeRoot();
  66354. me.storeListeners = null;
  66355. }
  66356. if (store) {
  66357. me.storeListeners = store.on({
  66358. destroyable: true,
  66359. scope: me,
  66360. filterchange: 'onFilterChange',
  66361. nodeappend: 'onNodeAppend',
  66362. nodecollapse: 'onNodeCollapse',
  66363. nodeexpand: 'onNodeExpand',
  66364. nodeinsert: 'onNodeInsert',
  66365. noderemove: 'onNodeRemove',
  66366. rootchange: 'onRootChange',
  66367. update: 'onNodeUpdate'
  66368. });
  66369. root = store.getRoot();
  66370. if (root) {
  66371. me.createRootItem(root);
  66372. }
  66373. }
  66374. if (!me.destroying) {
  66375. me.updateLayout();
  66376. }
  66377. },
  66378. updateExpanderFirst: function(expanderFirst) {
  66379. this.element.toggleCls(this.expanderFirstCls, expanderFirst);
  66380. },
  66381. updateExpanderOnly: function(value) {
  66382. this.element.toggleCls(this.expanderOnlyCls, !value);
  66383. },
  66384. updateHighlightPath: function(updatePath) {
  66385. this.element.toggleCls(this.highlightPathCls, updatePath);
  66386. },
  66387. updateMicro: function(micro) {
  66388. var me = this;
  66389. if (!micro) {
  66390. me.unfloatAll();
  66391. me.activeFloater = null;
  66392. }
  66393. me.element.toggleCls(me.microCls, micro);
  66394. },
  66395. updateUi: function(ui, oldValue) {
  66396. var me = this,
  66397. el = me.element,
  66398. uiPrefix = me.uiPrefix;
  66399. if (oldValue) {
  66400. el.removeCls(uiPrefix + oldValue);
  66401. }
  66402. if (ui) {
  66403. el.addCls(uiPrefix + ui);
  66404. }
  66405. delete me.iconSize;
  66406. me.syncIconSize();
  66407. },
  66408. getItem: function(node) {
  66409. var map = this.itemMap,
  66410. ret;
  66411. if (node && map) {
  66412. ret = map[node.internalId];
  66413. }
  66414. return ret || null;
  66415. },
  66416. getItemConfig: function(node, parent) {
  66417. return Ext.apply({
  66418. parentItem: parent.isRootListItem ? null : parent,
  66419. owner: this,
  66420. node: node,
  66421. indent: this.getIndent()
  66422. }, this.getDefaults());
  66423. },
  66424. privates: {
  66425. checkForOutsideClick: function(e) {
  66426. var floater = this.activeFloater;
  66427. if (!floater.element.contains(e.target)) {
  66428. this.unfloatAll();
  66429. }
  66430. },
  66431. collapsingForExpand: false,
  66432. createItem: function(node, parent) {
  66433. var me = this,
  66434. item = Ext.create(me.getItemConfig(node, parent)),
  66435. toolsElement = me.toolsElement,
  66436. toolEl, previousSibling;
  66437. if (parent.isRootListItem) {
  66438. toolEl = item.getToolElement();
  66439. if (toolEl) {
  66440. previousSibling = me.findVisiblePreviousSibling(node);
  66441. if (!previousSibling) {
  66442. toolsElement.insertFirst(toolEl);
  66443. } else {
  66444. previousSibling = me.getItem(previousSibling);
  66445. toolEl.insertAfter(previousSibling.getToolElement());
  66446. }
  66447. toolEl.dom.setAttribute('data-recordId', node.internalId);
  66448. toolEl.isTool = true;
  66449. }
  66450. }
  66451. me.itemMap[node.internalId] = item;
  66452. return item;
  66453. },
  66454. createRootItem: function(root) {
  66455. var me = this,
  66456. item;
  66457. me.itemMap = {};
  66458. me.rootItem = item = new Ext.list.RootTreeItem({
  66459. indent: me.getIndent(),
  66460. node: root,
  66461. owner: me
  66462. });
  66463. me.element.appendChild(item.element);
  66464. me.itemMap[root.internalId] = item;
  66465. },
  66466. findVisiblePreviousSibling: function(node) {
  66467. var sibling = node.previousSibling;
  66468. while (sibling) {
  66469. if (sibling.data.visible) {
  66470. return sibling;
  66471. }
  66472. sibling = sibling.previousSibling;
  66473. }
  66474. return null;
  66475. },
  66476. floatItem: function(item, byHover) {
  66477. var me = this,
  66478. floater;
  66479. if (item.getFloated()) {
  66480. return;
  66481. }
  66482. if (me.toolMouseListeners) {
  66483. me.toolMouseListeners.destroy();
  66484. me.floaterMouseListeners.destroy();
  66485. me.floaterMouseListeners = me.toolMouseListeners = null;
  66486. }
  66487. me.unfloatAll();
  66488. if (!byHover && !me.getFloatLeafItems() && item.getNode().isLeaf()) {
  66489. return;
  66490. }
  66491. me.activeFloater = floater = item;
  66492. me.floatedByHover = byHover;
  66493. item.setFloated(true);
  66494. if (byHover) {
  66495. me.toolMouseListeners = item.getToolElement().monitorMouseLeave(300, me.checkForMouseLeave, me);
  66496. me.floaterMouseListeners = (item.floater || item).el.monitorMouseLeave(300, me.checkForMouseLeave, me);
  66497. floater.element.on('mouseover', 'onMouseOver', me);
  66498. } else {
  66499. Ext.on('mousedown', 'checkForOutsideClick', me);
  66500. }
  66501. },
  66502. shouldRippleItem: function(item, e) {
  66503. if (item && item.getSelected()) {
  66504. return false;
  66505. }
  66506. return this.mixins.itemrippler.shouldRippleItem.call(this, item, e);
  66507. },
  66508. onTouchStart: function(e) {
  66509. this.doItemRipple(e);
  66510. },
  66511. onTouchEnd: function(e) {
  66512. this.doItemRipple(e);
  66513. },
  66514. doItemRipple: function(e) {
  66515. var me = this,
  66516. item = e.getTarget('[data-recordId]'),
  66517. id;
  66518. if (item) {
  66519. id = item.getAttribute('data-recordId');
  66520. item = me.itemMap[id];
  66521. if (item && me.shouldRippleItem(item, e)) {
  66522. this.rippleItem(item, e);
  66523. }
  66524. }
  66525. },
  66526. onClick: function(e) {
  66527. var item = e.getTarget('[data-recordId]'),
  66528. id;
  66529. if (item) {
  66530. id = item.getAttribute('data-recordId');
  66531. item = this.itemMap[id];
  66532. if (item) {
  66533. item.onClick(e);
  66534. }
  66535. }
  66536. },
  66537. onMouseEnter: function(e) {
  66538. this.onMouseOver(e);
  66539. },
  66540. onMouseLeave: function() {
  66541. this.setOverItem(null);
  66542. },
  66543. onMouseOver: function(e) {
  66544. var comp = Ext.Component.from(e);
  66545. this.setOverItem(comp && comp.isTreeListItem && comp);
  66546. },
  66547. checkForMouseLeave: function(e) {
  66548. var floater = this.activeFloater,
  66549. relatedTarget = e.getRelatedTarget();
  66550. if (floater) {
  66551. if (relatedTarget !== floater.getToolElement().dom && !floater.element.contains(relatedTarget)) {
  66552. this.unfloatAll();
  66553. }
  66554. }
  66555. },
  66556. onFilterChange: function(store) {
  66557. this.onRootChange(store.getRoot());
  66558. },
  66559. onNodeAppend: function(parentNode, node) {
  66560. if (parentNode) {
  66561. var item = this.itemMap[parentNode.internalId];
  66562. if (item) {
  66563. item.nodeInsert(node, null);
  66564. }
  66565. }
  66566. },
  66567. onNodeCollapse: function(node) {
  66568. var item = this.itemMap[node.internalId];
  66569. if (item) {
  66570. item.nodeCollapse(node, this.collapsingForExpand);
  66571. }
  66572. },
  66573. onNodeExpand: function(node) {
  66574. var me = this,
  66575. item = me.itemMap[node.internalId],
  66576. childNodes, len, i, parentNode, child;
  66577. if (item) {
  66578. if (!item.isRootItem && me.getSingleExpand()) {
  66579. me.collapsingForExpand = true;
  66580. parentNode = (item.getParentItem() || me.rootItem).getNode();
  66581. childNodes = parentNode.childNodes;
  66582. for (i = 0 , len = childNodes.length; i < len; ++i) {
  66583. child = childNodes[i];
  66584. if (child !== node) {
  66585. child.collapse();
  66586. }
  66587. }
  66588. me.collapsing = false;
  66589. }
  66590. item.nodeExpand(node);
  66591. }
  66592. },
  66593. onNodeInsert: function(parentNode, node, refNode) {
  66594. var item = this.itemMap[parentNode.internalId];
  66595. if (item) {
  66596. item.nodeInsert(node, refNode);
  66597. }
  66598. },
  66599. onNodeRemove: function(parentNode, node, isMove) {
  66600. if (parentNode && !isMove) {
  66601. var item = this.itemMap[parentNode.internalId];
  66602. if (item) {
  66603. item.nodeRemove(node);
  66604. }
  66605. }
  66606. },
  66607. onNodeUpdate: function(store, node, type, modifiedFieldNames) {
  66608. var item = this.itemMap[node.internalId];
  66609. if (item) {
  66610. item.nodeUpdate(node, modifiedFieldNames);
  66611. }
  66612. },
  66613. onRootChange: function(root) {
  66614. var me = this;
  66615. me.removeRoot();
  66616. if (root) {
  66617. me.createRootItem(root);
  66618. }
  66619. me.updateLayout();
  66620. me.fireEvent('refresh', me);
  66621. },
  66622. removeItem: function(node) {
  66623. var map = this.itemMap,
  66624. id = node.internalId,
  66625. item, toolEl;
  66626. if (map) {
  66627. item = map[id];
  66628. if (item.getParentItem() === null) {
  66629. toolEl = item.getToolElement();
  66630. if (toolEl) {
  66631. this.toolsElement.removeChild(toolEl);
  66632. }
  66633. }
  66634. delete map[id];
  66635. }
  66636. },
  66637. removeRoot: function() {
  66638. var me = this,
  66639. rootItem = me.rootItem;
  66640. if (rootItem) {
  66641. me.element.removeChild(rootItem.element);
  66642. me.rootItem = me.itemMap = Ext.destroy(rootItem);
  66643. }
  66644. },
  66645. onToolStripClick: function(e) {
  66646. var item = e.getTarget('[data-recordId]'),
  66647. id;
  66648. if (item) {
  66649. id = item.getAttribute('data-recordId');
  66650. item = this.itemMap[id];
  66651. if (item) {
  66652. if (item === this.activeFloater) {
  66653. this.unfloatAll();
  66654. } else {
  66655. this.floatItem(item, false);
  66656. }
  66657. }
  66658. }
  66659. },
  66660. onToolStripMouseOver: function(e) {
  66661. var item = e.getTarget('[data-recordId]'),
  66662. id;
  66663. if (item) {
  66664. id = item.getAttribute('data-recordId');
  66665. item = this.itemMap[id];
  66666. if (item) {
  66667. this.floatItem(item, true);
  66668. }
  66669. }
  66670. },
  66671. syncIconSize: function() {
  66672. var me = this,
  66673. size = me.iconSize || (me.iconSize = parseInt(me.element.getStyle('background-position'), 10));
  66674. me.setIconSize(size);
  66675. },
  66676. unfloatAll: function() {
  66677. var me = this,
  66678. floater = me.activeFloater;
  66679. if (floater) {
  66680. floater.setFloated(false);
  66681. me.activeFloater = null;
  66682. if (me.floatedByHover) {
  66683. if (me.toolMouseListeners) {
  66684. me.toolMouseListeners.destroy();
  66685. me.floaterMouseListeners.destroy();
  66686. me.floaterMouseListeners = me.toolMouseListeners = null;
  66687. }
  66688. floater.element.un('mouseover', 'onMouseOver', me);
  66689. } else {
  66690. Ext.un('mousedown', 'checkForOutsideClick', me);
  66691. }
  66692. }
  66693. },
  66694. defaultIconSize: 22,
  66695. updateIconSize: function(value) {
  66696. this.setIndent(value || this.defaultIconSize);
  66697. },
  66698. updateIndent: function(value) {
  66699. var rootItem = this.rootItem;
  66700. if (rootItem) {
  66701. rootItem.setIndent(value);
  66702. }
  66703. }
  66704. }
  66705. });
  66706. Ext.define('Ext.mixin.ConfigProxy', function(ConfigProxy) {
  66707. return {
  66708. extend: Ext.Mixin,
  66709. mixinConfig: {
  66710. id: 'configproxy',
  66711. extended: function(baseClass, derivedClass, classBody) {
  66712. var proxyConfig = classBody.proxyConfig;
  66713. derivedClass.$configProxies = Ext.apply({}, derivedClass.superclass.self.$configProxies);
  66714. if (proxyConfig) {
  66715. delete classBody.proxyConfig;
  66716. ConfigProxy.processClass(derivedClass, proxyConfig);
  66717. }
  66718. }
  66719. },
  66720. onClassMixedIn: function(targetClass) {
  66721. var prototype = targetClass.prototype,
  66722. proxyConfig = prototype.proxyConfig,
  66723. initConfig = prototype.initConfig;
  66724. prototype.$proxiedConfigs = null;
  66725. targetClass.$configProxies = {};
  66726. prototype.initConfig = function(config) {
  66727. initConfig.apply(this, arguments);
  66728. this.$proxiedConfigs = null;
  66729. return this;
  66730. };
  66731. if (proxyConfig) {
  66732. delete prototype.proxyConfig;
  66733. ConfigProxy.processClass(targetClass, proxyConfig);
  66734. }
  66735. },
  66736. getProxiedConfigs: function(name) {
  66737. var me = this,
  66738. configs = me.config,
  66739. configProxies = me.self.$configProxies[name],
  66740. i = configProxies && configProxies.length,
  66741. cfg, proxiedConfigs, ret, s, v;
  66742. if (i && me.isConfiguring) {
  66743. proxiedConfigs = me.$proxiedConfigs || (me.$proxiedConfigs = {});
  66744. while (i-- > 0) {
  66745. cfg = configProxies[i];
  66746. proxiedConfigs[s = cfg.name] = cfg;
  66747. if ((v = configs[s]) !== undefined) {
  66748. (ret || (ret = {}))[s] = v;
  66749. }
  66750. }
  66751. }
  66752. return ret;
  66753. },
  66754. mergeProxiedConfigs: function(name, itemConfig, alwaysClone) {
  66755. var me = this,
  66756. ret = itemConfig,
  66757. proxied = me.getProxiedConfigs(name),
  66758. configurator;
  66759. if (proxied) {
  66760. if (!itemConfig) {
  66761. ret = proxied;
  66762. } else if (itemConfig.constructor === Object) {
  66763. configurator = me.self.getConfigurator();
  66764. ret = configurator.merge(me, Ext.clone(itemConfig), proxied);
  66765. }
  66766. }
  66767. if (alwaysClone && ret === itemConfig) {
  66768. ret = Ext.clone(ret);
  66769. }
  66770. return ret;
  66771. },
  66772. statics: {
  66773. processClass: function(targetClass, proxyConfig) {
  66774. var ExtConfig = Ext.Config,
  66775. targetProto = targetClass.prototype,
  66776. add = {},
  66777. proxies = targetClass.$configProxies,
  66778. cfg, configs, itemGetter, i, item, methods, n, name, proxiedConfigs, s;
  66779. for (item in proxyConfig) {
  66780. itemGetter = ExtConfig.get(item).names.get;
  66781. configs = proxyConfig[item];
  66782. if (Ext.isArray(configs)) {
  66783. methods = null;
  66784. } else {
  66785. methods = configs.methods;
  66786. configs = configs.configs;
  66787. }
  66788. if (!(proxiedConfigs = proxies[item])) {
  66789. proxies[item] = proxiedConfigs = [];
  66790. } else {
  66791. proxies[item] = proxiedConfigs = proxiedConfigs.slice();
  66792. }
  66793. for (i = 0 , n = methods && methods.length; i < n; ++i) {
  66794. if (!targetProto[name = methods[i]]) {
  66795. targetProto[name] = ConfigProxy.wrapFn(itemGetter, name);
  66796. } else
  66797. {
  66798. Ext.raise('Cannot proxy method "' + name + '"');
  66799. }
  66800. }
  66801. for (i = 0 , n = configs && configs.length; i < n; ++i) {
  66802. cfg = ExtConfig.get(s = configs[i]);
  66803. if (s in add) {
  66804. Ext.raise('Duplicate proxy config definitions for "' + s + '"');
  66805. }
  66806. if (s in targetProto.config) {
  66807. Ext.raise('Config "' + s + '" already defined for class ' + targetProto.$className);
  66808. }
  66809. add[s] = undefined;
  66810. proxiedConfigs.push(cfg);
  66811. if (!targetProto[name = cfg.names.get]) {
  66812. targetProto[name] = ConfigProxy.wrapGet(itemGetter, name);
  66813. } else
  66814. {
  66815. Ext.raise('Cannot proxy "' + s + '" config getter');
  66816. }
  66817. if (!targetProto[name = cfg.names.set]) {
  66818. targetProto[name] = ConfigProxy.wrapSet(itemGetter, name, s);
  66819. } else
  66820. {
  66821. Ext.raise('Cannot proxy "' + s + '" config setter');
  66822. }
  66823. }
  66824. }
  66825. targetClass.addConfig(add);
  66826. },
  66827. wrapFn: function(itemGetter, name) {
  66828. return function() {
  66829. var item = this[itemGetter]();
  66830. return item && item[name].apply(item, arguments);
  66831. };
  66832. },
  66833. wrapGet: function(itemGetter, configGetter) {
  66834. return function() {
  66835. var item = this[itemGetter]();
  66836. return item && item[configGetter]();
  66837. };
  66838. },
  66839. wrapSet: function(itemGetter, configSetter, itemName) {
  66840. return function(value) {
  66841. var me = this,
  66842. item, proxiedConfigs;
  66843. if (!me.isConfiguring || value !== undefined) {
  66844. item = me[itemGetter]();
  66845. proxiedConfigs = me.$proxiedConfigs;
  66846. if (proxiedConfigs && proxiedConfigs[itemName]) {
  66847. delete proxiedConfigs[itemName];
  66848. item = null;
  66849. }
  66850. if (item) {
  66851. item[configSetter](value);
  66852. }
  66853. }
  66854. return me;
  66855. };
  66856. }
  66857. }
  66858. };
  66859. });
  66860. Ext.define('Ext.mixin.ConfigState', {
  66861. extend: Ext.Mixin,
  66862. mixinConfig: {
  66863. id: 'configstate'
  66864. },
  66865. alternateStateConfig: '',
  66866. toggleConfigState: function(isAlternate) {
  66867. var me = this,
  66868. state = me.capturedConfigState,
  66869. cfg = me.getConfig(me.alternateStateConfig),
  66870. key;
  66871. if (!cfg) {
  66872. return;
  66873. }
  66874. if (isAlternate) {
  66875. state = {};
  66876. for (key in cfg) {
  66877. state[key] = me.getConfig(key);
  66878. }
  66879. me.capturedConfigState = state;
  66880. me.setConfig(cfg);
  66881. }
  66882. else if (!me.isConfiguring && state) {
  66883. me.setConfig(state);
  66884. delete me.capturedConfigState;
  66885. }
  66886. }
  66887. });
  66888. Ext.define('Ext.mixin.Mashup', function(Mashup) {
  66889. return {
  66890. extend: 'Ext.Mixin',
  66891. mixinConfig: {
  66892. id: 'mashup',
  66893. extended: function(baseClass, derivedClass) {
  66894. Mashup.process(derivedClass);
  66895. }
  66896. },
  66897. statics: {
  66898. process: function(targetClass) {
  66899. var body = targetClass.prototype,
  66900. requiredScripts = body.requiredScripts,
  66901. hooks = targetClass._classHooks,
  66902. onCreated = hooks.onCreated,
  66903. xtypes = targetClass.prototype.xtypes,
  66904. mashup = Ext.manifest.mashup || {},
  66905. options = body.mashupConfig,
  66906. i, script;
  66907. if (requiredScripts) {
  66908. delete body.requiredScripts;
  66909. hooks.onCreated = function() {
  66910. var me = this,
  66911. scripts = [],
  66912. args = Ext.Array.slice(arguments),
  66913. redirect = mashup.redirect || {};
  66914. requiredScripts = scripts.concat(requiredScripts);
  66915. options = options && mashup[options.key];
  66916. if (xtypes) {
  66917. for (i = 0; !options && i < xtypes.length; ++i) {
  66918. options = mashup[xtypes[i]];
  66919. }
  66920. }
  66921. for (i = 0; i < requiredScripts.length; i++) {
  66922. script = requiredScripts[i];
  66923. if (redirect[script] === false) {
  66924. continue;
  66925. }
  66926. script = redirect[script] || script;
  66927. if (script.indexOf('{') > -1) {
  66928. if (options) {
  66929. script = new Ext.Template(script).apply(options);
  66930. } else
  66931. {
  66932. Ext.log.error('Missing mashup options for ' + body.$className + ' script "' + script + '"');
  66933. }
  66934. }
  66935. scripts.push(script);
  66936. }
  66937. if (!scripts.length) {
  66938. hooks.onCreated = onCreated;
  66939. hooks.onCreated.call(me, args);
  66940. return;
  66941. }
  66942. Ext.Loader.loadScripts({
  66943. url: scripts,
  66944. cache: true,
  66945. onError: function(opts, error) {
  66946. targetClass.scriptError = targetClass.prototype.scriptError = error;
  66947. hooks.onCreated = onCreated;
  66948. hooks.onCreated.call(me, args);
  66949. },
  66950. onLoad: function() {
  66951. hooks.onCreated = onCreated;
  66952. hooks.onCreated.call(me, args);
  66953. }
  66954. });
  66955. };
  66956. }
  66957. }
  66958. },
  66959. onClassMixedIn: function(targetClass) {
  66960. Mashup.process(targetClass);
  66961. }
  66962. };
  66963. });
  66964. Ext.define('Ext.mixin.Responsive', function(Responsive) {
  66965. return {
  66966. extend: Ext.Mixin,
  66967. mixinConfig: {
  66968. id: 'responsive',
  66969. after: {
  66970. destroy: 'destroy'
  66971. }
  66972. },
  66973. config: {
  66974. responsiveConfig: {
  66975. $value: undefined,
  66976. merge: function(newValue, oldValue, target, mixinClass) {
  66977. if (!newValue) {
  66978. return oldValue;
  66979. }
  66980. var ret = oldValue ? Ext.Object.chain(oldValue) : {},
  66981. rule;
  66982. for (rule in newValue) {
  66983. if (!mixinClass || !(rule in ret)) {
  66984. ret[rule] = {
  66985. fn: null,
  66986. config: newValue[rule]
  66987. };
  66988. }
  66989. }
  66990. return ret;
  66991. }
  66992. },
  66993. responsiveFormulas: {
  66994. $value: 0,
  66995. merge: function(newValue, oldValue, target, mixinClass) {
  66996. return this.mergeNew(newValue, oldValue, target, mixinClass);
  66997. }
  66998. }
  66999. },
  67000. destroy: function() {
  67001. Responsive.unregister(this);
  67002. },
  67003. privates: {
  67004. statics: {
  67005. active: false,
  67006. all: {},
  67007. context: Ext.Object.chain(Ext.platformTags),
  67008. count: 0,
  67009. nextId: 0,
  67010. activate: function() {
  67011. Responsive.active = true;
  67012. Responsive.updateContext();
  67013. Ext.on('resize', Responsive.onResize, Responsive);
  67014. },
  67015. deactivate: function() {
  67016. Responsive.active = false;
  67017. Ext.un('resize', Responsive.onResize, Responsive);
  67018. },
  67019. notify: function() {
  67020. var all = Responsive.all,
  67021. context = Responsive.context,
  67022. globalEvents = Ext.GlobalEvents,
  67023. timer = Responsive.timer,
  67024. id;
  67025. if (timer) {
  67026. Responsive.timer = Ext.unasap(timer);
  67027. }
  67028. Responsive.updateContext();
  67029. Ext.suspendLayouts();
  67030. globalEvents.fireEvent('beforeresponsiveupdate', context);
  67031. for (id in all) {
  67032. all[id].setupResponsiveContext();
  67033. }
  67034. globalEvents.fireEvent('beginresponsiveupdate', context);
  67035. for (id in all) {
  67036. all[id].updateResponsiveState();
  67037. }
  67038. globalEvents.fireEvent('responsiveupdate', context);
  67039. Ext.resumeLayouts(true);
  67040. },
  67041. onResize: function() {
  67042. if (!Responsive.timer) {
  67043. Responsive.timer = Ext.asap(Responsive.onTimer);
  67044. }
  67045. },
  67046. onTimer: function() {
  67047. Responsive.timer = null;
  67048. Responsive.notify();
  67049. },
  67050. processConfig: function(instance, instanceConfig, name) {
  67051. var value = instanceConfig && instanceConfig[name],
  67052. config = instance.config,
  67053. cfg, configurator;
  67054. if (value) {
  67055. configurator = instance.self.getConfigurator();
  67056. cfg = configurator.configs[name];
  67057. config[name] = cfg.merge(value, config[name], instance);
  67058. }
  67059. },
  67060. register: function(responder) {
  67061. var id = responder.$responsiveId;
  67062. if (!id) {
  67063. responder.$responsiveId = id = ++Responsive.nextId;
  67064. Responsive.all[id] = responder;
  67065. if (++Responsive.count === 1) {
  67066. Responsive.activate();
  67067. }
  67068. }
  67069. },
  67070. unregister: function(responder) {
  67071. var id = responder.$responsiveId;
  67072. if (id in Responsive.all) {
  67073. responder.$responsiveId = null;
  67074. delete Responsive.all[id];
  67075. if (--Responsive.count === 0) {
  67076. Responsive.deactivate();
  67077. }
  67078. }
  67079. },
  67080. updateContext: function() {
  67081. var El = Ext.Element,
  67082. width = El.getViewportWidth(),
  67083. height = El.getViewportHeight(),
  67084. context = Responsive.context;
  67085. context.width = width;
  67086. context.height = height;
  67087. context.tall = width < height;
  67088. context.wide = !context.tall;
  67089. context.landscape = context.portrait = false;
  67090. if (!context.platform) {
  67091. context.platform = Ext.platformTags;
  67092. }
  67093. context[Ext.dom.Element.getOrientation()] = true;
  67094. }
  67095. },
  67096. afterClassMixedIn: function(targetClass) {
  67097. var proto = targetClass.prototype,
  67098. responsiveConfig = proto.responsiveConfig,
  67099. responsiveFormulas = proto.responsiveFormulas,
  67100. config;
  67101. if (responsiveConfig || responsiveFormulas) {
  67102. config = {};
  67103. if (responsiveConfig) {
  67104. delete proto.responsiveConfig;
  67105. config.responsiveConfig = responsiveConfig;
  67106. }
  67107. if (responsiveFormulas) {
  67108. delete proto.responsiveFormulas;
  67109. config.responsiveFormulas = responsiveFormulas;
  67110. }
  67111. targetClass.getConfigurator().add(config);
  67112. }
  67113. },
  67114. applyResponsiveConfig: function(rules) {
  67115. for (var rule in rules) {
  67116. rules[rule].fn = Ext.createRuleFn(rule);
  67117. }
  67118. return rules;
  67119. },
  67120. applyResponsiveFormulas: function(formulas) {
  67121. var ret = {},
  67122. fn, name;
  67123. if (formulas) {
  67124. for (name in formulas) {
  67125. if (Ext.isString(fn = formulas[name])) {
  67126. fn = Ext.createRuleFn(fn);
  67127. }
  67128. ret[name] = fn;
  67129. }
  67130. }
  67131. return ret;
  67132. },
  67133. getResponsiveState: function() {
  67134. var context = Responsive.context,
  67135. rules = this.getResponsiveConfig(),
  67136. ret = {},
  67137. entry, rule;
  67138. if (rules) {
  67139. for (rule in rules) {
  67140. entry = rules[rule];
  67141. if (entry.fn.call(this, context)) {
  67142. Ext.merge(ret, entry.config);
  67143. }
  67144. }
  67145. }
  67146. return ret;
  67147. },
  67148. setupResponsiveContext: function() {
  67149. var formulas = this.getResponsiveFormulas(),
  67150. context = Responsive.context,
  67151. name;
  67152. if (formulas) {
  67153. for (name in formulas) {
  67154. context[name] = formulas[name].call(this, context);
  67155. }
  67156. }
  67157. },
  67158. transformInstanceConfig: function(instanceConfig) {
  67159. var me = this,
  67160. ret;
  67161. Responsive.register(me);
  67162. if (instanceConfig) {
  67163. Responsive.processConfig(me, instanceConfig, 'responsiveConfig');
  67164. Responsive.processConfig(me, instanceConfig, 'responsiveFormulas');
  67165. }
  67166. me.setupResponsiveContext();
  67167. ret = me.getResponsiveState();
  67168. if (instanceConfig) {
  67169. ret = Ext.merge({}, instanceConfig, ret);
  67170. delete ret.responsiveConfig;
  67171. delete ret.responsiveFormulas;
  67172. }
  67173. return ret;
  67174. },
  67175. updateResponsiveState: function() {
  67176. var config = this.getResponsiveState();
  67177. this.setConfig(config);
  67178. }
  67179. }
  67180. };
  67181. });
  67182. Ext.define('Ext.mixin.Selectable', {
  67183. extend: Ext.Mixin,
  67184. mixinConfig: {
  67185. id: 'selectable',
  67186. after: {
  67187. updateStore: 'updateStore'
  67188. }
  67189. },
  67190. config: {
  67191. disableSelection: null,
  67192. mode: 'SINGLE',
  67193. allowDeselect: false,
  67194. lastSelected: null,
  67195. lastFocused: null,
  67196. deselectOnContainerClick: true,
  67197. selected: true,
  67198. pruneRemoved: true,
  67199. selection: null,
  67200. twoWayBindable: {
  67201. selection: 1
  67202. },
  67203. publishes: {
  67204. selection: 1
  67205. }
  67206. },
  67207. modes: {
  67208. SINGLE: true,
  67209. SIMPLE: true,
  67210. MULTI: true
  67211. },
  67212. onNavigate: function(event) {},
  67213. selectableEventHooks: {
  67214. add: 'onSelectionStoreAdd',
  67215. remove: 'onSelectionStoreRemove',
  67216. update: 'onSelectionStoreUpdate',
  67217. clear: {
  67218. fn: 'onSelectionStoreClear',
  67219. priority: 1000
  67220. },
  67221. load: 'refreshSelection',
  67222. refresh: 'refreshSelection'
  67223. },
  67224. initSelectable: function() {
  67225. this.publishState('selection', this.getSelection());
  67226. },
  67227. applySelected: function(selected) {
  67228. if (!selected.isCollection) {
  67229. selected = new Ext.util.Collection(selected);
  67230. }
  67231. selected.addObserver(this);
  67232. return selected;
  67233. },
  67234. applyMode: function(mode) {
  67235. mode = mode ? mode.toUpperCase() : 'SINGLE';
  67236. return this.modes[mode] ? mode : 'SINGLE';
  67237. },
  67238. updateStore: function(newStore, oldStore) {
  67239. var me = this,
  67240. bindEvents = Ext.apply({}, me.selectableEventHooks, {
  67241. scope: me
  67242. });
  67243. if (oldStore && Ext.isObject(oldStore) && oldStore.isStore) {
  67244. if (oldStore.autoDestroy) {
  67245. oldStore.destroy();
  67246. } else {
  67247. oldStore.un(bindEvents);
  67248. }
  67249. }
  67250. if (newStore) {
  67251. newStore.on(bindEvents);
  67252. me.refreshSelection();
  67253. }
  67254. },
  67255. selectAll: function(silent) {
  67256. var me = this,
  67257. selections = me.getStore().getRange();
  67258. me.select(selections, true, silent);
  67259. },
  67260. deselectAll: function(supress) {
  67261. var me = this;
  67262. me.deselect(me.getSelected().getRange(), supress);
  67263. me.setLastSelected(null);
  67264. me.setLastFocused(null);
  67265. },
  67266. updateSelection: function(selection) {
  67267. if (this.changingSelection) {
  67268. return;
  67269. }
  67270. if (selection) {
  67271. this.select(selection);
  67272. } else {
  67273. this.deselectAll();
  67274. }
  67275. },
  67276. selectWithEvent: function(record) {
  67277. var me = this,
  67278. isSelected = me.isSelected(record);
  67279. switch (me.getMode()) {
  67280. case 'MULTI':
  67281. case 'SIMPLE':
  67282. if (isSelected) {
  67283. me.deselect(record);
  67284. } else {
  67285. me.select(record, true);
  67286. };
  67287. break;
  67288. case 'SINGLE':
  67289. if (me.getAllowDeselect() && isSelected) {
  67290. me.deselect(record);
  67291. } else {
  67292. me.select(record, false);
  67293. };
  67294. break;
  67295. }
  67296. },
  67297. selectRange: function(startRecord, endRecord, keepExisting) {
  67298. var me = this,
  67299. store = me.getStore(),
  67300. records = [],
  67301. tmp, i;
  67302. if (me.getDisableSelection()) {
  67303. return;
  67304. }
  67305. if (startRecord > endRecord) {
  67306. tmp = endRecord;
  67307. endRecord = startRecord;
  67308. startRecord = tmp;
  67309. }
  67310. for (i = startRecord; i <= endRecord; i++) {
  67311. records.push(store.getAt(i));
  67312. }
  67313. this.doMultiSelect(records, keepExisting);
  67314. },
  67315. select: function(records, keepExisting, suppressEvent) {
  67316. var me = this,
  67317. record;
  67318. if (me.getDisableSelection()) {
  67319. return;
  67320. }
  67321. if (typeof records === "number") {
  67322. records = [
  67323. me.getStore().getAt(records)
  67324. ];
  67325. }
  67326. if (!records) {
  67327. return;
  67328. }
  67329. if (me.getMode() == "SINGLE" && records) {
  67330. record = records.length ? records[0] : records;
  67331. me.doSingleSelect(record, suppressEvent);
  67332. } else {
  67333. me.doMultiSelect(records, keepExisting, suppressEvent);
  67334. }
  67335. },
  67336. doSingleSelect: function(record, suppressEvent) {
  67337. this.doMultiSelect([
  67338. record
  67339. ], false, suppressEvent);
  67340. },
  67341. doMultiSelect: function(records, keepExisting, suppressEvent) {
  67342. if (records === null || this.getDisableSelection()) {
  67343. return;
  67344. }
  67345. records = !Ext.isArray(records) ? [
  67346. records
  67347. ] : records;
  67348. var me = this,
  67349. selected = me.getSelected(),
  67350. selectionCount = selected.getCount(),
  67351. toRemove = [],
  67352. ln = records.length,
  67353. change = false,
  67354. i = 0,
  67355. record;
  67356. if (!keepExisting && selectionCount) {
  67357. toRemove = selected.getRange();
  67358. }
  67359. for (i = 0; i < ln; i++) {
  67360. record = records[i];
  67361. if (typeof record === 'number') {
  67362. records[i] = store.getAt(record);
  67363. }
  67364. }
  67365. selected.suppressEvent = suppressEvent;
  67366. selected.splice(selectionCount, toRemove, records);
  67367. selected.suppressEvent = false;
  67368. },
  67369. deselect: function(records, suppressEvent) {
  67370. var me = this;
  67371. if (me.getDisableSelection()) {
  67372. return;
  67373. }
  67374. records = Ext.isArray(records) ? records : [
  67375. records
  67376. ];
  67377. var selected = me.getSelected(),
  67378. store = me.getStore(),
  67379. len = records.length,
  67380. i, record;
  67381. for (i = 0; i < len; i++) {
  67382. record = records[i];
  67383. if (typeof record === 'number') {
  67384. records[i] = store.getAt(record);
  67385. }
  67386. }
  67387. selected.suppressEvent = suppressEvent;
  67388. selected.remove(records);
  67389. selected.suppressEvent = false;
  67390. },
  67391. onCollectionRemove: function(selectedCollection, chunk) {
  67392. var me = this,
  67393. lastSelected = me.getLastSelected(),
  67394. records = chunk.items;
  67395. if (lastSelected && !selectedCollection.contains(lastSelected)) {
  67396. me.setLastSelected(selectedCollection.last());
  67397. }
  67398. me.onItemDeselect(records, selectedCollection.suppressEvent);
  67399. if (!selectedCollection.suppressEvent) {
  67400. me.fireSelectionChange(records);
  67401. }
  67402. },
  67403. onCollectionAdd: function(selectedCollection, adds) {
  67404. var me = this,
  67405. records = adds.items;
  67406. me.setLastSelected(selectedCollection.last());
  67407. me.onItemSelect(records, selectedCollection.suppressEvent);
  67408. if (!selectedCollection.suppressEvent) {
  67409. me.fireSelectionChange(records);
  67410. }
  67411. },
  67412. updateLastFocused: function(newRecord, oldRecord) {
  67413. this.onLastFocusChanged(oldRecord, newRecord);
  67414. },
  67415. fireSelectionChange: function(records) {
  67416. var me = this;
  67417. me.changingSelection = true;
  67418. me.setSelection(me.getLastSelected() || null);
  67419. me.changingSelection = false;
  67420. me.fireAction('selectionchange', [
  67421. me,
  67422. records
  67423. ], 'getSelections');
  67424. },
  67425. getSelections: function() {
  67426. return this.getSelected().getRange();
  67427. },
  67428. isSelected: function(record) {
  67429. record = Ext.isNumber(record) ? this.getStore().getAt(record) : record;
  67430. return this.getSelected().indexOf(record) !== -1;
  67431. },
  67432. hasSelection: function() {
  67433. return this.getSelected().getCount() > 0;
  67434. },
  67435. refreshSelection: function() {
  67436. var me = this,
  67437. selected = me.getSelected(),
  67438. selections = selected.getRange(),
  67439. selectionLength = selections.length,
  67440. storeCollection = me.getStore().getData(),
  67441. toDeselect = [],
  67442. toReselect = [],
  67443. i, rec, matchingSelection;
  67444. if (me.getPruneRemoved()) {
  67445. storeCollection = storeCollection.getSource() || storeCollection;
  67446. for (i = 0; i < selectionLength; i++) {
  67447. rec = selections[i];
  67448. matchingSelection = storeCollection.get(storeCollection.getKey(rec));
  67449. if (matchingSelection) {
  67450. if (matchingSelection !== rec) {
  67451. toDeselect.push(rec);
  67452. toReselect.push(matchingSelection);
  67453. }
  67454. } else {
  67455. toDeselect.push(rec);
  67456. }
  67457. }
  67458. }
  67459. selected.suppressEvent = true;
  67460. selected.splice(selected.getCount(), toDeselect, toReselect);
  67461. selected.suppressEvent = false;
  67462. },
  67463. onSelectionStoreRemove: function(store, records) {
  67464. var me = this,
  67465. selected = me.getSelected(),
  67466. ln = records.length,
  67467. removed, record, i;
  67468. if (me.getDisableSelection()) {
  67469. return;
  67470. }
  67471. for (i = 0; i < ln; i++) {
  67472. record = records[i];
  67473. if (selected.remove(record)) {
  67474. if (me.getLastSelected() == record) {
  67475. me.setLastSelected(null);
  67476. }
  67477. if (me.getLastFocused() == record) {
  67478. me.setLastFocused(null);
  67479. }
  67480. removed = removed || [];
  67481. removed.push(record);
  67482. }
  67483. }
  67484. if (removed) {
  67485. me.fireSelectionChange([
  67486. removed
  67487. ]);
  67488. }
  67489. },
  67490. onSelectionStoreClear: function(store) {
  67491. var records = store.getData().items;
  67492. this.onSelectionStoreRemove(store, records);
  67493. },
  67494. getSelectionCount: function() {
  67495. return this.getSelected().getCount();
  67496. },
  67497. onSelectionStoreAdd: Ext.emptyFn,
  67498. onSelectionStoreUpdate: Ext.emptyFn,
  67499. onItemSelect: Ext.emptyFn,
  67500. onItemDeselect: Ext.emptyFn,
  67501. onLastFocusChanged: Ext.emptyFn,
  67502. onEditorKey: Ext.emptyFn
  67503. }, function() {});
  67504. Ext.define('Ext.mixin.StoreWatcher', {
  67505. mixinId: 'storewatcher',
  67506. config: {
  67507. dataSource: null,
  67508. owner: null,
  67509. ownerListeners: {
  67510. destroyable: true,
  67511. storechange: 'onStoreChange'
  67512. },
  67513. sourceListeners: null,
  67514. store: null,
  67515. storeListeners: null
  67516. },
  67517. afterClassMixedIn: function(targetClass) {
  67518. var configurator = this.getConfigurator(),
  67519. prototype = targetClass.prototype,
  67520. config = {},
  67521. prop;
  67522. for (prop in configurator.configs) {
  67523. if (prototype.hasOwnProperty(prop)) {
  67524. config[prop] = prototype[prop];
  67525. delete prototype[prop];
  67526. }
  67527. }
  67528. targetClass.addConfig(config);
  67529. },
  67530. onFilterChange: function(store) {
  67531. var source;
  67532. if (!store) {
  67533. source = null;
  67534. } else if (store.getDataSource) {
  67535. source = store.getDataSource();
  67536. } else {
  67537. source = store.getData();
  67538. }
  67539. this.setDataSource(source);
  67540. },
  67541. onStoreChange: function(comp, store) {
  67542. this.setStore(store);
  67543. },
  67544. updateDataSource: function(source) {
  67545. this.syncListeners(source, '$sourceListeners', 'getSourceListeners');
  67546. },
  67547. updateOwner: function(owner) {
  67548. this.syncListeners(owner, '$ownerListeners', 'getOwnerListeners');
  67549. this.setStore(owner ? owner.getStore() : null);
  67550. },
  67551. applyStore: function(store) {
  67552. return (store && !store.isEmptyStore) ? store : null;
  67553. },
  67554. updateStore: function(store) {
  67555. this.syncListeners(store, '$storeListeners', 'getStoreListeners');
  67556. this.onFilterChange(store);
  67557. },
  67558. privates: {
  67559. syncListeners: function(instance, token, listeners) {
  67560. var me = this,
  67561. old = me[token];
  67562. if (old) {
  67563. me[token] = null;
  67564. old.destroy();
  67565. }
  67566. if (instance) {
  67567. listeners = me[listeners]();
  67568. listeners = Ext.applyIf({
  67569. destroyable: true,
  67570. scope: me
  67571. }, listeners);
  67572. me[token] = instance.on(listeners);
  67573. }
  67574. }
  67575. }
  67576. });
  67577. Ext.define('Ext.mixin.StyleCacher', {
  67578. extend: Ext.Mixin,
  67579. mixinConfig: {
  67580. id: 'stylecacher'
  67581. },
  67582. getCachedStyle: function(el, style) {
  67583. var cache = this.$styleCache;
  67584. if (!cache) {
  67585. cache = this.$styleCache = {};
  67586. }
  67587. if (!(style in cache)) {
  67588. cache[style] = Ext.fly(el).getStyle(style);
  67589. }
  67590. return cache[style];
  67591. }
  67592. });
  67593. Ext.define('Ext.perf.Accumulator', function() {
  67594. var currentFrame = null,
  67595. khrome = Ext.global['chrome'],
  67596. formatTpl,
  67597. getTimestamp = function() {
  67598. getTimestamp = Ext.now;
  67599. var interval, toolbox;
  67600. if (Ext.isChrome && khrome && khrome.Interval) {
  67601. interval = new khrome.Interval();
  67602. interval.start();
  67603. getTimestamp = function() {
  67604. return interval.microseconds() / 1000;
  67605. };
  67606. } else if (window.ActiveXObject) {
  67607. try {
  67608. toolbox = new ActiveXObject('SenchaToolbox.Toolbox');
  67609. Ext.senchaToolbox = toolbox;
  67610. getTimestamp = function() {
  67611. return toolbox.milliseconds;
  67612. };
  67613. } catch (e) {}
  67614. }
  67615. Ext.perf.getTimestamp = Ext.perf.Accumulator.getTimestamp = getTimestamp;
  67616. return getTimestamp();
  67617. };
  67618. function adjustSet(set, time) {
  67619. set.sum += time;
  67620. set.min = Math.min(set.min, time);
  67621. set.max = Math.max(set.max, time);
  67622. }
  67623. function leaveFrame(time) {
  67624. var totalTime = time ? time : (getTimestamp() - this.time),
  67625. me = this,
  67626. accum = me.accum;
  67627. ++accum.count;
  67628. if (!--accum.depth) {
  67629. adjustSet(accum.total, totalTime);
  67630. }
  67631. adjustSet(accum.pure, totalTime - me.childTime);
  67632. currentFrame = me.parent;
  67633. if (currentFrame) {
  67634. ++currentFrame.accum.childCount;
  67635. currentFrame.childTime += totalTime;
  67636. }
  67637. }
  67638. function makeSet() {
  67639. return {
  67640. min: Number.MAX_VALUE,
  67641. max: 0,
  67642. sum: 0
  67643. };
  67644. }
  67645. function makeTap(me, fn) {
  67646. return function() {
  67647. var frame = me.enter(),
  67648. ret = fn.apply(this, arguments);
  67649. frame.leave();
  67650. return ret;
  67651. };
  67652. }
  67653. function setToJSON(count, childCount, calibration, set) {
  67654. var data = {
  67655. avg: 0,
  67656. min: set.min,
  67657. max: set.max,
  67658. sum: 0
  67659. };
  67660. if (count) {
  67661. calibration = calibration || 0;
  67662. data.sum = set.sum - childCount * calibration;
  67663. data.avg = data.sum / count;
  67664. }
  67665. return data;
  67666. }
  67667. return {
  67668. constructor: function(name) {
  67669. var me = this;
  67670. me.count = me.childCount = me.depth = me.maxDepth = 0;
  67671. me.pure = makeSet();
  67672. me.total = makeSet();
  67673. me.name = name;
  67674. },
  67675. statics: {
  67676. getTimestamp: getTimestamp
  67677. },
  67678. format: function(calibration) {
  67679. if (!formatTpl) {
  67680. formatTpl = new Ext.XTemplate([
  67681. '{name} - {count} call(s)',
  67682. '<tpl if="count">',
  67683. '<tpl if="childCount">',
  67684. ' ({childCount} children)',
  67685. '</tpl>',
  67686. '<tpl if="depth - 1">',
  67687. ' ({depth} deep)',
  67688. '</tpl>',
  67689. '<tpl for="times">',
  67690. ', {type}: {[this.time(values.sum)]} msec (',
  67691. 'avg={[this.time(values.sum / parent.count)]}',
  67692. ')',
  67693. '</tpl>',
  67694. '</tpl>'
  67695. ].join(''), {
  67696. time: function(t) {
  67697. return Math.round(t * 100) / 100;
  67698. }
  67699. });
  67700. }
  67701. var data = this.getData(calibration);
  67702. data.name = this.name;
  67703. data.pure.type = 'Pure';
  67704. data.total.type = 'Total';
  67705. data.times = [
  67706. data.pure,
  67707. data.total
  67708. ];
  67709. return formatTpl.apply(data);
  67710. },
  67711. getData: function(calibration) {
  67712. var me = this;
  67713. return {
  67714. count: me.count,
  67715. childCount: me.childCount,
  67716. depth: me.maxDepth,
  67717. pure: setToJSON(me.count, me.childCount, calibration, me.pure),
  67718. total: setToJSON(me.count, me.childCount, calibration, me.total)
  67719. };
  67720. },
  67721. enter: function() {
  67722. var me = this,
  67723. frame = {
  67724. accum: me,
  67725. leave: leaveFrame,
  67726. childTime: 0,
  67727. parent: currentFrame
  67728. };
  67729. ++me.depth;
  67730. if (me.maxDepth < me.depth) {
  67731. me.maxDepth = me.depth;
  67732. }
  67733. currentFrame = frame;
  67734. frame.time = getTimestamp();
  67735. return frame;
  67736. },
  67737. monitor: function(fn, scope, args) {
  67738. var frame = this.enter();
  67739. if (args) {
  67740. fn.apply(scope, args);
  67741. } else {
  67742. fn.call(scope);
  67743. }
  67744. frame.leave();
  67745. },
  67746. report: function() {
  67747. Ext.log(this.format());
  67748. },
  67749. tap: function(className, methodName) {
  67750. var me = this,
  67751. methods = typeof methodName === 'string' ? [
  67752. methodName
  67753. ] : methodName,
  67754. klass, statik, i, parts, length, name, src, tapFunc;
  67755. tapFunc = function() {
  67756. if (typeof className === 'string') {
  67757. klass = Ext.global;
  67758. parts = className.split('.');
  67759. for (i = 0 , length = parts.length; i < length; ++i) {
  67760. klass = klass[parts[i]];
  67761. }
  67762. } else {
  67763. klass = className;
  67764. }
  67765. for (i = 0 , length = methods.length; i < length; ++i) {
  67766. name = methods[i];
  67767. statik = name.charAt(0) === '!';
  67768. if (statik) {
  67769. name = name.substring(1);
  67770. } else {
  67771. statik = !(name in klass.prototype);
  67772. }
  67773. src = statik ? klass : klass.prototype;
  67774. src[name] = makeTap(me, src[name]);
  67775. }
  67776. };
  67777. Ext.ClassManager.onCreated(tapFunc, me, className);
  67778. return me;
  67779. }
  67780. };
  67781. }, function() {
  67782. Ext.perf.getTimestamp = this.getTimestamp;
  67783. });
  67784. Ext.define('Ext.perf.Monitor', {
  67785. singleton: true,
  67786. alternateClassName: 'Ext.Perf',
  67787. constructor: function() {
  67788. this.accumulators = [];
  67789. this.accumulatorsByName = {};
  67790. },
  67791. calibrate: function() {
  67792. var accum = new Ext.perf.Accumulator('$'),
  67793. total = accum.total,
  67794. getTimestamp = Ext.perf.Accumulator.getTimestamp,
  67795. count = 0,
  67796. frame, endTime, startTime;
  67797. startTime = getTimestamp();
  67798. do {
  67799. frame = accum.enter();
  67800. frame.leave();
  67801. ++count;
  67802. } while (total.sum < 100);
  67803. endTime = getTimestamp();
  67804. return (endTime - startTime) / count;
  67805. },
  67806. get: function(name) {
  67807. var me = this,
  67808. accum = me.accumulatorsByName[name];
  67809. if (!accum) {
  67810. me.accumulatorsByName[name] = accum = new Ext.perf.Accumulator(name);
  67811. me.accumulators.push(accum);
  67812. }
  67813. return accum;
  67814. },
  67815. enter: function(name) {
  67816. return this.get(name).enter();
  67817. },
  67818. monitor: function(name, fn, scope) {
  67819. this.get(name).monitor(fn, scope);
  67820. },
  67821. report: function() {
  67822. var me = this,
  67823. accumulators = me.accumulators,
  67824. calibration = me.calibrate();
  67825. accumulators.sort(function(a, b) {
  67826. return (a.name < b.name) ? -1 : ((b.name < a.name) ? 1 : 0);
  67827. });
  67828. me.updateGC();
  67829. Ext.log('Calibration: ' + Math.round(calibration * 100) / 100 + ' msec/sample');
  67830. Ext.each(accumulators, function(accum) {
  67831. Ext.log(accum.format(calibration));
  67832. });
  67833. },
  67834. getData: function(all) {
  67835. var ret = {},
  67836. accumulators = this.accumulators;
  67837. Ext.each(accumulators, function(accum) {
  67838. if (all || accum.count) {
  67839. ret[accum.name] = accum.getData();
  67840. }
  67841. });
  67842. return ret;
  67843. },
  67844. reset: function() {
  67845. Ext.each(this.accumulators, function(accum) {
  67846. var me = accum;
  67847. me.count = me.childCount = me.depth = me.maxDepth = 0;
  67848. me.pure = {
  67849. min: Number.MAX_VALUE,
  67850. max: 0,
  67851. sum: 0
  67852. };
  67853. me.total = {
  67854. min: Number.MAX_VALUE,
  67855. max: 0,
  67856. sum: 0
  67857. };
  67858. });
  67859. },
  67860. updateGC: function() {
  67861. var accumGC = this.accumulatorsByName.GC,
  67862. toolbox = Ext.senchaToolbox,
  67863. bucket;
  67864. if (accumGC) {
  67865. accumGC.count = toolbox.garbageCollectionCounter || 0;
  67866. if (accumGC.count) {
  67867. bucket = accumGC.pure;
  67868. accumGC.total.sum = bucket.sum = toolbox.garbageCollectionMilliseconds;
  67869. bucket.min = bucket.max = bucket.sum / accumGC.count;
  67870. bucket = accumGC.total;
  67871. bucket.min = bucket.max = bucket.sum / accumGC.count;
  67872. }
  67873. }
  67874. },
  67875. watchGC: function() {
  67876. Ext.perf.getTimestamp();
  67877. var toolbox = Ext.senchaToolbox;
  67878. if (toolbox) {
  67879. this.get("GC");
  67880. toolbox.watchGarbageCollector(false);
  67881. }
  67882. },
  67883. setup: function(config) {
  67884. if (!config) {
  67885. config = {
  67886. render: {
  67887. 'Ext.Component': 'render'
  67888. },
  67889. layout: {
  67890. 'Ext.layout.Context': 'run'
  67891. }
  67892. };
  67893. }
  67894. this.currentConfig = config;
  67895. var key, prop, accum, className, methods;
  67896. for (key in config) {
  67897. if (config.hasOwnProperty(key)) {
  67898. prop = config[key];
  67899. accum = Ext.Perf.get(key);
  67900. for (className in prop) {
  67901. if (prop.hasOwnProperty(className)) {
  67902. methods = prop[className];
  67903. accum.tap(className, methods);
  67904. }
  67905. }
  67906. }
  67907. }
  67908. this.watchGC();
  67909. },
  67910. setupLog: function(config) {
  67911. var className, cls, methods, method, override;
  67912. for (className in config) {
  67913. if (config.hasOwnProperty(className)) {
  67914. cls = Ext.ClassManager.get(className);
  67915. if (cls) {
  67916. methods = config[className];
  67917. override = {};
  67918. for (method in methods) {
  67919. override[method] = (function(methodName, idProp) {
  67920. return function() {
  67921. var before, diff, id, idHolder, ret;
  67922. before = +Date.now();
  67923. ret = this.callParent(arguments);
  67924. diff = +Date.now() - before;
  67925. if (window.console && diff > 0) {
  67926. idHolder = idProp === 'this' ? this : typeof idProp === 'string' ? this[idProp] : typeof idProp === 'number' ? arguments[idProp] : null;
  67927. if (idHolder) {
  67928. id = idHolder.id;
  67929. }
  67930. if (id != null) {
  67931. console.log(methodName + ' for ' + id + ': ' + diff + 'ms');
  67932. } else {
  67933. console.log(methodName + ' for unknown: ' + diff + 'ms');
  67934. }
  67935. if (console.trace) {
  67936. console.trace();
  67937. }
  67938. }
  67939. return ret;
  67940. };
  67941. })(method, methods[method]);
  67942. }
  67943. Ext.override(cls, override);
  67944. }
  67945. }
  67946. }
  67947. }
  67948. });
  67949. Ext.define('Ext.plugin.AbstractClipboard', {
  67950. extend: Ext.plugin.Abstract,
  67951. cachedConfig: {
  67952. formats: {
  67953. text: {
  67954. get: 'getTextData',
  67955. put: 'putTextData'
  67956. }
  67957. }
  67958. },
  67959. config: {
  67960. memory: null,
  67961. source: 'system',
  67962. system: 'text',
  67963. gridListeners: null
  67964. },
  67965. destroy: function() {
  67966. var me = this,
  67967. keyMap = me.keyMap,
  67968. shared = me.shared;
  67969. Ext.destroy(me.destroyListener);
  67970. if (keyMap) {
  67971. me.keyMap = Ext.destroy(keyMap);
  67972. if (!--shared.counter) {
  67973. shared.textArea = Ext.destroy(shared.textArea);
  67974. }
  67975. } else {
  67976. me.renderListener = Ext.destroy(me.renderListener);
  67977. }
  67978. me.callParent();
  67979. },
  67980. init: function(comp) {
  67981. var me = this,
  67982. listeners = me.getGridListeners();
  67983. if (comp.rendered) {
  67984. me.finishInit(comp);
  67985. } else if (listeners) {
  67986. me.renderListener = comp.on(Ext.apply({
  67987. scope: me,
  67988. destroyable: true,
  67989. single: true
  67990. }, listeners));
  67991. }
  67992. },
  67993. onCmpReady: function() {
  67994. this.renderListener = null;
  67995. this.finishInit(this.getCmp());
  67996. },
  67997. getTarget: function(comp) {
  67998. return comp.el;
  67999. },
  68000. privates: {
  68001. shared: {
  68002. counter: 0,
  68003. data: null,
  68004. textArea: null
  68005. },
  68006. applyMemory: function(value) {
  68007. value = this.applySource(value);
  68008. if (value) {
  68009. for (var i = value.length; i-- > 0; ) {
  68010. if (value[i] === 'system') {
  68011. Ext.raise('Invalid clipboard format "' + value[i] + '"');
  68012. }
  68013. }
  68014. }
  68015. return value;
  68016. },
  68017. applySource: function(value) {
  68018. if (value) {
  68019. if (Ext.isString(value)) {
  68020. value = [
  68021. value
  68022. ];
  68023. } else if (value.length === 0) {
  68024. value = null;
  68025. }
  68026. }
  68027. if (value) {
  68028. var formats = this.getFormats();
  68029. for (var i = value.length; i-- > 0; ) {
  68030. if (value[i] !== 'system' && !formats[value[i]]) {
  68031. Ext.raise('Invalid clipboard format "' + value[i] + '"');
  68032. }
  68033. }
  68034. }
  68035. return value || null;
  68036. },
  68037. applySystem: function(value) {
  68038. var formats = this.getFormats();
  68039. if (!formats[value]) {
  68040. Ext.raise('Invalid clipboard format "' + value + '"');
  68041. }
  68042. return value;
  68043. },
  68044. doCutCopy: function(event, erase) {
  68045. var me = this,
  68046. formats = me.allFormats || me.syncFormats(),
  68047. data = me.getData(erase, formats),
  68048. memory = me.getMemory(),
  68049. system = me.getSystem(),
  68050. sys;
  68051. if (me.validateAction(event) === false) {
  68052. return;
  68053. }
  68054. me.shared.data = memory && data;
  68055. if (system) {
  68056. sys = data[system];
  68057. if (formats[system] < 3) {
  68058. delete data[system];
  68059. }
  68060. me.setClipboardData(sys);
  68061. }
  68062. },
  68063. doPaste: function(format, data) {
  68064. var formats = this.getFormats();
  68065. this[formats[format].put](data, format);
  68066. },
  68067. finishInit: function(comp) {
  68068. var me = this;
  68069. me.keyMap = new Ext.util.KeyMap({
  68070. target: me.getTarget(comp),
  68071. ignoreInputFields: true,
  68072. binding: [
  68073. {
  68074. ctrl: true,
  68075. key: 'x',
  68076. fn: me.onCut,
  68077. scope: me
  68078. },
  68079. {
  68080. ctrl: true,
  68081. key: 'c',
  68082. fn: me.onCopy,
  68083. scope: me
  68084. },
  68085. {
  68086. ctrl: true,
  68087. key: 'v',
  68088. fn: me.onPaste,
  68089. scope: me
  68090. }
  68091. ]
  68092. });
  68093. ++me.shared.counter;
  68094. me.destroyListener = comp.on({
  68095. destroyable: true,
  68096. destroy: 'destroy',
  68097. scope: me
  68098. });
  68099. },
  68100. getData: function(erase, format) {
  68101. var me = this,
  68102. formats = me.getFormats(),
  68103. data, i, name, names;
  68104. if (Ext.isString(format)) {
  68105. if (!formats[format]) {
  68106. Ext.raise('Invalid clipboard format "' + format + '"');
  68107. }
  68108. data = me[formats[format].get](format, erase);
  68109. } else {
  68110. data = {};
  68111. names = [];
  68112. if (format) {
  68113. for (name in format) {
  68114. if (!formats[name]) {
  68115. Ext.raise('Invalid clipboard format "' + name + '"');
  68116. }
  68117. names.push(name);
  68118. }
  68119. } else {
  68120. names = Ext.Object.getAllKeys(formats);
  68121. }
  68122. for (i = names.length; i-- > 0; ) {
  68123. data[name] = me[formats[name].get](name, erase && !i);
  68124. }
  68125. }
  68126. return data;
  68127. },
  68128. getHiddenTextArea: function() {
  68129. var shared = this.shared,
  68130. el;
  68131. el = shared.textArea;
  68132. if (!el) {
  68133. el = shared.textArea = Ext.getBody().createChild({
  68134. tag: 'textarea',
  68135. tabIndex: -1,
  68136. style: {
  68137. position: 'absolute',
  68138. top: '-1000px',
  68139. width: '1px',
  68140. height: '1px'
  68141. }
  68142. });
  68143. el.suspendFocusEvents();
  68144. }
  68145. return el;
  68146. },
  68147. onCopy: function(keyCode, event) {
  68148. this.doCutCopy(event, false);
  68149. },
  68150. onCut: function(keyCode, event) {
  68151. this.doCutCopy(event, true);
  68152. },
  68153. onPaste: function(keyCode, event) {
  68154. var me = this,
  68155. sharedData = me.shared.data,
  68156. source = me.getSource(),
  68157. i, n, s;
  68158. if (me.validateAction(event) === false) {
  68159. return;
  68160. }
  68161. if (source) {
  68162. for (i = 0 , n = source.length; i < n; ++i) {
  68163. s = source[i];
  68164. if (s === 'system') {
  68165. s = me.getSystem();
  68166. me.pasteClipboardData(s);
  68167. break;
  68168. } else if (sharedData && (s in sharedData)) {
  68169. me.doPaste(s, sharedData[s]);
  68170. break;
  68171. }
  68172. }
  68173. }
  68174. },
  68175. pasteClipboardData: function(format) {
  68176. var me = this,
  68177. clippy = window.clipboardData,
  68178. area, focusEl;
  68179. if (clippy && clippy.getData) {
  68180. me.doPaste(format, clippy.getData("text"));
  68181. } else {
  68182. focusEl = Ext.Element.getActiveElement(true);
  68183. area = me.getHiddenTextArea().dom;
  68184. area.value = '';
  68185. if (focusEl) {
  68186. focusEl.suspendFocusEvents();
  68187. }
  68188. area.focus();
  68189. Ext.defer(function() {
  68190. if (focusEl) {
  68191. focusEl.focus();
  68192. focusEl.resumeFocusEvents();
  68193. }
  68194. me.doPaste(format, area.value);
  68195. area.value = '';
  68196. }, 100, me);
  68197. }
  68198. },
  68199. setClipboardData: function(data) {
  68200. var clippy = window.clipboardData;
  68201. if (clippy && clippy.setData) {
  68202. clippy.setData("text", data);
  68203. } else {
  68204. var me = this,
  68205. area = me.getHiddenTextArea().dom,
  68206. focusEl = Ext.Element.getActiveElement(true);
  68207. area.value = data;
  68208. if (focusEl) {
  68209. focusEl.suspendFocusEvents();
  68210. }
  68211. area.focus();
  68212. area.select();
  68213. Ext.defer(function() {
  68214. area.value = '';
  68215. if (focusEl) {
  68216. focusEl.focus();
  68217. focusEl.resumeFocusEvents();
  68218. }
  68219. }, 50);
  68220. }
  68221. },
  68222. syncFormats: function() {
  68223. var me = this,
  68224. map = {},
  68225. memory = me.getMemory(),
  68226. system = me.getSystem(),
  68227. i, s;
  68228. if (system) {
  68229. map[system] = 1;
  68230. }
  68231. if (memory) {
  68232. for (i = memory.length; i-- > 0; ) {
  68233. s = memory[i];
  68234. map[s] = map[s] ? 3 : 2;
  68235. }
  68236. }
  68237. return me.allFormats = map;
  68238. },
  68239. updateMemory: function() {
  68240. this.allFormats = null;
  68241. },
  68242. updateSystem: function() {
  68243. this.allFormats = null;
  68244. },
  68245. validateAction: Ext.privateFn
  68246. }
  68247. });
  68248. Ext.define('Ext.plugin.MouseEnter', {
  68249. extend: Ext.plugin.Abstract,
  68250. alias: 'plugin.mouseenter',
  68251. element: 'el',
  68252. init: function(component) {
  68253. if (!this.delegate) {
  68254. Ext.raise('mouseenter plugin must be configured with a delegate selector');
  68255. }
  68256. if (!this.handler) {
  68257. Ext.raise('mouseenter plugin must be configured with handler callback');
  68258. }
  68259. var me = this,
  68260. listeners = {
  68261. mouseover: 'onMouseEvent',
  68262. scope: me,
  68263. destroyable: true
  68264. },
  68265. element = me.element;
  68266. if (me.leaveHandler || me.delay) {
  68267. listeners.mouseout = 'onMouseEvent';
  68268. }
  68269. if (typeof element === 'string') {
  68270. element = component[me.element];
  68271. }
  68272. if (element) {
  68273. me.mouseListener = Ext.get(element).on(listeners);
  68274. } else
  68275. {
  68276. component.on({
  68277. render: function() {
  68278. me.mouseListener = component[me.element].on(listeners);
  68279. },
  68280. single: true
  68281. });
  68282. }
  68283. },
  68284. onMouseEvent: function(e) {
  68285. var me = this,
  68286. delegate = e.getTarget(me.delegate);
  68287. if (delegate && delegate !== e.getRelatedTarget(me.delegate)) {
  68288. if (me.delay) {
  68289. Ext.undefer(me.mouseEventTimer);
  68290. me.mouseEventTimer = Ext.defer(me.handleMouseEvent, me.delay, me, [
  68291. e,
  68292. delegate
  68293. ]);
  68294. } else {
  68295. me.handleMouseEvent(e, delegate);
  68296. }
  68297. }
  68298. },
  68299. handleMouseEvent: function(e, delegate) {
  68300. var me = this;
  68301. if (e.type === 'mouseover') {
  68302. Ext.callback(me.handler, null, [
  68303. e,
  68304. delegate
  68305. ], 0, me.cmp, me.scope);
  68306. } else if (me.leaveHandler) {
  68307. Ext.callback(me.leaveHandler, null, [
  68308. e,
  68309. delegate
  68310. ], 0, me.cmp, me.scope);
  68311. }
  68312. },
  68313. destroy: function() {
  68314. Ext.destroy(this.mouseListener);
  68315. this.callParent();
  68316. }
  68317. });
  68318. Ext.define('Ext.sparkline.Shape', {
  68319. constructor: function(target, id, type, args) {
  68320. var me = this;
  68321. me.target = target;
  68322. me.id = id;
  68323. me.type = type;
  68324. me.args = args;
  68325. },
  68326. append: function() {
  68327. this.target.appendShape(this);
  68328. return this;
  68329. }
  68330. });
  68331. Ext.define('Ext.sparkline.CanvasBase', {
  68332. shapeCount: 0,
  68333. _pxregex: /(\d+)(px)?\s*$/i,
  68334. constructor: function(ownerSparkLine) {
  68335. this.owner = ownerSparkLine;
  68336. this.rtl = this.owner.getInherited().rtl;
  68337. },
  68338. setWidth: function(width) {
  68339. this.pixelWidth = width;
  68340. },
  68341. setHeight: function(height) {
  68342. this.pixelHeight = height;
  68343. },
  68344. drawLine: function(x1, y1, x2, y2, lineColor, lineWidth) {
  68345. return this.drawShape([
  68346. [
  68347. x1,
  68348. y1
  68349. ],
  68350. [
  68351. x2,
  68352. y2
  68353. ]
  68354. ], lineColor, lineWidth);
  68355. },
  68356. drawShape: function(path, lineColor, fillColor, lineWidth) {
  68357. return this._genShape('Shape', [
  68358. path,
  68359. lineColor,
  68360. fillColor,
  68361. lineWidth
  68362. ]);
  68363. },
  68364. drawCircle: function(x, y, radius, lineColor, fillColor, lineWidth) {
  68365. return this._genShape('Circle', [
  68366. x,
  68367. y,
  68368. radius,
  68369. lineColor,
  68370. fillColor,
  68371. lineWidth
  68372. ]);
  68373. },
  68374. drawPieSlice: function(x, y, radius, startAngle, endAngle, lineColor, fillColor) {
  68375. return this._genShape('PieSlice', [
  68376. x,
  68377. y,
  68378. radius,
  68379. startAngle,
  68380. endAngle,
  68381. lineColor,
  68382. fillColor
  68383. ]);
  68384. },
  68385. drawRect: function(x, y, width, height, lineColor, fillColor) {
  68386. return this._genShape('Rect', [
  68387. x,
  68388. y,
  68389. width,
  68390. height,
  68391. lineColor,
  68392. fillColor
  68393. ]);
  68394. },
  68395. getElement: function() {
  68396. return this.el;
  68397. },
  68398. getLastShapeId: function() {
  68399. return this.lastShapeId;
  68400. },
  68401. reset: function() {
  68402. Ext.raise('reset not implemented');
  68403. },
  68404. _genShape: function(shapetype, shapeargs) {
  68405. var id = this.shapeCount++;
  68406. shapeargs.unshift(id);
  68407. return new Ext.sparkline.Shape(this, id, shapetype, shapeargs);
  68408. },
  68409. appendShape: function(shape) {
  68410. Ext.raise('appendShape not implemented');
  68411. },
  68412. replaceWithShape: function(shapeid, shape) {
  68413. Ext.raise('replaceWithShape not implemented');
  68414. },
  68415. insertAfterShape: function(shapeid, shape) {
  68416. Ext.raise('insertAfterShape not implemented');
  68417. },
  68418. removeShapeId: function(shapeid) {
  68419. Ext.raise('removeShapeId not implemented');
  68420. },
  68421. getShapeAt: function(x, y) {
  68422. Ext.raise('getShapeAt not implemented');
  68423. },
  68424. render: function() {
  68425. Ext.raise('render not implemented');
  68426. }
  68427. });
  68428. Ext.define('Ext.sparkline.CanvasCanvas', {
  68429. extend: Ext.sparkline.CanvasBase,
  68430. statics: {
  68431. contextOverrides: (function() {
  68432. var ratio = window.devicePixelRatio || 1;
  68433. return {
  68434. moveTo: function(x, y) {
  68435. if (this.rtl) {
  68436. x = this.canvas.width - x - 1;
  68437. }
  68438. this.$moveTo(x * ratio, y * ratio);
  68439. },
  68440. lineTo: function(x, y) {
  68441. if (this.rtl) {
  68442. x = this.canvas.width - x - 1;
  68443. }
  68444. this.$lineTo(x * ratio, y * ratio);
  68445. },
  68446. arc: function(x, y, radius, startAngle, endAngle, counterclockwise) {
  68447. if (this.rtl) {
  68448. x = this.canvas.width - x - 1;
  68449. }
  68450. this.$arc(x * ratio, y * ratio, radius * ratio, startAngle, endAngle, counterclockwise);
  68451. },
  68452. clearRect: function(x, y, width, height) {
  68453. if (this.rtl) {
  68454. x = this.canvas.width - x - width;
  68455. }
  68456. this.$clearRect(x * ratio, y * ratio, width * ratio, height * ratio);
  68457. }
  68458. };
  68459. })()
  68460. },
  68461. setWidth: function(width) {
  68462. this.callParent(arguments);
  68463. this.owner.element.dom.width = width * (window.devicePixelRatio || 1);
  68464. },
  68465. setHeight: function(height) {
  68466. this.callParent(arguments);
  68467. this.owner.element.dom.height = height * (window.devicePixelRatio || 1);
  68468. },
  68469. onOwnerUpdate: function() {
  68470. var me = this;
  68471. me.el = me.owner.element;
  68472. me.interact = !me.owner.initialConfig.disableInteraction;
  68473. me.shapes = {};
  68474. me.shapeseq = [];
  68475. me.currentTargetShapeId = me.lastShapeId = null;
  68476. },
  68477. _getContext: function(lineColor, fillColor, lineWidth) {
  68478. var context = this.context,
  68479. overrides, name;
  68480. if (!context) {
  68481. this.context = context = this.el.dom.getContext('2d');
  68482. overrides = Ext.sparkline.CanvasCanvas.contextOverrides;
  68483. for (name in overrides) {
  68484. context['$' + name] = context[name];
  68485. }
  68486. Ext.apply(context, overrides);
  68487. context.rtl = this.rtl;
  68488. }
  68489. if (lineColor != null) {
  68490. context.strokeStyle = lineColor;
  68491. }
  68492. context.lineWidth = lineWidth || 1;
  68493. if (fillColor != null) {
  68494. context.fillStyle = fillColor;
  68495. }
  68496. return context;
  68497. },
  68498. reset: function() {
  68499. var context = this._getContext();
  68500. context.clearRect(0, 0, this.pixelWidth, this.pixelHeight);
  68501. this.shapes = {};
  68502. this.shapeseq = [];
  68503. this.currentTargetShapeId = this.lastShapeId = null;
  68504. },
  68505. _drawShape: function(shapeid, path, lineColor, fillColor, lineWidth) {
  68506. var context = this._getContext(lineColor, fillColor, lineWidth),
  68507. xIncr = this.rtl ? -0.5 : 0.5,
  68508. i, plen;
  68509. context.beginPath();
  68510. context.moveTo(path[0][0] + xIncr, path[0][1] + 0.5);
  68511. for (i = 1 , plen = path.length; i < plen; i++) {
  68512. context.lineTo(path[i][0] + xIncr, path[i][1] + 0.5);
  68513. }
  68514. if (lineColor != null) {
  68515. context.stroke();
  68516. }
  68517. if (fillColor != null) {
  68518. context.fill();
  68519. }
  68520. if (this.targetX != null && this.targetY != null && context.isPointInPath(this.targetX, this.targetY)) {
  68521. this.currentTargetShapeId = shapeid;
  68522. }
  68523. },
  68524. _drawCircle: function(shapeid, x, y, radius, lineColor, fillColor, lineWidth) {
  68525. var context = this._getContext(lineColor, fillColor, lineWidth);
  68526. context.beginPath();
  68527. context.arc(x, y, radius, 0, 2 * Math.PI, false);
  68528. if (this.targetX != null && this.targetY != null && context.isPointInPath(this.targetX, this.targetY)) {
  68529. this.currentTargetShapeId = shapeid;
  68530. }
  68531. if (lineColor != null) {
  68532. context.stroke();
  68533. }
  68534. if (fillColor != null) {
  68535. context.fill();
  68536. }
  68537. },
  68538. _drawPieSlice: function(shapeid, x, y, radius, startAngle, endAngle, lineColor, fillColor) {
  68539. var context = this._getContext(lineColor, fillColor);
  68540. context.beginPath();
  68541. context.moveTo(x, y);
  68542. context.arc(x, y, radius, startAngle, endAngle, false);
  68543. context.lineTo(x, y);
  68544. context.closePath();
  68545. if (lineColor != null) {
  68546. context.stroke();
  68547. }
  68548. if (fillColor) {
  68549. context.fill();
  68550. }
  68551. if (this.targetX !== undefined && this.targetY !== undefined && context.isPointInPath(this.targetX, this.targetY)) {
  68552. this.currentTargetShapeId = shapeid;
  68553. }
  68554. },
  68555. _drawRect: function(shapeid, x, y, width, height, lineColor, fillColor) {
  68556. return this._drawShape(shapeid, [
  68557. [
  68558. x,
  68559. y
  68560. ],
  68561. [
  68562. x + width,
  68563. y
  68564. ],
  68565. [
  68566. x + width,
  68567. y + height
  68568. ],
  68569. [
  68570. x,
  68571. y + height
  68572. ],
  68573. [
  68574. x,
  68575. y
  68576. ]
  68577. ], lineColor, fillColor);
  68578. },
  68579. appendShape: function(shape) {
  68580. this.shapes[shape.id] = shape;
  68581. this.shapeseq.push(shape.id);
  68582. this.lastShapeId = shape.id;
  68583. return shape.id;
  68584. },
  68585. replaceWithShape: function(shapeid, shape) {
  68586. var shapeseq = this.shapeseq,
  68587. i;
  68588. this.shapes[shape.id] = shape;
  68589. for (i = shapeseq.length; i--; ) {
  68590. if (shapeseq[i] === shapeid) {
  68591. shapeseq[i] = shape.id;
  68592. }
  68593. }
  68594. delete this.shapes[shapeid];
  68595. },
  68596. replaceWithShapes: function(shapeids, shapes) {
  68597. var shapeseq = this.shapeseq,
  68598. shapemap = {},
  68599. sid, i, first;
  68600. for (i = shapeids.length; i--; ) {
  68601. shapemap[shapeids[i]] = true;
  68602. }
  68603. for (i = shapeseq.length; i--; ) {
  68604. sid = shapeseq[i];
  68605. if (shapemap[sid]) {
  68606. shapeseq.splice(i, 1);
  68607. delete this.shapes[sid];
  68608. first = i;
  68609. }
  68610. }
  68611. for (i = shapes.length; i--; ) {
  68612. shapeseq.splice(first, 0, shapes[i].id);
  68613. this.shapes[shapes[i].id] = shapes[i];
  68614. }
  68615. },
  68616. insertAfterShape: function(shapeid, shape) {
  68617. var shapeseq = this.shapeseq,
  68618. i;
  68619. for (i = shapeseq.length; i--; ) {
  68620. if (shapeseq[i] === shapeid) {
  68621. shapeseq.splice(i + 1, 0, shape.id);
  68622. this.shapes[shape.id] = shape;
  68623. return;
  68624. }
  68625. }
  68626. },
  68627. removeShapeId: function(shapeid) {
  68628. var shapeseq = this.shapeseq,
  68629. i;
  68630. for (i = shapeseq.length; i--; ) {
  68631. if (shapeseq[i] === shapeid) {
  68632. shapeseq.splice(i, 1);
  68633. break;
  68634. }
  68635. }
  68636. delete this.shapes[shapeid];
  68637. },
  68638. getShapeAt: function(x, y) {
  68639. if (this.rtl) {
  68640. x = this.el.dom.width - x - 1;
  68641. }
  68642. this.targetX = x;
  68643. this.targetY = y;
  68644. this.render();
  68645. return this.currentTargetShapeId;
  68646. },
  68647. render: function() {
  68648. var shapeseq = this.shapeseq,
  68649. shapes = this.shapes,
  68650. shapeCount = shapeseq.length,
  68651. context = this._getContext(),
  68652. shapeid, shape, i;
  68653. context.clearRect(0, 0, this.pixelWidth, this.pixelHeight);
  68654. for (i = 0; i < shapeCount; i++) {
  68655. shapeid = shapeseq[i];
  68656. shape = shapes[shapeid];
  68657. this['_draw' + shape.type].apply(this, shape.args);
  68658. }
  68659. if (!this.interact) {
  68660. this.shapes = {};
  68661. this.shapeseq = [];
  68662. }
  68663. }
  68664. });
  68665. Ext.define('Ext.sparkline.VmlCanvas', {
  68666. extend: Ext.sparkline.CanvasBase,
  68667. setWidth: function(width) {
  68668. var me = this;
  68669. me.callParent(arguments);
  68670. me.owner.groupEl.dom.coordsize = me.width + ' ' + (me.height || 0);
  68671. me.owner.groupEl.dom.style.width = width + 'px';
  68672. },
  68673. setHeight: function(height) {
  68674. var me = this;
  68675. me.callParent(arguments);
  68676. me.owner.groupEl.dom.coordsize = (me.width || 0) + ' ' + me.height;
  68677. me.owner.groupEl.dom.style.height = height + 'px';
  68678. },
  68679. onOwnerUpdate: function() {
  68680. var me = this;
  68681. me.group = me.owner.groupEl;
  68682. me.el = me.owner.element;
  68683. me.prerender = [];
  68684. },
  68685. _drawShape: function(shapeid, path, lineColor, fillColor, lineWidth) {
  68686. var vpath = [],
  68687. initial, stroke, fill, closed, plen, i;
  68688. for (i = 0 , plen = path.length; i < plen; i++) {
  68689. vpath[i] = (path[i][0]) + ',' + (path[i][1]);
  68690. }
  68691. initial = vpath.splice(0, 1);
  68692. lineWidth = lineWidth == null ? 1 : lineWidth;
  68693. stroke = lineColor == null ? ' stroked="false" ' : ' strokeWeight="' + lineWidth + 'px" strokeColor="' + lineColor + '" ';
  68694. fill = fillColor == null ? ' filled="false"' : ' fillColor="' + fillColor + '" filled="true" ';
  68695. closed = vpath[0] === vpath[vpath.length - 1] ? 'x ' : '';
  68696. return [
  68697. '<svml:shape coordorigin="0 0" coordsize="',
  68698. this.pixelWidth,
  68699. ' ',
  68700. this.pixelHeight,
  68701. '" id="jqsshape',
  68702. shapeid,
  68703. '" ',
  68704. stroke,
  68705. fill,
  68706. ' style="position:absolute;height:',
  68707. this.pixelHeight,
  68708. 'px;width:',
  68709. this.pixelWidth,
  68710. 'px" ',
  68711. ' path="m ',
  68712. initial,
  68713. ' l ',
  68714. vpath.join(', '),
  68715. ' ',
  68716. closed,
  68717. 'e"></svml:shape>'
  68718. ].join('');
  68719. },
  68720. _drawCircle: function(shapeid, x, y, radius, lineColor, fillColor, lineWidth) {
  68721. var circumference = radius * 2,
  68722. stroke, fill;
  68723. x -= radius;
  68724. y -= radius;
  68725. stroke = lineColor == null ? ' stroked="false" ' : ' strokeWeight="' + lineWidth + 'px" strokeColor="' + lineColor + '" ';
  68726. fill = fillColor == null ? ' filled="false"' : ' fillColor="' + fillColor + '" filled="true" ';
  68727. return [
  68728. '<svml:oval id="jqsshape',
  68729. shapeid,
  68730. '" ',
  68731. stroke,
  68732. fill,
  68733. ' style="position:absolute;top:',
  68734. y,
  68735. 'px; left:',
  68736. x,
  68737. 'px;width:',
  68738. circumference,
  68739. 'px;height:',
  68740. circumference,
  68741. 'px"></svml:oval>'
  68742. ].join('');
  68743. },
  68744. _drawPieSlice: function(shapeid, x, y, radius, startAngle, endAngle, lineColor, fillColor) {
  68745. var vpath,
  68746. width = this.pixelWidth,
  68747. height = this.pixelHeight,
  68748. startx, starty, endx, endy,
  68749. stroke = lineColor == null ? ' stroked="false" ' : ' strokeWeight="1px" strokeColor="' + lineColor + '" ',
  68750. fill = fillColor == null ? ' filled="false"' : ' fillColor="' + fillColor + '" filled="true" ';
  68751. if (startAngle === endAngle) {
  68752. return '';
  68753. }
  68754. if ((endAngle - startAngle) === (2 * Math.PI)) {
  68755. startAngle = 0;
  68756. endAngle = (2 * Math.PI);
  68757. }
  68758. startx = x + Math.round(Math.cos(startAngle) * radius);
  68759. starty = y + Math.round(Math.sin(startAngle) * radius);
  68760. endx = x + Math.round(Math.cos(endAngle) * radius);
  68761. endy = y + Math.round(Math.sin(endAngle) * radius);
  68762. if (startx === endx && starty === endy) {
  68763. if ((endAngle - startAngle) < Math.PI) {
  68764. return '';
  68765. }
  68766. startx = endx = x + radius;
  68767. starty = endy = y;
  68768. }
  68769. if (startx === endx && starty === endy && (endAngle - startAngle) < Math.PI) {
  68770. return '';
  68771. }
  68772. vpath = [
  68773. x - radius,
  68774. y - radius,
  68775. x + radius,
  68776. y + radius,
  68777. startx,
  68778. starty,
  68779. endx,
  68780. endy
  68781. ];
  68782. return [
  68783. '<svml:shape coordorigin="0 0" coordsize="',
  68784. width,
  68785. ' ',
  68786. height,
  68787. '" id="jqsshape',
  68788. shapeid,
  68789. '" ',
  68790. stroke,
  68791. fill,
  68792. ' style="position:absolute;height:',
  68793. height,
  68794. 'px;width:',
  68795. width,
  68796. 'px" path="m ',
  68797. x,
  68798. ',',
  68799. y,
  68800. ' wa ',
  68801. vpath.join(', '),
  68802. ' x e"></svml:shape>'
  68803. ].join('');
  68804. },
  68805. _drawRect: function(shapeid, x, y, width, height, lineColor, fillColor) {
  68806. return this._drawShape(shapeid, [
  68807. [
  68808. x,
  68809. y
  68810. ],
  68811. [
  68812. x,
  68813. y + height
  68814. ],
  68815. [
  68816. x + width,
  68817. y + height
  68818. ],
  68819. [
  68820. x + width,
  68821. y
  68822. ],
  68823. [
  68824. x,
  68825. y
  68826. ]
  68827. ], lineColor, fillColor);
  68828. },
  68829. reset: function() {
  68830. Ext.fly(this.group).empty();
  68831. },
  68832. appendShape: function(shape) {
  68833. this.prerender.push(this['_draw' + shape.type].apply(this, shape.args));
  68834. this.lastShapeId = shape.id;
  68835. return shape.id;
  68836. },
  68837. replaceWithShape: function(shapeid, shape) {
  68838. var existing = this.el.getById('jqsshape' + shapeid, true),
  68839. vel = this['_draw' + shape.type].apply(this, shape.args);
  68840. existing.outerHTML = vel;
  68841. },
  68842. replaceWithShapes: function(shapeids, shapes) {
  68843. var existing = this.el.getById('jqsshape' + shapeids[0], true),
  68844. replace = '',
  68845. slen = shapes.length,
  68846. i;
  68847. for (i = 0; i < slen; i++) {
  68848. replace += this['_draw' + shapes[i].type].apply(this, shapes[i].args);
  68849. }
  68850. existing.outerHTML = replace;
  68851. for (i = 1; i < shapeids.length; i++) {
  68852. this.el.getById('jqsshape' + shapeids[i]).destroy();
  68853. }
  68854. },
  68855. insertAfterShape: function(shapeid, shape) {
  68856. var existing = this.el.getById('jqsshape' + shapeid, true),
  68857. vel = this['_draw' + shape.type].apply(this, shape.args);
  68858. existing.insertAdjacentHTML('afterEnd', vel);
  68859. },
  68860. removeShapeId: function(shapeid) {
  68861. var existing = this.el.getById('jqsshape' + shapeid, true);
  68862. this.group.removeChild(existing);
  68863. },
  68864. getShapeAt: function(x, y) {
  68865. var shapeid = this.el.id.substr(8);
  68866. return shapeid;
  68867. },
  68868. render: function() {
  68869. this.group.dom.innerHTML = this.prerender.join('');
  68870. }
  68871. }, function() {
  68872. Ext.onInternalReady(function() {
  68873. var doc = document;
  68874. if (doc.namespaces && !doc.namespaces.svml) {
  68875. doc.namespaces.add("svml", "urn:schemas-microsoft-com:vml", '#default#VML');
  68876. }
  68877. });
  68878. });
  68879. Ext.define('Ext.util.Color', {
  68880. alternateClassName: 'Ext.draw.Color',
  68881. statics: {
  68882. colorToHexRe: /(.*?)rgb\((\d+),\s*(\d+),\s*(\d+)\)/,
  68883. rgbToHexRe: /\s*rgb\((\d+),\s*(\d+),\s*(\d+)\)/,
  68884. rgbaToHexRe: /\s*rgba\((\d+),\s*(\d+),\s*(\d+),\s*([\.\d]+)\)/,
  68885. 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*/,
  68886. NONE: 'none',
  68887. RGBA_NONE: 'rgba(0, 0, 0, 0)'
  68888. },
  68889. isColor: true,
  68890. lightnessFactor: 0.2,
  68891. constructor: function(red, green, blue, alpha) {
  68892. this.setRGB(red, green, blue, alpha);
  68893. },
  68894. clone: function() {
  68895. var me = this;
  68896. return new this.self(me.r, me.g, me.b, me.a);
  68897. },
  68898. setRGB: function(red, green, blue, alpha) {
  68899. var me = this;
  68900. me.r = Math.min(255, Math.max(0, red));
  68901. me.g = Math.min(255, Math.max(0, green));
  68902. me.b = Math.min(255, Math.max(0, blue));
  68903. if (alpha === undefined) {
  68904. me.a = 1;
  68905. } else {
  68906. me.a = Math.min(1, Math.max(0, alpha));
  68907. }
  68908. },
  68909. getBrightness: function() {
  68910. var r = this.r / 255 * 100,
  68911. g = this.g / 255 * 100,
  68912. b = this.b / 255 * 100;
  68913. return ((r * 299) + (g * 587) + (b * 114)) / 1000;
  68914. },
  68915. getGrayscale: function() {
  68916. return this.r * 0.3 + this.g * 0.59 + this.b * 0.11;
  68917. },
  68918. getHSL: function() {
  68919. var me = this,
  68920. r = me.r / 255,
  68921. g = me.g / 255,
  68922. b = me.b / 255,
  68923. max = Math.max(r, g, b),
  68924. min = Math.min(r, g, b),
  68925. delta = max - min,
  68926. h,
  68927. s = 0,
  68928. l = 0.5 * (max + min);
  68929. if (min !== max) {
  68930. s = (l <= 0.5) ? delta / (max + min) : delta / (2 - max - min);
  68931. if (r === max) {
  68932. h = 60 * (g - b) / delta;
  68933. } else if (g === max) {
  68934. h = 120 + 60 * (b - r) / delta;
  68935. } else {
  68936. h = 240 + 60 * (r - g) / delta;
  68937. }
  68938. if (h < 0) {
  68939. h += 360;
  68940. }
  68941. if (h >= 360) {
  68942. h -= 360;
  68943. }
  68944. }
  68945. return [
  68946. h,
  68947. s,
  68948. l
  68949. ];
  68950. },
  68951. getHSV: function() {
  68952. var me = this,
  68953. r = me.r / 255,
  68954. g = me.g / 255,
  68955. b = me.b / 255,
  68956. max = Math.max(r, g, b),
  68957. min = Math.min(r, g, b),
  68958. C = max - min,
  68959. h,
  68960. s = 0,
  68961. v = max;
  68962. if (min != max) {
  68963. s = v ? C / v : 0;
  68964. if (r === max) {
  68965. h = 60 * (g - b) / C;
  68966. } else if (g === max) {
  68967. h = 60 * (b - r) / C + 120;
  68968. } else {
  68969. h = 60 * (r - g) / C + 240;
  68970. }
  68971. if (h < 0) {
  68972. h += 360;
  68973. }
  68974. if (h >= 360) {
  68975. h -= 360;
  68976. }
  68977. }
  68978. return [
  68979. h,
  68980. s,
  68981. v
  68982. ];
  68983. },
  68984. setHSL: function(h, s, l) {
  68985. var me = this,
  68986. abs = Math.abs,
  68987. c, x, m;
  68988. h = (h % 360 + 360) % 360;
  68989. s = s > 1 ? 1 : s < 0 ? 0 : s;
  68990. l = l > 1 ? 1 : l < 0 ? 0 : l;
  68991. if (s === 0 || h === null) {
  68992. l *= 255;
  68993. me.setRGB(l, l, l);
  68994. } else {
  68995. h /= 60;
  68996. c = s * (1 - abs(2 * l - 1));
  68997. x = c * (1 - abs(h % 2 - 1));
  68998. m = l - c / 2;
  68999. m *= 255;
  69000. c *= 255;
  69001. x *= 255;
  69002. switch (Math.floor(h)) {
  69003. case 0:
  69004. me.setRGB(c + m, x + m, m);
  69005. break;
  69006. case 1:
  69007. me.setRGB(x + m, c + m, m);
  69008. break;
  69009. case 2:
  69010. me.setRGB(m, c + m, x + m);
  69011. break;
  69012. case 3:
  69013. me.setRGB(m, x + m, c + m);
  69014. break;
  69015. case 4:
  69016. me.setRGB(x + m, m, c + m);
  69017. break;
  69018. case 5:
  69019. me.setRGB(c + m, m, x + m);
  69020. break;
  69021. }
  69022. }
  69023. return me;
  69024. },
  69025. setHSV: function(h, s, v) {
  69026. var me = this,
  69027. c, x, m;
  69028. h = (h % 360 + 360) % 360;
  69029. s = s > 1 ? 1 : s < 0 ? 0 : s;
  69030. v = v > 1 ? 1 : v < 0 ? 0 : v;
  69031. if (s === 0 || h === null) {
  69032. v *= 255;
  69033. me.setRGB(v, v, v);
  69034. } else {
  69035. h /= 60;
  69036. c = v * s;
  69037. x = c * (1 - Math.abs(h % 2 - 1));
  69038. m = v - c;
  69039. m *= 255;
  69040. c *= 255;
  69041. x *= 255;
  69042. switch (Math.floor(h)) {
  69043. case 0:
  69044. me.setRGB(c + m, x + m, m);
  69045. break;
  69046. case 1:
  69047. me.setRGB(x + m, c + m, m);
  69048. break;
  69049. case 2:
  69050. me.setRGB(m, c + m, x + m);
  69051. break;
  69052. case 3:
  69053. me.setRGB(m, x + m, c + m);
  69054. break;
  69055. case 4:
  69056. me.setRGB(x + m, m, c + m);
  69057. break;
  69058. case 5:
  69059. me.setRGB(c + m, m, x + m);
  69060. break;
  69061. }
  69062. }
  69063. return me;
  69064. },
  69065. createLighter: function(factor) {
  69066. var color = this.clone();
  69067. color.lighten(factor);
  69068. return color;
  69069. },
  69070. lighten: function(factor) {
  69071. if (!factor && factor !== 0) {
  69072. factor = this.lightnessFactor;
  69073. }
  69074. var hsl = this.getHSL();
  69075. this.setHSL(hsl[0], hsl[1], Ext.Number.constrain(hsl[2] + factor, 0, 1));
  69076. },
  69077. createDarker: function(factor) {
  69078. var color = this.clone();
  69079. color.darken(factor);
  69080. return color;
  69081. },
  69082. darken: function(factor) {
  69083. if (!factor && factor !== 0) {
  69084. factor = this.lightnessFactor;
  69085. }
  69086. return this.lighten(-factor);
  69087. },
  69088. toString: function() {
  69089. var me = this,
  69090. round = Math.round;
  69091. if (me.a === 1) {
  69092. var r = round(me.r).toString(16),
  69093. g = round(me.g).toString(16),
  69094. b = round(me.b).toString(16);
  69095. r = (r.length === 1) ? '0' + r : r;
  69096. g = (g.length === 1) ? '0' + g : g;
  69097. b = (b.length === 1) ? '0' + b : b;
  69098. return [
  69099. '#',
  69100. r,
  69101. g,
  69102. b
  69103. ].join('');
  69104. } else {
  69105. return 'rgba(' + [
  69106. round(me.r),
  69107. round(me.g),
  69108. round(me.b),
  69109. me.a === 0 ? 0 : me.a.toFixed(15)
  69110. ].join(', ') + ')';
  69111. }
  69112. },
  69113. toHex: function(color) {
  69114. var r = this.r,
  69115. g = this.g,
  69116. b = this.b,
  69117. rgb = b | (g << 8) | (r << 16);
  69118. return '#' + ('000000' + rgb.toString(16)).slice(-6);
  69119. },
  69120. setFromString: function(str) {
  69121. var values, r, g, b,
  69122. a = 1,
  69123. parse = parseInt;
  69124. if (str === Ext.util.Color.NONE) {
  69125. this.r = this.g = this.b = this.a = 0;
  69126. return this;
  69127. }
  69128. if ((str.length === 4 || str.length === 7) && str.substr(0, 1) === '#') {
  69129. values = str.match(Ext.util.Color.hexRe);
  69130. if (values) {
  69131. r = parse(values[1], 16) >> 0;
  69132. g = parse(values[2], 16) >> 0;
  69133. b = parse(values[3], 16) >> 0;
  69134. if (str.length === 4) {
  69135. r += (r * 16);
  69136. g += (g * 16);
  69137. b += (b * 16);
  69138. }
  69139. }
  69140. } else if ((values = str.match(Ext.util.Color.rgbToHexRe))) {
  69141. r = +values[1];
  69142. g = +values[2];
  69143. b = +values[3];
  69144. } else if ((values = str.match(Ext.util.Color.rgbaToHexRe))) {
  69145. r = +values[1];
  69146. g = +values[2];
  69147. b = +values[3];
  69148. a = +values[4];
  69149. } else {
  69150. if (Ext.util.Color.ColorList.hasOwnProperty(str.toLowerCase())) {
  69151. return this.setFromString(Ext.util.Color.ColorList[str.toLowerCase()]);
  69152. }
  69153. }
  69154. if (typeof r === 'undefined') {
  69155. return this;
  69156. }
  69157. this.r = r;
  69158. this.g = g;
  69159. this.b = b;
  69160. this.a = a;
  69161. return this;
  69162. }
  69163. }, function() {
  69164. var flyColor = new this();
  69165. this.addStatics({
  69166. fly: function(red, green, blue, alpha) {
  69167. switch (arguments.length) {
  69168. case 1:
  69169. flyColor.setFromString(red);
  69170. break;
  69171. case 3:
  69172. case 4:
  69173. flyColor.setRGB(red, green, blue, alpha);
  69174. break;
  69175. default:
  69176. return null;
  69177. }
  69178. return flyColor;
  69179. },
  69180. ColorList: {
  69181. aliceblue: '#f0f8ff',
  69182. antiquewhite: '#faebd7',
  69183. aqua: '#00ffff',
  69184. aquamarine: '#7fffd4',
  69185. azure: '#f0ffff',
  69186. beige: '#f5f5dc',
  69187. bisque: '#ffe4c4',
  69188. black: '#000000',
  69189. blanchedalmond: '#ffebcd',
  69190. blue: '#0000ff',
  69191. blueviolet: '#8a2be2',
  69192. brown: '#a52a2a',
  69193. burlywood: '#deb887',
  69194. cadetblue: '#5f9ea0',
  69195. chartreuse: '#7fff00',
  69196. chocolate: '#d2691e',
  69197. coral: '#ff7f50',
  69198. cornflowerblue: '#6495ed',
  69199. cornsilk: '#fff8dc',
  69200. crimson: '#dc143c',
  69201. cyan: '#00ffff',
  69202. darkblue: '#00008b',
  69203. darkcyan: '#008b8b',
  69204. darkgoldenrod: '#b8860b',
  69205. darkgray: '#a9a9a9',
  69206. darkgreen: '#006400',
  69207. darkkhaki: '#bdb76b',
  69208. darkmagenta: '#8b008b',
  69209. darkolivegreen: '#556b2f',
  69210. darkorange: '#ff8c00',
  69211. darkorchid: '#9932cc',
  69212. darkred: '#8b0000',
  69213. darksalmon: '#e9967a',
  69214. darkseagreen: '#8fbc8f',
  69215. darkslateblue: '#483d8b',
  69216. darkslategray: '#2f4f4f',
  69217. darkturquoise: '#00ced1',
  69218. darkviolet: '#9400d3',
  69219. deeppink: '#ff1493',
  69220. deepskyblue: '#00bfff',
  69221. dimgray: '#696969',
  69222. dodgerblue: '#1e90ff',
  69223. firebrick: '#b22222',
  69224. floralwhite: '#fffaf0',
  69225. forestgreen: '#228b22',
  69226. fuchsia: '#ff00ff',
  69227. gainsboro: '#dcdcdc',
  69228. ghostwhite: '#f8f8ff',
  69229. gold: '#ffd700',
  69230. goldenrod: '#daa520',
  69231. gray: '#808080',
  69232. green: '#008000',
  69233. greenyellow: '#adff2f',
  69234. honeydew: '#f0fff0',
  69235. hotpink: '#ff69b4',
  69236. indianred: '#cd5c5c',
  69237. indigo: '#4b0082',
  69238. ivory: '#fffff0',
  69239. khaki: '#f0e68c',
  69240. lavender: '#e6e6fa',
  69241. lavenderblush: '#fff0f5',
  69242. lawngreen: '#7cfc00',
  69243. lemonchiffon: '#fffacd',
  69244. lightblue: '#add8e6',
  69245. lightcoral: '#f08080',
  69246. lightcyan: '#e0ffff',
  69247. lightgoldenrodyellow: '#fafad2',
  69248. lightgray: '#d3d3d3',
  69249. lightgrey: '#d3d3d3',
  69250. lightgreen: '#90ee90',
  69251. lightpink: '#ffb6c1',
  69252. lightsalmon: '#ffa07a',
  69253. lightseagreen: '#20b2aa',
  69254. lightskyblue: '#87cefa',
  69255. lightslategray: '#778899',
  69256. lightsteelblue: '#b0c4de',
  69257. lightyellow: '#ffffe0',
  69258. lime: '#00ff00',
  69259. limegreen: '#32cd32',
  69260. linen: '#faf0e6',
  69261. magenta: '#ff00ff',
  69262. maroon: '#800000',
  69263. mediumaquamarine: '#66cdaa',
  69264. mediumblue: '#0000cd',
  69265. mediumorchid: '#ba55d3',
  69266. mediumpurple: '#9370d8',
  69267. mediumseagreen: '#3cb371',
  69268. mediumslateblue: '#7b68ee',
  69269. mediumspringgreen: '#00fa9a',
  69270. mediumturquoise: '#48d1cc',
  69271. mediumvioletred: '#c71585',
  69272. midnightblue: '#191970',
  69273. mintcream: '#f5fffa',
  69274. mistyrose: '#ffe4e1',
  69275. moccasin: '#ffe4b5',
  69276. navajowhite: '#ffdead',
  69277. navy: '#000080',
  69278. oldlace: '#fdf5e6',
  69279. olive: '#808000',
  69280. olivedrab: '#6b8e23',
  69281. orange: '#ffa500',
  69282. orangered: '#ff4500',
  69283. orchid: '#da70d6',
  69284. palegoldenrod: '#eee8aa',
  69285. palegreen: '#98fb98',
  69286. paleturquoise: '#afeeee',
  69287. palevioletred: '#d87093',
  69288. papayawhip: '#ffefd5',
  69289. peachpuff: '#ffdab9',
  69290. peru: '#cd853f',
  69291. pink: '#ffc0cb',
  69292. plum: '#dda0dd',
  69293. powderblue: '#b0e0e6',
  69294. purple: '#800080',
  69295. red: '#ff0000',
  69296. rosybrown: '#bc8f8f',
  69297. royalblue: '#4169e1',
  69298. saddlebrown: '#8b4513',
  69299. salmon: '#fa8072',
  69300. sandybrown: '#f4a460',
  69301. seagreen: '#2e8b57',
  69302. seashell: '#fff5ee',
  69303. sienna: '#a0522d',
  69304. silver: '#c0c0c0',
  69305. skyblue: '#87ceeb',
  69306. slateblue: '#6a5acd',
  69307. slategray: '#708090',
  69308. snow: '#fffafa',
  69309. springgreen: '#00ff7f',
  69310. steelblue: '#4682b4',
  69311. tan: '#d2b48c',
  69312. teal: '#008080',
  69313. thistle: '#d8bfd8',
  69314. tomato: '#ff6347',
  69315. turquoise: '#40e0d0',
  69316. violet: '#ee82ee',
  69317. wheat: '#f5deb3',
  69318. white: '#ffffff',
  69319. whitesmoke: '#f5f5f5',
  69320. yellow: '#ffff00',
  69321. yellowgreen: '#9acd32'
  69322. },
  69323. fromHSL: function(h, s, l) {
  69324. return (new this(0, 0, 0, 0)).setHSL(h, s, l);
  69325. },
  69326. fromHSV: function(h, s, v) {
  69327. return (new this(0, 0, 0, 0)).setHSL(h, s, v);
  69328. },
  69329. fromString: function(color) {
  69330. return (new this(0, 0, 0, 0)).setFromString(color);
  69331. },
  69332. create: function(arg) {
  69333. if (arg instanceof this) {
  69334. return arg;
  69335. } else if (Ext.isArray(arg)) {
  69336. return new Ext.util.Color(arg[0], arg[1], arg[2], arg[3]);
  69337. } else if (Ext.isString(arg)) {
  69338. return Ext.util.Color.fromString(arg);
  69339. } else if (arguments.length > 2) {
  69340. return new Ext.util.Color(arguments[0], arguments[1], arguments[2], arguments[3]);
  69341. } else {
  69342. return new Ext.util.Color(0, 0, 0, 0);
  69343. }
  69344. }
  69345. });
  69346. });
  69347. Ext.define('Ext.sparkline.Base', {
  69348. extend: Ext.Gadget,
  69349. xtype: 'sparkline',
  69350. cachedConfig: {
  69351. lineColor: '#157fcc',
  69352. defaultPixelsPerValue: 3,
  69353. tagValuesAttribute: 'values',
  69354. enableTagOptions: false,
  69355. enableHighlight: true,
  69356. highlightColor: null,
  69357. highlightLighten: 0.1,
  69358. tooltipSkipNull: true,
  69359. tooltipPrefix: '',
  69360. tooltipSuffix: '',
  69361. disableTooltips: false,
  69362. disableInteraction: false,
  69363. tipTpl: null
  69364. },
  69365. config: {
  69366. values: null
  69367. },
  69368. baseCls: Ext.baseCSSPrefix + 'sparkline',
  69369. element: {
  69370. tag: 'canvas',
  69371. reference: 'element',
  69372. style: {
  69373. display: 'inline-block',
  69374. verticalAlign: 'top'
  69375. },
  69376. listeners: {
  69377. mouseenter: 'onMouseEnter',
  69378. mouseleave: 'onMouseLeave',
  69379. mousemove: 'onMouseMove'
  69380. },
  69381. width: 0,
  69382. height: 0
  69383. },
  69384. defaultBindProperty: 'values',
  69385. redrawQueue: {},
  69386. inheritableStatics: {
  69387. onClassCreated: function(cls) {
  69388. var configUpdater = cls.prototype.updateConfigChange,
  69389. proto = cls.prototype,
  69390. configs = cls.getConfigurator().configs,
  69391. config, updaterName;
  69392. for (config in configs) {
  69393. if (config !== 'tipTpl') {
  69394. updaterName = Ext.Config.get(config).names.update;
  69395. if (proto[updaterName]) {
  69396. proto[updaterName] = Ext.Function.createSequence(proto[updaterName], configUpdater);
  69397. } else {
  69398. proto[updaterName] = configUpdater;
  69399. }
  69400. }
  69401. }
  69402. }
  69403. },
  69404. constructor: function(config) {
  69405. var me = this,
  69406. ns = Ext.sparkline;
  69407. me.canvas = Ext.supports.Canvas ? new ns.CanvasCanvas(me) : new ns.VmlCanvas(me);
  69408. me.callParent([
  69409. config
  69410. ]);
  69411. },
  69412. all: function(val, arr, ignoreNull) {
  69413. var i;
  69414. for (i = arr.length; i--; ) {
  69415. if (ignoreNull && arr[i] === null) {
  69416. continue;
  69417. }
  69418. if (arr[i] !== val) {
  69419. return false;
  69420. }
  69421. }
  69422. return true;
  69423. },
  69424. updateConfigChange: function(newValue) {
  69425. var me = this;
  69426. if (me.bufferRedraw || !me.height || !me.width) {
  69427. me.redrawQueue[me.getId()] = me;
  69428. if (!me.redrawTimer) {
  69429. Ext.sparkline.Base.prototype.redrawTimer = Ext.raf(me.processRedrawQueue);
  69430. }
  69431. } else {
  69432. me.redraw();
  69433. }
  69434. return newValue;
  69435. },
  69436. applyTipTpl: function(tipTpl) {
  69437. if (tipTpl && !tipTpl.isTemplate) {
  69438. tipTpl = new Ext.XTemplate(tipTpl);
  69439. }
  69440. return tipTpl;
  69441. },
  69442. normalizeValue: function(val) {
  69443. var nf;
  69444. switch (val) {
  69445. case 'undefined':
  69446. val = undefined;
  69447. break;
  69448. case 'null':
  69449. val = null;
  69450. break;
  69451. case 'true':
  69452. val = true;
  69453. break;
  69454. case 'false':
  69455. val = false;
  69456. break;
  69457. default:
  69458. nf = parseFloat(val);
  69459. if (val == nf) {
  69460. val = nf;
  69461. };
  69462. }
  69463. return val;
  69464. },
  69465. normalizeValues: function(vals) {
  69466. var i,
  69467. result = [];
  69468. for (i = vals.length; i--; ) {
  69469. result[i] = this.normalizeValue(vals[i]);
  69470. }
  69471. return result;
  69472. },
  69473. updateWidth: function(width, oldWidth) {
  69474. var me = this,
  69475. dom = me.element.dom,
  69476. measurer = me.measurer;
  69477. me.callParent([
  69478. width,
  69479. oldWidth
  69480. ]);
  69481. me.canvas.setWidth(width);
  69482. me.width = width;
  69483. if (me.height == null && measurer) {
  69484. me.setHeight(parseInt(measurer.getCachedStyle(dom.parentNode, 'line-height'), 10));
  69485. }
  69486. },
  69487. updateHeight: function(height, oldHeight) {
  69488. var me = this;
  69489. me.callParent([
  69490. height,
  69491. oldHeight
  69492. ]);
  69493. me.canvas.setHeight(height);
  69494. me.height = height;
  69495. },
  69496. setValues: function(values) {
  69497. var me = this,
  69498. oldValues = me.getValues();
  69499. values = values == null ? [] : Ext.Array.from(values);
  69500. me.values = values;
  69501. me.callParent([
  69502. values
  69503. ]);
  69504. if (values === oldValues) {
  69505. me.updateValues([
  69506. values,
  69507. oldValues
  69508. ]);
  69509. }
  69510. },
  69511. redraw: function() {
  69512. var me = this;
  69513. if (!me.destroyed) {
  69514. me.canvas.onOwnerUpdate();
  69515. me.canvas.reset();
  69516. if (me.getValues()) {
  69517. me.onUpdate();
  69518. me.renderGraph();
  69519. }
  69520. }
  69521. },
  69522. onUpdate: Ext.emptyFn,
  69523. renderGraph: function() {
  69524. var ret = true;
  69525. if (this.disabled) {
  69526. this.canvas.reset();
  69527. ret = false;
  69528. }
  69529. return ret;
  69530. },
  69531. onMouseEnter: function(e) {
  69532. this.onMouseMove(e);
  69533. },
  69534. onMouseMove: function(e) {
  69535. var me = this;
  69536. me.canvasRegion = me.canvasRegion || me.canvas.el.getRegion();
  69537. me.currentPageXY = e.getPoint();
  69538. me.redraw();
  69539. },
  69540. onMouseLeave: function() {
  69541. var me = this;
  69542. me.canvasRegion = me.currentPageXY = me.targetX = me.targetY = null;
  69543. me.redraw();
  69544. me.hideTip();
  69545. },
  69546. updateDisplay: function() {
  69547. var me = this,
  69548. values = me.getValues(),
  69549. tipHtml, region;
  69550. if (values && values.length && me.currentPageXY && me.canvasRegion.contains(me.currentPageXY)) {
  69551. region = me.getRegion(me.currentPageXY[0] - me.canvasRegion.left, (me.canvasRegion.bottom - 1) - me.currentPageXY[1]);
  69552. if (region != null && me.isValidRegion(region, values)) {
  69553. if (!me.disableHighlight) {
  69554. me.renderHighlight(region);
  69555. }
  69556. if (!me.getDisableTooltips()) {
  69557. tipHtml = me.getRegionTooltip(region);
  69558. }
  69559. }
  69560. if (me.hasListeners.sparklineregionchange) {
  69561. me.fireEvent('sparklineregionchange', me);
  69562. }
  69563. if (tipHtml) {
  69564. me.getSharedTooltip().setHtml(tipHtml);
  69565. me.showTip();
  69566. }
  69567. }
  69568. if (!tipHtml) {
  69569. me.hideTip();
  69570. }
  69571. },
  69572. getRegion: Ext.emptyFn,
  69573. getRegionTooltip: function(region) {
  69574. var me = this,
  69575. entries = [],
  69576. tipTpl = me.getTipTpl(),
  69577. fields, showFields, showFieldsKey, newFields, fv, formatter, fieldlen, i, j;
  69578. fields = me.getRegionFields(region);
  69579. formatter = me.tooltipFormatter;
  69580. if (formatter) {
  69581. return formatter(me, me, fields);
  69582. }
  69583. if (!tipTpl) {
  69584. return '';
  69585. }
  69586. if (!Ext.isArray(fields)) {
  69587. fields = [
  69588. fields
  69589. ];
  69590. }
  69591. showFields = me.tooltipFormatFieldlist;
  69592. showFieldsKey = me.tooltipFormatFieldlistKey;
  69593. if (showFields && showFieldsKey) {
  69594. newFields = [];
  69595. for (i = fields.length; i--; ) {
  69596. fv = fields[i][showFieldsKey];
  69597. if ((j = Ext.Array.indexOf(fv, showFields)) !== -1) {
  69598. newFields[j] = fields[i];
  69599. }
  69600. }
  69601. fields = newFields;
  69602. }
  69603. fieldlen = fields.length;
  69604. for (j = 0; j < fieldlen; j++) {
  69605. if (!fields[j].isNull || !me.getTooltipSkipNull()) {
  69606. Ext.apply(fields[j], {
  69607. prefix: me.getTooltipPrefix(),
  69608. suffix: me.getTooltipSuffix()
  69609. });
  69610. entries.push(tipTpl.apply(fields[j]));
  69611. }
  69612. }
  69613. if (entries.length) {
  69614. return entries.join('<br>');
  69615. }
  69616. return '';
  69617. },
  69618. getRegionFields: Ext.emptyFn,
  69619. calcHighlightColor: function(color) {
  69620. var me = this,
  69621. highlightColor = me.getHighlightColor(),
  69622. lighten = me.getHighlightLighten(),
  69623. o;
  69624. if (highlightColor) {
  69625. return highlightColor;
  69626. }
  69627. if (lighten) {
  69628. o = Ext.util.Color.fromString(color);
  69629. if (o) {
  69630. o.lighten(lighten);
  69631. color = o.toHex();
  69632. }
  69633. }
  69634. return color;
  69635. },
  69636. destroy: function() {
  69637. delete this.redrawQueue[this.getId()];
  69638. this.callParent();
  69639. },
  69640. privates: {
  69641. hideTip: Ext.privateFn,
  69642. isValidRegion: function(region, values) {
  69643. return region < values.length;
  69644. },
  69645. showTip: Ext.privateFn
  69646. }
  69647. }, function(SparklineBase) {
  69648. var proto = SparklineBase.prototype;
  69649. proto.getSharedTooltip = function() {
  69650. var me = this,
  69651. tooltip = me.tooltip;
  69652. if (!tooltip) {
  69653. proto.tooltip = tooltip = SparklineBase.constructTip();
  69654. }
  69655. return tooltip;
  69656. };
  69657. SparklineBase.onClassCreated(SparklineBase);
  69658. proto.processRedrawQueue = function() {
  69659. var redrawQueue = proto.redrawQueue,
  69660. id;
  69661. for (id in redrawQueue) {
  69662. redrawQueue[id].redraw();
  69663. }
  69664. proto.redrawQueue = {};
  69665. proto.redrawTimer = 0;
  69666. };
  69667. });
  69668. Ext.define('Ext.sparkline.BarBase', {
  69669. extend: Ext.sparkline.Base,
  69670. renderHighlight: function(region) {
  69671. this.renderRegion(region, true);
  69672. },
  69673. renderGraph: function() {
  69674. var me = this,
  69675. values = me.values,
  69676. canvas = me.canvas,
  69677. regionShapes = me.regionShapes || (me.regionShapes = {}),
  69678. shapes, ids, i, j;
  69679. if (!me.callParent()) {
  69680. return;
  69681. }
  69682. for (i = values.length; i--; ) {
  69683. shapes = me.renderRegion(i);
  69684. if (shapes) {
  69685. if (Ext.isArray(shapes)) {
  69686. ids = [];
  69687. for (j = shapes.length; j--; ) {
  69688. shapes[j].append();
  69689. ids.push(shapes[j].id);
  69690. }
  69691. regionShapes[i] = ids;
  69692. } else {
  69693. shapes.append();
  69694. regionShapes[i] = shapes.id;
  69695. }
  69696. } else
  69697. {
  69698. regionShapes[i] = null;
  69699. }
  69700. }
  69701. if (me.currentPageXY) {
  69702. me.currentRegion = null;
  69703. me.updateDisplay();
  69704. }
  69705. canvas.render();
  69706. }
  69707. });
  69708. Ext.define('Ext.sparkline.RangeMap', {
  69709. constructor: function(map) {
  69710. var key, range,
  69711. rangelist = [];
  69712. for (key in map) {
  69713. if (map.hasOwnProperty(key) && typeof key === 'string' && key.indexOf(':') > -1) {
  69714. range = key.split(':');
  69715. range[0] = range[0].length === 0 ? -Infinity : parseFloat(range[0]);
  69716. range[1] = range[1].length === 0 ? Infinity : parseFloat(range[1]);
  69717. range[2] = map[key];
  69718. rangelist.push(range);
  69719. }
  69720. }
  69721. this.map = map;
  69722. this.rangelist = rangelist || false;
  69723. },
  69724. get: function(value) {
  69725. var rangelist = this.rangelist,
  69726. i, range, result;
  69727. if ((result = this.map[value]) !== undefined) {
  69728. return result;
  69729. }
  69730. if (rangelist) {
  69731. for (i = rangelist.length; i--; ) {
  69732. range = rangelist[i];
  69733. if (range[0] <= value && range[1] >= value) {
  69734. return range[2];
  69735. }
  69736. }
  69737. }
  69738. }
  69739. });
  69740. Ext.define('Ext.sparkline.Bar', {
  69741. extend: Ext.sparkline.BarBase,
  69742. alias: 'widget.sparklinebar',
  69743. config: {
  69744. barColor: '#3366cc',
  69745. negBarColor: '#f44',
  69746. stackedBarColor: [
  69747. '#3366cc',
  69748. '#dc3912',
  69749. '#ff9900',
  69750. '#109618',
  69751. '#66aa00',
  69752. '#dd4477',
  69753. '#0099c6',
  69754. '#990099'
  69755. ],
  69756. zeroColor: null,
  69757. nullColor: null,
  69758. zeroAxis: true,
  69759. barWidth: 4,
  69760. barSpacing: 1,
  69761. chartRangeMin: null,
  69762. chartRangeMax: null,
  69763. chartRangeClip: false,
  69764. colorMap: null
  69765. },
  69766. tipTpl: '&#9679; {prefix}{value}{suffix}',
  69767. remove: function(vals, filter) {
  69768. var i, vl,
  69769. result = [];
  69770. for (i = 0 , vl = vals.length; i < vl; i++) {
  69771. if (vals[i] !== filter) {
  69772. result.push(vals[i]);
  69773. }
  69774. }
  69775. return result;
  69776. },
  69777. all: function(arr, val, ignoreNull) {
  69778. var i;
  69779. for (i = arr.length; i--; ) {
  69780. if (ignoreNull && arr[i] === null) {
  69781. continue;
  69782. }
  69783. if (arr[i] !== val) {
  69784. return false;
  69785. }
  69786. }
  69787. return true;
  69788. },
  69789. applyColorMap: function(colorMap) {
  69790. var me = this;
  69791. if (Ext.isArray(colorMap)) {
  69792. me.colorMapByIndex = colorMap;
  69793. me.colorMapByValue = null;
  69794. } else {
  69795. me.colorMapByIndex = null;
  69796. me.colorMapByValue = colorMap;
  69797. if (me.colorMapByValue && me.colorMapByValue.get == null) {
  69798. me.colorMapByValue = new Ext.sparkline.RangeMap(colorMap);
  69799. }
  69800. }
  69801. me.updateConfigChange();
  69802. return colorMap;
  69803. },
  69804. onUpdate: function() {
  69805. var me = this,
  69806. values = me.values,
  69807. barWidth = me.getBarWidth(),
  69808. barSpacing = me.getBarSpacing(),
  69809. chartRangeMin = me.getChartRangeMin(),
  69810. chartRangeMax = me.getChartRangeMax(),
  69811. chartRangeClip = me.getChartRangeClip(),
  69812. stackMin = Infinity,
  69813. stackMax = -Infinity,
  69814. isStackString, groupMin, groupMax, stackRanges, numValues, i, vlen, range,
  69815. zeroAxis = me.getZeroAxis(),
  69816. xAxisOffset, min, max, clipMin, clipMax, stacked, vlist, j, slen, svals, val, yoffset, yMaxCalc,
  69817. stackTotals = [],
  69818. stackRangesNeg = [];
  69819. for (i = 0 , vlen = values.length; i < vlen; i++) {
  69820. val = values[i];
  69821. isStackString = typeof (val) === 'string' && val.indexOf(':') > -1;
  69822. if (isStackString || Ext.isArray(val)) {
  69823. stacked = true;
  69824. if (isStackString) {
  69825. val = values[i] = me.normalizeValues(val.split(':'));
  69826. }
  69827. val = me.remove(val, null);
  69828. groupMin = Math.min.apply(Math, val);
  69829. groupMax = Math.max.apply(Math, val);
  69830. if (groupMin < stackMin) {
  69831. stackMin = groupMin;
  69832. }
  69833. if (groupMax > stackMax) {
  69834. stackMax = groupMax;
  69835. }
  69836. }
  69837. }
  69838. me.stacked = stacked;
  69839. me.regionShapes = {};
  69840. me.totalBarWidth = barWidth + barSpacing;
  69841. if (values.length) {
  69842. me.width = (values.length * barWidth) + ((values.length - 1) * barSpacing);
  69843. }
  69844. if (chartRangeClip) {
  69845. clipMin = chartRangeMin == null ? -Infinity : chartRangeMin;
  69846. clipMax = chartRangeMax == null ? Infinity : chartRangeMax;
  69847. }
  69848. numValues = [];
  69849. stackRanges = stacked ? [] : numValues;
  69850. for (i = 0 , vlen = values.length; i < vlen; i++) {
  69851. if (stacked) {
  69852. vlist = values[i];
  69853. values[i] = svals = [];
  69854. stackTotals[i] = 0;
  69855. stackRanges[i] = stackRangesNeg[i] = 0;
  69856. for (j = 0 , slen = vlist.length; j < slen; j++) {
  69857. val = svals[j] = chartRangeClip ? Ext.Number.constrain(vlist[j], clipMin, clipMax) : vlist[j];
  69858. if (val !== null) {
  69859. if (val > 0) {
  69860. stackTotals[i] += val;
  69861. }
  69862. if (stackMin < 0 && stackMax > 0) {
  69863. if (val < 0) {
  69864. stackRangesNeg[i] += Math.abs(val);
  69865. } else {
  69866. stackRanges[i] += val;
  69867. }
  69868. } else {
  69869. stackRanges[i] += Math.abs(val - (val < 0 ? stackMax : stackMin));
  69870. }
  69871. numValues.push(val);
  69872. }
  69873. }
  69874. } else {
  69875. val = chartRangeClip ? Ext.Number.constrain(values[i], clipMin, clipMax) : values[i];
  69876. val = values[i] = me.normalizeValue(val);
  69877. if (val !== null) {
  69878. numValues.push(val);
  69879. }
  69880. }
  69881. }
  69882. me.max = max = Math.max.apply(Math, numValues);
  69883. me.min = min = Math.min.apply(Math, numValues);
  69884. me.stackMax = stackMax = stacked ? Math.max.apply(Math, stackTotals) : max;
  69885. me.stackMin = stackMin = stacked ? Math.min.apply(Math, numValues) : min;
  69886. if (chartRangeMin != null && (chartRangeClip || chartRangeMin < min)) {
  69887. min = chartRangeMin;
  69888. }
  69889. if (chartRangeMax != null && (chartRangeClip || chartRangeMax > max)) {
  69890. max = chartRangeMax;
  69891. }
  69892. if (min <= 0 && max >= 0 && zeroAxis) {
  69893. xAxisOffset = 0;
  69894. } else if (!zeroAxis) {
  69895. xAxisOffset = min;
  69896. } else if (min > 0) {
  69897. xAxisOffset = min;
  69898. } else {
  69899. xAxisOffset = max;
  69900. }
  69901. me.xAxisOffset = xAxisOffset;
  69902. range = stacked ? (Math.max.apply(Math, stackRanges) + Math.max.apply(Math, stackRangesNeg)) : max - min;
  69903. me.canvasHeightEf = (zeroAxis && min < 0) ? me.getHeight() - 2 : me.getHeight() - 1;
  69904. if (min < xAxisOffset) {
  69905. yMaxCalc = (stacked && max >= 0) ? stackMax : max;
  69906. yoffset = (yMaxCalc - xAxisOffset) / range * me.getHeight();
  69907. if (yoffset !== Math.ceil(yoffset)) {
  69908. me.canvasHeightEf -= 2;
  69909. yoffset = Math.ceil(yoffset);
  69910. }
  69911. } else {
  69912. yoffset = me.getHeight();
  69913. }
  69914. me.yoffset = yoffset;
  69915. me.range = range;
  69916. },
  69917. getRegion: function(x, y) {
  69918. var result = Math.floor(x / this.totalBarWidth);
  69919. return (result < 0 || result >= this.values.length) ? undefined : result;
  69920. },
  69921. getRegionFields: function(region) {
  69922. var values = Ext.Array.from(this.values[region]),
  69923. result = [],
  69924. value, i;
  69925. for (i = values.length; i--; ) {
  69926. value = values[i];
  69927. result.push({
  69928. isNull: value === null,
  69929. value: value,
  69930. color: this.calcColor(i, value, region),
  69931. offset: region
  69932. });
  69933. }
  69934. return result;
  69935. },
  69936. calcColor: function(stacknum, value, valuenum) {
  69937. var me = this,
  69938. colorMapByIndex = me.colorMapByIndex,
  69939. colorMapByValue = me.colorMapByValue,
  69940. color, newColor,
  69941. zeroColor = me.getZeroColor();
  69942. if (this.stacked) {
  69943. color = me.getStackedBarColor();
  69944. } else {
  69945. color = (value < 0) ? me.getNegBarColor() : me.getBarColor();
  69946. }
  69947. if (value === 0 && zeroColor != null) {
  69948. color = zeroColor;
  69949. }
  69950. if (colorMapByValue && (newColor = colorMapByValue.get(value))) {
  69951. color = newColor;
  69952. } else if (colorMapByIndex && colorMapByIndex.length > valuenum) {
  69953. color = colorMapByIndex[valuenum];
  69954. }
  69955. return Ext.isArray(color) ? color[stacknum % color.length] : color;
  69956. },
  69957. renderRegion: function(valuenum, highlight) {
  69958. var me = this,
  69959. vals = me.values[valuenum],
  69960. xaxisOffset = me.xAxisOffset,
  69961. range = me.range,
  69962. stacked = me.stacked,
  69963. canvas = me.canvas,
  69964. barWidth = me.getBarWidth(),
  69965. x = valuenum * me.totalBarWidth,
  69966. canvasHeightEf = me.canvasHeightEf,
  69967. yoffset = me.yoffset,
  69968. y, height, color, isNull, yoffsetNeg, i, valcount, val, minPlotted, allMin,
  69969. nullColor = me.getNullColor();
  69970. vals = Ext.isArray(vals) ? vals : [
  69971. vals
  69972. ];
  69973. valcount = vals.length;
  69974. val = vals[0];
  69975. isNull = me.all(vals, null);
  69976. allMin = me.all(vals, xaxisOffset, true);
  69977. if (isNull) {
  69978. if (nullColor) {
  69979. color = highlight ? nullColor : me.calcHighlightColor(nullColor, me);
  69980. y = (yoffset > 0) ? yoffset - 1 : yoffset;
  69981. canvas.drawRect(x, y, barWidth - 1, 0, color, color).append();
  69982. }
  69983. return;
  69984. }
  69985. yoffsetNeg = yoffset;
  69986. for (i = 0; i < valcount; i++) {
  69987. val = vals[i];
  69988. if (stacked && val === xaxisOffset) {
  69989. if (!allMin || minPlotted) {
  69990. continue;
  69991. }
  69992. minPlotted = true;
  69993. }
  69994. if (range > 0) {
  69995. height = Math.floor(canvasHeightEf * ((Math.abs(val - xaxisOffset) / range))) + 1;
  69996. } else {
  69997. height = 1;
  69998. }
  69999. if (val < xaxisOffset || (val === xaxisOffset && yoffset === 0)) {
  70000. y = yoffsetNeg;
  70001. yoffsetNeg += height;
  70002. } else {
  70003. y = yoffset - height;
  70004. yoffset -= height;
  70005. }
  70006. color = me.calcColor(i, val, valuenum);
  70007. if (highlight) {
  70008. color = me.calcHighlightColor(color, me);
  70009. }
  70010. canvas.drawRect(x, y, barWidth - 1, height - 1, color, color).append();
  70011. }
  70012. }
  70013. }, function(cls) {
  70014. cls.onClassCreated(cls);
  70015. });
  70016. Ext.define('Ext.sparkline.Box', {
  70017. extend: Ext.sparkline.Base,
  70018. alias: 'widget.sparklinebox',
  70019. config: {
  70020. raw: false,
  70021. boxLineColor: '#000',
  70022. boxFillColor: '#cdf',
  70023. whiskerColor: '#000',
  70024. outlierLineColor: '#333',
  70025. outlierFillColor: '#fff',
  70026. medianColor: '#f00',
  70027. showOutliers: true,
  70028. outlierIQR: 1.5,
  70029. spotRadius: 1.5,
  70030. target: null,
  70031. targetColor: '#4a2',
  70032. chartRangeMin: null,
  70033. chartRangeMax: null
  70034. },
  70035. tipTpl: [
  70036. '{field:this.fields}: {value}',
  70037. {
  70038. fields: function(v) {
  70039. var fields = {
  70040. lq: 'Lower Quartile',
  70041. med: 'Median',
  70042. uq: 'Upper Quartile',
  70043. lo: 'Left Outlier',
  70044. ro: 'Right Outlier',
  70045. lw: 'Left Whisker',
  70046. rw: 'Right Whisker'
  70047. };
  70048. return fields[v];
  70049. }
  70050. }
  70051. ],
  70052. tooltipFormatFieldlistKey: 'field',
  70053. quartile: function(values, q) {
  70054. var vl;
  70055. if (q === 2) {
  70056. vl = Math.floor(values.length / 2);
  70057. return values.length % 2 ? values[vl] : (values[vl - 1] + values[vl]) / 2;
  70058. } else {
  70059. if (values.length % 2) {
  70060. vl = (values.length * q + q) / 4;
  70061. return vl % 1 ? (values[Math.floor(vl)] + values[Math.floor(vl) - 1]) / 2 : values[vl - 1];
  70062. } else {
  70063. vl = (values.length * q + 2) / 4;
  70064. return vl % 1 ? (values[Math.floor(vl)] + values[Math.floor(vl) - 1]) / 2 : values[vl - 1];
  70065. }
  70066. }
  70067. },
  70068. applyValues: function(newValues) {
  70069. newValues = Ext.Array.map(Ext.Array.from(newValues), Number);
  70070. if (!this.raw) {
  70071. newValues.sort(function(a, b) {
  70072. return a - b;
  70073. });
  70074. }
  70075. this.disabled = !(newValues && newValues.length);
  70076. this.updateConfigChange();
  70077. return newValues;
  70078. },
  70079. getRegion: function() {
  70080. return 1;
  70081. },
  70082. getRegionFields: function() {
  70083. var result = [
  70084. {
  70085. field: 'lq',
  70086. value: this.quartiles[0]
  70087. },
  70088. {
  70089. field: 'med',
  70090. value: this.quartiles[1]
  70091. },
  70092. {
  70093. field: 'uq',
  70094. value: this.quartiles[2]
  70095. }
  70096. ];
  70097. if (this.loutlier !== undefined) {
  70098. result.push({
  70099. field: 'lo',
  70100. value: this.loutlier
  70101. });
  70102. }
  70103. if (this.routlier !== undefined) {
  70104. result.push({
  70105. field: 'ro',
  70106. value: this.routlier
  70107. });
  70108. }
  70109. if (this.lwhisker !== undefined) {
  70110. result.push({
  70111. field: 'lw',
  70112. value: this.lwhisker
  70113. });
  70114. }
  70115. if (this.rwhisker !== undefined) {
  70116. result.push({
  70117. field: 'rw',
  70118. value: this.rwhisker
  70119. });
  70120. }
  70121. return result;
  70122. },
  70123. renderHighlight: Ext.emptyFn,
  70124. renderGraph: function() {
  70125. var me = this,
  70126. canvas = me.canvas,
  70127. values = me.values,
  70128. vlen = values.length,
  70129. canvasWidth = me.getWidth(),
  70130. canvasHeight = me.getHeight(),
  70131. chartRangeMin = me.getChartRangeMin(),
  70132. chartRangeMax = me.getChartRangeMax(),
  70133. minValue = chartRangeMin == null ? Math.min.apply(Math, values) : chartRangeMin,
  70134. maxValue = chartRangeMax == null ? Math.max.apply(Math, values) : chartRangeMax,
  70135. canvasLeft = 0,
  70136. lwhisker, loutlier, iqr, q1, q2, q3, rwhisker, routlier, i, size, unitSize,
  70137. spotRadius = me.getSpotRadius(),
  70138. outlierLineColor = me.getOutlierLineColor(),
  70139. outlierFillColor = me.getOutlierFillColor(),
  70140. showOutliers = me.getShowOutliers(),
  70141. outlierIQR = me.getOutlierIQR(),
  70142. lineColor = me.getLineColor(),
  70143. whiskerColor = me.getWhiskerColor(),
  70144. targetColor = me.getTargetColor();
  70145. if (!me.callParent()) {
  70146. return;
  70147. }
  70148. if (me.raw) {
  70149. if (showOutliers && values.length > 5) {
  70150. loutlier = values[0];
  70151. lwhisker = values[1];
  70152. q1 = values[2];
  70153. q2 = values[3];
  70154. q3 = values[4];
  70155. rwhisker = values[5];
  70156. routlier = values[6];
  70157. } else {
  70158. lwhisker = values[0];
  70159. q1 = values[1];
  70160. q2 = values[2];
  70161. q3 = values[3];
  70162. rwhisker = values[4];
  70163. }
  70164. } else {
  70165. q1 = me.quartile(values, 1);
  70166. q2 = me.quartile(values, 2);
  70167. q3 = me.quartile(values, 3);
  70168. iqr = q3 - q1;
  70169. if (showOutliers) {
  70170. lwhisker = rwhisker = null;
  70171. for (i = 0; i < vlen; i++) {
  70172. if (lwhisker == null && values[i] > q1 - (iqr * outlierIQR)) {
  70173. lwhisker = values[i];
  70174. }
  70175. if (values[i] < q3 + (iqr * outlierIQR)) {
  70176. rwhisker = values[i];
  70177. }
  70178. }
  70179. loutlier = values[0];
  70180. routlier = values[vlen - 1];
  70181. } else {
  70182. lwhisker = values[0];
  70183. rwhisker = values[vlen - 1];
  70184. }
  70185. }
  70186. me.quartiles = [
  70187. q1,
  70188. q2,
  70189. q3
  70190. ];
  70191. me.lwhisker = lwhisker;
  70192. me.rwhisker = rwhisker;
  70193. me.loutlier = loutlier;
  70194. me.routlier = routlier;
  70195. unitSize = canvasWidth / (maxValue - minValue + 1);
  70196. if (showOutliers) {
  70197. canvasLeft = Math.ceil(spotRadius);
  70198. canvasWidth -= 2 * Math.ceil(spotRadius);
  70199. unitSize = canvasWidth / (maxValue - minValue + 1);
  70200. if (loutlier < lwhisker) {
  70201. canvas.drawCircle((loutlier - minValue) * unitSize + canvasLeft, canvasHeight / 2, spotRadius, outlierLineColor, outlierFillColor).append();
  70202. }
  70203. if (routlier > rwhisker) {
  70204. canvas.drawCircle((routlier - minValue) * unitSize + canvasLeft, canvasHeight / 2, spotRadius, outlierLineColor, outlierFillColor).append();
  70205. }
  70206. }
  70207. 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();
  70208. canvas.drawLine(Math.round((lwhisker - minValue) * unitSize + canvasLeft), Math.round(canvasHeight / 2), Math.round((q1 - minValue) * unitSize + canvasLeft), Math.round(canvasHeight / 2), lineColor).append();
  70209. 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();
  70210. canvas.drawLine(Math.round((rwhisker - minValue) * unitSize + canvasLeft), Math.round(canvasHeight / 2), Math.round((q3 - minValue) * unitSize + canvasLeft), Math.round(canvasHeight / 2), lineColor).append();
  70211. 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();
  70212. 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();
  70213. if (me.target) {
  70214. size = Math.ceil(me.spotRadius);
  70215. 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();
  70216. 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();
  70217. }
  70218. if (me.currentPageXY && me.canvasRegion.contains(me.currentPageXY)) {
  70219. me.currentRegion = null;
  70220. me.updateDisplay();
  70221. }
  70222. canvas.render();
  70223. }
  70224. });
  70225. Ext.define('Ext.sparkline.Bullet', {
  70226. extend: Ext.sparkline.Base,
  70227. alias: 'widget.sparklinebullet',
  70228. config: {
  70229. targetColor: '#f33',
  70230. targetWidth: 3,
  70231. performanceColor: '#33f',
  70232. rangeColors: [
  70233. '#d3dafe',
  70234. '#a8b6ff',
  70235. '#7f94ff'
  70236. ],
  70237. base: null
  70238. },
  70239. tipTpl: [
  70240. '{fieldkey:this.fields} - {value}',
  70241. {
  70242. fields: function(v) {
  70243. if (v === 'r') {
  70244. return 'Range';
  70245. }
  70246. if (v === 'p') {
  70247. return 'Performance';
  70248. }
  70249. if (v === 't') {
  70250. return 'Target';
  70251. }
  70252. }
  70253. }
  70254. ],
  70255. applyValues: function(newValues) {
  70256. newValues = Ext.Array.map(Ext.Array.from(newValues), this.normalizeValue);
  70257. this.disabled = !(newValues && newValues.length);
  70258. this.updateConfigChange();
  70259. return newValues;
  70260. },
  70261. onUpdate: function() {
  70262. var me = this,
  70263. values = me.values,
  70264. min, max, vals,
  70265. base = me.getBase();
  70266. me.callParent(arguments);
  70267. vals = values.slice();
  70268. vals[0] = vals[0] === null ? vals[2] : vals[0];
  70269. vals[1] = values[1] === null ? vals[2] : vals[1];
  70270. min = Math.min.apply(Math, values);
  70271. max = Math.max.apply(Math, values);
  70272. if (base == null) {
  70273. min = min < 0 ? min : 0;
  70274. } else {
  70275. min = base;
  70276. }
  70277. me.min = min;
  70278. me.max = max;
  70279. me.range = max - min;
  70280. me.shapes = {};
  70281. me.valueShapes = {};
  70282. me.regiondata = {};
  70283. if (!values.length) {
  70284. me.disabled = true;
  70285. }
  70286. },
  70287. getRegion: function(x, y) {
  70288. var shapeid = this.canvas.getShapeAt(x, y);
  70289. return (shapeid !== undefined && this.shapes[shapeid] !== undefined) ? this.shapes[shapeid] : undefined;
  70290. },
  70291. getRegionFields: function(region) {
  70292. return {
  70293. fieldkey: region.substr(0, 1),
  70294. value: this.values[parseInt(region.substr(1), 10)],
  70295. region: region
  70296. };
  70297. },
  70298. renderHighlight: function(region) {
  70299. var me = this,
  70300. valueShapes = me.valueShapes,
  70301. shapes = me.shapes,
  70302. shapeId = valueShapes[region],
  70303. shape;
  70304. delete shapes[shapeId];
  70305. switch (region.substr(0, 1)) {
  70306. case 'r':
  70307. shape = me.renderRange(parseInt(region.substr(1), 10), true);
  70308. break;
  70309. case 'p':
  70310. shape = me.renderPerformance(true);
  70311. break;
  70312. case 't':
  70313. shape = me.renderTarget(true);
  70314. break;
  70315. }
  70316. valueShapes[region] = shape.id;
  70317. shapes[shape.id] = region;
  70318. me.canvas.replaceWithShape(shapeId, shape);
  70319. },
  70320. renderRange: function(region, highlight) {
  70321. var me = this,
  70322. rangeval = me.values[region],
  70323. rangewidth = Math.round(me.getWidth() * ((rangeval - me.min) / me.range)),
  70324. colors = me.getRangeColors(),
  70325. color = colors[Math.min(region - 2, colors.length - 1)];
  70326. if (highlight) {
  70327. color = me.calcHighlightColor(color);
  70328. }
  70329. return me.canvas.drawRect(0, 0, rangewidth - 1, me.getHeight() - 1, color, color);
  70330. },
  70331. renderPerformance: function(highlight) {
  70332. var perfval = this.values[1],
  70333. perfwidth = Math.round(this.getWidth() * ((perfval - this.min) / this.range)),
  70334. color = this.getPerformanceColor();
  70335. if (highlight) {
  70336. color = this.calcHighlightColor(color);
  70337. }
  70338. return this.canvas.drawRect(0, Math.round(this.getHeight() * 0.3), perfwidth - 1, Math.round(this.getHeight() * 0.4) - 1, color, color);
  70339. },
  70340. renderTarget: function(highlight) {
  70341. var targetval = this.values[0],
  70342. targetWidth = this.getTargetWidth(),
  70343. x = Math.round(this.getWidth() * ((targetval - this.min) / this.range) - (targetWidth / 2)),
  70344. targettop = Math.round(this.getHeight() * 0.1),
  70345. targetheight = this.getHeight() - (targettop * 2),
  70346. color = this.getTargetColor();
  70347. if (highlight) {
  70348. color = this.calcHighlightColor(color);
  70349. }
  70350. return this.canvas.drawRect(x, targettop, targetWidth - 1, targetheight - 1, color, color);
  70351. },
  70352. renderGraph: function() {
  70353. var me = this,
  70354. vlen = me.values.length,
  70355. canvas = me.canvas,
  70356. i, shape,
  70357. shapes = me.shapes || (me.shapes = {}),
  70358. valueShapes = me.valueShapes || (me.valueShapes = {});
  70359. if (!me.callParent()) {
  70360. return;
  70361. }
  70362. for (i = 2; i < vlen; i++) {
  70363. shape = me.renderRange(i).append();
  70364. shapes[shape.id] = 'r' + i;
  70365. valueShapes['r' + i] = shape.id;
  70366. }
  70367. if (me.values[1] !== null) {
  70368. shape = me.renderPerformance().append();
  70369. shapes[shape.id] = 'p1';
  70370. valueShapes.p1 = shape.id;
  70371. }
  70372. if (me.values[0] !== null) {
  70373. shape = this.renderTarget().append();
  70374. shapes[shape.id] = 't0';
  70375. valueShapes.t0 = shape.id;
  70376. }
  70377. if (me.currentPageXY && me.canvasRegion.contains(me.currentPageXY)) {
  70378. me.updateDisplay();
  70379. }
  70380. canvas.render();
  70381. },
  70382. privates: {
  70383. isValidRegion: function(region, values) {
  70384. return parseInt(region.substr(1), 10) < values.length;
  70385. }
  70386. }
  70387. });
  70388. Ext.define('Ext.sparkline.Discrete', {
  70389. extend: Ext.sparkline.BarBase,
  70390. alias: 'widget.sparklinediscrete',
  70391. config: {
  70392. lineHeight: 'auto',
  70393. thresholdColor: null,
  70394. thresholdValue: 0,
  70395. chartRangeMax: null,
  70396. chartRangeMin: null,
  70397. chartRangeClip: false
  70398. },
  70399. tipTpl: '{prefix}{value}{suffix}',
  70400. applyValues: function(newValues) {
  70401. newValues = Ext.Array.map(Ext.Array.from(newValues), Number);
  70402. this.disabled = !(newValues && newValues.length);
  70403. this.updateConfigChange();
  70404. return newValues;
  70405. },
  70406. onUpdate: function() {
  70407. var me = this,
  70408. values = me.values,
  70409. chartRangeMin = me.getChartRangeMin(),
  70410. chartRangeMax = me.getChartRangeMax(),
  70411. chartRangeClip = me.getChartRangeClip();
  70412. me.callParent(arguments);
  70413. me.regionShapes = {};
  70414. me.min = Math.min.apply(Math, values);
  70415. me.max = Math.max.apply(Math, values);
  70416. me.range = me.max - me.min;
  70417. me.width = me.getWidth();
  70418. me.interval = Math.floor(me.width / values.length);
  70419. me.itemWidth = me.width / values.length;
  70420. if (chartRangeMin != null && (chartRangeClip || chartRangeMin < me.min)) {
  70421. me.min = chartRangeMin;
  70422. }
  70423. if (chartRangeMax != null && (chartRangeClip || chartRangeMax > me.max)) {
  70424. me.max = chartRangeMax;
  70425. }
  70426. if (me.canvas) {
  70427. if (me.getLineHeight() === 'auto') {
  70428. me.setLineHeight(Math.round(me.getHeight() * 0.3));
  70429. }
  70430. }
  70431. },
  70432. getRegion: function(x, y) {
  70433. return Math.floor(x / this.itemWidth);
  70434. },
  70435. getRegionFields: function(region) {
  70436. return {
  70437. isNull: this.values[region] === undefined,
  70438. value: this.values[region],
  70439. offset: region
  70440. };
  70441. },
  70442. renderRegion: function(valuenum, highlight) {
  70443. var me = this,
  70444. values = me.values,
  70445. min = me.min,
  70446. max = me.max,
  70447. range = me.range,
  70448. interval = me.interval,
  70449. canvas = me.canvas,
  70450. canvasHeight = me.getHeight(),
  70451. lineHeight = me.getLineHeight(),
  70452. pheight = canvasHeight - lineHeight,
  70453. ytop, val, color, x,
  70454. thresholdColor = me.getThresholdColor();
  70455. val = Ext.Number.constrain(values[valuenum], min, max);
  70456. x = valuenum * interval;
  70457. ytop = Math.round(pheight - pheight * ((val - min) / range));
  70458. color = (thresholdColor && val < me.getThresholdValue()) ? thresholdColor : me.getLineColor();
  70459. if (highlight) {
  70460. color = me.calcHighlightColor(color);
  70461. }
  70462. canvas.drawLine(x, ytop, x, ytop + lineHeight, color).append();
  70463. }
  70464. });
  70465. Ext.define('Ext.sparkline.Line', {
  70466. extend: Ext.sparkline.Base,
  70467. alias: 'widget.sparklineline',
  70468. config: {
  70469. fillColor: '#def',
  70470. spotColor: '#f80',
  70471. highlightSpotColor: '#5f5',
  70472. highlightLineColor: '#f22',
  70473. spotRadius: 1.5,
  70474. minSpotColor: '#f80',
  70475. maxSpotColor: '#f80',
  70476. lineWidth: 1,
  70477. normalRangeMin: null,
  70478. normalRangeMax: null,
  70479. normalRangeColor: '#ccc',
  70480. drawNormalOnTop: false,
  70481. chartRangeMin: null,
  70482. chartRangeMax: null,
  70483. chartRangeMinX: null,
  70484. chartRangeMaxX: null,
  70485. valueSpots: null
  70486. },
  70487. tipTpl: '&#9679; {prefix}{y}{suffix}',
  70488. applyValueSpots: function(valueSpots) {
  70489. if (valueSpots && !valueSpots.get) {
  70490. valueSpots = new Ext.sparkline.RangeMap(valueSpots);
  70491. }
  70492. this.updateConfigChange();
  70493. return valueSpots;
  70494. },
  70495. onUpdate: function() {
  70496. this.vertices = [];
  70497. this.regionMap = [];
  70498. this.xvalues = [];
  70499. this.yvalues = [];
  70500. this.yminmax = [];
  70501. },
  70502. getRegion: function(x, y) {
  70503. var i,
  70504. regionMap = this.regionMap;
  70505. for (i = regionMap.length; i--; ) {
  70506. if (regionMap[i] !== null && x >= regionMap[i][0] && x <= regionMap[i][1]) {
  70507. return regionMap[i][2];
  70508. }
  70509. }
  70510. return undefined;
  70511. },
  70512. getRegionFields: function(region) {
  70513. return {
  70514. isNull: this.yvalues[region] === null,
  70515. x: this.xvalues[region],
  70516. y: this.yvalues[region],
  70517. color: this.getLineColor(),
  70518. fillColor: this.getFillColor(),
  70519. offset: region
  70520. };
  70521. },
  70522. renderHighlight: function(region) {
  70523. var me = this,
  70524. canvas = me.canvas,
  70525. vertex = me.vertices[region],
  70526. spotRadius = me.getSpotRadius(),
  70527. highlightSpotColor = me.getHighlightSpotColor(),
  70528. highlightLineColor = me.getHighlightLineColor();
  70529. if (!vertex) {
  70530. return;
  70531. }
  70532. if (spotRadius && highlightSpotColor) {
  70533. canvas.drawCircle(vertex[0], vertex[1], spotRadius, null, highlightSpotColor).append();
  70534. }
  70535. if (highlightLineColor) {
  70536. canvas.drawLine(vertex[0], me.canvasTop, vertex[0], me.canvasTop + me.getHeight(), highlightLineColor).append();
  70537. }
  70538. },
  70539. scanValues: function() {
  70540. var me = this,
  70541. values = me.values,
  70542. valcount = values.length,
  70543. xvalues = me.xvalues,
  70544. yvalues = me.yvalues,
  70545. yminmax = me.yminmax,
  70546. i, val;
  70547. for (i = 0; i < valcount; i++) {
  70548. val = values[i];
  70549. if (typeof val === 'string') {
  70550. val = val.split(':');
  70551. }
  70552. if (val && val.length === 2) {
  70553. xvalues.push(Number(val[0]));
  70554. yvalues.push(val = Number(val[1]));
  70555. yminmax.push(val);
  70556. } else
  70557. {
  70558. xvalues.push(i);
  70559. if (val == null || val === 'null') {
  70560. yvalues.push(null);
  70561. } else {
  70562. yvalues.push(val = Number(val));
  70563. yminmax.push(val);
  70564. }
  70565. }
  70566. }
  70567. if (me.xvalues) {
  70568. xvalues = me.xvalues;
  70569. }
  70570. me.maxy = me.maxyorg = Math.max.apply(Math, yminmax);
  70571. me.miny = me.minyorg = Math.min.apply(Math, yminmax);
  70572. me.maxx = Math.max.apply(Math, xvalues);
  70573. me.minx = Math.min.apply(Math, xvalues);
  70574. me.xvalues = xvalues;
  70575. me.yvalues = yvalues;
  70576. me.yminmax = yminmax;
  70577. },
  70578. processRangeOptions: function() {
  70579. var me = this,
  70580. normalRangeMin = me.getNormalRangeMin(),
  70581. normalRangeMax = me.getNormalRangeMax(),
  70582. chartRangeMin = me.getChartRangeMin(),
  70583. chartRangeMinX = me.getChartRangeMinX(),
  70584. chartRangeMax = me.getChartRangeMax(),
  70585. chartRangeMaxX = me.getChartRangeMaxX();
  70586. if (normalRangeMin != null) {
  70587. if (normalRangeMin < me.miny) {
  70588. me.miny = normalRangeMin;
  70589. }
  70590. if (normalRangeMax > me.maxy) {
  70591. me.maxy = normalRangeMax;
  70592. }
  70593. }
  70594. if (chartRangeMin != null && (me.chartRangeClip || chartRangeMin < me.miny)) {
  70595. me.miny = chartRangeMin;
  70596. }
  70597. if (chartRangeMax != null && (me.chartRangeClip || chartRangeMax > me.maxy)) {
  70598. this.maxy = chartRangeMax;
  70599. }
  70600. if (chartRangeMinX != null && (me.chartRangeClipX || chartRangeMinX < me.minx)) {
  70601. me.minx = chartRangeMinX;
  70602. }
  70603. if (chartRangeMaxX != null && (me.chartRangeClipX || chartRangeMaxX > me.maxx)) {
  70604. me.maxx = chartRangeMaxX;
  70605. }
  70606. },
  70607. drawNormalRange: function(canvasLeft, canvasTop, canvasHeight, canvasWidth, rangey) {
  70608. var normalRangeMin = this.getNormalRangeMin(),
  70609. normalRangeMax = this.getNormalRangeMax(),
  70610. ytop = canvasTop + Math.round(canvasHeight - (canvasHeight * ((normalRangeMax - this.miny) / rangey))),
  70611. height = Math.round((canvasHeight * (normalRangeMax - normalRangeMin)) / rangey);
  70612. this.canvas.drawRect(canvasLeft, ytop, canvasWidth, height, undefined, this.normalRangeColor).append();
  70613. },
  70614. renderGraph: function() {
  70615. var me = this,
  70616. canvas = me.canvas,
  70617. canvasWidth = me.getWidth(),
  70618. canvasHeight = me.getHeight(),
  70619. vertices = me.vertices,
  70620. spotRadius = me.getSpotRadius(),
  70621. regionMap = me.regionMap,
  70622. rangeX, Y, yvallast, canvasTop, canvasLeft, vertex, path, paths, x, y, xNext, xPos, xPosNext, last, next, yValCount, lineShapes, fillShapes, plen,
  70623. valueSpots = me.getValueSpots(),
  70624. hlSpotsEnabled, color, xValues, yValues, i,
  70625. spotColor = me.getSpotColor(),
  70626. minSpotColor = me.getMinSpotColor(),
  70627. maxSpotColor = me.getMaxSpotColor(),
  70628. normalRangeMin = me.getNormalRangeMin(),
  70629. drawNormalOnTop = me.getDrawNormalOnTop();
  70630. if (!me.callParent()) {
  70631. return;
  70632. }
  70633. me.scanValues();
  70634. me.processRangeOptions();
  70635. xValues = me.xvalues;
  70636. yValues = me.yvalues;
  70637. if (!me.yminmax.length || me.yvalues.length < 2) {
  70638. return;
  70639. }
  70640. canvasTop = canvasLeft = 0;
  70641. rangeX = me.maxx - me.minx === 0 ? 1 : me.maxx - me.minx;
  70642. Y = me.maxy - me.miny === 0 ? 1 : me.maxy - me.miny;
  70643. yvallast = me.yvalues.length - 1;
  70644. if (spotRadius && (canvasWidth < (spotRadius * 4) || canvasHeight < (spotRadius * 4))) {
  70645. spotRadius = 0;
  70646. }
  70647. if (spotRadius) {
  70648. hlSpotsEnabled = me.getHighlightSpotColor() && !me.disableInteraction;
  70649. if (hlSpotsEnabled || minSpotColor || (spotColor && yValues[yvallast] === me.miny)) {
  70650. canvasHeight -= Math.ceil(spotRadius);
  70651. }
  70652. if (hlSpotsEnabled || maxSpotColor || (spotColor && yValues[yvallast] === me.maxy)) {
  70653. canvasHeight -= Math.ceil(spotRadius);
  70654. canvasTop += Math.ceil(spotRadius);
  70655. }
  70656. if (hlSpotsEnabled || ((minSpotColor || maxSpotColor) && (yValues[0] === me.miny || yValues[0] === me.maxy))) {
  70657. canvasLeft += Math.ceil(spotRadius);
  70658. canvasWidth -= Math.ceil(spotRadius);
  70659. }
  70660. if (hlSpotsEnabled || spotColor || (minSpotColor || maxSpotColor && (yValues[yvallast] === me.miny || yValues[yvallast] === me.maxy))) {
  70661. canvasWidth -= Math.ceil(spotRadius);
  70662. }
  70663. }
  70664. canvasHeight--;
  70665. if (normalRangeMin != null && !drawNormalOnTop) {
  70666. me.drawNormalRange(canvasLeft, canvasTop, canvasHeight, canvasWidth, Y);
  70667. }
  70668. path = [];
  70669. paths = [
  70670. path
  70671. ];
  70672. last = next = null;
  70673. yValCount = yValues.length;
  70674. for (i = 0; i < yValCount; i++) {
  70675. x = xValues[i];
  70676. xNext = xValues[i + 1];
  70677. y = yValues[i];
  70678. xPos = canvasLeft + Math.round((x - me.minx) * (canvasWidth / rangeX));
  70679. xPosNext = i < yValCount - 1 ? canvasLeft + Math.round((xNext - me.minx) * (canvasWidth / rangeX)) : canvasWidth;
  70680. next = xPos + ((xPosNext - xPos) / 2);
  70681. regionMap[i] = [
  70682. last || 0,
  70683. next,
  70684. i
  70685. ];
  70686. last = next;
  70687. if (y === null) {
  70688. if (i) {
  70689. if (yValues[i - 1] !== null) {
  70690. path = [];
  70691. paths.push(path);
  70692. }
  70693. vertices.push(null);
  70694. }
  70695. } else {
  70696. if (y < me.miny) {
  70697. y = me.miny;
  70698. }
  70699. if (y > me.maxy) {
  70700. y = me.maxy;
  70701. }
  70702. if (!path.length) {
  70703. path.push([
  70704. xPos,
  70705. canvasTop + canvasHeight
  70706. ]);
  70707. }
  70708. vertex = [
  70709. xPos,
  70710. canvasTop + Math.round(canvasHeight - (canvasHeight * ((y - this.miny) / Y)))
  70711. ];
  70712. path.push(vertex);
  70713. vertices.push(vertex);
  70714. }
  70715. }
  70716. lineShapes = [];
  70717. fillShapes = [];
  70718. plen = paths.length;
  70719. for (i = 0; i < plen; i++) {
  70720. path = paths[i];
  70721. if (path.length) {
  70722. if (me.fillColor) {
  70723. path.push([
  70724. path[path.length - 1][0],
  70725. (canvasTop + canvasHeight)
  70726. ]);
  70727. fillShapes.push(path.slice(0));
  70728. path.pop();
  70729. }
  70730. if (path.length > 2) {
  70731. path[0] = [
  70732. path[0][0],
  70733. path[1][1]
  70734. ];
  70735. }
  70736. lineShapes.push(path);
  70737. }
  70738. }
  70739. plen = fillShapes.length;
  70740. for (i = 0; i < plen; i++) {
  70741. canvas.drawShape(fillShapes[i], me.fillColor, me.fillColor).append();
  70742. }
  70743. if (normalRangeMin != null && drawNormalOnTop) {
  70744. me.drawNormalRange(canvasLeft, canvasTop, canvasHeight, canvasWidth, Y);
  70745. }
  70746. plen = lineShapes.length;
  70747. for (i = 0; i < plen; i++) {
  70748. canvas.drawShape(lineShapes[i], me.getLineColor(), null, me.getLineWidth()).append();
  70749. }
  70750. if (spotRadius && valueSpots) {
  70751. if (valueSpots.get == null) {
  70752. valueSpots = new Ext.sparkline.RangeMap(valueSpots);
  70753. }
  70754. for (i = 0; i < yValCount; i++) {
  70755. color = valueSpots.get(yValues[i]);
  70756. if (color) {
  70757. 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();
  70758. }
  70759. }
  70760. }
  70761. if (spotRadius && spotColor && yValues[yvallast] != null) {
  70762. 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();
  70763. }
  70764. if (me.maxy !== me.minyorg) {
  70765. if (spotRadius && minSpotColor) {
  70766. x = xValues[Ext.Array.indexOf(yValues, me.minyorg)];
  70767. canvas.drawCircle(canvasLeft + Math.round((x - me.minx) * (canvasWidth / rangeX)), canvasTop + Math.round(canvasHeight - (canvasHeight * ((me.minyorg - me.miny) / Y))), spotRadius, null, minSpotColor).append();
  70768. }
  70769. if (spotRadius && maxSpotColor) {
  70770. x = xValues[Ext.Array.indexOf(yValues, me.maxyorg)];
  70771. canvas.drawCircle(canvasLeft + Math.round((x - me.minx) * (canvasWidth / rangeX)), canvasTop + Math.round(canvasHeight - (canvasHeight * ((me.maxyorg - me.miny) / Y))), spotRadius, null, maxSpotColor).append();
  70772. }
  70773. }
  70774. me.canvasTop = canvasTop;
  70775. if (me.currentPageXY && me.canvasRegion.contains(me.currentPageXY)) {
  70776. me.updateDisplay();
  70777. }
  70778. canvas.render();
  70779. }
  70780. });
  70781. Ext.define('Ext.sparkline.Pie', {
  70782. extend: Ext.sparkline.Base,
  70783. alias: 'widget.sparklinepie',
  70784. config: {
  70785. offset: 0,
  70786. sliceColors: [
  70787. '#3366cc',
  70788. '#dc3912',
  70789. '#ff9900',
  70790. '#109618',
  70791. '#66aa00',
  70792. '#dd4477',
  70793. '#0099c6',
  70794. '#990099'
  70795. ],
  70796. borderWidth: 0,
  70797. borderColor: '#000'
  70798. },
  70799. tipTpl: '&#9679; {value} ({percent:number("0.0")}%)',
  70800. applyValues: function(newValues) {
  70801. newValues = Ext.Array.map(Ext.Array.from(newValues), Number);
  70802. this.disabled = !(newValues && newValues.length);
  70803. this.updateConfigChange();
  70804. return newValues;
  70805. },
  70806. onUpdate: function() {
  70807. var me = this,
  70808. values = me.values,
  70809. total = 0,
  70810. i;
  70811. me.callParent(arguments);
  70812. me.shapes = {};
  70813. me.valueShapes = {};
  70814. if (values.length > 0) {
  70815. for (i = values.length; i--; ) {
  70816. total += values[i];
  70817. }
  70818. }
  70819. me.total = total;
  70820. me.radius = Math.floor(Math.min(me.getWidth(), me.getHeight()) / 2);
  70821. },
  70822. getRegion: function(x, y) {
  70823. var ratio = window.devicePixelRatio || 1,
  70824. shapeid = this.canvas.getShapeAt(x * ratio, y * ratio);
  70825. return (shapeid != null && this.shapes[shapeid] != null) ? this.shapes[shapeid] : null;
  70826. },
  70827. getRegionFields: function(region) {
  70828. var sliceColors = this.getSliceColors();
  70829. return {
  70830. isNull: this.values[region] == null,
  70831. value: this.values[region],
  70832. percent: this.values[region] / this.total * 100,
  70833. color: sliceColors[region % sliceColors.length],
  70834. offset: region
  70835. };
  70836. },
  70837. renderHighlight: function(region) {
  70838. this.renderSlice(region, true).append();
  70839. },
  70840. renderSlice: function(valuenum, highlight) {
  70841. var me = this,
  70842. canvas = me.canvas,
  70843. radius = me.radius,
  70844. borderWidth = me.getBorderWidth(),
  70845. offset = me.getOffset(),
  70846. circle = 2 * Math.PI,
  70847. values = me.values,
  70848. total = me.total,
  70849. next = offset ? (2 * Math.PI) * (offset / 360) : 0,
  70850. start, end, i, vlen, color,
  70851. sliceColors = this.getSliceColors();
  70852. vlen = values.length;
  70853. for (i = 0; i < vlen; i++) {
  70854. start = next;
  70855. end = next;
  70856. if (total > 0) {
  70857. end = next + (circle * (values[i] / total));
  70858. }
  70859. if (valuenum === i) {
  70860. color = sliceColors[i % sliceColors.length];
  70861. if (highlight) {
  70862. color = me.calcHighlightColor(color);
  70863. }
  70864. return canvas.drawPieSlice(radius, radius, radius - borderWidth, start, end, null, color);
  70865. }
  70866. next = end;
  70867. }
  70868. },
  70869. renderGraph: function() {
  70870. var me = this,
  70871. canvas = me.canvas,
  70872. values = me.values,
  70873. radius = me.radius,
  70874. borderWidth = me.getBorderWidth(),
  70875. shape, i,
  70876. shapes = me.shapes || (me.shapes = {}),
  70877. valueShapes = me.valueShapes || (me.valueShapes = {});
  70878. if (!me.callParent()) {
  70879. return;
  70880. }
  70881. if (borderWidth) {
  70882. canvas.drawCircle(radius, radius, Math.floor(radius - (borderWidth / 2)), me.getBorderColor(), null, borderWidth).append();
  70883. }
  70884. for (i = values.length; i--; ) {
  70885. if (values[i]) {
  70886. shape = me.renderSlice(i).append();
  70887. valueShapes[i] = shape.id;
  70888. shapes[shape.id] = i;
  70889. }
  70890. }
  70891. if (me.currentPageXY && me.canvasRegion.contains(me.currentPageXY)) {
  70892. me.currentRegion = null;
  70893. me.updateDisplay();
  70894. }
  70895. canvas.render();
  70896. }
  70897. });
  70898. Ext.define('Ext.sparkline.TriState', {
  70899. extend: Ext.sparkline.BarBase,
  70900. alias: 'widget.sparklinetristate',
  70901. config: {
  70902. barWidth: 4,
  70903. barSpacing: 1,
  70904. posBarColor: '#6f6',
  70905. negBarColor: '#f44',
  70906. zeroBarColor: '#999',
  70907. colorMap: {}
  70908. },
  70909. tipTpl: [
  70910. '&#9679; {value:this.states}',
  70911. {
  70912. states: function(v) {
  70913. var value = Number(v);
  70914. if (value === -1) {
  70915. return 'Loss';
  70916. }
  70917. if (value === 0) {
  70918. return 'Draw';
  70919. }
  70920. if (value === 1) {
  70921. return 'Win';
  70922. }
  70923. return v;
  70924. }
  70925. }
  70926. ],
  70927. applyColorMap: function(colorMap) {
  70928. var me = this;
  70929. if (Ext.isArray(colorMap)) {
  70930. me.colorMapByIndex = colorMap;
  70931. me.colorMapByValue = null;
  70932. } else {
  70933. me.colorMapByIndex = null;
  70934. me.colorMapByValue = colorMap;
  70935. if (me.colorMapByValue && me.colorMapByValue.get == null) {
  70936. me.colorMapByValue = new Ext.sparkline.RangeMap(colorMap);
  70937. }
  70938. }
  70939. me.updateConfigChange();
  70940. return colorMap;
  70941. },
  70942. applyValues: function(newValues) {
  70943. newValues = Ext.Array.map(Ext.Array.from(newValues), Number);
  70944. this.disabled = !(newValues && newValues.length);
  70945. this.updateConfigChange();
  70946. return newValues;
  70947. },
  70948. onUpdate: function() {
  70949. this.totalBarWidth = this.getBarWidth() + this.getBarSpacing();
  70950. },
  70951. getBarWidth: function() {
  70952. var values = this.values;
  70953. return this._barWidth || (this.getWidth() - (values.length - 1) * this.getBarSpacing()) / values.length;
  70954. },
  70955. getRegion: function(x, y) {
  70956. return Math.floor(x / this.totalBarWidth);
  70957. },
  70958. getRegionFields: function(region) {
  70959. return {
  70960. isNull: this.values[region] == null,
  70961. value: this.values[region],
  70962. color: this.calcColor(this.values[region], region),
  70963. offset: region
  70964. };
  70965. },
  70966. calcColor: function(value, valuenum) {
  70967. var me = this,
  70968. values = me.values,
  70969. colorMapByIndex = me.colorMapByIndex,
  70970. colorMapByValue = me.colorMapByValue,
  70971. color, newColor;
  70972. if (colorMapByValue && (newColor = colorMapByValue.get(value))) {
  70973. color = newColor;
  70974. } else if (colorMapByIndex && colorMapByIndex.length > valuenum) {
  70975. color = colorMapByIndex[valuenum];
  70976. } else if (values[valuenum] < 0) {
  70977. color = me.getNegBarColor();
  70978. } else if (values[valuenum] > 0) {
  70979. color = me.getPosBarColor();
  70980. } else {
  70981. color = me.getZeroBarColor();
  70982. }
  70983. return color;
  70984. },
  70985. renderRegion: function(valuenum, highlight) {
  70986. var me = this,
  70987. values = me.values,
  70988. canvas = me.canvas,
  70989. canvasHeight, height, halfHeight, x, y, color;
  70990. canvasHeight = canvas.pixelHeight;
  70991. halfHeight = Math.round(canvasHeight / 2);
  70992. x = valuenum * me.totalBarWidth;
  70993. if (values[valuenum] < 0) {
  70994. y = halfHeight;
  70995. height = halfHeight - 1;
  70996. } else if (values[valuenum] > 0) {
  70997. y = 0;
  70998. height = halfHeight - 1;
  70999. } else {
  71000. y = halfHeight - 1;
  71001. height = 2;
  71002. }
  71003. color = me.calcColor(values[valuenum], valuenum);
  71004. if (color == null) {
  71005. return;
  71006. }
  71007. if (highlight) {
  71008. color = me.calcHighlightColor(color);
  71009. }
  71010. canvas.drawRect(x, y, me.getBarWidth() - 1, height - 1, color, color).append();
  71011. }
  71012. });
  71013. Ext.define('Ext.util.Base64', {
  71014. singleton: true,
  71015. _str: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
  71016. encode: function(input) {
  71017. var me = this;
  71018. var output = '',
  71019. chr1, chr2, chr3, enc1, enc2, enc3, enc4,
  71020. i = 0;
  71021. input = me._utf8_encode(input);
  71022. var len = input.length;
  71023. while (i < len) {
  71024. chr1 = input.charCodeAt(i++);
  71025. chr2 = input.charCodeAt(i++);
  71026. chr3 = input.charCodeAt(i++);
  71027. enc1 = chr1 >> 2;
  71028. enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
  71029. enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
  71030. enc4 = chr3 & 63;
  71031. if (isNaN(chr2)) {
  71032. enc3 = enc4 = 64;
  71033. } else if (isNaN(chr3)) {
  71034. enc4 = 64;
  71035. }
  71036. output = output + me._str.charAt(enc1) + me._str.charAt(enc2) + me._str.charAt(enc3) + me._str.charAt(enc4);
  71037. }
  71038. return output;
  71039. },
  71040. decode: function(input) {
  71041. var me = this;
  71042. var output = '',
  71043. chr1, chr2, chr3, enc1, enc2, enc3, enc4,
  71044. i = 0;
  71045. input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");
  71046. var len = input.length;
  71047. while (i < len) {
  71048. enc1 = me._str.indexOf(input.charAt(i++));
  71049. enc2 = me._str.indexOf(input.charAt(i++));
  71050. enc3 = me._str.indexOf(input.charAt(i++));
  71051. enc4 = me._str.indexOf(input.charAt(i++));
  71052. chr1 = (enc1 << 2) | (enc2 >> 4);
  71053. chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
  71054. chr3 = ((enc3 & 3) << 6) | enc4;
  71055. output = output + String.fromCharCode(chr1);
  71056. if (enc3 !== 64) {
  71057. output = output + String.fromCharCode(chr2);
  71058. }
  71059. if (enc4 !== 64) {
  71060. output = output + String.fromCharCode(chr3);
  71061. }
  71062. }
  71063. output = me._utf8_decode(output);
  71064. return output;
  71065. },
  71066. _utf8_encode: function(string) {
  71067. string = string.replace(/\r\n/g, "\n");
  71068. var utftext = '',
  71069. n = 0,
  71070. len = string.length;
  71071. for (; n < len; n++) {
  71072. var c = string.charCodeAt(n);
  71073. if (c < 128) {
  71074. utftext += String.fromCharCode(c);
  71075. } else if ((c > 127) && (c < 2048)) {
  71076. utftext += String.fromCharCode((c >> 6) | 192);
  71077. utftext += String.fromCharCode((c & 63) | 128);
  71078. } else {
  71079. utftext += String.fromCharCode((c >> 12) | 224);
  71080. utftext += String.fromCharCode(((c >> 6) & 63) | 128);
  71081. utftext += String.fromCharCode((c & 63) | 128);
  71082. }
  71083. }
  71084. return utftext;
  71085. },
  71086. _utf8_decode: function(utftext) {
  71087. var string = '',
  71088. i = 0,
  71089. c = 0,
  71090. c3 = 0,
  71091. c2 = 0,
  71092. len = utftext.length;
  71093. while (i < len) {
  71094. c = utftext.charCodeAt(i);
  71095. if (c < 128) {
  71096. string += String.fromCharCode(c);
  71097. i++;
  71098. } else if ((c > 191) && (c < 224)) {
  71099. c2 = utftext.charCodeAt(i + 1);
  71100. string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
  71101. i += 2;
  71102. } else {
  71103. c2 = utftext.charCodeAt(i + 1);
  71104. c3 = utftext.charCodeAt(i + 2);
  71105. string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
  71106. i += 3;
  71107. }
  71108. }
  71109. return string;
  71110. }
  71111. });
  71112. Ext.define('Ext.util.DelimitedValue', {
  71113. dateFormat: 'C',
  71114. delimiter: '\t',
  71115. lineBreak: '\n',
  71116. quote: '"',
  71117. lineBreakRe: /\r?\n/g,
  71118. lastLineBreakRe: /(\r?\n|\r)$/,
  71119. constructor: function(config) {
  71120. if (config) {
  71121. Ext.apply(this, config);
  71122. }
  71123. this.parseREs = {};
  71124. this.quoteREs = {};
  71125. },
  71126. decode: function(input, delimiter, quoteChar) {
  71127. if (!input) {
  71128. return [];
  71129. }
  71130. var me = this,
  71131. delim = delimiter || me.delimiter,
  71132. row = [],
  71133. result = [
  71134. row
  71135. ],
  71136. quote = quoteChar !== undefined ? quoteChar : me.quote,
  71137. quoteREs = me.quoteREs,
  71138. parseREs = me.parseREs,
  71139. parseRE, dblQuoteRE, arrMatches, strMatchedDelimiter, strMatchedValue;
  71140. parseRE = quote === me.quote ? parseREs[delim] : null;
  71141. parseRE = parseRE || new RegExp(
  71142. "(\\" + delim + "|\\r?\\n|\\r|^)" +
  71143. "(?:" + (quote === null ? '()' : "\\" + quote + "([^\\" + quote + "]*(?:\\" + quote + "\\" + quote + "[^\\" + quote + "]*)*)\\" + quote + "|") +
  71144. "([^" + (quote === null ? '' : quote) + delim + "\\r\\n]*))", "gi");
  71145. dblQuoteRE = quote === me.quote ? quoteREs[quote] : null;
  71146. dblQuoteRE = dblQuoteRE || new RegExp('\\' + quote + '\\' + quote, 'g');
  71147. input = input.replace(me.lastLineBreakRe, '');
  71148. while ((arrMatches = parseRE.exec(input))) {
  71149. strMatchedDelimiter = arrMatches[1];
  71150. if (strMatchedDelimiter.length && strMatchedDelimiter !== delim) {
  71151. result.push(row = []);
  71152. }
  71153. if (!arrMatches.index && arrMatches[0].charAt(0) === delim) {
  71154. row.push('');
  71155. }
  71156. if (arrMatches[2]) {
  71157. strMatchedValue = arrMatches[2].replace(dblQuoteRE, quote);
  71158. } else {
  71159. strMatchedValue = arrMatches[3];
  71160. }
  71161. row.push(strMatchedValue);
  71162. }
  71163. return result;
  71164. },
  71165. encode: function(input, delimiter, quoteChar) {
  71166. var me = this,
  71167. delim = delimiter || me.delimiter,
  71168. dateFormat = me.dateFormat,
  71169. quote = quoteChar !== undefined ? quoteChar : me.quote,
  71170. twoQuotes = quote + quote,
  71171. rowIndex = input.length,
  71172. lineBreakRe = me.lineBreakRe,
  71173. result = [],
  71174. outputRow = [],
  71175. col, columnIndex, inputRow;
  71176. while (rowIndex-- > 0) {
  71177. inputRow = input[rowIndex];
  71178. outputRow.length = columnIndex = inputRow.length;
  71179. while (columnIndex-- > 0) {
  71180. col = inputRow[columnIndex];
  71181. if (col == null) {
  71182. col = '';
  71183. } else if (typeof col === 'string') {
  71184. if (col && quote !== null) {
  71185. if (col.indexOf(quote) > -1) {
  71186. col = quote + col.split(quote).join(twoQuotes) + quote;
  71187. } else if (col.indexOf(delim) > -1 || lineBreakRe.test(col)) {
  71188. col = quote + col + quote;
  71189. }
  71190. }
  71191. } else if (Ext.isDate(col)) {
  71192. col = Ext.Date.format(col, dateFormat);
  71193. }
  71194. else if (col && (isNaN(col) || Ext.isArray(col))) {
  71195. Ext.raise('Cannot serialize ' + Ext.typeOf(col) + ' into CSV');
  71196. }
  71197. outputRow[columnIndex] = col;
  71198. }
  71199. result[rowIndex] = outputRow.join(delim);
  71200. }
  71201. return result.join(me.lineBreak);
  71202. }
  71203. });
  71204. Ext.define('Ext.util.CSV', {
  71205. extend: Ext.util.DelimitedValue,
  71206. singleton: true,
  71207. delimiter: ','
  71208. });
  71209. Ext.define('Ext.util.ClickRepeater', {
  71210. alternateClassName: 'Ext.util.TapRepeater',
  71211. mixins: [
  71212. Ext.mixin.Observable
  71213. ],
  71214. config: {
  71215. el: null,
  71216. target: null,
  71217. disabled: null
  71218. },
  71219. interval: 20,
  71220. delay: 250,
  71221. preventDefault: true,
  71222. stopDefault: false,
  71223. timer: 0,
  71224. handler: null,
  71225. scope: null,
  71226. constructor: function(config) {
  71227. var me = this;
  71228. if (arguments.length === 2) {
  71229. me.setEl(config);
  71230. config = arguments[1];
  71231. }
  71232. me.mixins.observable.constructor.call(this, config);
  71233. },
  71234. destroy: function() {
  71235. this.setEl(null);
  71236. this.callParent();
  71237. },
  71238. privates: {
  71239. fireClick: function(e) {
  71240. var me = this;
  71241. me.fireEvent("click", me, e);
  71242. Ext.callback(me.handler, me.scope, [
  71243. me,
  71244. e
  71245. ], 0, me.getTarget());
  71246. },
  71247. updateDisabled: function(disabled) {
  71248. var me = this;
  71249. if (disabled) {
  71250. me.savedEl = me.getEl();
  71251. me.setEl(null);
  71252. } else if (me.savedEl) {
  71253. me.setEl(me.savedEl);
  71254. }
  71255. },
  71256. updateTarget: function(target) {
  71257. this.setEl(target.el);
  71258. },
  71259. updateEl: function(newEl, oldEl) {
  71260. var me = this,
  71261. elListeners;
  71262. if (oldEl) {
  71263. oldEl.selectable();
  71264. Ext.undefer(me.timer);
  71265. if (me.pressedCls) {
  71266. oldEl.removeCls(me.pressedCls);
  71267. }
  71268. Ext.getDoc().un('mouseup', me.handleMouseUp, me);
  71269. me.elListeners = Ext.destroy(me.elListeners);
  71270. }
  71271. if (newEl) {
  71272. newEl.unselectable();
  71273. elListeners = {
  71274. mousedown: me.handleMouseDown,
  71275. scope: me,
  71276. destroyable: true
  71277. };
  71278. if (me.preventDefault || me.stopDefault) {
  71279. elListeners.click = me.eventOptions;
  71280. }
  71281. me.elListeners = newEl.on(elListeners);
  71282. }
  71283. },
  71284. eventOptions: function(e) {
  71285. if (this.preventDefault) {
  71286. e.preventDefault();
  71287. }
  71288. if (this.stopDefault) {
  71289. e.stopEvent();
  71290. }
  71291. },
  71292. handleMouseDown: function(e) {
  71293. var me = this,
  71294. el = me.getEl();
  71295. Ext.undefer(me.timer);
  71296. if (me.pressedCls) {
  71297. el.addCls(me.pressedCls);
  71298. }
  71299. me.mousedownTime = Ext.now();
  71300. if (e.pointerType === 'mouse') {
  71301. el.on("mouseout", me.handleMouseOut, me);
  71302. }
  71303. Ext.getDoc().on("mouseup", me.handleMouseUp, me);
  71304. me.fireEvent("mousedown", me, e);
  71305. me.fireClick(e);
  71306. if (me.accelerate) {
  71307. me.delay = 400;
  71308. }
  71309. me.timer = Ext.defer(me.click, me.delay || me.interval, me, [
  71310. e
  71311. ]);
  71312. if (me.mousedownPreventDefault) {
  71313. e.preventDefault();
  71314. }
  71315. if (me.mousedownStopEvent) {
  71316. e.stopEvent();
  71317. }
  71318. },
  71319. click: function(e) {
  71320. var me = this;
  71321. me.fireClick(e);
  71322. me.timer = Ext.defer(me.click, me.accelerate ? me.easeOutExpo(Ext.now() - me.mousedownTime, 400, -390, 12000) : me.interval, me, [
  71323. e
  71324. ]);
  71325. },
  71326. easeOutExpo: function(t, b, c, d) {
  71327. return (t === d) ? b + c : c * (-Math.pow(2, -10 * t / d) + 1) + b;
  71328. },
  71329. handleMouseOut: function() {
  71330. var me = this,
  71331. el = me.getEl();
  71332. Ext.undefer(me.timer);
  71333. if (me.pressedCls) {
  71334. el.removeCls(me.pressedCls);
  71335. }
  71336. el.on("mouseover", me.handleMouseReturn, me);
  71337. },
  71338. handleMouseReturn: function(e) {
  71339. var me = this,
  71340. el = me.getEl();
  71341. el.un("mouseover", me.handleMouseReturn, me);
  71342. if (me.pressedCls) {
  71343. el.addCls(me.pressedCls);
  71344. }
  71345. me.click(e);
  71346. },
  71347. handleMouseUp: function(e) {
  71348. var me = this,
  71349. el = me.getEl();
  71350. Ext.undefer(me.timer);
  71351. el.un("mouseover", me.handleMouseReturn, me);
  71352. el.un("mouseout", me.handleMouseOut, me);
  71353. Ext.getDoc().un("mouseup", me.handleMouseUp, me);
  71354. if (me.pressedCls) {
  71355. el.removeCls(me.pressedCls);
  71356. }
  71357. me.fireEvent("mouseup", me, e);
  71358. }
  71359. }
  71360. });
  71361. Ext.define('Ext.util.Cookies', {
  71362. singleton: true,
  71363. set: function(name, value) {
  71364. var argv = arguments,
  71365. argc = argv.length,
  71366. expires = (argc > 2) ? argv[2] : null,
  71367. path = (argc > 3) ? argv[3] : '/',
  71368. domain = (argc > 4) ? argv[4] : null,
  71369. secure = (argc > 5) ? argv[5] : false;
  71370. document.cookie = name + "=" + escape(value) + ((expires === null) ? "" : ("; expires=" + expires.toUTCString())) + ((path === null) ? "" : ("; path=" + path)) + ((domain === null) ? "" : ("; domain=" + domain)) + ((secure === true) ? "; secure" : "");
  71371. },
  71372. get: function(name) {
  71373. var parts = document.cookie.split('; '),
  71374. len = parts.length,
  71375. item, i, ret;
  71376. for (i = 0; i < len; ++i) {
  71377. item = parts[i].split('=');
  71378. if (item[0] === name) {
  71379. ret = item[1];
  71380. return ret ? unescape(ret) : '';
  71381. }
  71382. }
  71383. return null;
  71384. },
  71385. clear: function(name, path) {
  71386. if (this.get(name)) {
  71387. path = path || '/';
  71388. document.cookie = name + '=' + '; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=' + path;
  71389. }
  71390. }
  71391. });
  71392. Ext.define('Ext.util.LocalStorage', {
  71393. id: null,
  71394. destroyed: false,
  71395. lazyKeys: true,
  71396. prefix: '',
  71397. session: false,
  71398. _keys: null,
  71399. _store: null,
  71400. _users: 0,
  71401. statics: {
  71402. cache: {},
  71403. get: function(id) {
  71404. var me = this,
  71405. cache = me.cache,
  71406. config = {
  71407. _users: 1
  71408. },
  71409. instance;
  71410. if (Ext.isString(id)) {
  71411. config.id = id;
  71412. } else {
  71413. Ext.apply(config, id);
  71414. }
  71415. if (!(instance = cache[config.id])) {
  71416. instance = new me(config);
  71417. } else {
  71418. if (instance === true) {
  71419. Ext.raise('Creating a shared instance of private local store "' + me.id + '".');
  71420. }
  71421. ++instance._users;
  71422. }
  71423. return instance;
  71424. },
  71425. supported: true
  71426. },
  71427. constructor: function(config) {
  71428. var me = this;
  71429. Ext.apply(me, config);
  71430. if (!me.hasOwnProperty('id')) {
  71431. Ext.raise("No id was provided to the local store.");
  71432. }
  71433. if (me._users) {
  71434. Ext.util.LocalStorage.cache[me.id] = me;
  71435. } else
  71436. {
  71437. if (Ext.util.LocalStorage.cache[me.id]) {
  71438. Ext.raise('Cannot create duplicate instance of local store "' + me.id + '". Use Ext.util.LocalStorage.get() to share instances.');
  71439. }
  71440. Ext.util.LocalStorage.cache[me.id] = true;
  71441. }
  71442. me.init();
  71443. },
  71444. init: function() {
  71445. var me = this,
  71446. id = me.id;
  71447. if (!me.prefix && id) {
  71448. me.prefix = id + '-';
  71449. }
  71450. me._store = (me.session ? window.sessionStorage : window.localStorage);
  71451. },
  71452. destroy: function() {
  71453. var me = this;
  71454. if (me._users) {
  71455. Ext.log.warn('LocalStorage(id=' + me.id + ') destroyed while in use');
  71456. }
  71457. delete Ext.util.LocalStorage.cache[me.id];
  71458. me._store = me._keys = null;
  71459. me.callParent();
  71460. },
  71461. getKeys: function() {
  71462. var me = this,
  71463. store = me._store,
  71464. prefix = me.prefix,
  71465. keys = me._keys,
  71466. n = prefix.length,
  71467. i, key;
  71468. if (!keys) {
  71469. me._keys = keys = [];
  71470. for (i = store.length; i--; ) {
  71471. key = store.key(i);
  71472. if (key.length > n) {
  71473. if (prefix === key.substring(0, n)) {
  71474. keys.push(key.substring(n));
  71475. }
  71476. }
  71477. }
  71478. }
  71479. return keys;
  71480. },
  71481. release: function() {
  71482. if (!--this._users) {
  71483. this.destroy();
  71484. }
  71485. },
  71486. save: Ext.emptyFn,
  71487. clear: function() {
  71488. var me = this,
  71489. store = me._store,
  71490. prefix = me.prefix,
  71491. keys = me._keys || me.getKeys(),
  71492. i;
  71493. for (i = keys.length; i--; ) {
  71494. store.removeItem(prefix + keys[i]);
  71495. }
  71496. keys.length = 0;
  71497. },
  71498. key: function(index) {
  71499. var keys = this._keys || this.getKeys();
  71500. return (0 <= index && index < keys.length) ? keys[index] : null;
  71501. },
  71502. getItem: function(key) {
  71503. var k = this.prefix + key;
  71504. return this._store.getItem(k);
  71505. },
  71506. removeItem: function(key) {
  71507. var me = this,
  71508. k = me.prefix + key,
  71509. store = me._store,
  71510. keys = me._keys,
  71511. length = store.length;
  71512. store.removeItem(k);
  71513. if (keys && length !== store.length) {
  71514. if (me.lazyKeys) {
  71515. me._keys = null;
  71516. } else {
  71517. Ext.Array.remove(keys, key);
  71518. }
  71519. }
  71520. },
  71521. setItem: function(key, value) {
  71522. var me = this,
  71523. k = me.prefix + key,
  71524. store = me._store,
  71525. length = store.length,
  71526. keys = me._keys;
  71527. store.setItem(k, value);
  71528. if (keys && length !== store.length) {
  71529. keys.push(key);
  71530. }
  71531. }
  71532. }, function() {
  71533. var LocalStorage = this;
  71534. if ('localStorage' in window) {
  71535. return;
  71536. }
  71537. if (!Ext.isIE) {
  71538. LocalStorage.supported = false;
  71539. LocalStorage.prototype.init = function() {
  71540. Ext.raise("Local storage is not supported on this browser");
  71541. };
  71542. return;
  71543. }
  71544. LocalStorage.override({
  71545. data: null,
  71546. flushDelay: 1,
  71547. init: function() {
  71548. var me = this,
  71549. data = me.data,
  71550. el;
  71551. me.el = el = document.createElement('div');
  71552. el.id = (me.id || (me.id = 'extjs-localstore'));
  71553. el.addBehavior('#default#userdata');
  71554. Ext.getHead().dom.appendChild(el);
  71555. el.load(me.id);
  71556. data = el.getAttribute('xdata');
  71557. me.data = data = (data ? Ext.decode(data) : {});
  71558. me._flushFn = function() {
  71559. me._timer = null;
  71560. me.save(0);
  71561. };
  71562. },
  71563. destroy: function() {
  71564. var me = this,
  71565. el = me.el;
  71566. if (el) {
  71567. if (me._timer) {
  71568. me.save();
  71569. }
  71570. el.parentNode.removeChild(el);
  71571. me.data = me.el = null;
  71572. me.callParent();
  71573. }
  71574. },
  71575. getKeys: function() {
  71576. var me = this,
  71577. keys = me._keys;
  71578. if (!keys) {
  71579. me._keys = keys = Ext.Object.getKeys(me.data);
  71580. }
  71581. return keys;
  71582. },
  71583. save: function(delay) {
  71584. var me = this;
  71585. if (!delay) {
  71586. me._timer = Ext.undefer(me._timer);
  71587. me.el.setAttribute('xdata', Ext.encode(me.data));
  71588. me.el.save(me.id);
  71589. } else if (!me._timer) {
  71590. me._timer = Ext.defer(me._flushFn, delay);
  71591. }
  71592. },
  71593. clear: function() {
  71594. var me = this;
  71595. me.data = {};
  71596. me._keys = null;
  71597. me.save(me.flushDelay);
  71598. },
  71599. getItem: function(key) {
  71600. var data = this.data;
  71601. return (key in data) ? data[key] : null;
  71602. },
  71603. removeItem: function(key) {
  71604. var me = this,
  71605. keys = me._keys,
  71606. data = me.data;
  71607. if (key in data) {
  71608. delete data[key];
  71609. if (keys) {
  71610. if (me.lazyKeys) {
  71611. me._keys = null;
  71612. } else {
  71613. Ext.Array.remove(keys, key);
  71614. }
  71615. }
  71616. me.save(me.flushDelay);
  71617. }
  71618. },
  71619. setItem: function(key, value) {
  71620. var me = this,
  71621. data = me.data,
  71622. keys = me._keys;
  71623. if (keys && !(key in data)) {
  71624. keys.push(key);
  71625. }
  71626. data[key] = value;
  71627. me.save(me.flushDelay);
  71628. }
  71629. });
  71630. });
  71631. Ext.define('Ext.util.Spans', {
  71632. isSpans: true,
  71633. constructor: function() {
  71634. this.spans = this.spans || [];
  71635. },
  71636. clear: function() {
  71637. this.spans.length = 0;
  71638. return this;
  71639. },
  71640. add: function(begin, end) {
  71641. if (end === undefined) {
  71642. if (typeof begin === 'number') {
  71643. end = begin + 1;
  71644. } else {
  71645. end = begin[1];
  71646. begin = begin[0];
  71647. }
  71648. }
  71649. var me = this,
  71650. spans = me.spans,
  71651. b, e, first, last, span;
  71652. first = me.bisect(begin);
  71653. if (first) {
  71654. span = spans[first - 1];
  71655. b = span[0];
  71656. e = span[1];
  71657. if (begin <= e) {
  71658. if (end <= e) {
  71659. return false;
  71660. }
  71661. begin = b;
  71662. spans.splice(--first, 1);
  71663. }
  71664. }
  71665. last = me.bisect(end);
  71666. if (last > first) {
  71667. span = spans[last - 1];
  71668. end = Math.max(end, span[1]);
  71669. }
  71670. if (last < spans.length) {
  71671. span = spans[last];
  71672. if (end === span[0]) {
  71673. end = span[1];
  71674. ++last;
  71675. }
  71676. }
  71677. spans.splice(first, last - first, [
  71678. begin,
  71679. end
  71680. ]);
  71681. return true;
  71682. },
  71683. contains: function(begin, end) {
  71684. if (end === undefined) {
  71685. if (typeof begin === 'number') {
  71686. end = begin + 1;
  71687. } else {
  71688. end = begin[1];
  71689. begin = begin[0];
  71690. }
  71691. }
  71692. var spans = this.spans,
  71693. index = this.bisect(begin),
  71694. ret = false,
  71695. e, span;
  71696. if (index && begin < (e = spans[index - 1][1])) {
  71697. ret = end <= e;
  71698. } else if (index < spans.length) {
  71699. span = spans[index];
  71700. ret = span[0] <= begin && end <= span[1];
  71701. }
  71702. return ret;
  71703. },
  71704. each: function(fn, scope) {
  71705. var spans = this.spans,
  71706. len = spans.length,
  71707. i, span, j;
  71708. for (i = 0; i < len; i++) {
  71709. span = spans[i];
  71710. for (j = span[0]; j < span[1]; j++) {
  71711. if (fn.call(scope || this, i) === false) {
  71712. return;
  71713. }
  71714. }
  71715. }
  71716. },
  71717. intersects: function(begin, end) {
  71718. if (end === undefined) {
  71719. if (typeof begin === 'number') {
  71720. end = begin + 1;
  71721. } else {
  71722. end = begin[1];
  71723. begin = begin[0];
  71724. }
  71725. }
  71726. var spans = this.spans,
  71727. index = this.bisect(begin),
  71728. ret = false;
  71729. if (index && begin < spans[index - 1][1]) {
  71730. ret = true;
  71731. } else if (index < spans.length) {
  71732. ret = spans[index][0] < end;
  71733. }
  71734. return ret;
  71735. },
  71736. remove: function(begin, end) {
  71737. if (end === undefined) {
  71738. if (typeof begin === 'number') {
  71739. end = begin + 1;
  71740. } else {
  71741. end = begin[1];
  71742. begin = begin[0];
  71743. }
  71744. }
  71745. var me = this,
  71746. spans = me.spans,
  71747. first = me.bisect(begin),
  71748. ret = false,
  71749. last, span, tmp;
  71750. if (first) {
  71751. span = spans[first - 1];
  71752. tmp = span[1];
  71753. if (begin < tmp) {
  71754. span[1] = begin;
  71755. if (end < tmp) {
  71756. spans.splice(first, 0, [
  71757. end,
  71758. tmp
  71759. ]);
  71760. return true;
  71761. }
  71762. ret = true;
  71763. }
  71764. }
  71765. last = me.bisect(end);
  71766. if (first < last) {
  71767. ret = true;
  71768. span = spans[last - 1];
  71769. if (end < span[1]) {
  71770. span[0] = end;
  71771. --last;
  71772. }
  71773. last -= first;
  71774. if (last) {
  71775. spans.splice(first, last);
  71776. }
  71777. }
  71778. return ret;
  71779. },
  71780. stash: function() {
  71781. return this.spans.slice();
  71782. },
  71783. unstash: function(pickle) {
  71784. this.spans = pickle;
  71785. return this;
  71786. },
  71787. getCount: function() {
  71788. var spans = this.spans,
  71789. len = spans.length,
  71790. result = 0,
  71791. i, span;
  71792. for (i = 0; i < len; i++) {
  71793. span = spans[i];
  71794. result += span[1] - span[0];
  71795. }
  71796. return result;
  71797. },
  71798. privates: {
  71799. bisect: function(value) {
  71800. return Ext.Number.bisectTuples(this.spans, value, 0);
  71801. }
  71802. }
  71803. });
  71804. Ext.define('Ext.util.TsvDecoder', {
  71805. extend: Ext.util.DelimitedValue,
  71806. alternateClassName: 'Ext.util.TSV',
  71807. delimiter: '\t'
  71808. }, function(TSVClass) {
  71809. Ext.util.TSV = new TSVClass();
  71810. });
  71811. Ext.define('Ext.util.TaskManager', {
  71812. extend: Ext.util.TaskRunner,
  71813. alternateClassName: [
  71814. 'Ext.TaskManager'
  71815. ],
  71816. singleton: true
  71817. });
  71818. Ext.define('Ext.util.TextMetrics', {
  71819. statics: {
  71820. shared: null,
  71821. measure: function(el, text, fixedWidth) {
  71822. var me = this,
  71823. shared = me.shared || (me.shared = new me(el, fixedWidth));
  71824. shared.bind(el);
  71825. shared.setFixedWidth(fixedWidth || 'auto');
  71826. return shared.getSize(text);
  71827. },
  71828. destroy: function() {
  71829. this.shared = Ext.destroy(this.shared);
  71830. }
  71831. },
  71832. constructor: function(bindTo, fixedWidth) {
  71833. var me = this,
  71834. measure = me.measure = Ext.getBody().createChild({
  71835. 'data-sticky': true,
  71836. role: 'presentation',
  71837. cls: Ext.baseCSSPrefix + 'textmetrics',
  71838. style: {
  71839. position: 'absolute',
  71840. left: '-1000px',
  71841. top: '-1000px',
  71842. visibility: 'hidden'
  71843. }
  71844. });
  71845. if (bindTo) {
  71846. me.bind(bindTo);
  71847. }
  71848. if (fixedWidth) {
  71849. measure.setWidth(fixedWidth);
  71850. }
  71851. },
  71852. getSize: function(text) {
  71853. var measure = this.measure,
  71854. size;
  71855. measure.setHtml(text);
  71856. size = measure.getSize();
  71857. measure.setHtml('');
  71858. return size;
  71859. },
  71860. bind: function(el) {
  71861. this.measure.setStyle(
  71862. (this.el || (this.self.prototype.el = new Ext.dom.Fly())).attach(el).getStyle([
  71863. 'font-size',
  71864. 'font-size-adjust',
  71865. 'font-style',
  71866. 'font-weight',
  71867. 'font-family',
  71868. 'font-kerning',
  71869. 'font-stretch',
  71870. 'line-height',
  71871. 'text-transform',
  71872. 'text-decoration',
  71873. 'letter-spacing',
  71874. 'word-break'
  71875. ]));
  71876. },
  71877. setFixedWidth: function(width) {
  71878. this.measure.setWidth(width);
  71879. },
  71880. getWidth: function(text) {
  71881. this.measure.dom.style.width = 'auto';
  71882. return this.getSize(text).width;
  71883. },
  71884. getHeight: function(text) {
  71885. return this.getSize(text).height;
  71886. },
  71887. destroy: function() {
  71888. var me = this;
  71889. me.el = me.measure = Ext.destroy(me.measure);
  71890. me.callParent();
  71891. }
  71892. }, function() {
  71893. Ext.Element.override({
  71894. getTextWidth: function(text, min, max) {
  71895. return Ext.Number.constrain(Ext.util.TextMetrics.measure(this.dom, Ext.valueFrom(text, this.dom.innerHTML, true)).width, min || 0, max || 1000000);
  71896. }
  71897. });
  71898. });
  71899. Ext.define('Ext.util.paintmonitor.OverflowChange', {
  71900. extend: Ext.util.paintmonitor.Abstract,
  71901. eventName: Ext.browser.is.Firefox ? 'overflow' : 'overflowchanged',
  71902. monitorClass: 'overflowchange',
  71903. onElementPainted: function(e) {
  71904. this.getCallback().apply(this.getScope(), this.getArgs());
  71905. }
  71906. });
  71907. Ext.define('Ext.util.sizemonitor.OverflowChange', {
  71908. extend: Ext.util.sizemonitor.Abstract,
  71909. constructor: function(config) {
  71910. this.onExpand = this.onExpand.bind(this);
  71911. this.onShrink = this.onShrink.bind(this);
  71912. this.callParent(arguments);
  71913. },
  71914. getElementConfig: function() {
  71915. return {
  71916. reference: 'detectorsContainer',
  71917. classList: [
  71918. Ext.baseCSSPrefix + 'size-monitors',
  71919. 'overflowchanged'
  71920. ],
  71921. children: [
  71922. {
  71923. reference: 'expandMonitor',
  71924. className: 'expand',
  71925. children: [
  71926. {
  71927. reference: 'expandHelper'
  71928. }
  71929. ]
  71930. },
  71931. {
  71932. reference: 'shrinkMonitor',
  71933. className: 'shrink',
  71934. children: [
  71935. {
  71936. reference: 'shrinkHelper'
  71937. }
  71938. ]
  71939. }
  71940. ]
  71941. };
  71942. },
  71943. bindListeners: function(bind) {
  71944. var method = bind ? 'addEventListener' : 'removeEventListener';
  71945. this.expandMonitor[method](Ext.browser.is.Firefox ? 'underflow' : 'overflowchanged', this.onExpand, true);
  71946. this.shrinkMonitor[method](Ext.browser.is.Firefox ? 'overflow' : 'overflowchanged', this.onShrink, true);
  71947. },
  71948. onExpand: function(e) {
  71949. if (!(this.destroyed || (Ext.browser.is.Webkit && e.horizontalOverflow && e.verticalOverflow))) {
  71950. Ext.TaskQueue.requestRead('refresh', this);
  71951. }
  71952. },
  71953. onShrink: function(e) {
  71954. if (!(this.destroyed || (Ext.browser.is.Webkit && !e.horizontalOverflow && !e.verticalOverflow))) {
  71955. Ext.TaskQueue.requestRead('refresh', this);
  71956. }
  71957. },
  71958. refreshMonitors: function() {
  71959. if (this.destroying || this.destroyed) {
  71960. return;
  71961. }
  71962. var expandHelper = this.expandHelper,
  71963. shrinkHelper = this.shrinkHelper,
  71964. contentBounds = this.getContentBounds(),
  71965. width = contentBounds.width,
  71966. height = contentBounds.height,
  71967. style;
  71968. if (expandHelper && !expandHelper.destroyed) {
  71969. style = expandHelper.style;
  71970. style.width = (width + 1) + 'px';
  71971. style.height = (height + 1) + 'px';
  71972. }
  71973. if (shrinkHelper && !shrinkHelper.destroyed) {
  71974. style = shrinkHelper.style;
  71975. style.width = width + 'px';
  71976. style.height = height + 'px';
  71977. }
  71978. Ext.TaskQueue.requestRead('refresh', this);
  71979. },
  71980. destroy: function() {
  71981. this.onExpand = this.onShrink = null;
  71982. this.callParent();
  71983. }
  71984. });
  71985. Ext.define('Ext.util.translatable.ScrollParent', {
  71986. extend: Ext.util.translatable.Dom,
  71987. alias: 'translatable.scrollparent',
  71988. isScrollParent: true,
  71989. applyElement: function(element) {
  71990. var el = Ext.get(element);
  71991. if (el) {
  71992. this.parent = el.parent();
  71993. }
  71994. return el;
  71995. },
  71996. doTranslate: function(x, y) {
  71997. var parent = this.parent;
  71998. parent.setScrollLeft(Math.round(-x));
  71999. parent.setScrollTop(Math.round(-y));
  72000. this.callParent([
  72001. x,
  72002. y
  72003. ]);
  72004. },
  72005. getPosition: function() {
  72006. var me = this,
  72007. position = me.position,
  72008. parent = me.parent;
  72009. position.x = parent.getScrollLeft();
  72010. position.y = parent.getScrollTop();
  72011. return position;
  72012. }
  72013. });
  72014. Ext.ClassManager.addNameAlternateMappings({
  72015. "Ext.AbstractComponent": [],
  72016. "Ext.AbstractManager": [],
  72017. "Ext.ActionSheet": [],
  72018. "Ext.Ajax": [],
  72019. "Ext.Anim": [],
  72020. "Ext.AnimationQueue": [],
  72021. "Ext.Audio": [],
  72022. "Ext.Button": [],
  72023. "Ext.Component": [
  72024. "Ext.lib.Component",
  72025. "Ext.Gadget"
  72026. ],
  72027. "Ext.ComponentManager": [
  72028. "Ext.ComponentMgr"
  72029. ],
  72030. "Ext.ComponentQuery": [],
  72031. "Ext.Container": [
  72032. "Ext.lib.Container",
  72033. "Ext.container.Container"
  72034. ],
  72035. "Ext.Decorator": [],
  72036. "Ext.Deferred": [],
  72037. "Ext.Dialog": [
  72038. "Ext.Window",
  72039. "Ext.window.Window"
  72040. ],
  72041. "Ext.Editor": [],
  72042. "Ext.Evented": [
  72043. "Ext.EventedBase"
  72044. ],
  72045. "Ext.GlobalEvents": [
  72046. "Ext.globalEvents"
  72047. ],
  72048. "Ext.Glyph": [],
  72049. "Ext.Img": [
  72050. "Ext.Image"
  72051. ],
  72052. "Ext.Indicator": [],
  72053. "Ext.Label": [],
  72054. "Ext.LoadMask": [],
  72055. "Ext.Mask": [],
  72056. "Ext.Media": [],
  72057. "Ext.MessageBox": [],
  72058. "Ext.Mixin": [],
  72059. "Ext.Panel": [
  72060. "Ext.panel.Panel"
  72061. ],
  72062. "Ext.Progress": [
  72063. "Ext.ProgressBarWidget"
  72064. ],
  72065. "Ext.ProgressBase": [],
  72066. "Ext.Promise": [],
  72067. "Ext.SegmentedButton": [
  72068. "Ext.button.Segmented"
  72069. ],
  72070. "Ext.Sheet": [],
  72071. "Ext.Spacer": [],
  72072. "Ext.SplitButton": [],
  72073. "Ext.TaskQueue": [],
  72074. "Ext.Template": [],
  72075. "Ext.Title": [],
  72076. "Ext.TitleBar": [],
  72077. "Ext.Toast": [],
  72078. "Ext.Tool": [
  72079. "Ext.panel.Tool"
  72080. ],
  72081. "Ext.Toolbar": [],
  72082. "Ext.Video": [],
  72083. "Ext.Widget": [
  72084. "Ext.Gadget"
  72085. ],
  72086. "Ext.XTemplate": [],
  72087. "Ext.app.Application": [],
  72088. "Ext.app.BaseController": [],
  72089. "Ext.app.Controller": [],
  72090. "Ext.app.EventBus": [],
  72091. "Ext.app.EventDomain": [],
  72092. "Ext.app.Profile": [],
  72093. "Ext.app.Util": [],
  72094. "Ext.app.ViewController": [],
  72095. "Ext.app.ViewModel": [],
  72096. "Ext.app.bind.AbstractStub": [],
  72097. "Ext.app.bind.BaseBinding": [],
  72098. "Ext.app.bind.Binding": [],
  72099. "Ext.app.bind.Formula": [],
  72100. "Ext.app.bind.LinkStub": [],
  72101. "Ext.app.bind.Multi": [],
  72102. "Ext.app.bind.Parser": [],
  72103. "Ext.app.bind.RootStub": [],
  72104. "Ext.app.bind.Stub": [],
  72105. "Ext.app.bind.Template": [],
  72106. "Ext.app.bind.TemplateBinding": [],
  72107. "Ext.app.domain.Component": [],
  72108. "Ext.app.domain.Controller": [],
  72109. "Ext.app.domain.Direct": [],
  72110. "Ext.app.domain.Global": [],
  72111. "Ext.app.domain.Store": [],
  72112. "Ext.app.domain.View": [],
  72113. "Ext.behavior.Behavior": [],
  72114. "Ext.carousel.Carousel": [
  72115. "Ext.Carousel"
  72116. ],
  72117. "Ext.carousel.Infinite": [],
  72118. "Ext.carousel.Item": [],
  72119. "Ext.data.AbstractStore": [],
  72120. "Ext.data.ArrayStore": [
  72121. "Ext.data.SimpleStore"
  72122. ],
  72123. "Ext.data.Batch": [],
  72124. "Ext.data.BufferedStore": [],
  72125. "Ext.data.ChainedStore": [],
  72126. "Ext.data.Connection": [],
  72127. "Ext.data.DirectStore": [],
  72128. "Ext.data.Error": [],
  72129. "Ext.data.ErrorCollection": [
  72130. "Ext.data.Errors"
  72131. ],
  72132. "Ext.data.Group": [],
  72133. "Ext.data.JsonP": [],
  72134. "Ext.data.JsonPStore": [],
  72135. "Ext.data.JsonStore": [],
  72136. "Ext.data.LocalStore": [],
  72137. "Ext.data.Model": [
  72138. "Ext.data.Record"
  72139. ],
  72140. "Ext.data.ModelManager": [
  72141. "Ext.ModelMgr"
  72142. ],
  72143. "Ext.data.NodeInterface": [],
  72144. "Ext.data.NodeStore": [],
  72145. "Ext.data.PageMap": [],
  72146. "Ext.data.ProxyStore": [],
  72147. "Ext.data.Range": [],
  72148. "Ext.data.Request": [],
  72149. "Ext.data.ResultSet": [],
  72150. "Ext.data.Session": [],
  72151. "Ext.data.SortTypes": [],
  72152. "Ext.data.Store": [],
  72153. "Ext.data.StoreManager": [
  72154. "Ext.StoreMgr",
  72155. "Ext.data.StoreMgr",
  72156. "Ext.StoreManager"
  72157. ],
  72158. "Ext.data.TreeModel": [],
  72159. "Ext.data.TreeStore": [],
  72160. "Ext.data.Types": [],
  72161. "Ext.data.Validation": [],
  72162. "Ext.data.XmlStore": [],
  72163. "Ext.data.field.Boolean": [],
  72164. "Ext.data.field.Date": [],
  72165. "Ext.data.field.Field": [
  72166. "Ext.data.Field"
  72167. ],
  72168. "Ext.data.field.Integer": [],
  72169. "Ext.data.field.Number": [],
  72170. "Ext.data.field.String": [],
  72171. "Ext.data.flash.BinaryXhr": [],
  72172. "Ext.data.identifier.Generator": [],
  72173. "Ext.data.identifier.Negative": [],
  72174. "Ext.data.identifier.Sequential": [],
  72175. "Ext.data.identifier.Uuid": [],
  72176. "Ext.data.matrix.Matrix": [],
  72177. "Ext.data.matrix.Side": [],
  72178. "Ext.data.matrix.Slice": [],
  72179. "Ext.data.operation.Create": [],
  72180. "Ext.data.operation.Destroy": [],
  72181. "Ext.data.operation.Operation": [
  72182. "Ext.data.Operation"
  72183. ],
  72184. "Ext.data.operation.Read": [],
  72185. "Ext.data.operation.Update": [],
  72186. "Ext.data.proxy.Ajax": [
  72187. "Ext.data.HttpProxy",
  72188. "Ext.data.AjaxProxy"
  72189. ],
  72190. "Ext.data.proxy.Client": [
  72191. "Ext.data.ClientProxy"
  72192. ],
  72193. "Ext.data.proxy.Direct": [
  72194. "Ext.data.DirectProxy"
  72195. ],
  72196. "Ext.data.proxy.JsonP": [
  72197. "Ext.data.ScriptTagProxy"
  72198. ],
  72199. "Ext.data.proxy.LocalStorage": [
  72200. "Ext.data.LocalStorageProxy"
  72201. ],
  72202. "Ext.data.proxy.Memory": [
  72203. "Ext.data.MemoryProxy"
  72204. ],
  72205. "Ext.data.proxy.Proxy": [
  72206. "Ext.data.DataProxy",
  72207. "Ext.data.Proxy"
  72208. ],
  72209. "Ext.data.proxy.Rest": [
  72210. "Ext.data.RestProxy"
  72211. ],
  72212. "Ext.data.proxy.Server": [
  72213. "Ext.data.ServerProxy"
  72214. ],
  72215. "Ext.data.proxy.SessionStorage": [
  72216. "Ext.data.SessionStorageProxy"
  72217. ],
  72218. "Ext.data.proxy.WebStorage": [
  72219. "Ext.data.WebStorageProxy"
  72220. ],
  72221. "Ext.data.reader.Array": [
  72222. "Ext.data.ArrayReader"
  72223. ],
  72224. "Ext.data.reader.Json": [
  72225. "Ext.data.JsonReader"
  72226. ],
  72227. "Ext.data.reader.Reader": [
  72228. "Ext.data.Reader",
  72229. "Ext.data.DataReader"
  72230. ],
  72231. "Ext.data.reader.Xml": [
  72232. "Ext.data.XmlReader"
  72233. ],
  72234. "Ext.data.request.Ajax": [],
  72235. "Ext.data.request.Base": [],
  72236. "Ext.data.request.Form": [],
  72237. "Ext.data.schema.Association": [],
  72238. "Ext.data.schema.ManyToMany": [],
  72239. "Ext.data.schema.ManyToOne": [],
  72240. "Ext.data.schema.Namer": [],
  72241. "Ext.data.schema.OneToOne": [],
  72242. "Ext.data.schema.Role": [],
  72243. "Ext.data.schema.Schema": [],
  72244. "Ext.data.session.BatchVisitor": [],
  72245. "Ext.data.session.ChangesVisitor": [],
  72246. "Ext.data.session.ChildChangesVisitor": [],
  72247. "Ext.data.summary.Average": [],
  72248. "Ext.data.summary.Base": [],
  72249. "Ext.data.summary.Count": [],
  72250. "Ext.data.summary.Max": [],
  72251. "Ext.data.summary.Min": [],
  72252. "Ext.data.summary.Sum": [],
  72253. "Ext.data.validator.AbstractDate": [],
  72254. "Ext.data.validator.Bound": [],
  72255. "Ext.data.validator.CIDRv4": [],
  72256. "Ext.data.validator.CIDRv6": [],
  72257. "Ext.data.validator.Currency": [],
  72258. "Ext.data.validator.CurrencyUS": [],
  72259. "Ext.data.validator.Date": [],
  72260. "Ext.data.validator.DateTime": [],
  72261. "Ext.data.validator.Email": [],
  72262. "Ext.data.validator.Exclusion": [],
  72263. "Ext.data.validator.Format": [],
  72264. "Ext.data.validator.IPAddress": [],
  72265. "Ext.data.validator.Inclusion": [],
  72266. "Ext.data.validator.Length": [],
  72267. "Ext.data.validator.List": [],
  72268. "Ext.data.validator.NotNull": [],
  72269. "Ext.data.validator.Number": [],
  72270. "Ext.data.validator.Phone": [],
  72271. "Ext.data.validator.Presence": [],
  72272. "Ext.data.validator.Range": [],
  72273. "Ext.data.validator.Time": [],
  72274. "Ext.data.validator.Url": [],
  72275. "Ext.data.validator.Validator": [],
  72276. "Ext.data.virtual.Group": [],
  72277. "Ext.data.virtual.Page": [],
  72278. "Ext.data.virtual.PageMap": [],
  72279. "Ext.data.virtual.Range": [],
  72280. "Ext.data.virtual.Store": [],
  72281. "Ext.data.writer.Json": [
  72282. "Ext.data.JsonWriter"
  72283. ],
  72284. "Ext.data.writer.Writer": [
  72285. "Ext.data.DataWriter",
  72286. "Ext.data.Writer"
  72287. ],
  72288. "Ext.data.writer.Xml": [
  72289. "Ext.data.XmlWriter"
  72290. ],
  72291. "Ext.dataview.Abstract": [],
  72292. "Ext.dataview.BoundList": [],
  72293. "Ext.dataview.BoundListLocation": [],
  72294. "Ext.dataview.BoundListNavigationModel": [],
  72295. "Ext.dataview.Component": [],
  72296. "Ext.dataview.DataItem": [
  72297. "Ext.dataview.component.DataItem"
  72298. ],
  72299. "Ext.dataview.DataView": [
  72300. "Ext.DataView"
  72301. ],
  72302. "Ext.dataview.Disclosable": [],
  72303. "Ext.dataview.EmptyText": [],
  72304. "Ext.dataview.GenericItem": [],
  72305. "Ext.dataview.IndexBar": [
  72306. "Ext.IndexBar"
  72307. ],
  72308. "Ext.dataview.ItemHeader": [],
  72309. "Ext.dataview.List": [
  72310. "Ext.List"
  72311. ],
  72312. "Ext.dataview.ListItem": [
  72313. "Ext.dataview.component.ListItem"
  72314. ],
  72315. "Ext.dataview.Location": [],
  72316. "Ext.dataview.NavigationModel": [],
  72317. "Ext.dataview.NestedList": [
  72318. "Ext.NestedList"
  72319. ],
  72320. "Ext.dataview.Pinnable": [],
  72321. "Ext.dataview.SimpleListItem": [
  72322. "Ext.dataview.component.SimpleListItem"
  72323. ],
  72324. "Ext.dataview.listswiper.Accordion": [],
  72325. "Ext.dataview.listswiper.Item": [],
  72326. "Ext.dataview.listswiper.ListSwiper": [],
  72327. "Ext.dataview.listswiper.Stepper": [],
  72328. "Ext.dataview.plugin.ItemTip": [],
  72329. "Ext.dataview.plugin.ListPaging": [
  72330. "Ext.plugin.ListPaging"
  72331. ],
  72332. "Ext.dataview.plugin.SortableList": [
  72333. "Ext.plugin.SortableList"
  72334. ],
  72335. "Ext.dataview.pullrefresh.Bar": [],
  72336. "Ext.dataview.pullrefresh.Item": [],
  72337. "Ext.dataview.pullrefresh.PullRefresh": [
  72338. "Ext.plugin.PullRefresh"
  72339. ],
  72340. "Ext.dataview.pullrefresh.Spinner": [],
  72341. "Ext.dataview.selection.Model": [],
  72342. "Ext.dataview.selection.Records": [],
  72343. "Ext.dataview.selection.Rows": [],
  72344. "Ext.dataview.selection.Selection": [],
  72345. "Ext.direct.Event": [],
  72346. "Ext.direct.ExceptionEvent": [],
  72347. "Ext.direct.JsonProvider": [],
  72348. "Ext.direct.Manager": [],
  72349. "Ext.direct.PollingProvider": [],
  72350. "Ext.direct.Provider": [],
  72351. "Ext.direct.RemotingEvent": [],
  72352. "Ext.direct.RemotingMethod": [],
  72353. "Ext.direct.RemotingProvider": [],
  72354. "Ext.direct.Transaction": [],
  72355. "Ext.dom.CompositeElement": [
  72356. "Ext.CompositeElement"
  72357. ],
  72358. "Ext.dom.CompositeElementLite": [
  72359. "Ext.CompositeElementLite"
  72360. ],
  72361. "Ext.dom.Element": [
  72362. "Ext.Element"
  72363. ],
  72364. "Ext.dom.ElementEvent": [],
  72365. "Ext.dom.Fly": [
  72366. "Ext.dom.Element.Fly"
  72367. ],
  72368. "Ext.dom.GarbageCollector": [],
  72369. "Ext.dom.Helper": [
  72370. "Ext.DomHelper",
  72371. "Ext.core.DomHelper"
  72372. ],
  72373. "Ext.dom.Query": [
  72374. "Ext.core.DomQuery",
  72375. "Ext.DomQuery"
  72376. ],
  72377. "Ext.dom.Shadow": [
  72378. "Ext.Shadow"
  72379. ],
  72380. "Ext.dom.Shim": [],
  72381. "Ext.dom.TouchAction": [],
  72382. "Ext.dom.Underlay": [],
  72383. "Ext.dom.UnderlayPool": [],
  72384. "Ext.drag.Constraint": [],
  72385. "Ext.drag.Info": [],
  72386. "Ext.drag.Item": [],
  72387. "Ext.drag.Manager": [],
  72388. "Ext.drag.Source": [],
  72389. "Ext.drag.Target": [],
  72390. "Ext.drag.proxy.None": [],
  72391. "Ext.drag.proxy.Original": [],
  72392. "Ext.drag.proxy.Placeholder": [],
  72393. "Ext.event.Event": [
  72394. "Ext.EventObjectImpl"
  72395. ],
  72396. "Ext.event.gesture.DoubleTap": [],
  72397. "Ext.event.gesture.Drag": [],
  72398. "Ext.event.gesture.EdgeSwipe": [],
  72399. "Ext.event.gesture.LongPress": [],
  72400. "Ext.event.gesture.MultiTouch": [],
  72401. "Ext.event.gesture.Pinch": [],
  72402. "Ext.event.gesture.Recognizer": [],
  72403. "Ext.event.gesture.Rotate": [],
  72404. "Ext.event.gesture.SingleTouch": [],
  72405. "Ext.event.gesture.Swipe": [],
  72406. "Ext.event.gesture.Tap": [],
  72407. "Ext.event.publisher.Dom": [],
  72408. "Ext.event.publisher.ElementPaint": [],
  72409. "Ext.event.publisher.ElementSize": [],
  72410. "Ext.event.publisher.Focus": [],
  72411. "Ext.event.publisher.Gesture": [],
  72412. "Ext.event.publisher.Publisher": [],
  72413. "Ext.field.BoxLabelable": [],
  72414. "Ext.field.Checkbox": [
  72415. "Ext.form.Checkbox"
  72416. ],
  72417. "Ext.field.ComboBox": [
  72418. "Ext.form.field.ComboBox"
  72419. ],
  72420. "Ext.field.Container": [],
  72421. "Ext.field.Date": [
  72422. "Ext.form.DatePicker",
  72423. "Ext.field.DatePicker"
  72424. ],
  72425. "Ext.field.DatePickerNative": [
  72426. "Ext.form.DatePickerNative"
  72427. ],
  72428. "Ext.field.Display": [
  72429. "Ext.form.Display"
  72430. ],
  72431. "Ext.field.Email": [
  72432. "Ext.form.Email"
  72433. ],
  72434. "Ext.field.Field": [
  72435. "Ext.form.Field"
  72436. ],
  72437. "Ext.field.File": [],
  72438. "Ext.field.FileButton": [],
  72439. "Ext.field.Hidden": [
  72440. "Ext.form.Hidden"
  72441. ],
  72442. "Ext.field.Input": [],
  72443. "Ext.field.InputMask": [],
  72444. "Ext.field.Manager": [],
  72445. "Ext.field.Number": [
  72446. "Ext.form.Number"
  72447. ],
  72448. "Ext.field.Panel": [],
  72449. "Ext.field.Password": [
  72450. "Ext.form.Password"
  72451. ],
  72452. "Ext.field.Picker": [],
  72453. "Ext.field.Radio": [
  72454. "Ext.form.Radio"
  72455. ],
  72456. "Ext.field.Search": [
  72457. "Ext.form.Search"
  72458. ],
  72459. "Ext.field.Select": [
  72460. "Ext.form.Select"
  72461. ],
  72462. "Ext.field.SingleSlider": [],
  72463. "Ext.field.Slider": [
  72464. "Ext.form.Slider"
  72465. ],
  72466. "Ext.field.Spinner": [
  72467. "Ext.form.Spinner"
  72468. ],
  72469. "Ext.field.Text": [
  72470. "Ext.form.Text"
  72471. ],
  72472. "Ext.field.TextArea": [
  72473. "Ext.form.TextArea"
  72474. ],
  72475. "Ext.field.Time": [],
  72476. "Ext.field.Toggle": [
  72477. "Ext.form.Toggle"
  72478. ],
  72479. "Ext.field.Url": [
  72480. "Ext.form.Url"
  72481. ],
  72482. "Ext.field.trigger.Base": [],
  72483. "Ext.field.trigger.Clear": [],
  72484. "Ext.field.trigger.Component": [],
  72485. "Ext.field.trigger.Date": [],
  72486. "Ext.field.trigger.Expand": [],
  72487. "Ext.field.trigger.File": [],
  72488. "Ext.field.trigger.Menu": [],
  72489. "Ext.field.trigger.Reveal": [],
  72490. "Ext.field.trigger.Search": [],
  72491. "Ext.field.trigger.SpinDown": [],
  72492. "Ext.field.trigger.SpinUp": [],
  72493. "Ext.field.trigger.Time": [],
  72494. "Ext.field.trigger.Trigger": [],
  72495. "Ext.form.Borders": [],
  72496. "Ext.form.FieldSet": [],
  72497. "Ext.form.Panel": [
  72498. "Ext.form.FormPanel"
  72499. ],
  72500. "Ext.fx.Animation": [],
  72501. "Ext.fx.Runner": [],
  72502. "Ext.fx.State": [],
  72503. "Ext.fx.animation.Abstract": [],
  72504. "Ext.fx.animation.Cube": [],
  72505. "Ext.fx.animation.Fade": [
  72506. "Ext.fx.animation.FadeIn"
  72507. ],
  72508. "Ext.fx.animation.FadeOut": [],
  72509. "Ext.fx.animation.Flip": [],
  72510. "Ext.fx.animation.Pop": [
  72511. "Ext.fx.animation.PopIn"
  72512. ],
  72513. "Ext.fx.animation.PopOut": [],
  72514. "Ext.fx.animation.Slide": [
  72515. "Ext.fx.animation.SlideIn"
  72516. ],
  72517. "Ext.fx.animation.SlideOut": [],
  72518. "Ext.fx.animation.Wipe": [
  72519. "Ext.fx.animation.WipeIn"
  72520. ],
  72521. "Ext.fx.animation.WipeOut": [],
  72522. "Ext.fx.easing.Abstract": [],
  72523. "Ext.fx.easing.Bounce": [],
  72524. "Ext.fx.easing.BoundMomentum": [],
  72525. "Ext.fx.easing.EaseIn": [],
  72526. "Ext.fx.easing.EaseOut": [],
  72527. "Ext.fx.easing.Easing": [],
  72528. "Ext.fx.easing.Linear": [],
  72529. "Ext.fx.easing.Momentum": [],
  72530. "Ext.fx.runner.Css": [],
  72531. "Ext.fx.runner.CssAnimation": [],
  72532. "Ext.fx.runner.CssTransition": [
  72533. "Ext.Animator"
  72534. ],
  72535. "Ext.grid.CellEditor": [],
  72536. "Ext.grid.Grid": [],
  72537. "Ext.grid.HeaderContainer": [],
  72538. "Ext.grid.Location": [],
  72539. "Ext.grid.NavigationModel": [],
  72540. "Ext.grid.PagingToolbar": [],
  72541. "Ext.grid.Row": [],
  72542. "Ext.grid.RowBody": [],
  72543. "Ext.grid.RowHeader": [],
  72544. "Ext.grid.SummaryRow": [],
  72545. "Ext.grid.Tree": [
  72546. "Ext.tree.Tree"
  72547. ],
  72548. "Ext.grid.cell.Base": [],
  72549. "Ext.grid.cell.Boolean": [],
  72550. "Ext.grid.cell.Cell": [],
  72551. "Ext.grid.cell.Check": [],
  72552. "Ext.grid.cell.Date": [],
  72553. "Ext.grid.cell.Expander": [],
  72554. "Ext.grid.cell.Number": [],
  72555. "Ext.grid.cell.RowNumberer": [],
  72556. "Ext.grid.cell.Text": [],
  72557. "Ext.grid.cell.Tree": [],
  72558. "Ext.grid.cell.Widget": [],
  72559. "Ext.grid.column.Boolean": [],
  72560. "Ext.grid.column.Check": [],
  72561. "Ext.grid.column.Column": [
  72562. "Ext.grid.column.Template"
  72563. ],
  72564. "Ext.grid.column.Date": [],
  72565. "Ext.grid.column.Number": [],
  72566. "Ext.grid.column.RowNumberer": [],
  72567. "Ext.grid.column.Selection": [],
  72568. "Ext.grid.column.Text": [],
  72569. "Ext.grid.column.Tree": [],
  72570. "Ext.grid.menu.Columns": [],
  72571. "Ext.grid.menu.GroupByThis": [],
  72572. "Ext.grid.menu.ShowInGroups": [],
  72573. "Ext.grid.menu.SortAsc": [],
  72574. "Ext.grid.menu.SortDesc": [],
  72575. "Ext.grid.plugin.CellEditing": [],
  72576. "Ext.grid.plugin.Clipboard": [],
  72577. "Ext.grid.plugin.ColumnResizing": [],
  72578. "Ext.grid.plugin.Editable": [],
  72579. "Ext.grid.plugin.PagingToolbar": [],
  72580. "Ext.grid.plugin.RowExpander": [],
  72581. "Ext.grid.plugin.RowOperations": [
  72582. "Ext.grid.plugin.MultiSelection"
  72583. ],
  72584. "Ext.grid.plugin.Summary": [
  72585. "Ext.grid.plugin.SummaryRow"
  72586. ],
  72587. "Ext.grid.plugin.ViewOptions": [],
  72588. "Ext.grid.plugin.ViewOptionsListItem": [],
  72589. "Ext.grid.selection.Cells": [],
  72590. "Ext.grid.selection.Columns": [],
  72591. "Ext.grid.selection.Model": [],
  72592. "Ext.grid.selection.Replicator": [],
  72593. "Ext.grid.selection.SelectionExtender": [],
  72594. "Ext.layout.Auto": [
  72595. "Ext.layout.Default"
  72596. ],
  72597. "Ext.layout.Box": [],
  72598. "Ext.layout.Card": [],
  72599. "Ext.layout.Carousel": [],
  72600. "Ext.layout.Center": [],
  72601. "Ext.layout.Fit": [],
  72602. "Ext.layout.Float": [],
  72603. "Ext.layout.Form": [],
  72604. "Ext.layout.HBox": [],
  72605. "Ext.layout.VBox": [],
  72606. "Ext.layout.card.fx.Abstract": [],
  72607. "Ext.layout.card.fx.Cover": [],
  72608. "Ext.layout.card.fx.Cube": [],
  72609. "Ext.layout.card.fx.Fade": [],
  72610. "Ext.layout.card.fx.Flip": [],
  72611. "Ext.layout.card.fx.Pop": [],
  72612. "Ext.layout.card.fx.Reveal": [],
  72613. "Ext.layout.card.fx.Scroll": [],
  72614. "Ext.layout.card.fx.ScrollCover": [],
  72615. "Ext.layout.card.fx.ScrollReveal": [],
  72616. "Ext.layout.card.fx.Serial": [],
  72617. "Ext.layout.card.fx.Slide": [],
  72618. "Ext.layout.card.fx.Style": [],
  72619. "Ext.layout.overflow.Scroller": [],
  72620. "Ext.layout.wrapper.BoxDock": [],
  72621. "Ext.layout.wrapper.Inner": [],
  72622. "Ext.list.AbstractTreeItem": [],
  72623. "Ext.list.Location": [],
  72624. "Ext.list.RootTreeItem": [],
  72625. "Ext.list.Tree": [],
  72626. "Ext.list.TreeItem": [],
  72627. "Ext.menu.CheckItem": [],
  72628. "Ext.menu.Item": [
  72629. "Ext.menu.TextItem"
  72630. ],
  72631. "Ext.menu.Manager": [
  72632. "Ext.menu.MenuMgr"
  72633. ],
  72634. "Ext.menu.Menu": [],
  72635. "Ext.menu.RadioItem": [],
  72636. "Ext.menu.Separator": [],
  72637. "Ext.mixin.Accessible": [],
  72638. "Ext.mixin.Bindable": [],
  72639. "Ext.mixin.Bufferable": [],
  72640. "Ext.mixin.ComponentDelegation": [],
  72641. "Ext.mixin.ConfigProxy": [],
  72642. "Ext.mixin.ConfigState": [],
  72643. "Ext.mixin.Container": [],
  72644. "Ext.mixin.Dirty": [],
  72645. "Ext.mixin.Factoryable": [],
  72646. "Ext.mixin.Focusable": [],
  72647. "Ext.mixin.FocusableContainer": [],
  72648. "Ext.mixin.Hookable": [],
  72649. "Ext.mixin.Inheritable": [],
  72650. "Ext.mixin.ItemRippler": [],
  72651. "Ext.mixin.Keyboard": [],
  72652. "Ext.mixin.Mashup": [],
  72653. "Ext.mixin.Pluggable": [],
  72654. "Ext.mixin.Progressable": [],
  72655. "Ext.mixin.Queryable": [],
  72656. "Ext.mixin.Responsive": [],
  72657. "Ext.mixin.Selectable": [],
  72658. "Ext.mixin.StoreWatcher": [],
  72659. "Ext.mixin.StyleCacher": [],
  72660. "Ext.mixin.Templatable": [],
  72661. "Ext.mixin.Toolable": [],
  72662. "Ext.mixin.Traversable": [],
  72663. "Ext.navigation.Bar": [],
  72664. "Ext.navigation.View": [
  72665. "Ext.NavigationView"
  72666. ],
  72667. "Ext.override.sparkline.Base": [],
  72668. "Ext.overrides.Progress": [],
  72669. "Ext.overrides.Widget": [],
  72670. "Ext.overrides.app.Application": [],
  72671. "Ext.overrides.dom.Element": [],
  72672. "Ext.overrides.drag.proxy.Placeholder": [],
  72673. "Ext.overrides.list.Tree": [],
  72674. "Ext.overrides.list.TreeItem": [],
  72675. "Ext.panel.Collapser": [],
  72676. "Ext.panel.Collapsible": [],
  72677. "Ext.panel.Date": [],
  72678. "Ext.panel.DateTitle": [],
  72679. "Ext.panel.DateView": [],
  72680. "Ext.panel.Header": [],
  72681. "Ext.panel.Resizable": [],
  72682. "Ext.panel.Resizer": [],
  72683. "Ext.panel.Time": [],
  72684. "Ext.panel.TimeHeader": [],
  72685. "Ext.panel.TimeView": [],
  72686. "Ext.panel.Title": [],
  72687. "Ext.panel.YearPicker": [],
  72688. "Ext.parse.Parser": [],
  72689. "Ext.parse.Symbol": [],
  72690. "Ext.parse.Tokenizer": [],
  72691. "Ext.parse.symbol.Constant": [],
  72692. "Ext.parse.symbol.Infix": [],
  72693. "Ext.parse.symbol.InfixRight": [],
  72694. "Ext.parse.symbol.Paren": [],
  72695. "Ext.parse.symbol.Prefix": [],
  72696. "Ext.perf.Accumulator": [],
  72697. "Ext.perf.Monitor": [
  72698. "Ext.Perf"
  72699. ],
  72700. "Ext.picker.Date": [
  72701. "Ext.DatePicker"
  72702. ],
  72703. "Ext.picker.Picker": [
  72704. "Ext.Picker"
  72705. ],
  72706. "Ext.picker.Slot": [],
  72707. "Ext.picker.Tablet": [],
  72708. "Ext.plugin.Abstract": [
  72709. "Ext.AbstractPlugin"
  72710. ],
  72711. "Ext.plugin.AbstractClipboard": [],
  72712. "Ext.plugin.MouseEnter": [],
  72713. "Ext.plugin.Responsive": [],
  72714. "Ext.plugin.TabGuard": [],
  72715. "Ext.promise.Consequence": [],
  72716. "Ext.promise.Deferred": [],
  72717. "Ext.promise.Promise": [],
  72718. "Ext.route.Action": [],
  72719. "Ext.route.Handler": [],
  72720. "Ext.route.Mixin": [],
  72721. "Ext.route.Route": [],
  72722. "Ext.route.Router": [],
  72723. "Ext.scroll.Scroller": [],
  72724. "Ext.slider.Slider": [],
  72725. "Ext.slider.Thumb": [],
  72726. "Ext.slider.Toggle": [],
  72727. "Ext.sparkline.Bar": [],
  72728. "Ext.sparkline.BarBase": [],
  72729. "Ext.sparkline.Base": [],
  72730. "Ext.sparkline.Box": [],
  72731. "Ext.sparkline.Bullet": [],
  72732. "Ext.sparkline.CanvasBase": [],
  72733. "Ext.sparkline.CanvasCanvas": [],
  72734. "Ext.sparkline.Discrete": [],
  72735. "Ext.sparkline.Line": [],
  72736. "Ext.sparkline.Pie": [],
  72737. "Ext.sparkline.RangeMap": [],
  72738. "Ext.sparkline.Shape": [],
  72739. "Ext.sparkline.TriState": [],
  72740. "Ext.sparkline.VmlCanvas": [],
  72741. "Ext.tab.Bar": [
  72742. "Ext.TabBar"
  72743. ],
  72744. "Ext.tab.Panel": [
  72745. "Ext.TabPanel"
  72746. ],
  72747. "Ext.tab.Tab": [
  72748. "Ext.Tab"
  72749. ],
  72750. "Ext.tip.Manager": [],
  72751. "Ext.tip.ToolTip": [],
  72752. "Ext.util.AbstractMixedCollection": [],
  72753. "Ext.util.Audio": [],
  72754. "Ext.util.Bag": [],
  72755. "Ext.util.Base64": [],
  72756. "Ext.util.BufferedCollection": [],
  72757. "Ext.util.CSS": [],
  72758. "Ext.util.CSV": [],
  72759. "Ext.util.ClickRepeater": [
  72760. "Ext.util.TapRepeater"
  72761. ],
  72762. "Ext.util.Collection": [],
  72763. "Ext.util.CollectionKey": [],
  72764. "Ext.util.Color": [
  72765. "Ext.draw.Color"
  72766. ],
  72767. "Ext.util.Cookies": [],
  72768. "Ext.util.DelimitedValue": [],
  72769. "Ext.util.Draggable": [],
  72770. "Ext.util.Filter": [],
  72771. "Ext.util.FilterCollection": [],
  72772. "Ext.util.Fly": [],
  72773. "Ext.util.Format": [],
  72774. "Ext.util.Geolocation": [
  72775. "Ext.util.GeoLocation"
  72776. ],
  72777. "Ext.util.Group": [],
  72778. "Ext.util.GroupCollection": [],
  72779. "Ext.util.Grouper": [],
  72780. "Ext.util.HashMap": [],
  72781. "Ext.util.History": [
  72782. "Ext.History"
  72783. ],
  72784. "Ext.util.Inflector": [],
  72785. "Ext.util.InputBlocker": [],
  72786. "Ext.util.ItemCollection": [
  72787. "Ext.ItemCollection"
  72788. ],
  72789. "Ext.util.KeyMap": [
  72790. "Ext.KeyMap"
  72791. ],
  72792. "Ext.util.KeyNav": [
  72793. "Ext.KeyNav"
  72794. ],
  72795. "Ext.util.LineSegment": [],
  72796. "Ext.util.LocalStorage": [],
  72797. "Ext.util.LruCache": [],
  72798. "Ext.util.MixedCollection": [],
  72799. "Ext.util.ObjectTemplate": [],
  72800. "Ext.util.Observable": [],
  72801. "Ext.util.Offset": [],
  72802. "Ext.util.PaintMonitor": [],
  72803. "Ext.util.Point": [],
  72804. "Ext.util.PositionMap": [],
  72805. "Ext.util.Positionable": [],
  72806. "Ext.util.Region": [],
  72807. "Ext.util.Schedulable": [],
  72808. "Ext.util.Scheduler": [],
  72809. "Ext.util.SizeMonitor": [],
  72810. "Ext.util.Sortable": [],
  72811. "Ext.util.Sorter": [],
  72812. "Ext.util.SorterCollection": [],
  72813. "Ext.util.Spans": [],
  72814. "Ext.util.TextMetrics": [],
  72815. "Ext.util.TranslatableGroup": [],
  72816. "Ext.util.TranslatableList": [],
  72817. "Ext.util.TsvDecoder": [
  72818. "Ext.util.TSV"
  72819. ],
  72820. "Ext.util.Wrapper": [],
  72821. "Ext.util.XTemplateCompiler": [],
  72822. "Ext.util.XTemplateParser": [],
  72823. "Ext.util.paintmonitor.Abstract": [],
  72824. "Ext.util.paintmonitor.CssAnimation": [],
  72825. "Ext.util.paintmonitor.OverflowChange": [],
  72826. "Ext.util.sizemonitor.Abstract": [],
  72827. "Ext.util.sizemonitor.OverflowChange": [],
  72828. "Ext.util.sizemonitor.Scroll": [],
  72829. "Ext.util.translatable.Abstract": [],
  72830. "Ext.util.translatable.Component": [],
  72831. "Ext.util.translatable.CssPosition": [],
  72832. "Ext.util.translatable.CssTransform": [],
  72833. "Ext.util.translatable.Dom": [],
  72834. "Ext.util.translatable.ScrollParent": [],
  72835. "Ext.util.translatable.ScrollPosition": [],
  72836. "Ext.viewport.Android": [],
  72837. "Ext.viewport.Default": [],
  72838. "Ext.viewport.Ios": [],
  72839. "Ext.viewport.Viewport": [],
  72840. "Ext.viewport.WindowsPhone": [
  72841. "Ext.viewport.WP"
  72842. ]
  72843. });
  72844. Ext.ClassManager.addNameAliasMappings({
  72845. "Ext.AbstractComponent": [],
  72846. "Ext.AbstractManager": [],
  72847. "Ext.ActionSheet": [
  72848. "widget.actionsheet"
  72849. ],
  72850. "Ext.Ajax": [],
  72851. "Ext.Anim": [],
  72852. "Ext.AnimationQueue": [],
  72853. "Ext.Audio": [
  72854. "widget.audio"
  72855. ],
  72856. "Ext.Button": [
  72857. "widget.button"
  72858. ],
  72859. "Ext.Component": [
  72860. "widget.component"
  72861. ],
  72862. "Ext.ComponentManager": [],
  72863. "Ext.ComponentQuery": [],
  72864. "Ext.Container": [
  72865. "widget.container"
  72866. ],
  72867. "Ext.Decorator": [],
  72868. "Ext.Deferred": [],
  72869. "Ext.Dialog": [
  72870. "widget.dialog",
  72871. "widget.window"
  72872. ],
  72873. "Ext.Editor": [
  72874. "widget.editor"
  72875. ],
  72876. "Ext.Evented": [],
  72877. "Ext.GlobalEvents": [],
  72878. "Ext.Glyph": [],
  72879. "Ext.Img": [
  72880. "widget.image",
  72881. "widget.img"
  72882. ],
  72883. "Ext.Indicator": [
  72884. "widget.indicator"
  72885. ],
  72886. "Ext.Label": [
  72887. "widget.label"
  72888. ],
  72889. "Ext.LoadMask": [
  72890. "widget.loadmask"
  72891. ],
  72892. "Ext.Mask": [
  72893. "widget.mask"
  72894. ],
  72895. "Ext.Media": [
  72896. "widget.media"
  72897. ],
  72898. "Ext.MessageBox": [
  72899. "widget.messagebox"
  72900. ],
  72901. "Ext.Mixin": [],
  72902. "Ext.Panel": [
  72903. "widget.panel"
  72904. ],
  72905. "Ext.Progress": [
  72906. "widget.progress",
  72907. "widget.progressbarwidget"
  72908. ],
  72909. "Ext.ProgressBase": [],
  72910. "Ext.Promise": [],
  72911. "Ext.SegmentedButton": [
  72912. "widget.segmentedbutton"
  72913. ],
  72914. "Ext.Sheet": [
  72915. "widget.sheet"
  72916. ],
  72917. "Ext.Spacer": [
  72918. "widget.spacer"
  72919. ],
  72920. "Ext.SplitButton": [
  72921. "widget.splitbutton"
  72922. ],
  72923. "Ext.TaskQueue": [],
  72924. "Ext.Template": [],
  72925. "Ext.Title": [
  72926. "widget.title"
  72927. ],
  72928. "Ext.TitleBar": [
  72929. "widget.titlebar"
  72930. ],
  72931. "Ext.Toast": [],
  72932. "Ext.Tool": [
  72933. "widget.paneltool",
  72934. "widget.tool"
  72935. ],
  72936. "Ext.Toolbar": [
  72937. "widget.toolbar"
  72938. ],
  72939. "Ext.Video": [
  72940. "widget.video"
  72941. ],
  72942. "Ext.Widget": [
  72943. "widget.widget"
  72944. ],
  72945. "Ext.XTemplate": [],
  72946. "Ext.app.Application": [],
  72947. "Ext.app.BaseController": [],
  72948. "Ext.app.Controller": [],
  72949. "Ext.app.EventBus": [],
  72950. "Ext.app.EventDomain": [],
  72951. "Ext.app.Profile": [],
  72952. "Ext.app.Util": [],
  72953. "Ext.app.ViewController": [
  72954. "controller.controller"
  72955. ],
  72956. "Ext.app.ViewModel": [
  72957. "viewmodel.default"
  72958. ],
  72959. "Ext.app.bind.AbstractStub": [],
  72960. "Ext.app.bind.BaseBinding": [],
  72961. "Ext.app.bind.Binding": [],
  72962. "Ext.app.bind.Formula": [],
  72963. "Ext.app.bind.LinkStub": [],
  72964. "Ext.app.bind.Multi": [],
  72965. "Ext.app.bind.Parser": [],
  72966. "Ext.app.bind.RootStub": [],
  72967. "Ext.app.bind.Stub": [],
  72968. "Ext.app.bind.Template": [],
  72969. "Ext.app.bind.TemplateBinding": [],
  72970. "Ext.app.domain.Component": [],
  72971. "Ext.app.domain.Controller": [],
  72972. "Ext.app.domain.Direct": [],
  72973. "Ext.app.domain.Global": [],
  72974. "Ext.app.domain.Store": [],
  72975. "Ext.app.domain.View": [],
  72976. "Ext.behavior.Behavior": [],
  72977. "Ext.carousel.Carousel": [
  72978. "widget.carousel"
  72979. ],
  72980. "Ext.carousel.Infinite": [],
  72981. "Ext.carousel.Item": [],
  72982. "Ext.data.AbstractStore": [],
  72983. "Ext.data.ArrayStore": [
  72984. "store.array"
  72985. ],
  72986. "Ext.data.Batch": [],
  72987. "Ext.data.BufferedStore": [
  72988. "store.buffered"
  72989. ],
  72990. "Ext.data.ChainedStore": [
  72991. "store.chained"
  72992. ],
  72993. "Ext.data.Connection": [],
  72994. "Ext.data.DirectStore": [
  72995. "store.direct"
  72996. ],
  72997. "Ext.data.Error": [],
  72998. "Ext.data.ErrorCollection": [],
  72999. "Ext.data.Group": [],
  73000. "Ext.data.JsonP": [],
  73001. "Ext.data.JsonPStore": [
  73002. "store.jsonp"
  73003. ],
  73004. "Ext.data.JsonStore": [
  73005. "store.json"
  73006. ],
  73007. "Ext.data.LocalStore": [],
  73008. "Ext.data.Model": [],
  73009. "Ext.data.ModelManager": [],
  73010. "Ext.data.NodeInterface": [],
  73011. "Ext.data.NodeStore": [
  73012. "store.node"
  73013. ],
  73014. "Ext.data.PageMap": [],
  73015. "Ext.data.ProxyStore": [],
  73016. "Ext.data.Range": [],
  73017. "Ext.data.Request": [],
  73018. "Ext.data.ResultSet": [],
  73019. "Ext.data.Session": [],
  73020. "Ext.data.SortTypes": [],
  73021. "Ext.data.Store": [
  73022. "store.store"
  73023. ],
  73024. "Ext.data.StoreManager": [],
  73025. "Ext.data.TreeModel": [],
  73026. "Ext.data.TreeStore": [
  73027. "store.tree"
  73028. ],
  73029. "Ext.data.Types": [],
  73030. "Ext.data.Validation": [],
  73031. "Ext.data.XmlStore": [
  73032. "store.xml"
  73033. ],
  73034. "Ext.data.field.Boolean": [
  73035. "data.field.bool",
  73036. "data.field.boolean"
  73037. ],
  73038. "Ext.data.field.Date": [
  73039. "data.field.date"
  73040. ],
  73041. "Ext.data.field.Field": [
  73042. "data.field.auto"
  73043. ],
  73044. "Ext.data.field.Integer": [
  73045. "data.field.int",
  73046. "data.field.integer"
  73047. ],
  73048. "Ext.data.field.Number": [
  73049. "data.field.float",
  73050. "data.field.number"
  73051. ],
  73052. "Ext.data.field.String": [
  73053. "data.field.string"
  73054. ],
  73055. "Ext.data.flash.BinaryXhr": [],
  73056. "Ext.data.identifier.Generator": [
  73057. "data.identifier.default"
  73058. ],
  73059. "Ext.data.identifier.Negative": [
  73060. "data.identifier.negative"
  73061. ],
  73062. "Ext.data.identifier.Sequential": [
  73063. "data.identifier.sequential"
  73064. ],
  73065. "Ext.data.identifier.Uuid": [
  73066. "data.identifier.uuid"
  73067. ],
  73068. "Ext.data.matrix.Matrix": [],
  73069. "Ext.data.matrix.Side": [],
  73070. "Ext.data.matrix.Slice": [],
  73071. "Ext.data.operation.Create": [
  73072. "data.operation.create"
  73073. ],
  73074. "Ext.data.operation.Destroy": [
  73075. "data.operation.destroy"
  73076. ],
  73077. "Ext.data.operation.Operation": [],
  73078. "Ext.data.operation.Read": [
  73079. "data.operation.read"
  73080. ],
  73081. "Ext.data.operation.Update": [
  73082. "data.operation.update"
  73083. ],
  73084. "Ext.data.proxy.Ajax": [
  73085. "proxy.ajax"
  73086. ],
  73087. "Ext.data.proxy.Client": [],
  73088. "Ext.data.proxy.Direct": [
  73089. "proxy.direct"
  73090. ],
  73091. "Ext.data.proxy.JsonP": [
  73092. "proxy.jsonp",
  73093. "proxy.scripttag"
  73094. ],
  73095. "Ext.data.proxy.LocalStorage": [
  73096. "proxy.localstorage"
  73097. ],
  73098. "Ext.data.proxy.Memory": [
  73099. "proxy.memory"
  73100. ],
  73101. "Ext.data.proxy.Proxy": [
  73102. "proxy.proxy"
  73103. ],
  73104. "Ext.data.proxy.Rest": [
  73105. "proxy.rest"
  73106. ],
  73107. "Ext.data.proxy.Server": [
  73108. "proxy.server"
  73109. ],
  73110. "Ext.data.proxy.SessionStorage": [
  73111. "proxy.sessionstorage"
  73112. ],
  73113. "Ext.data.proxy.WebStorage": [],
  73114. "Ext.data.reader.Array": [
  73115. "reader.array"
  73116. ],
  73117. "Ext.data.reader.Json": [
  73118. "reader.json"
  73119. ],
  73120. "Ext.data.reader.Reader": [
  73121. "reader.base"
  73122. ],
  73123. "Ext.data.reader.Xml": [
  73124. "reader.xml"
  73125. ],
  73126. "Ext.data.request.Ajax": [
  73127. "request.ajax"
  73128. ],
  73129. "Ext.data.request.Base": [],
  73130. "Ext.data.request.Form": [
  73131. "request.form"
  73132. ],
  73133. "Ext.data.schema.Association": [],
  73134. "Ext.data.schema.ManyToMany": [],
  73135. "Ext.data.schema.ManyToOne": [],
  73136. "Ext.data.schema.Namer": [
  73137. "namer.default"
  73138. ],
  73139. "Ext.data.schema.OneToOne": [],
  73140. "Ext.data.schema.Role": [],
  73141. "Ext.data.schema.Schema": [
  73142. "schema.default"
  73143. ],
  73144. "Ext.data.session.BatchVisitor": [],
  73145. "Ext.data.session.ChangesVisitor": [],
  73146. "Ext.data.session.ChildChangesVisitor": [],
  73147. "Ext.data.summary.Average": [
  73148. "data.summary.average"
  73149. ],
  73150. "Ext.data.summary.Base": [
  73151. "data.summary.base"
  73152. ],
  73153. "Ext.data.summary.Count": [
  73154. "data.summary.count"
  73155. ],
  73156. "Ext.data.summary.Max": [
  73157. "data.summary.max"
  73158. ],
  73159. "Ext.data.summary.Min": [
  73160. "data.summary.min"
  73161. ],
  73162. "Ext.data.summary.Sum": [
  73163. "data.summary.sum"
  73164. ],
  73165. "Ext.data.validator.AbstractDate": [],
  73166. "Ext.data.validator.Bound": [
  73167. "data.validator.bound"
  73168. ],
  73169. "Ext.data.validator.CIDRv4": [
  73170. "data.validator.cidrv4"
  73171. ],
  73172. "Ext.data.validator.CIDRv6": [
  73173. "data.validator.cidrv6"
  73174. ],
  73175. "Ext.data.validator.Currency": [
  73176. "data.validator.currency"
  73177. ],
  73178. "Ext.data.validator.CurrencyUS": [
  73179. "data.validator.currency-us"
  73180. ],
  73181. "Ext.data.validator.Date": [
  73182. "data.validator.date"
  73183. ],
  73184. "Ext.data.validator.DateTime": [
  73185. "data.validator.datetime"
  73186. ],
  73187. "Ext.data.validator.Email": [
  73188. "data.validator.email"
  73189. ],
  73190. "Ext.data.validator.Exclusion": [
  73191. "data.validator.exclusion"
  73192. ],
  73193. "Ext.data.validator.Format": [
  73194. "data.validator.format"
  73195. ],
  73196. "Ext.data.validator.IPAddress": [
  73197. "data.validator.ipaddress"
  73198. ],
  73199. "Ext.data.validator.Inclusion": [
  73200. "data.validator.inclusion"
  73201. ],
  73202. "Ext.data.validator.Length": [
  73203. "data.validator.length"
  73204. ],
  73205. "Ext.data.validator.List": [
  73206. "data.validator.list"
  73207. ],
  73208. "Ext.data.validator.NotNull": [
  73209. "data.validator.notnull"
  73210. ],
  73211. "Ext.data.validator.Number": [
  73212. "data.validator.number"
  73213. ],
  73214. "Ext.data.validator.Phone": [
  73215. "data.validator.phone"
  73216. ],
  73217. "Ext.data.validator.Presence": [
  73218. "data.validator.presence"
  73219. ],
  73220. "Ext.data.validator.Range": [
  73221. "data.validator.range"
  73222. ],
  73223. "Ext.data.validator.Time": [
  73224. "data.validator.time"
  73225. ],
  73226. "Ext.data.validator.Url": [
  73227. "data.validator.url"
  73228. ],
  73229. "Ext.data.validator.Validator": [
  73230. "data.validator.base"
  73231. ],
  73232. "Ext.data.virtual.Group": [],
  73233. "Ext.data.virtual.Page": [],
  73234. "Ext.data.virtual.PageMap": [],
  73235. "Ext.data.virtual.Range": [],
  73236. "Ext.data.virtual.Store": [
  73237. "store.virtual"
  73238. ],
  73239. "Ext.data.writer.Json": [
  73240. "writer.json"
  73241. ],
  73242. "Ext.data.writer.Writer": [
  73243. "writer.base"
  73244. ],
  73245. "Ext.data.writer.Xml": [
  73246. "writer.xml"
  73247. ],
  73248. "Ext.dataview.Abstract": [],
  73249. "Ext.dataview.BoundList": [
  73250. "widget.boundlist"
  73251. ],
  73252. "Ext.dataview.BoundListLocation": [],
  73253. "Ext.dataview.BoundListNavigationModel": [
  73254. "navmodel.boundlist"
  73255. ],
  73256. "Ext.dataview.Component": [
  73257. "widget.componentdataview"
  73258. ],
  73259. "Ext.dataview.DataItem": [
  73260. "widget.dataitem"
  73261. ],
  73262. "Ext.dataview.DataView": [
  73263. "widget.dataview"
  73264. ],
  73265. "Ext.dataview.Disclosable": [],
  73266. "Ext.dataview.EmptyText": [
  73267. "widget.emptytext"
  73268. ],
  73269. "Ext.dataview.GenericItem": [],
  73270. "Ext.dataview.IndexBar": [
  73271. "widget.indexbar"
  73272. ],
  73273. "Ext.dataview.ItemHeader": [
  73274. "widget.itemheader"
  73275. ],
  73276. "Ext.dataview.List": [
  73277. "widget.list"
  73278. ],
  73279. "Ext.dataview.ListItem": [
  73280. "widget.listitem"
  73281. ],
  73282. "Ext.dataview.Location": [],
  73283. "Ext.dataview.NavigationModel": [
  73284. "navmodel.dataview"
  73285. ],
  73286. "Ext.dataview.NestedList": [
  73287. "widget.nestedlist"
  73288. ],
  73289. "Ext.dataview.Pinnable": [],
  73290. "Ext.dataview.SimpleListItem": [
  73291. "widget.simplelistitem"
  73292. ],
  73293. "Ext.dataview.listswiper.Accordion": [
  73294. "widget.listswiperaccordion"
  73295. ],
  73296. "Ext.dataview.listswiper.Item": [
  73297. "widget.listswiperitem"
  73298. ],
  73299. "Ext.dataview.listswiper.ListSwiper": [
  73300. "plugin.listswiper"
  73301. ],
  73302. "Ext.dataview.listswiper.Stepper": [
  73303. "widget.listswiperstepper"
  73304. ],
  73305. "Ext.dataview.plugin.ItemTip": [
  73306. "plugin.dataviewtip"
  73307. ],
  73308. "Ext.dataview.plugin.ListPaging": [
  73309. "plugin.listpaging"
  73310. ],
  73311. "Ext.dataview.plugin.SortableList": [
  73312. "plugin.sortablelist"
  73313. ],
  73314. "Ext.dataview.pullrefresh.Bar": [
  73315. "widget.pullrefreshbar"
  73316. ],
  73317. "Ext.dataview.pullrefresh.Item": [],
  73318. "Ext.dataview.pullrefresh.PullRefresh": [
  73319. "plugin.pullrefresh"
  73320. ],
  73321. "Ext.dataview.pullrefresh.Spinner": [
  73322. "widget.pullrefreshspinner"
  73323. ],
  73324. "Ext.dataview.selection.Model": [
  73325. "selmodel.dataview"
  73326. ],
  73327. "Ext.dataview.selection.Records": [
  73328. "selection.records"
  73329. ],
  73330. "Ext.dataview.selection.Rows": [
  73331. "selection.rows"
  73332. ],
  73333. "Ext.dataview.selection.Selection": [],
  73334. "Ext.direct.Event": [
  73335. "direct.event"
  73336. ],
  73337. "Ext.direct.ExceptionEvent": [
  73338. "direct.exception"
  73339. ],
  73340. "Ext.direct.JsonProvider": [
  73341. "direct.jsonprovider"
  73342. ],
  73343. "Ext.direct.Manager": [],
  73344. "Ext.direct.PollingProvider": [
  73345. "direct.pollingprovider"
  73346. ],
  73347. "Ext.direct.Provider": [
  73348. "direct.provider"
  73349. ],
  73350. "Ext.direct.RemotingEvent": [
  73351. "direct.rpc"
  73352. ],
  73353. "Ext.direct.RemotingMethod": [],
  73354. "Ext.direct.RemotingProvider": [
  73355. "direct.remotingprovider"
  73356. ],
  73357. "Ext.direct.Transaction": [
  73358. "direct.transaction"
  73359. ],
  73360. "Ext.dom.CompositeElement": [],
  73361. "Ext.dom.CompositeElementLite": [],
  73362. "Ext.dom.Element": [],
  73363. "Ext.dom.ElementEvent": [],
  73364. "Ext.dom.Fly": [],
  73365. "Ext.dom.GarbageCollector": [],
  73366. "Ext.dom.Helper": [],
  73367. "Ext.dom.Query": [],
  73368. "Ext.dom.Shadow": [],
  73369. "Ext.dom.Shim": [],
  73370. "Ext.dom.TouchAction": [],
  73371. "Ext.dom.Underlay": [],
  73372. "Ext.dom.UnderlayPool": [],
  73373. "Ext.drag.Constraint": [
  73374. "drag.constraint.base"
  73375. ],
  73376. "Ext.drag.Info": [],
  73377. "Ext.drag.Item": [],
  73378. "Ext.drag.Manager": [],
  73379. "Ext.drag.Source": [],
  73380. "Ext.drag.Target": [],
  73381. "Ext.drag.proxy.None": [
  73382. "drag.proxy.none"
  73383. ],
  73384. "Ext.drag.proxy.Original": [
  73385. "drag.proxy.original"
  73386. ],
  73387. "Ext.drag.proxy.Placeholder": [
  73388. "drag.proxy.placeholder"
  73389. ],
  73390. "Ext.event.Event": [],
  73391. "Ext.event.gesture.DoubleTap": [],
  73392. "Ext.event.gesture.Drag": [],
  73393. "Ext.event.gesture.EdgeSwipe": [],
  73394. "Ext.event.gesture.LongPress": [],
  73395. "Ext.event.gesture.MultiTouch": [],
  73396. "Ext.event.gesture.Pinch": [],
  73397. "Ext.event.gesture.Recognizer": [],
  73398. "Ext.event.gesture.Rotate": [],
  73399. "Ext.event.gesture.SingleTouch": [],
  73400. "Ext.event.gesture.Swipe": [],
  73401. "Ext.event.gesture.Tap": [],
  73402. "Ext.event.publisher.Dom": [],
  73403. "Ext.event.publisher.ElementPaint": [],
  73404. "Ext.event.publisher.ElementSize": [],
  73405. "Ext.event.publisher.Focus": [],
  73406. "Ext.event.publisher.Gesture": [],
  73407. "Ext.event.publisher.Publisher": [],
  73408. "Ext.field.BoxLabelable": [],
  73409. "Ext.field.Checkbox": [
  73410. "widget.checkbox",
  73411. "widget.checkboxfield"
  73412. ],
  73413. "Ext.field.ComboBox": [
  73414. "widget.combobox",
  73415. "widget.comboboxfield"
  73416. ],
  73417. "Ext.field.Container": [
  73418. "widget.containerfield",
  73419. "widget.fieldcontainer"
  73420. ],
  73421. "Ext.field.Date": [
  73422. "widget.datefield",
  73423. "widget.datepickerfield"
  73424. ],
  73425. "Ext.field.DatePickerNative": [
  73426. "widget.datepickernativefield"
  73427. ],
  73428. "Ext.field.Display": [
  73429. "widget.displayfield"
  73430. ],
  73431. "Ext.field.Email": [
  73432. "widget.emailfield"
  73433. ],
  73434. "Ext.field.Field": [
  73435. "widget.field"
  73436. ],
  73437. "Ext.field.File": [
  73438. "widget.filefield"
  73439. ],
  73440. "Ext.field.FileButton": [
  73441. "widget.filebutton"
  73442. ],
  73443. "Ext.field.Hidden": [
  73444. "widget.hiddenfield"
  73445. ],
  73446. "Ext.field.Input": [
  73447. "widget.inputfield"
  73448. ],
  73449. "Ext.field.InputMask": [],
  73450. "Ext.field.Manager": [],
  73451. "Ext.field.Number": [
  73452. "widget.numberfield"
  73453. ],
  73454. "Ext.field.Panel": [
  73455. "widget.fieldpanel"
  73456. ],
  73457. "Ext.field.Password": [
  73458. "widget.passwordfield"
  73459. ],
  73460. "Ext.field.Picker": [
  73461. "widget.pickerfield"
  73462. ],
  73463. "Ext.field.Radio": [
  73464. "widget.radio",
  73465. "widget.radiofield"
  73466. ],
  73467. "Ext.field.Search": [
  73468. "widget.searchfield"
  73469. ],
  73470. "Ext.field.Select": [
  73471. "widget.selectfield"
  73472. ],
  73473. "Ext.field.SingleSlider": [
  73474. "widget.singlesliderfield"
  73475. ],
  73476. "Ext.field.Slider": [
  73477. "widget.sliderfield"
  73478. ],
  73479. "Ext.field.Spinner": [
  73480. "widget.spinnerfield"
  73481. ],
  73482. "Ext.field.Text": [
  73483. "widget.textfield"
  73484. ],
  73485. "Ext.field.TextArea": [
  73486. "widget.textareafield"
  73487. ],
  73488. "Ext.field.Time": [
  73489. "widget.timefield"
  73490. ],
  73491. "Ext.field.Toggle": [
  73492. "widget.togglefield"
  73493. ],
  73494. "Ext.field.Url": [
  73495. "widget.urlfield"
  73496. ],
  73497. "Ext.field.trigger.Base": [
  73498. "trigger.base"
  73499. ],
  73500. "Ext.field.trigger.Clear": [
  73501. "trigger.clear",
  73502. "widget.cleartrigger"
  73503. ],
  73504. "Ext.field.trigger.Component": [
  73505. "trigger.component"
  73506. ],
  73507. "Ext.field.trigger.Date": [
  73508. "trigger.date",
  73509. "widget.datetrigger"
  73510. ],
  73511. "Ext.field.trigger.Expand": [
  73512. "trigger.expand",
  73513. "widget.expandtrigger"
  73514. ],
  73515. "Ext.field.trigger.File": [
  73516. "trigger.file"
  73517. ],
  73518. "Ext.field.trigger.Menu": [
  73519. "trigger.menu",
  73520. "widget.menutrigger"
  73521. ],
  73522. "Ext.field.trigger.Reveal": [
  73523. "trigger.reveal",
  73524. "widget.revealtrigger"
  73525. ],
  73526. "Ext.field.trigger.Search": [
  73527. "trigger.search",
  73528. "widget.searchtrigger"
  73529. ],
  73530. "Ext.field.trigger.SpinDown": [
  73531. "trigger.spindown",
  73532. "widget.spindowntrigger"
  73533. ],
  73534. "Ext.field.trigger.SpinUp": [
  73535. "trigger.spinup",
  73536. "widget.spinuptrigger"
  73537. ],
  73538. "Ext.field.trigger.Time": [
  73539. "trigger.time",
  73540. "widget.timetrigger"
  73541. ],
  73542. "Ext.field.trigger.Trigger": [
  73543. "trigger.trigger",
  73544. "widget.trigger"
  73545. ],
  73546. "Ext.form.Borders": [],
  73547. "Ext.form.FieldSet": [
  73548. "widget.fieldset"
  73549. ],
  73550. "Ext.form.Panel": [
  73551. "widget.formpanel"
  73552. ],
  73553. "Ext.fx.Animation": [],
  73554. "Ext.fx.Runner": [],
  73555. "Ext.fx.State": [],
  73556. "Ext.fx.animation.Abstract": [],
  73557. "Ext.fx.animation.Cube": [
  73558. "animation.cube"
  73559. ],
  73560. "Ext.fx.animation.Fade": [
  73561. "animation.fade",
  73562. "animation.fadeIn"
  73563. ],
  73564. "Ext.fx.animation.FadeOut": [
  73565. "animation.fadeOut"
  73566. ],
  73567. "Ext.fx.animation.Flip": [
  73568. "animation.flip"
  73569. ],
  73570. "Ext.fx.animation.Pop": [
  73571. "animation.pop",
  73572. "animation.popIn"
  73573. ],
  73574. "Ext.fx.animation.PopOut": [
  73575. "animation.popOut"
  73576. ],
  73577. "Ext.fx.animation.Slide": [
  73578. "animation.slide",
  73579. "animation.slideIn"
  73580. ],
  73581. "Ext.fx.animation.SlideOut": [
  73582. "animation.slideOut"
  73583. ],
  73584. "Ext.fx.animation.Wipe": [],
  73585. "Ext.fx.animation.WipeOut": [],
  73586. "Ext.fx.easing.Abstract": [],
  73587. "Ext.fx.easing.Bounce": [],
  73588. "Ext.fx.easing.BoundMomentum": [],
  73589. "Ext.fx.easing.EaseIn": [
  73590. "easing.ease-in"
  73591. ],
  73592. "Ext.fx.easing.EaseOut": [
  73593. "easing.ease-out"
  73594. ],
  73595. "Ext.fx.easing.Easing": [],
  73596. "Ext.fx.easing.Linear": [
  73597. "easing.linear"
  73598. ],
  73599. "Ext.fx.easing.Momentum": [],
  73600. "Ext.fx.runner.Css": [],
  73601. "Ext.fx.runner.CssAnimation": [],
  73602. "Ext.fx.runner.CssTransition": [],
  73603. "Ext.grid.CellEditor": [
  73604. "widget.celleditor"
  73605. ],
  73606. "Ext.grid.Grid": [
  73607. "widget.grid"
  73608. ],
  73609. "Ext.grid.HeaderContainer": [
  73610. "widget.headercontainer"
  73611. ],
  73612. "Ext.grid.Location": [],
  73613. "Ext.grid.NavigationModel": [
  73614. "navmodel.grid"
  73615. ],
  73616. "Ext.grid.PagingToolbar": [
  73617. "widget.pagingtoolbar"
  73618. ],
  73619. "Ext.grid.Row": [
  73620. "widget.gridrow"
  73621. ],
  73622. "Ext.grid.RowBody": [
  73623. "widget.rowbody"
  73624. ],
  73625. "Ext.grid.RowHeader": [
  73626. "widget.rowheader"
  73627. ],
  73628. "Ext.grid.SummaryRow": [
  73629. "widget.gridsummaryrow"
  73630. ],
  73631. "Ext.grid.Tree": [
  73632. "widget.tree"
  73633. ],
  73634. "Ext.grid.cell.Base": [
  73635. "widget.gridcellbase"
  73636. ],
  73637. "Ext.grid.cell.Boolean": [
  73638. "widget.booleancell"
  73639. ],
  73640. "Ext.grid.cell.Cell": [
  73641. "widget.gridcell"
  73642. ],
  73643. "Ext.grid.cell.Check": [
  73644. "widget.checkcell"
  73645. ],
  73646. "Ext.grid.cell.Date": [
  73647. "widget.datecell"
  73648. ],
  73649. "Ext.grid.cell.Expander": [
  73650. "widget.expandercell"
  73651. ],
  73652. "Ext.grid.cell.Number": [
  73653. "widget.numbercell"
  73654. ],
  73655. "Ext.grid.cell.RowNumberer": [
  73656. "widget.rownumberercell"
  73657. ],
  73658. "Ext.grid.cell.Text": [
  73659. "widget.textcell"
  73660. ],
  73661. "Ext.grid.cell.Tree": [
  73662. "widget.treecell"
  73663. ],
  73664. "Ext.grid.cell.Widget": [
  73665. "widget.widgetcell"
  73666. ],
  73667. "Ext.grid.column.Boolean": [
  73668. "widget.booleancolumn"
  73669. ],
  73670. "Ext.grid.column.Check": [
  73671. "widget.checkcolumn"
  73672. ],
  73673. "Ext.grid.column.Column": [
  73674. "widget.column",
  73675. "widget.gridcolumn",
  73676. "widget.templatecolumn"
  73677. ],
  73678. "Ext.grid.column.Date": [
  73679. "widget.datecolumn"
  73680. ],
  73681. "Ext.grid.column.Number": [
  73682. "widget.numbercolumn"
  73683. ],
  73684. "Ext.grid.column.RowNumberer": [
  73685. "widget.rownumberer"
  73686. ],
  73687. "Ext.grid.column.Selection": [
  73688. "widget.selectioncolumn"
  73689. ],
  73690. "Ext.grid.column.Text": [
  73691. "widget.textcolumn"
  73692. ],
  73693. "Ext.grid.column.Tree": [
  73694. "widget.treecolumn"
  73695. ],
  73696. "Ext.grid.menu.Columns": [
  73697. "widget.gridcolumnsmenu"
  73698. ],
  73699. "Ext.grid.menu.GroupByThis": [
  73700. "widget.gridgroupbythismenuitem"
  73701. ],
  73702. "Ext.grid.menu.ShowInGroups": [
  73703. "widget.gridshowingroupsmenuitem"
  73704. ],
  73705. "Ext.grid.menu.SortAsc": [
  73706. "widget.gridsortascmenuitem"
  73707. ],
  73708. "Ext.grid.menu.SortDesc": [
  73709. "widget.gridsortdescmenuitem"
  73710. ],
  73711. "Ext.grid.plugin.CellEditing": [
  73712. "plugin.cellediting",
  73713. "plugin.gridcellediting"
  73714. ],
  73715. "Ext.grid.plugin.Clipboard": [
  73716. "plugin.clipboard"
  73717. ],
  73718. "Ext.grid.plugin.ColumnResizing": [
  73719. "plugin.columnresizing",
  73720. "plugin.gridcolumnresizing"
  73721. ],
  73722. "Ext.grid.plugin.Editable": [
  73723. "plugin.grideditable"
  73724. ],
  73725. "Ext.grid.plugin.PagingToolbar": [
  73726. "plugin.gridpagingtoolbar",
  73727. "plugin.pagingtoolbar"
  73728. ],
  73729. "Ext.grid.plugin.RowExpander": [
  73730. "plugin.rowexpander"
  73731. ],
  73732. "Ext.grid.plugin.RowOperations": [
  73733. "plugin.gridmultiselection",
  73734. "plugin.multiselection",
  73735. "plugin.rowoperations"
  73736. ],
  73737. "Ext.grid.plugin.Summary": [
  73738. "plugin.gridsummary",
  73739. "plugin.gridsummaryrow",
  73740. "plugin.summaryrow"
  73741. ],
  73742. "Ext.grid.plugin.ViewOptions": [
  73743. "plugin.gridviewoptions"
  73744. ],
  73745. "Ext.grid.plugin.ViewOptionsListItem": [
  73746. "widget.viewoptionslistitem"
  73747. ],
  73748. "Ext.grid.selection.Cells": [
  73749. "selection.cells"
  73750. ],
  73751. "Ext.grid.selection.Columns": [
  73752. "selection.columns"
  73753. ],
  73754. "Ext.grid.selection.Model": [
  73755. "selmodel.grid"
  73756. ],
  73757. "Ext.grid.selection.Replicator": [
  73758. "plugin.selectionreplicator"
  73759. ],
  73760. "Ext.grid.selection.SelectionExtender": [],
  73761. "Ext.layout.Auto": [
  73762. "layout.auto",
  73763. "layout.default"
  73764. ],
  73765. "Ext.layout.Box": [
  73766. "layout.box"
  73767. ],
  73768. "Ext.layout.Card": [
  73769. "layout.card"
  73770. ],
  73771. "Ext.layout.Carousel": [
  73772. "layout.carousel"
  73773. ],
  73774. "Ext.layout.Center": [
  73775. "layout.center"
  73776. ],
  73777. "Ext.layout.Fit": [
  73778. "layout.fit"
  73779. ],
  73780. "Ext.layout.Float": [
  73781. "layout.float"
  73782. ],
  73783. "Ext.layout.Form": [
  73784. "layout.form"
  73785. ],
  73786. "Ext.layout.HBox": [
  73787. "layout.hbox"
  73788. ],
  73789. "Ext.layout.VBox": [
  73790. "layout.vbox"
  73791. ],
  73792. "Ext.layout.card.fx.Abstract": [
  73793. "layout.card.fx.abstract"
  73794. ],
  73795. "Ext.layout.card.fx.Cover": [
  73796. "layout.card.fx.cover"
  73797. ],
  73798. "Ext.layout.card.fx.Cube": [
  73799. "layout.card.fx.cube"
  73800. ],
  73801. "Ext.layout.card.fx.Fade": [
  73802. "layout.card.fx.fade"
  73803. ],
  73804. "Ext.layout.card.fx.Flip": [
  73805. "layout.card.fx.flip"
  73806. ],
  73807. "Ext.layout.card.fx.Pop": [
  73808. "layout.card.fx.pop"
  73809. ],
  73810. "Ext.layout.card.fx.Reveal": [
  73811. "layout.card.fx.reveal"
  73812. ],
  73813. "Ext.layout.card.fx.Scroll": [
  73814. "layout.card.fx.scroll"
  73815. ],
  73816. "Ext.layout.card.fx.ScrollCover": [
  73817. "layout.card.fx.scrollcover"
  73818. ],
  73819. "Ext.layout.card.fx.ScrollReveal": [
  73820. "layout.card.fx.scrollreveal"
  73821. ],
  73822. "Ext.layout.card.fx.Serial": [],
  73823. "Ext.layout.card.fx.Slide": [
  73824. "layout.card.fx.slide"
  73825. ],
  73826. "Ext.layout.card.fx.Style": [],
  73827. "Ext.layout.overflow.Scroller": [
  73828. "layout.overflow.scroller"
  73829. ],
  73830. "Ext.layout.wrapper.BoxDock": [],
  73831. "Ext.layout.wrapper.Inner": [],
  73832. "Ext.list.AbstractTreeItem": [],
  73833. "Ext.list.Location": [],
  73834. "Ext.list.RootTreeItem": [],
  73835. "Ext.list.Tree": [
  73836. "widget.treelist"
  73837. ],
  73838. "Ext.list.TreeItem": [
  73839. "widget.treelistitem"
  73840. ],
  73841. "Ext.menu.CheckItem": [
  73842. "widget.menucheckitem"
  73843. ],
  73844. "Ext.menu.Item": [
  73845. "widget.menuitem"
  73846. ],
  73847. "Ext.menu.Manager": [],
  73848. "Ext.menu.Menu": [
  73849. "widget.menu"
  73850. ],
  73851. "Ext.menu.RadioItem": [
  73852. "widget.menuradioitem"
  73853. ],
  73854. "Ext.menu.Separator": [
  73855. "widget.menuseparator"
  73856. ],
  73857. "Ext.mixin.Accessible": [],
  73858. "Ext.mixin.Bindable": [],
  73859. "Ext.mixin.Bufferable": [],
  73860. "Ext.mixin.ComponentDelegation": [],
  73861. "Ext.mixin.ConfigProxy": [],
  73862. "Ext.mixin.ConfigState": [],
  73863. "Ext.mixin.Container": [],
  73864. "Ext.mixin.Dirty": [],
  73865. "Ext.mixin.Factoryable": [],
  73866. "Ext.mixin.Focusable": [],
  73867. "Ext.mixin.FocusableContainer": [],
  73868. "Ext.mixin.Hookable": [],
  73869. "Ext.mixin.Inheritable": [],
  73870. "Ext.mixin.ItemRippler": [],
  73871. "Ext.mixin.Keyboard": [],
  73872. "Ext.mixin.Mashup": [],
  73873. "Ext.mixin.Pluggable": [],
  73874. "Ext.mixin.Progressable": [],
  73875. "Ext.mixin.Queryable": [],
  73876. "Ext.mixin.Responsive": [],
  73877. "Ext.mixin.Selectable": [],
  73878. "Ext.mixin.StoreWatcher": [],
  73879. "Ext.mixin.StyleCacher": [],
  73880. "Ext.mixin.Templatable": [],
  73881. "Ext.mixin.Toolable": [],
  73882. "Ext.mixin.Traversable": [],
  73883. "Ext.navigation.Bar": [],
  73884. "Ext.navigation.View": [
  73885. "widget.navigationview"
  73886. ],
  73887. "Ext.override.sparkline.Base": [],
  73888. "Ext.overrides.Progress": [],
  73889. "Ext.overrides.Widget": [],
  73890. "Ext.overrides.app.Application": [],
  73891. "Ext.overrides.dom.Element": [],
  73892. "Ext.overrides.drag.proxy.Placeholder": [],
  73893. "Ext.overrides.list.Tree": [],
  73894. "Ext.overrides.list.TreeItem": [],
  73895. "Ext.panel.Collapser": [],
  73896. "Ext.panel.Collapsible": [],
  73897. "Ext.panel.Date": [
  73898. "widget.datepanel"
  73899. ],
  73900. "Ext.panel.DateTitle": [
  73901. "widget.datetitle"
  73902. ],
  73903. "Ext.panel.DateView": [
  73904. "widget.dateview"
  73905. ],
  73906. "Ext.panel.Header": [
  73907. "widget.panelheader"
  73908. ],
  73909. "Ext.panel.Resizable": [],
  73910. "Ext.panel.Resizer": [],
  73911. "Ext.panel.Time": [
  73912. "widget.timepanel"
  73913. ],
  73914. "Ext.panel.TimeHeader": [
  73915. "widget.analogtimeheader"
  73916. ],
  73917. "Ext.panel.TimeView": [
  73918. "widget.analogtime"
  73919. ],
  73920. "Ext.panel.Title": [
  73921. "widget.paneltitle"
  73922. ],
  73923. "Ext.panel.YearPicker": [
  73924. "widget.yearpicker"
  73925. ],
  73926. "Ext.parse.Parser": [],
  73927. "Ext.parse.Symbol": [],
  73928. "Ext.parse.Tokenizer": [],
  73929. "Ext.parse.symbol.Constant": [],
  73930. "Ext.parse.symbol.Infix": [],
  73931. "Ext.parse.symbol.InfixRight": [],
  73932. "Ext.parse.symbol.Paren": [],
  73933. "Ext.parse.symbol.Prefix": [],
  73934. "Ext.perf.Accumulator": [],
  73935. "Ext.perf.Monitor": [],
  73936. "Ext.picker.Date": [
  73937. "widget.datepicker"
  73938. ],
  73939. "Ext.picker.Picker": [
  73940. "widget.picker"
  73941. ],
  73942. "Ext.picker.Slot": [
  73943. "widget.pickerslot"
  73944. ],
  73945. "Ext.picker.Tablet": [
  73946. "widget.tabletpicker"
  73947. ],
  73948. "Ext.plugin.Abstract": [],
  73949. "Ext.plugin.AbstractClipboard": [],
  73950. "Ext.plugin.MouseEnter": [
  73951. "plugin.mouseenter"
  73952. ],
  73953. "Ext.plugin.Responsive": [
  73954. "plugin.responsive"
  73955. ],
  73956. "Ext.plugin.TabGuard": [
  73957. "plugin.tabguard"
  73958. ],
  73959. "Ext.promise.Consequence": [],
  73960. "Ext.promise.Deferred": [],
  73961. "Ext.promise.Promise": [],
  73962. "Ext.route.Action": [],
  73963. "Ext.route.Handler": [],
  73964. "Ext.route.Mixin": [],
  73965. "Ext.route.Route": [],
  73966. "Ext.route.Router": [],
  73967. "Ext.scroll.Scroller": [
  73968. "scroller.scroller"
  73969. ],
  73970. "Ext.slider.Slider": [
  73971. "widget.slider"
  73972. ],
  73973. "Ext.slider.Thumb": [
  73974. "widget.thumb"
  73975. ],
  73976. "Ext.slider.Toggle": [
  73977. "widget.toggleslider"
  73978. ],
  73979. "Ext.sparkline.Bar": [
  73980. "widget.sparklinebar"
  73981. ],
  73982. "Ext.sparkline.BarBase": [],
  73983. "Ext.sparkline.Base": [
  73984. "widget.sparkline"
  73985. ],
  73986. "Ext.sparkline.Box": [
  73987. "widget.sparklinebox"
  73988. ],
  73989. "Ext.sparkline.Bullet": [
  73990. "widget.sparklinebullet"
  73991. ],
  73992. "Ext.sparkline.CanvasBase": [],
  73993. "Ext.sparkline.CanvasCanvas": [],
  73994. "Ext.sparkline.Discrete": [
  73995. "widget.sparklinediscrete"
  73996. ],
  73997. "Ext.sparkline.Line": [
  73998. "widget.sparklineline"
  73999. ],
  74000. "Ext.sparkline.Pie": [
  74001. "widget.sparklinepie"
  74002. ],
  74003. "Ext.sparkline.RangeMap": [],
  74004. "Ext.sparkline.Shape": [],
  74005. "Ext.sparkline.TriState": [
  74006. "widget.sparklinetristate"
  74007. ],
  74008. "Ext.sparkline.VmlCanvas": [],
  74009. "Ext.tab.Bar": [
  74010. "widget.tabbar"
  74011. ],
  74012. "Ext.tab.Panel": [
  74013. "widget.tabpanel"
  74014. ],
  74015. "Ext.tab.Tab": [
  74016. "widget.tab"
  74017. ],
  74018. "Ext.tip.Manager": [],
  74019. "Ext.tip.ToolTip": [
  74020. "widget.tooltip"
  74021. ],
  74022. "Ext.util.AbstractMixedCollection": [],
  74023. "Ext.util.Audio": [],
  74024. "Ext.util.Bag": [],
  74025. "Ext.util.Base64": [],
  74026. "Ext.util.BufferedCollection": [],
  74027. "Ext.util.CSS": [],
  74028. "Ext.util.CSV": [],
  74029. "Ext.util.ClickRepeater": [],
  74030. "Ext.util.Collection": [],
  74031. "Ext.util.CollectionKey": [],
  74032. "Ext.util.Color": [],
  74033. "Ext.util.Cookies": [],
  74034. "Ext.util.DelimitedValue": [],
  74035. "Ext.util.Draggable": [],
  74036. "Ext.util.Filter": [],
  74037. "Ext.util.FilterCollection": [],
  74038. "Ext.util.Fly": [],
  74039. "Ext.util.Format": [],
  74040. "Ext.util.Geolocation": [],
  74041. "Ext.util.Group": [],
  74042. "Ext.util.GroupCollection": [],
  74043. "Ext.util.Grouper": [],
  74044. "Ext.util.HashMap": [],
  74045. "Ext.util.History": [],
  74046. "Ext.util.Inflector": [],
  74047. "Ext.util.InputBlocker": [],
  74048. "Ext.util.ItemCollection": [],
  74049. "Ext.util.KeyMap": [],
  74050. "Ext.util.KeyNav": [],
  74051. "Ext.util.LineSegment": [],
  74052. "Ext.util.LocalStorage": [],
  74053. "Ext.util.LruCache": [],
  74054. "Ext.util.MixedCollection": [],
  74055. "Ext.util.ObjectTemplate": [],
  74056. "Ext.util.Observable": [],
  74057. "Ext.util.Offset": [],
  74058. "Ext.util.PaintMonitor": [],
  74059. "Ext.util.Point": [],
  74060. "Ext.util.PositionMap": [],
  74061. "Ext.util.Positionable": [],
  74062. "Ext.util.Region": [],
  74063. "Ext.util.Schedulable": [],
  74064. "Ext.util.Scheduler": [],
  74065. "Ext.util.SizeMonitor": [],
  74066. "Ext.util.Sortable": [],
  74067. "Ext.util.Sorter": [],
  74068. "Ext.util.SorterCollection": [],
  74069. "Ext.util.Spans": [],
  74070. "Ext.util.TextMetrics": [],
  74071. "Ext.util.TranslatableGroup": [],
  74072. "Ext.util.TranslatableList": [],
  74073. "Ext.util.TsvDecoder": [],
  74074. "Ext.util.Wrapper": [],
  74075. "Ext.util.XTemplateCompiler": [],
  74076. "Ext.util.XTemplateParser": [],
  74077. "Ext.util.paintmonitor.Abstract": [],
  74078. "Ext.util.paintmonitor.CssAnimation": [],
  74079. "Ext.util.paintmonitor.OverflowChange": [],
  74080. "Ext.util.sizemonitor.Abstract": [],
  74081. "Ext.util.sizemonitor.OverflowChange": [],
  74082. "Ext.util.sizemonitor.Scroll": [],
  74083. "Ext.util.translatable.Abstract": [],
  74084. "Ext.util.translatable.Component": [
  74085. "translatable.component"
  74086. ],
  74087. "Ext.util.translatable.CssPosition": [
  74088. "translatable.cssposition"
  74089. ],
  74090. "Ext.util.translatable.CssTransform": [
  74091. "translatable.csstransform"
  74092. ],
  74093. "Ext.util.translatable.Dom": [
  74094. "translatable.dom"
  74095. ],
  74096. "Ext.util.translatable.ScrollParent": [
  74097. "translatable.scrollparent"
  74098. ],
  74099. "Ext.util.translatable.ScrollPosition": [
  74100. "translatable.scrollposition"
  74101. ],
  74102. "Ext.viewport.Android": [],
  74103. "Ext.viewport.Default": [
  74104. "widget.viewport"
  74105. ],
  74106. "Ext.viewport.Ios": [],
  74107. "Ext.viewport.Viewport": [],
  74108. "Ext.viewport.WindowsPhone": []
  74109. });