ext-all-debug.js 909 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805
  1. /*
  2. * Ext JS Library 2.0.2
  3. * Copyright(c) 2006-2008, Ext JS, LLC.
  4. * licensing@extjs.com
  5. *
  6. * http://extjs.com/license
  7. */
  8. Ext.DomHelper = function(){
  9. var tempTableEl = null;
  10. var emptyTags = /^(?:br|frame|hr|img|input|link|meta|range|spacer|wbr|area|param|col)$/i;
  11. var tableRe = /^table|tbody|tr|td$/i;
  12. var createHtml = function(o){
  13. if(typeof o == 'string'){
  14. return o;
  15. }
  16. var b = "";
  17. if (Ext.isArray(o)) {
  18. for (var i = 0, l = o.length; i < l; i++) {
  19. b += createHtml(o[i]);
  20. }
  21. return b;
  22. }
  23. if(!o.tag){
  24. o.tag = "div";
  25. }
  26. b += "<" + o.tag;
  27. for(var attr in o){
  28. if(attr == "tag" || attr == "children" || attr == "cn" || attr == "html" || typeof o[attr] == "function") continue;
  29. if(attr == "style"){
  30. var s = o["style"];
  31. if(typeof s == "function"){
  32. s = s.call();
  33. }
  34. if(typeof s == "string"){
  35. b += ' style="' + s + '"';
  36. }else if(typeof s == "object"){
  37. b += ' style="';
  38. for(var key in s){
  39. if(typeof s[key] != "function"){
  40. b += key + ":" + s[key] + ";";
  41. }
  42. }
  43. b += '"';
  44. }
  45. }else{
  46. if(attr == "cls"){
  47. b += ' class="' + o["cls"] + '"';
  48. }else if(attr == "htmlFor"){
  49. b += ' for="' + o["htmlFor"] + '"';
  50. }else{
  51. b += " " + attr + '="' + o[attr] + '"';
  52. }
  53. }
  54. }
  55. if(emptyTags.test(o.tag)){
  56. b += "/>";
  57. }else{
  58. b += ">";
  59. var cn = o.children || o.cn;
  60. if(cn){
  61. b += createHtml(cn);
  62. } else if(o.html){
  63. b += o.html;
  64. }
  65. b += "</" + o.tag + ">";
  66. }
  67. return b;
  68. };
  69. var createDom = function(o, parentNode){
  70. var el;
  71. if (Ext.isArray(o)) {
  72. el = document.createDocumentFragment();
  73. for(var i = 0, l = o.length; i < l; i++) {
  74. createDom(o[i], el);
  75. }
  76. } else if (typeof o == "string)") {
  77. el = document.createTextNode(o);
  78. } else {
  79. el = document.createElement(o.tag||'div');
  80. var useSet = !!el.setAttribute;
  81. for(var attr in o){
  82. if(attr == "tag" || attr == "children" || attr == "cn" || attr == "html" || attr == "style" || typeof o[attr] == "function") continue;
  83. if(attr=="cls"){
  84. el.className = o["cls"];
  85. }else{
  86. if(useSet) el.setAttribute(attr, o[attr]);
  87. else el[attr] = o[attr];
  88. }
  89. }
  90. Ext.DomHelper.applyStyles(el, o.style);
  91. var cn = o.children || o.cn;
  92. if(cn){
  93. createDom(cn, el);
  94. } else if(o.html){
  95. el.innerHTML = o.html;
  96. }
  97. }
  98. if(parentNode){
  99. parentNode.appendChild(el);
  100. }
  101. return el;
  102. };
  103. var ieTable = function(depth, s, h, e){
  104. tempTableEl.innerHTML = [s, h, e].join('');
  105. var i = -1, el = tempTableEl;
  106. while(++i < depth){
  107. el = el.firstChild;
  108. }
  109. return el;
  110. };
  111. var ts = '<table>',
  112. te = '</table>',
  113. tbs = ts+'<tbody>',
  114. tbe = '</tbody>'+te,
  115. trs = tbs + '<tr>',
  116. tre = '</tr>'+tbe;
  117. var insertIntoTable = function(tag, where, el, html){
  118. if(!tempTableEl){
  119. tempTableEl = document.createElement('div');
  120. }
  121. var node;
  122. var before = null;
  123. if(tag == 'td'){
  124. if(where == 'afterbegin' || where == 'beforeend'){
  125. return;
  126. }
  127. if(where == 'beforebegin'){
  128. before = el;
  129. el = el.parentNode;
  130. } else{
  131. before = el.nextSibling;
  132. el = el.parentNode;
  133. }
  134. node = ieTable(4, trs, html, tre);
  135. }
  136. else if(tag == 'tr'){
  137. if(where == 'beforebegin'){
  138. before = el;
  139. el = el.parentNode;
  140. node = ieTable(3, tbs, html, tbe);
  141. } else if(where == 'afterend'){
  142. before = el.nextSibling;
  143. el = el.parentNode;
  144. node = ieTable(3, tbs, html, tbe);
  145. } else{
  146. if(where == 'afterbegin'){
  147. before = el.firstChild;
  148. }
  149. node = ieTable(4, trs, html, tre);
  150. }
  151. } else if(tag == 'tbody'){
  152. if(where == 'beforebegin'){
  153. before = el;
  154. el = el.parentNode;
  155. node = ieTable(2, ts, html, te);
  156. } else if(where == 'afterend'){
  157. before = el.nextSibling;
  158. el = el.parentNode;
  159. node = ieTable(2, ts, html, te);
  160. } else{
  161. if(where == 'afterbegin'){
  162. before = el.firstChild;
  163. }
  164. node = ieTable(3, tbs, html, tbe);
  165. }
  166. } else{
  167. if(where == 'beforebegin' || where == 'afterend'){
  168. return;
  169. }
  170. if(where == 'afterbegin'){
  171. before = el.firstChild;
  172. }
  173. node = ieTable(2, ts, html, te);
  174. }
  175. el.insertBefore(node, before);
  176. return node;
  177. };
  178. return {
  179. useDom : false,
  180. markup : function(o){
  181. return createHtml(o);
  182. },
  183. applyStyles : function(el, styles){
  184. if(styles){
  185. el = Ext.fly(el);
  186. if(typeof styles == "string"){
  187. var re = /\s?([a-z\-]*)\:\s?([^;]*);?/gi;
  188. var matches;
  189. while ((matches = re.exec(styles)) != null){
  190. el.setStyle(matches[1], matches[2]);
  191. }
  192. }else if (typeof styles == "object"){
  193. for (var style in styles){
  194. el.setStyle(style, styles[style]);
  195. }
  196. }else if (typeof styles == "function"){
  197. Ext.DomHelper.applyStyles(el, styles.call());
  198. }
  199. }
  200. },
  201. insertHtml : function(where, el, html){
  202. where = where.toLowerCase();
  203. if(el.insertAdjacentHTML){
  204. if(tableRe.test(el.tagName)){
  205. var rs;
  206. if(rs = insertIntoTable(el.tagName.toLowerCase(), where, el, html)){
  207. return rs;
  208. }
  209. }
  210. switch(where){
  211. case "beforebegin":
  212. el.insertAdjacentHTML('BeforeBegin', html);
  213. return el.previousSibling;
  214. case "afterbegin":
  215. el.insertAdjacentHTML('AfterBegin', html);
  216. return el.firstChild;
  217. case "beforeend":
  218. el.insertAdjacentHTML('BeforeEnd', html);
  219. return el.lastChild;
  220. case "afterend":
  221. el.insertAdjacentHTML('AfterEnd', html);
  222. return el.nextSibling;
  223. }
  224. throw 'Illegal insertion point -> "' + where + '"';
  225. }
  226. var range = el.ownerDocument.createRange();
  227. var frag;
  228. switch(where){
  229. case "beforebegin":
  230. range.setStartBefore(el);
  231. frag = range.createContextualFragment(html);
  232. el.parentNode.insertBefore(frag, el);
  233. return el.previousSibling;
  234. case "afterbegin":
  235. if(el.firstChild){
  236. range.setStartBefore(el.firstChild);
  237. frag = range.createContextualFragment(html);
  238. el.insertBefore(frag, el.firstChild);
  239. return el.firstChild;
  240. }else{
  241. el.innerHTML = html;
  242. return el.firstChild;
  243. }
  244. case "beforeend":
  245. if(el.lastChild){
  246. range.setStartAfter(el.lastChild);
  247. frag = range.createContextualFragment(html);
  248. el.appendChild(frag);
  249. return el.lastChild;
  250. }else{
  251. el.innerHTML = html;
  252. return el.lastChild;
  253. }
  254. case "afterend":
  255. range.setStartAfter(el);
  256. frag = range.createContextualFragment(html);
  257. el.parentNode.insertBefore(frag, el.nextSibling);
  258. return el.nextSibling;
  259. }
  260. throw 'Illegal insertion point -> "' + where + '"';
  261. },
  262. insertBefore : function(el, o, returnElement){
  263. return this.doInsert(el, o, returnElement, "beforeBegin");
  264. },
  265. insertAfter : function(el, o, returnElement){
  266. return this.doInsert(el, o, returnElement, "afterEnd", "nextSibling");
  267. },
  268. insertFirst : function(el, o, returnElement){
  269. return this.doInsert(el, o, returnElement, "afterBegin", "firstChild");
  270. },
  271. doInsert : function(el, o, returnElement, pos, sibling){
  272. el = Ext.getDom(el);
  273. var newNode;
  274. if(this.useDom){
  275. newNode = createDom(o, null);
  276. (sibling === "firstChild" ? el : el.parentNode).insertBefore(newNode, sibling ? el[sibling] : el);
  277. }else{
  278. var html = createHtml(o);
  279. newNode = this.insertHtml(pos, el, html);
  280. }
  281. return returnElement ? Ext.get(newNode, true) : newNode;
  282. },
  283. append : function(el, o, returnElement){
  284. el = Ext.getDom(el);
  285. var newNode;
  286. if(this.useDom){
  287. newNode = createDom(o, null);
  288. el.appendChild(newNode);
  289. }else{
  290. var html = createHtml(o);
  291. newNode = this.insertHtml("beforeEnd", el, html);
  292. }
  293. return returnElement ? Ext.get(newNode, true) : newNode;
  294. },
  295. overwrite : function(el, o, returnElement){
  296. el = Ext.getDom(el);
  297. el.innerHTML = createHtml(o);
  298. return returnElement ? Ext.get(el.firstChild, true) : el.firstChild;
  299. },
  300. createTemplate : function(o){
  301. var html = createHtml(o);
  302. return new Ext.Template(html);
  303. }
  304. };
  305. }();
  306. Ext.Template = function(html){
  307. var a = arguments;
  308. if(Ext.isArray(html)){
  309. html = html.join("");
  310. }else if(a.length > 1){
  311. var buf = [];
  312. for(var i = 0, len = a.length; i < len; i++){
  313. if(typeof a[i] == 'object'){
  314. Ext.apply(this, a[i]);
  315. }else{
  316. buf[buf.length] = a[i];
  317. }
  318. }
  319. html = buf.join('');
  320. }
  321. this.html = html;
  322. if(this.compiled){
  323. this.compile();
  324. }
  325. };
  326. Ext.Template.prototype = {
  327. applyTemplate : function(values){
  328. if(this.compiled){
  329. return this.compiled(values);
  330. }
  331. var useF = this.disableFormats !== true;
  332. var fm = Ext.util.Format, tpl = this;
  333. var fn = function(m, name, format, args){
  334. if(format && useF){
  335. if(format.substr(0, 5) == "this."){
  336. return tpl.call(format.substr(5), values[name], values);
  337. }else{
  338. if(args){
  339. var re = /^\s*['"](.*)["']\s*$/;
  340. args = args.split(',');
  341. for(var i = 0, len = args.length; i < len; i++){
  342. args[i] = args[i].replace(re, "$1");
  343. }
  344. args = [values[name]].concat(args);
  345. }else{
  346. args = [values[name]];
  347. }
  348. return fm[format].apply(fm, args);
  349. }
  350. }else{
  351. return values[name] !== undefined ? values[name] : "";
  352. }
  353. };
  354. return this.html.replace(this.re, fn);
  355. },
  356. set : function(html, compile){
  357. this.html = html;
  358. this.compiled = null;
  359. if(compile){
  360. this.compile();
  361. }
  362. return this;
  363. },
  364. disableFormats : false,
  365. re : /\{([\w-]+)(?:\:([\w\.]*)(?:\((.*?)?\))?)?\}/g,
  366. compile : function(){
  367. var fm = Ext.util.Format;
  368. var useF = this.disableFormats !== true;
  369. var sep = Ext.isGecko ? "+" : ",";
  370. var fn = function(m, name, format, args){
  371. if(format && useF){
  372. args = args ? ',' + args : "";
  373. if(format.substr(0, 5) != "this."){
  374. format = "fm." + format + '(';
  375. }else{
  376. format = 'this.call("'+ format.substr(5) + '", ';
  377. args = ", values";
  378. }
  379. }else{
  380. args= ''; format = "(values['" + name + "'] == undefined ? '' : ";
  381. }
  382. return "'"+ sep + format + "values['" + name + "']" + args + ")"+sep+"'";
  383. };
  384. var body;
  385. if(Ext.isGecko){
  386. body = "this.compiled = function(values){ return '" +
  387. this.html.replace(/\\/g, '\\\\').replace(/(\r\n|\n)/g, '\\n').replace(/'/g, "\\'").replace(this.re, fn) +
  388. "';};";
  389. }else{
  390. body = ["this.compiled = function(values){ return ['"];
  391. body.push(this.html.replace(/\\/g, '\\\\').replace(/(\r\n|\n)/g, '\\n').replace(/'/g, "\\'").replace(this.re, fn));
  392. body.push("'].join('');};");
  393. body = body.join('');
  394. }
  395. eval(body);
  396. return this;
  397. },
  398. call : function(fnName, value, allValues){
  399. return this[fnName](value, allValues);
  400. },
  401. insertFirst: function(el, values, returnElement){
  402. return this.doInsert('afterBegin', el, values, returnElement);
  403. },
  404. insertBefore: function(el, values, returnElement){
  405. return this.doInsert('beforeBegin', el, values, returnElement);
  406. },
  407. insertAfter : function(el, values, returnElement){
  408. return this.doInsert('afterEnd', el, values, returnElement);
  409. },
  410. append : function(el, values, returnElement){
  411. return this.doInsert('beforeEnd', el, values, returnElement);
  412. },
  413. doInsert : function(where, el, values, returnEl){
  414. el = Ext.getDom(el);
  415. var newNode = Ext.DomHelper.insertHtml(where, el, this.applyTemplate(values));
  416. return returnEl ? Ext.get(newNode, true) : newNode;
  417. },
  418. overwrite : function(el, values, returnElement){
  419. el = Ext.getDom(el);
  420. el.innerHTML = this.applyTemplate(values);
  421. return returnElement ? Ext.get(el.firstChild, true) : el.firstChild;
  422. }
  423. };
  424. Ext.Template.prototype.apply = Ext.Template.prototype.applyTemplate;
  425. Ext.DomHelper.Template = Ext.Template;
  426. Ext.Template.from = function(el, config){
  427. el = Ext.getDom(el);
  428. return new Ext.Template(el.value || el.innerHTML, config || '');
  429. };
  430. Ext.DomQuery = function(){
  431. var cache = {}, simpleCache = {}, valueCache = {};
  432. var nonSpace = /\S/;
  433. var trimRe = /^\s+|\s+$/g;
  434. var tplRe = /\{(\d+)\}/g;
  435. var modeRe = /^(\s?[\/>+~]\s?|\s|$)/;
  436. var tagTokenRe = /^(#)?([\w-\*]+)/;
  437. var nthRe = /(\d*)n\+?(\d*)/, nthRe2 = /\D/;
  438. function child(p, index){
  439. var i = 0;
  440. var n = p.firstChild;
  441. while(n){
  442. if(n.nodeType == 1){
  443. if(++i == index){
  444. return n;
  445. }
  446. }
  447. n = n.nextSibling;
  448. }
  449. return null;
  450. };
  451. function next(n){
  452. while((n = n.nextSibling) && n.nodeType != 1);
  453. return n;
  454. };
  455. function prev(n){
  456. while((n = n.previousSibling) && n.nodeType != 1);
  457. return n;
  458. };
  459. function children(d){
  460. var n = d.firstChild, ni = -1;
  461. while(n){
  462. var nx = n.nextSibling;
  463. if(n.nodeType == 3 && !nonSpace.test(n.nodeValue)){
  464. d.removeChild(n);
  465. }else{
  466. n.nodeIndex = ++ni;
  467. }
  468. n = nx;
  469. }
  470. return this;
  471. };
  472. function byClassName(c, a, v){
  473. if(!v){
  474. return c;
  475. }
  476. var r = [], ri = -1, cn;
  477. for(var i = 0, ci; ci = c[i]; i++){
  478. if((' '+ci.className+' ').indexOf(v) != -1){
  479. r[++ri] = ci;
  480. }
  481. }
  482. return r;
  483. };
  484. function attrValue(n, attr){
  485. if(!n.tagName && typeof n.length != "undefined"){
  486. n = n[0];
  487. }
  488. if(!n){
  489. return null;
  490. }
  491. if(attr == "for"){
  492. return n.htmlFor;
  493. }
  494. if(attr == "class" || attr == "className"){
  495. return n.className;
  496. }
  497. return n.getAttribute(attr) || n[attr];
  498. };
  499. function getNodes(ns, mode, tagName){
  500. var result = [], ri = -1, cs;
  501. if(!ns){
  502. return result;
  503. }
  504. tagName = tagName || "*";
  505. if(typeof ns.getElementsByTagName != "undefined"){
  506. ns = [ns];
  507. }
  508. if(!mode){
  509. for(var i = 0, ni; ni = ns[i]; i++){
  510. cs = ni.getElementsByTagName(tagName);
  511. for(var j = 0, ci; ci = cs[j]; j++){
  512. result[++ri] = ci;
  513. }
  514. }
  515. }else if(mode == "/" || mode == ">"){
  516. var utag = tagName.toUpperCase();
  517. for(var i = 0, ni, cn; ni = ns[i]; i++){
  518. cn = ni.children || ni.childNodes;
  519. for(var j = 0, cj; cj = cn[j]; j++){
  520. if(cj.nodeName == utag || cj.nodeName == tagName || tagName == '*'){
  521. result[++ri] = cj;
  522. }
  523. }
  524. }
  525. }else if(mode == "+"){
  526. var utag = tagName.toUpperCase();
  527. for(var i = 0, n; n = ns[i]; i++){
  528. while((n = n.nextSibling) && n.nodeType != 1);
  529. if(n && (n.nodeName == utag || n.nodeName == tagName || tagName == '*')){
  530. result[++ri] = n;
  531. }
  532. }
  533. }else if(mode == "~"){
  534. for(var i = 0, n; n = ns[i]; i++){
  535. while((n = n.nextSibling) && (n.nodeType != 1 || (tagName == '*' || n.tagName.toLowerCase()!=tagName)));
  536. if(n){
  537. result[++ri] = n;
  538. }
  539. }
  540. }
  541. return result;
  542. };
  543. function concat(a, b){
  544. if(b.slice){
  545. return a.concat(b);
  546. }
  547. for(var i = 0, l = b.length; i < l; i++){
  548. a[a.length] = b[i];
  549. }
  550. return a;
  551. }
  552. function byTag(cs, tagName){
  553. if(cs.tagName || cs == document){
  554. cs = [cs];
  555. }
  556. if(!tagName){
  557. return cs;
  558. }
  559. var r = [], ri = -1;
  560. tagName = tagName.toLowerCase();
  561. for(var i = 0, ci; ci = cs[i]; i++){
  562. if(ci.nodeType == 1 && ci.tagName.toLowerCase()==tagName){
  563. r[++ri] = ci;
  564. }
  565. }
  566. return r;
  567. };
  568. function byId(cs, attr, id){
  569. if(cs.tagName || cs == document){
  570. cs = [cs];
  571. }
  572. if(!id){
  573. return cs;
  574. }
  575. var r = [], ri = -1;
  576. for(var i = 0,ci; ci = cs[i]; i++){
  577. if(ci && ci.id == id){
  578. r[++ri] = ci;
  579. return r;
  580. }
  581. }
  582. return r;
  583. };
  584. function byAttribute(cs, attr, value, op, custom){
  585. var r = [], ri = -1, st = custom=="{";
  586. var f = Ext.DomQuery.operators[op];
  587. for(var i = 0, ci; ci = cs[i]; i++){
  588. var a;
  589. if(st){
  590. a = Ext.DomQuery.getStyle(ci, attr);
  591. }
  592. else if(attr == "class" || attr == "className"){
  593. a = ci.className;
  594. }else if(attr == "for"){
  595. a = ci.htmlFor;
  596. }else if(attr == "href"){
  597. a = ci.getAttribute("href", 2);
  598. }else{
  599. a = ci.getAttribute(attr);
  600. }
  601. if((f && f(a, value)) || (!f && a)){
  602. r[++ri] = ci;
  603. }
  604. }
  605. return r;
  606. };
  607. function byPseudo(cs, name, value){
  608. return Ext.DomQuery.pseudos[name](cs, value);
  609. };
  610. var isIE = window.ActiveXObject ? true : false;
  611. eval("var batch = 30803;");
  612. var key = 30803;
  613. function nodupIEXml(cs){
  614. var d = ++key;
  615. cs[0].setAttribute("_nodup", d);
  616. var r = [cs[0]];
  617. for(var i = 1, len = cs.length; i < len; i++){
  618. var c = cs[i];
  619. if(!c.getAttribute("_nodup") != d){
  620. c.setAttribute("_nodup", d);
  621. r[r.length] = c;
  622. }
  623. }
  624. for(var i = 0, len = cs.length; i < len; i++){
  625. cs[i].removeAttribute("_nodup");
  626. }
  627. return r;
  628. }
  629. function nodup(cs){
  630. if(!cs){
  631. return [];
  632. }
  633. var len = cs.length, c, i, r = cs, cj, ri = -1;
  634. if(!len || typeof cs.nodeType != "undefined" || len == 1){
  635. return cs;
  636. }
  637. if(isIE && typeof cs[0].selectSingleNode != "undefined"){
  638. return nodupIEXml(cs);
  639. }
  640. var d = ++key;
  641. cs[0]._nodup = d;
  642. for(i = 1; c = cs[i]; i++){
  643. if(c._nodup != d){
  644. c._nodup = d;
  645. }else{
  646. r = [];
  647. for(var j = 0; j < i; j++){
  648. r[++ri] = cs[j];
  649. }
  650. for(j = i+1; cj = cs[j]; j++){
  651. if(cj._nodup != d){
  652. cj._nodup = d;
  653. r[++ri] = cj;
  654. }
  655. }
  656. return r;
  657. }
  658. }
  659. return r;
  660. }
  661. function quickDiffIEXml(c1, c2){
  662. var d = ++key;
  663. for(var i = 0, len = c1.length; i < len; i++){
  664. c1[i].setAttribute("_qdiff", d);
  665. }
  666. var r = [];
  667. for(var i = 0, len = c2.length; i < len; i++){
  668. if(c2[i].getAttribute("_qdiff") != d){
  669. r[r.length] = c2[i];
  670. }
  671. }
  672. for(var i = 0, len = c1.length; i < len; i++){
  673. c1[i].removeAttribute("_qdiff");
  674. }
  675. return r;
  676. }
  677. function quickDiff(c1, c2){
  678. var len1 = c1.length;
  679. if(!len1){
  680. return c2;
  681. }
  682. if(isIE && c1[0].selectSingleNode){
  683. return quickDiffIEXml(c1, c2);
  684. }
  685. var d = ++key;
  686. for(var i = 0; i < len1; i++){
  687. c1[i]._qdiff = d;
  688. }
  689. var r = [];
  690. for(var i = 0, len = c2.length; i < len; i++){
  691. if(c2[i]._qdiff != d){
  692. r[r.length] = c2[i];
  693. }
  694. }
  695. return r;
  696. }
  697. function quickId(ns, mode, root, id){
  698. if(ns == root){
  699. var d = root.ownerDocument || root;
  700. return d.getElementById(id);
  701. }
  702. ns = getNodes(ns, mode, "*");
  703. return byId(ns, null, id);
  704. }
  705. return {
  706. getStyle : function(el, name){
  707. return Ext.fly(el).getStyle(name);
  708. },
  709. compile : function(path, type){
  710. type = type || "select";
  711. var fn = ["var f = function(root){\n var mode; ++batch; var n = root || document;\n"];
  712. var q = path, mode, lq;
  713. var tk = Ext.DomQuery.matchers;
  714. var tklen = tk.length;
  715. var mm;
  716. var lmode = q.match(modeRe);
  717. if(lmode && lmode[1]){
  718. fn[fn.length] = 'mode="'+lmode[1].replace(trimRe, "")+'";';
  719. q = q.replace(lmode[1], "");
  720. }
  721. while(path.substr(0, 1)=="/"){
  722. path = path.substr(1);
  723. }
  724. while(q && lq != q){
  725. lq = q;
  726. var tm = q.match(tagTokenRe);
  727. if(type == "select"){
  728. if(tm){
  729. if(tm[1] == "#"){
  730. fn[fn.length] = 'n = quickId(n, mode, root, "'+tm[2]+'");';
  731. }else{
  732. fn[fn.length] = 'n = getNodes(n, mode, "'+tm[2]+'");';
  733. }
  734. q = q.replace(tm[0], "");
  735. }else if(q.substr(0, 1) != '@'){
  736. fn[fn.length] = 'n = getNodes(n, mode, "*");';
  737. }
  738. }else{
  739. if(tm){
  740. if(tm[1] == "#"){
  741. fn[fn.length] = 'n = byId(n, null, "'+tm[2]+'");';
  742. }else{
  743. fn[fn.length] = 'n = byTag(n, "'+tm[2]+'");';
  744. }
  745. q = q.replace(tm[0], "");
  746. }
  747. }
  748. while(!(mm = q.match(modeRe))){
  749. var matched = false;
  750. for(var j = 0; j < tklen; j++){
  751. var t = tk[j];
  752. var m = q.match(t.re);
  753. if(m){
  754. fn[fn.length] = t.select.replace(tplRe, function(x, i){
  755. return m[i];
  756. });
  757. q = q.replace(m[0], "");
  758. matched = true;
  759. break;
  760. }
  761. }
  762. if(!matched){
  763. throw 'Error parsing selector, parsing failed at "' + q + '"';
  764. }
  765. }
  766. if(mm[1]){
  767. fn[fn.length] = 'mode="'+mm[1].replace(trimRe, "")+'";';
  768. q = q.replace(mm[1], "");
  769. }
  770. }
  771. fn[fn.length] = "return nodup(n);\n}";
  772. eval(fn.join(""));
  773. return f;
  774. },
  775. select : function(path, root, type){
  776. if(!root || root == document){
  777. root = document;
  778. }
  779. if(typeof root == "string"){
  780. root = document.getElementById(root);
  781. }
  782. var paths = path.split(",");
  783. var results = [];
  784. for(var i = 0, len = paths.length; i < len; i++){
  785. var p = paths[i].replace(trimRe, "");
  786. if(!cache[p]){
  787. cache[p] = Ext.DomQuery.compile(p);
  788. if(!cache[p]){
  789. throw p + " is not a valid selector";
  790. }
  791. }
  792. var result = cache[p](root);
  793. if(result && result != document){
  794. results = results.concat(result);
  795. }
  796. }
  797. if(paths.length > 1){
  798. return nodup(results);
  799. }
  800. return results;
  801. },
  802. selectNode : function(path, root){
  803. return Ext.DomQuery.select(path, root)[0];
  804. },
  805. selectValue : function(path, root, defaultValue){
  806. path = path.replace(trimRe, "");
  807. if(!valueCache[path]){
  808. valueCache[path] = Ext.DomQuery.compile(path, "select");
  809. }
  810. var n = valueCache[path](root);
  811. n = n[0] ? n[0] : n;
  812. var v = (n && n.firstChild ? n.firstChild.nodeValue : null);
  813. return ((v === null||v === undefined||v==='') ? defaultValue : v);
  814. },
  815. selectNumber : function(path, root, defaultValue){
  816. var v = Ext.DomQuery.selectValue(path, root, defaultValue || 0);
  817. return parseFloat(v);
  818. },
  819. is : function(el, ss){
  820. if(typeof el == "string"){
  821. el = document.getElementById(el);
  822. }
  823. var isArray = Ext.isArray(el);
  824. var result = Ext.DomQuery.filter(isArray ? el : [el], ss);
  825. return isArray ? (result.length == el.length) : (result.length > 0);
  826. },
  827. filter : function(els, ss, nonMatches){
  828. ss = ss.replace(trimRe, "");
  829. if(!simpleCache[ss]){
  830. simpleCache[ss] = Ext.DomQuery.compile(ss, "simple");
  831. }
  832. var result = simpleCache[ss](els);
  833. return nonMatches ? quickDiff(result, els) : result;
  834. },
  835. matchers : [{
  836. re: /^\.([\w-]+)/,
  837. select: 'n = byClassName(n, null, " {1} ");'
  838. }, {
  839. re: /^\:([\w-]+)(?:\(((?:[^\s>\/]*|.*?))\))?/,
  840. select: 'n = byPseudo(n, "{1}", "{2}");'
  841. },{
  842. re: /^(?:([\[\{])(?:@)?([\w-]+)\s?(?:(=|.=)\s?['"]?(.*?)["']?)?[\]\}])/,
  843. select: 'n = byAttribute(n, "{2}", "{4}", "{3}", "{1}");'
  844. }, {
  845. re: /^#([\w-]+)/,
  846. select: 'n = byId(n, null, "{1}");'
  847. },{
  848. re: /^@([\w-]+)/,
  849. select: 'return {firstChild:{nodeValue:attrValue(n, "{1}")}};'
  850. }
  851. ],
  852. operators : {
  853. "=" : function(a, v){
  854. return a == v;
  855. },
  856. "!=" : function(a, v){
  857. return a != v;
  858. },
  859. "^=" : function(a, v){
  860. return a && a.substr(0, v.length) == v;
  861. },
  862. "$=" : function(a, v){
  863. return a && a.substr(a.length-v.length) == v;
  864. },
  865. "*=" : function(a, v){
  866. return a && a.indexOf(v) !== -1;
  867. },
  868. "%=" : function(a, v){
  869. return (a % v) == 0;
  870. },
  871. "|=" : function(a, v){
  872. return a && (a == v || a.substr(0, v.length+1) == v+'-');
  873. },
  874. "~=" : function(a, v){
  875. return a && (' '+a+' ').indexOf(' '+v+' ') != -1;
  876. }
  877. },
  878. pseudos : {
  879. "first-child" : function(c){
  880. var r = [], ri = -1, n;
  881. for(var i = 0, ci; ci = n = c[i]; i++){
  882. while((n = n.previousSibling) && n.nodeType != 1);
  883. if(!n){
  884. r[++ri] = ci;
  885. }
  886. }
  887. return r;
  888. },
  889. "last-child" : function(c){
  890. var r = [], ri = -1, n;
  891. for(var i = 0, ci; ci = n = c[i]; i++){
  892. while((n = n.nextSibling) && n.nodeType != 1);
  893. if(!n){
  894. r[++ri] = ci;
  895. }
  896. }
  897. return r;
  898. },
  899. "nth-child" : function(c, a) {
  900. var r = [], ri = -1;
  901. var m = nthRe.exec(a == "even" && "2n" || a == "odd" && "2n+1" || !nthRe2.test(a) && "n+" + a || a);
  902. var f = (m[1] || 1) - 0, l = m[2] - 0;
  903. for(var i = 0, n; n = c[i]; i++){
  904. var pn = n.parentNode;
  905. if (batch != pn._batch) {
  906. var j = 0;
  907. for(var cn = pn.firstChild; cn; cn = cn.nextSibling){
  908. if(cn.nodeType == 1){
  909. cn.nodeIndex = ++j;
  910. }
  911. }
  912. pn._batch = batch;
  913. }
  914. if (f == 1) {
  915. if (l == 0 || n.nodeIndex == l){
  916. r[++ri] = n;
  917. }
  918. } else if ((n.nodeIndex + l) % f == 0){
  919. r[++ri] = n;
  920. }
  921. }
  922. return r;
  923. },
  924. "only-child" : function(c){
  925. var r = [], ri = -1;;
  926. for(var i = 0, ci; ci = c[i]; i++){
  927. if(!prev(ci) && !next(ci)){
  928. r[++ri] = ci;
  929. }
  930. }
  931. return r;
  932. },
  933. "empty" : function(c){
  934. var r = [], ri = -1;
  935. for(var i = 0, ci; ci = c[i]; i++){
  936. var cns = ci.childNodes, j = 0, cn, empty = true;
  937. while(cn = cns[j]){
  938. ++j;
  939. if(cn.nodeType == 1 || cn.nodeType == 3){
  940. empty = false;
  941. break;
  942. }
  943. }
  944. if(empty){
  945. r[++ri] = ci;
  946. }
  947. }
  948. return r;
  949. },
  950. "contains" : function(c, v){
  951. var r = [], ri = -1;
  952. for(var i = 0, ci; ci = c[i]; i++){
  953. if((ci.textContent||ci.innerText||'').indexOf(v) != -1){
  954. r[++ri] = ci;
  955. }
  956. }
  957. return r;
  958. },
  959. "nodeValue" : function(c, v){
  960. var r = [], ri = -1;
  961. for(var i = 0, ci; ci = c[i]; i++){
  962. if(ci.firstChild && ci.firstChild.nodeValue == v){
  963. r[++ri] = ci;
  964. }
  965. }
  966. return r;
  967. },
  968. "checked" : function(c){
  969. var r = [], ri = -1;
  970. for(var i = 0, ci; ci = c[i]; i++){
  971. if(ci.checked == true){
  972. r[++ri] = ci;
  973. }
  974. }
  975. return r;
  976. },
  977. "not" : function(c, ss){
  978. return Ext.DomQuery.filter(c, ss, true);
  979. },
  980. "any" : function(c, selectors){
  981. var ss = selectors.split('|');
  982. var r = [], ri = -1, s;
  983. for(var i = 0, ci; ci = c[i]; i++){
  984. for(var j = 0; s = ss[j]; j++){
  985. if(Ext.DomQuery.is(ci, s)){
  986. r[++ri] = ci;
  987. break;
  988. }
  989. }
  990. }
  991. return r;
  992. },
  993. "odd" : function(c){
  994. return this["nth-child"](c, "odd");
  995. },
  996. "even" : function(c){
  997. return this["nth-child"](c, "even");
  998. },
  999. "nth" : function(c, a){
  1000. return c[a-1] || [];
  1001. },
  1002. "first" : function(c){
  1003. return c[0] || [];
  1004. },
  1005. "last" : function(c){
  1006. return c[c.length-1] || [];
  1007. },
  1008. "has" : function(c, ss){
  1009. var s = Ext.DomQuery.select;
  1010. var r = [], ri = -1;
  1011. for(var i = 0, ci; ci = c[i]; i++){
  1012. if(s(ss, ci).length > 0){
  1013. r[++ri] = ci;
  1014. }
  1015. }
  1016. return r;
  1017. },
  1018. "next" : function(c, ss){
  1019. var is = Ext.DomQuery.is;
  1020. var r = [], ri = -1;
  1021. for(var i = 0, ci; ci = c[i]; i++){
  1022. var n = next(ci);
  1023. if(n && is(n, ss)){
  1024. r[++ri] = ci;
  1025. }
  1026. }
  1027. return r;
  1028. },
  1029. "prev" : function(c, ss){
  1030. var is = Ext.DomQuery.is;
  1031. var r = [], ri = -1;
  1032. for(var i = 0, ci; ci = c[i]; i++){
  1033. var n = prev(ci);
  1034. if(n && is(n, ss)){
  1035. r[++ri] = ci;
  1036. }
  1037. }
  1038. return r;
  1039. }
  1040. }
  1041. };
  1042. }();
  1043. Ext.query = Ext.DomQuery.select;
  1044. Ext.util.Observable = function(){
  1045. if(this.listeners){
  1046. this.on(this.listeners);
  1047. delete this.listeners;
  1048. }
  1049. };
  1050. Ext.util.Observable.prototype = {
  1051. fireEvent : function(){
  1052. if(this.eventsSuspended !== true){
  1053. var ce = this.events[arguments[0].toLowerCase()];
  1054. if(typeof ce == "object"){
  1055. return ce.fire.apply(ce, Array.prototype.slice.call(arguments, 1));
  1056. }
  1057. }
  1058. return true;
  1059. },
  1060. filterOptRe : /^(?:scope|delay|buffer|single)$/,
  1061. addListener : function(eventName, fn, scope, o){
  1062. if(typeof eventName == "object"){
  1063. o = eventName;
  1064. for(var e in o){
  1065. if(this.filterOptRe.test(e)){
  1066. continue;
  1067. }
  1068. if(typeof o[e] == "function"){
  1069. this.addListener(e, o[e], o.scope, o);
  1070. }else{
  1071. this.addListener(e, o[e].fn, o[e].scope, o[e]);
  1072. }
  1073. }
  1074. return;
  1075. }
  1076. o = (!o || typeof o == "boolean") ? {} : o;
  1077. eventName = eventName.toLowerCase();
  1078. var ce = this.events[eventName] || true;
  1079. if(typeof ce == "boolean"){
  1080. ce = new Ext.util.Event(this, eventName);
  1081. this.events[eventName] = ce;
  1082. }
  1083. ce.addListener(fn, scope, o);
  1084. },
  1085. removeListener : function(eventName, fn, scope){
  1086. var ce = this.events[eventName.toLowerCase()];
  1087. if(typeof ce == "object"){
  1088. ce.removeListener(fn, scope);
  1089. }
  1090. },
  1091. purgeListeners : function(){
  1092. for(var evt in this.events){
  1093. if(typeof this.events[evt] == "object"){
  1094. this.events[evt].clearListeners();
  1095. }
  1096. }
  1097. },
  1098. relayEvents : function(o, events){
  1099. var createHandler = function(ename){
  1100. return function(){
  1101. return this.fireEvent.apply(this, Ext.combine(ename, Array.prototype.slice.call(arguments, 0)));
  1102. };
  1103. };
  1104. for(var i = 0, len = events.length; i < len; i++){
  1105. var ename = events[i];
  1106. if(!this.events[ename]){ this.events[ename] = true; };
  1107. o.on(ename, createHandler(ename), this);
  1108. }
  1109. },
  1110. addEvents : function(o){
  1111. if(!this.events){
  1112. this.events = {};
  1113. }
  1114. if(typeof o == 'string'){
  1115. for(var i = 0, a = arguments, v; v = a[i]; i++){
  1116. if(!this.events[a[i]]){
  1117. o[a[i]] = true;
  1118. }
  1119. }
  1120. }else{
  1121. Ext.applyIf(this.events, o);
  1122. }
  1123. },
  1124. hasListener : function(eventName){
  1125. var e = this.events[eventName];
  1126. return typeof e == "object" && e.listeners.length > 0;
  1127. },
  1128. suspendEvents : function(){
  1129. this.eventsSuspended = true;
  1130. },
  1131. resumeEvents : function(){
  1132. this.eventsSuspended = false;
  1133. },
  1134. getMethodEvent : function(method){
  1135. if(!this.methodEvents){
  1136. this.methodEvents = {};
  1137. }
  1138. var e = this.methodEvents[method];
  1139. if(!e){
  1140. e = {};
  1141. this.methodEvents[method] = e;
  1142. e.originalFn = this[method];
  1143. e.methodName = method;
  1144. e.before = [];
  1145. e.after = [];
  1146. var returnValue, v, cancel;
  1147. var obj = this;
  1148. var makeCall = function(fn, scope, args){
  1149. if((v = fn.apply(scope || obj, args)) !== undefined){
  1150. if(typeof v === 'object'){
  1151. if(v.returnValue !== undefined){
  1152. returnValue = v.returnValue;
  1153. }else{
  1154. returnValue = v;
  1155. }
  1156. if(v.cancel === true){
  1157. cancel = true;
  1158. }
  1159. }else if(v === false){
  1160. cancel = true;
  1161. }else {
  1162. returnValue = v;
  1163. }
  1164. }
  1165. }
  1166. this[method] = function(){
  1167. returnValue = v = undefined; cancel = false;
  1168. var args = Array.prototype.slice.call(arguments, 0);
  1169. for(var i = 0, len = e.before.length; i < len; i++){
  1170. makeCall(e.before[i].fn, e.before[i].scope, args);
  1171. if(cancel){
  1172. return returnValue;
  1173. }
  1174. }
  1175. if((v = e.originalFn.apply(obj, args)) !== undefined){
  1176. returnValue = v;
  1177. }
  1178. for(var i = 0, len = e.after.length; i < len; i++){
  1179. makeCall(e.after[i].fn, e.after[i].scope, args);
  1180. if(cancel){
  1181. return returnValue;
  1182. }
  1183. }
  1184. return returnValue;
  1185. };
  1186. }
  1187. return e;
  1188. },
  1189. beforeMethod : function(method, fn, scope){
  1190. var e = this.getMethodEvent(method);
  1191. e.before.push({fn: fn, scope: scope});
  1192. },
  1193. afterMethod : function(method, fn, scope){
  1194. var e = this.getMethodEvent(method);
  1195. e.after.push({fn: fn, scope: scope});
  1196. },
  1197. removeMethodListener : function(method, fn, scope){
  1198. var e = this.getMethodEvent(method);
  1199. for(var i = 0, len = e.before.length; i < len; i++){
  1200. if(e.before[i].fn == fn && e.before[i].scope == scope){
  1201. e.before.splice(i, 1);
  1202. return;
  1203. }
  1204. }
  1205. for(var i = 0, len = e.after.length; i < len; i++){
  1206. if(e.after[i].fn == fn && e.after[i].scope == scope){
  1207. e.after.splice(i, 1);
  1208. return;
  1209. }
  1210. }
  1211. }
  1212. };
  1213. Ext.util.Observable.prototype.on = Ext.util.Observable.prototype.addListener;
  1214. Ext.util.Observable.prototype.un = Ext.util.Observable.prototype.removeListener;
  1215. Ext.util.Observable.capture = function(o, fn, scope){
  1216. o.fireEvent = o.fireEvent.createInterceptor(fn, scope);
  1217. };
  1218. Ext.util.Observable.releaseCapture = function(o){
  1219. o.fireEvent = Ext.util.Observable.prototype.fireEvent;
  1220. };
  1221. (function(){
  1222. var createBuffered = function(h, o, scope){
  1223. var task = new Ext.util.DelayedTask();
  1224. return function(){
  1225. task.delay(o.buffer, h, scope, Array.prototype.slice.call(arguments, 0));
  1226. };
  1227. };
  1228. var createSingle = function(h, e, fn, scope){
  1229. return function(){
  1230. e.removeListener(fn, scope);
  1231. return h.apply(scope, arguments);
  1232. };
  1233. };
  1234. var createDelayed = function(h, o, scope){
  1235. return function(){
  1236. var args = Array.prototype.slice.call(arguments, 0);
  1237. setTimeout(function(){
  1238. h.apply(scope, args);
  1239. }, o.delay || 10);
  1240. };
  1241. };
  1242. Ext.util.Event = function(obj, name){
  1243. this.name = name;
  1244. this.obj = obj;
  1245. this.listeners = [];
  1246. };
  1247. Ext.util.Event.prototype = {
  1248. addListener : function(fn, scope, options){
  1249. scope = scope || this.obj;
  1250. if(!this.isListening(fn, scope)){
  1251. var l = this.createListener(fn, scope, options);
  1252. if(!this.firing){
  1253. this.listeners.push(l);
  1254. }else{ this.listeners = this.listeners.slice(0);
  1255. this.listeners.push(l);
  1256. }
  1257. }
  1258. },
  1259. createListener : function(fn, scope, o){
  1260. o = o || {};
  1261. scope = scope || this.obj;
  1262. var l = {fn: fn, scope: scope, options: o};
  1263. var h = fn;
  1264. if(o.delay){
  1265. h = createDelayed(h, o, scope);
  1266. }
  1267. if(o.single){
  1268. h = createSingle(h, this, fn, scope);
  1269. }
  1270. if(o.buffer){
  1271. h = createBuffered(h, o, scope);
  1272. }
  1273. l.fireFn = h;
  1274. return l;
  1275. },
  1276. findListener : function(fn, scope){
  1277. scope = scope || this.obj;
  1278. var ls = this.listeners;
  1279. for(var i = 0, len = ls.length; i < len; i++){
  1280. var l = ls[i];
  1281. if(l.fn == fn && l.scope == scope){
  1282. return i;
  1283. }
  1284. }
  1285. return -1;
  1286. },
  1287. isListening : function(fn, scope){
  1288. return this.findListener(fn, scope) != -1;
  1289. },
  1290. removeListener : function(fn, scope){
  1291. var index;
  1292. if((index = this.findListener(fn, scope)) != -1){
  1293. if(!this.firing){
  1294. this.listeners.splice(index, 1);
  1295. }else{
  1296. this.listeners = this.listeners.slice(0);
  1297. this.listeners.splice(index, 1);
  1298. }
  1299. return true;
  1300. }
  1301. return false;
  1302. },
  1303. clearListeners : function(){
  1304. this.listeners = [];
  1305. },
  1306. fire : function(){
  1307. var ls = this.listeners, scope, len = ls.length;
  1308. if(len > 0){
  1309. this.firing = true;
  1310. var args = Array.prototype.slice.call(arguments, 0);
  1311. for(var i = 0; i < len; i++){
  1312. var l = ls[i];
  1313. if(l.fireFn.apply(l.scope||this.obj||window, arguments) === false){
  1314. this.firing = false;
  1315. return false;
  1316. }
  1317. }
  1318. this.firing = false;
  1319. }
  1320. return true;
  1321. }
  1322. };
  1323. })();
  1324. Ext.EventManager = function(){
  1325. var docReadyEvent, docReadyProcId, docReadyState = false;
  1326. var resizeEvent, resizeTask, textEvent, textSize;
  1327. var E = Ext.lib.Event;
  1328. var D = Ext.lib.Dom;
  1329. var fireDocReady = function(){
  1330. if(!docReadyState){
  1331. docReadyState = true;
  1332. Ext.isReady = true;
  1333. if(docReadyProcId){
  1334. clearInterval(docReadyProcId);
  1335. }
  1336. if(Ext.isGecko || Ext.isOpera) {
  1337. document.removeEventListener("DOMContentLoaded", fireDocReady, false);
  1338. }
  1339. if(Ext.isIE){
  1340. var defer = document.getElementById("ie-deferred-loader");
  1341. if(defer){
  1342. defer.onreadystatechange = null;
  1343. defer.parentNode.removeChild(defer);
  1344. }
  1345. }
  1346. if(docReadyEvent){
  1347. docReadyEvent.fire();
  1348. docReadyEvent.clearListeners();
  1349. }
  1350. }
  1351. };
  1352. var initDocReady = function(){
  1353. docReadyEvent = new Ext.util.Event();
  1354. if(Ext.isGecko || Ext.isOpera) {
  1355. document.addEventListener("DOMContentLoaded", fireDocReady, false);
  1356. }else if(Ext.isIE){
  1357. document.write("<s"+'cript id="ie-deferred-loader" defer="defer" src="/'+'/:"></s'+"cript>");
  1358. var defer = document.getElementById("ie-deferred-loader");
  1359. defer.onreadystatechange = function(){
  1360. if(this.readyState == "complete"){
  1361. fireDocReady();
  1362. }
  1363. };
  1364. }else if(Ext.isSafari){
  1365. docReadyProcId = setInterval(function(){
  1366. var rs = document.readyState;
  1367. if(rs == "complete") {
  1368. fireDocReady();
  1369. }
  1370. }, 10);
  1371. }
  1372. E.on(window, "load", fireDocReady);
  1373. };
  1374. var createBuffered = function(h, o){
  1375. var task = new Ext.util.DelayedTask(h);
  1376. return function(e){
  1377. e = new Ext.EventObjectImpl(e);
  1378. task.delay(o.buffer, h, null, [e]);
  1379. };
  1380. };
  1381. var createSingle = function(h, el, ename, fn){
  1382. return function(e){
  1383. Ext.EventManager.removeListener(el, ename, fn);
  1384. h(e);
  1385. };
  1386. };
  1387. var createDelayed = function(h, o){
  1388. return function(e){
  1389. e = new Ext.EventObjectImpl(e);
  1390. setTimeout(function(){
  1391. h(e);
  1392. }, o.delay || 10);
  1393. };
  1394. };
  1395. var listen = function(element, ename, opt, fn, scope){
  1396. var o = (!opt || typeof opt == "boolean") ? {} : opt;
  1397. fn = fn || o.fn; scope = scope || o.scope;
  1398. var el = Ext.getDom(element);
  1399. if(!el){
  1400. throw "Error listening for \"" + ename + '\". Element "' + element + '" doesn\'t exist.';
  1401. }
  1402. var h = function(e){
  1403. e = Ext.EventObject.setEvent(e);
  1404. var t;
  1405. if(o.delegate){
  1406. t = e.getTarget(o.delegate, el);
  1407. if(!t){
  1408. return;
  1409. }
  1410. }else{
  1411. t = e.target;
  1412. }
  1413. if(o.stopEvent === true){
  1414. e.stopEvent();
  1415. }
  1416. if(o.preventDefault === true){
  1417. e.preventDefault();
  1418. }
  1419. if(o.stopPropagation === true){
  1420. e.stopPropagation();
  1421. }
  1422. if(o.normalized === false){
  1423. e = e.browserEvent;
  1424. }
  1425. fn.call(scope || el, e, t, o);
  1426. };
  1427. if(o.delay){
  1428. h = createDelayed(h, o);
  1429. }
  1430. if(o.single){
  1431. h = createSingle(h, el, ename, fn);
  1432. }
  1433. if(o.buffer){
  1434. h = createBuffered(h, o);
  1435. }
  1436. fn._handlers = fn._handlers || [];
  1437. fn._handlers.push([Ext.id(el), ename, h]);
  1438. E.on(el, ename, h);
  1439. if(ename == "mousewheel" && el.addEventListener){
  1440. el.addEventListener("DOMMouseScroll", h, false);
  1441. E.on(window, 'unload', function(){
  1442. el.removeEventListener("DOMMouseScroll", h, false);
  1443. });
  1444. }
  1445. if(ename == "mousedown" && el == document){
  1446. Ext.EventManager.stoppedMouseDownEvent.addListener(h);
  1447. }
  1448. return h;
  1449. };
  1450. var stopListening = function(el, ename, fn){
  1451. var id = Ext.id(el), hds = fn._handlers, hd = fn;
  1452. if(hds){
  1453. for(var i = 0, len = hds.length; i < len; i++){
  1454. var h = hds[i];
  1455. if(h[0] == id && h[1] == ename){
  1456. hd = h[2];
  1457. hds.splice(i, 1);
  1458. break;
  1459. }
  1460. }
  1461. }
  1462. E.un(el, ename, hd);
  1463. el = Ext.getDom(el);
  1464. if(ename == "mousewheel" && el.addEventListener){
  1465. el.removeEventListener("DOMMouseScroll", hd, false);
  1466. }
  1467. if(ename == "mousedown" && el == document){
  1468. Ext.EventManager.stoppedMouseDownEvent.removeListener(hd);
  1469. }
  1470. };
  1471. var propRe = /^(?:scope|delay|buffer|single|stopEvent|preventDefault|stopPropagation|normalized|args|delegate)$/;
  1472. var pub = {
  1473. addListener : function(element, eventName, fn, scope, options){
  1474. if(typeof eventName == "object"){
  1475. var o = eventName;
  1476. for(var e in o){
  1477. if(propRe.test(e)){
  1478. continue;
  1479. }
  1480. if(typeof o[e] == "function"){
  1481. listen(element, e, o, o[e], o.scope);
  1482. }else{
  1483. listen(element, e, o[e]);
  1484. }
  1485. }
  1486. return;
  1487. }
  1488. return listen(element, eventName, options, fn, scope);
  1489. },
  1490. removeListener : function(element, eventName, fn){
  1491. return stopListening(element, eventName, fn);
  1492. },
  1493. onDocumentReady : function(fn, scope, options){
  1494. if(docReadyState){
  1495. docReadyEvent.addListener(fn, scope, options);
  1496. docReadyEvent.fire();
  1497. docReadyEvent.clearListeners();
  1498. return;
  1499. }
  1500. if(!docReadyEvent){
  1501. initDocReady();
  1502. }
  1503. docReadyEvent.addListener(fn, scope, options);
  1504. },
  1505. onWindowResize : function(fn, scope, options){
  1506. if(!resizeEvent){
  1507. resizeEvent = new Ext.util.Event();
  1508. resizeTask = new Ext.util.DelayedTask(function(){
  1509. resizeEvent.fire(D.getViewWidth(), D.getViewHeight());
  1510. });
  1511. E.on(window, "resize", this.fireWindowResize, this);
  1512. }
  1513. resizeEvent.addListener(fn, scope, options);
  1514. },
  1515. fireWindowResize : function(){
  1516. if(resizeEvent){
  1517. if((Ext.isIE||Ext.isAir) && resizeTask){
  1518. resizeTask.delay(50);
  1519. }else{
  1520. resizeEvent.fire(D.getViewWidth(), D.getViewHeight());
  1521. }
  1522. }
  1523. },
  1524. onTextResize : function(fn, scope, options){
  1525. if(!textEvent){
  1526. textEvent = new Ext.util.Event();
  1527. var textEl = new Ext.Element(document.createElement('div'));
  1528. textEl.dom.className = 'x-text-resize';
  1529. textEl.dom.innerHTML = 'X';
  1530. textEl.appendTo(document.body);
  1531. textSize = textEl.dom.offsetHeight;
  1532. setInterval(function(){
  1533. if(textEl.dom.offsetHeight != textSize){
  1534. textEvent.fire(textSize, textSize = textEl.dom.offsetHeight);
  1535. }
  1536. }, this.textResizeInterval);
  1537. }
  1538. textEvent.addListener(fn, scope, options);
  1539. },
  1540. removeResizeListener : function(fn, scope){
  1541. if(resizeEvent){
  1542. resizeEvent.removeListener(fn, scope);
  1543. }
  1544. },
  1545. fireResize : function(){
  1546. if(resizeEvent){
  1547. resizeEvent.fire(D.getViewWidth(), D.getViewHeight());
  1548. }
  1549. },
  1550. ieDeferSrc : false,
  1551. textResizeInterval : 50
  1552. };
  1553. pub.on = pub.addListener;
  1554. pub.un = pub.removeListener;
  1555. pub.stoppedMouseDownEvent = new Ext.util.Event();
  1556. return pub;
  1557. }();
  1558. Ext.onReady = Ext.EventManager.onDocumentReady;
  1559. Ext.onReady(function(){
  1560. var bd = Ext.getBody();
  1561. if(!bd){ return; }
  1562. var cls = [
  1563. Ext.isIE ? "ext-ie " + (Ext.isIE6 ? 'ext-ie6' : 'ext-ie7')
  1564. : Ext.isGecko ? "ext-gecko"
  1565. : Ext.isOpera ? "ext-opera"
  1566. : Ext.isSafari ? "ext-safari" : ""];
  1567. if(Ext.isMac){
  1568. cls.push("ext-mac");
  1569. }
  1570. if(Ext.isLinux){
  1571. cls.push("ext-linux");
  1572. }
  1573. if(Ext.isBorderBox){
  1574. cls.push('ext-border-box');
  1575. }
  1576. if(Ext.isStrict){
  1577. var p = bd.dom.parentNode;
  1578. if(p){
  1579. p.className += ' ext-strict';
  1580. }
  1581. }
  1582. bd.addClass(cls.join(' '));
  1583. });
  1584. Ext.EventObject = function(){
  1585. var E = Ext.lib.Event;
  1586. var safariKeys = {
  1587. 63234 : 37,
  1588. 63235 : 39,
  1589. 63232 : 38,
  1590. 63233 : 40,
  1591. 63276 : 33,
  1592. 63277 : 34,
  1593. 63272 : 46,
  1594. 63273 : 36,
  1595. 63275 : 35
  1596. };
  1597. var btnMap = Ext.isIE ? {1:0,4:1,2:2} :
  1598. (Ext.isSafari ? {1:0,2:1,3:2} : {0:0,1:1,2:2});
  1599. Ext.EventObjectImpl = function(e){
  1600. if(e){
  1601. this.setEvent(e.browserEvent || e);
  1602. }
  1603. };
  1604. Ext.EventObjectImpl.prototype = {
  1605. browserEvent : null,
  1606. button : -1,
  1607. shiftKey : false,
  1608. ctrlKey : false,
  1609. altKey : false,
  1610. BACKSPACE : 8,
  1611. TAB : 9,
  1612. RETURN : 13,
  1613. ENTER : 13,
  1614. SHIFT : 16,
  1615. CONTROL : 17,
  1616. ESC : 27,
  1617. SPACE : 32,
  1618. PAGEUP : 33,
  1619. PAGEDOWN : 34,
  1620. END : 35,
  1621. HOME : 36,
  1622. LEFT : 37,
  1623. UP : 38,
  1624. RIGHT : 39,
  1625. DOWN : 40,
  1626. DELETE : 46,
  1627. F5 : 116,
  1628. setEvent : function(e){
  1629. if(e == this || (e && e.browserEvent)){
  1630. return e;
  1631. }
  1632. this.browserEvent = e;
  1633. if(e){
  1634. this.button = e.button ? btnMap[e.button] : (e.which ? e.which-1 : -1);
  1635. if(e.type == 'click' && this.button == -1){
  1636. this.button = 0;
  1637. }
  1638. this.type = e.type;
  1639. this.shiftKey = e.shiftKey;
  1640. this.ctrlKey = e.ctrlKey || e.metaKey;
  1641. this.altKey = e.altKey;
  1642. this.keyCode = e.keyCode;
  1643. this.charCode = e.charCode;
  1644. this.target = E.getTarget(e);
  1645. this.xy = E.getXY(e);
  1646. }else{
  1647. this.button = -1;
  1648. this.shiftKey = false;
  1649. this.ctrlKey = false;
  1650. this.altKey = false;
  1651. this.keyCode = 0;
  1652. this.charCode =0;
  1653. this.target = null;
  1654. this.xy = [0, 0];
  1655. }
  1656. return this;
  1657. },
  1658. stopEvent : function(){
  1659. if(this.browserEvent){
  1660. if(this.browserEvent.type == 'mousedown'){
  1661. Ext.EventManager.stoppedMouseDownEvent.fire(this);
  1662. }
  1663. E.stopEvent(this.browserEvent);
  1664. }
  1665. },
  1666. preventDefault : function(){
  1667. if(this.browserEvent){
  1668. E.preventDefault(this.browserEvent);
  1669. }
  1670. },
  1671. isNavKeyPress : function(){
  1672. var k = this.keyCode;
  1673. k = Ext.isSafari ? (safariKeys[k] || k) : k;
  1674. return (k >= 33 && k <= 40) || k == this.RETURN || k == this.TAB || k == this.ESC;
  1675. },
  1676. isSpecialKey : function(){
  1677. var k = this.keyCode;
  1678. return (this.type == 'keypress' && this.ctrlKey) || k == 9 || k == 13 || k == 40 || k == 27 ||
  1679. (k == 16) || (k == 17) ||
  1680. (k >= 18 && k <= 20) ||
  1681. (k >= 33 && k <= 35) ||
  1682. (k >= 36 && k <= 39) ||
  1683. (k >= 44 && k <= 45);
  1684. },
  1685. stopPropagation : function(){
  1686. if(this.browserEvent){
  1687. if(this.browserEvent.type == 'mousedown'){
  1688. Ext.EventManager.stoppedMouseDownEvent.fire(this);
  1689. }
  1690. E.stopPropagation(this.browserEvent);
  1691. }
  1692. },
  1693. getCharCode : function(){
  1694. return this.charCode || this.keyCode;
  1695. },
  1696. getKey : function(){
  1697. var k = this.keyCode || this.charCode;
  1698. return Ext.isSafari ? (safariKeys[k] || k) : k;
  1699. },
  1700. getPageX : function(){
  1701. return this.xy[0];
  1702. },
  1703. getPageY : function(){
  1704. return this.xy[1];
  1705. },
  1706. getTime : function(){
  1707. if(this.browserEvent){
  1708. return E.getTime(this.browserEvent);
  1709. }
  1710. return null;
  1711. },
  1712. getXY : function(){
  1713. return this.xy;
  1714. },
  1715. getTarget : function(selector, maxDepth, returnEl){
  1716. var t = Ext.get(this.target);
  1717. return selector ? t.findParent(selector, maxDepth, returnEl) : (returnEl ? t : this.target);
  1718. },
  1719. getRelatedTarget : function(){
  1720. if(this.browserEvent){
  1721. return E.getRelatedTarget(this.browserEvent);
  1722. }
  1723. return null;
  1724. },
  1725. getWheelDelta : function(){
  1726. var e = this.browserEvent;
  1727. var delta = 0;
  1728. if(e.wheelDelta){
  1729. delta = e.wheelDelta/120;
  1730. }else if(e.detail){
  1731. delta = -e.detail/3;
  1732. }
  1733. return delta;
  1734. },
  1735. hasModifier : function(){
  1736. return ((this.ctrlKey || this.altKey) || this.shiftKey) ? true : false;
  1737. },
  1738. within : function(el, related){
  1739. var t = this[related ? "getRelatedTarget" : "getTarget"]();
  1740. try {
  1741. return t && Ext.fly(el).contains(t);
  1742. } catch(e){}
  1743. return false;
  1744. },
  1745. getPoint : function(){
  1746. return new Ext.lib.Point(this.xy[0], this.xy[1]);
  1747. }
  1748. };
  1749. return new Ext.EventObjectImpl();
  1750. }();
  1751. (function(){
  1752. var D = Ext.lib.Dom;
  1753. var E = Ext.lib.Event;
  1754. var A = Ext.lib.Anim;
  1755. var propCache = {};
  1756. var camelRe = /(-[a-z])/gi;
  1757. var camelFn = function(m, a){ return a.charAt(1).toUpperCase(); };
  1758. var view = document.defaultView;
  1759. Ext.Element = function(element, forceNew){
  1760. var dom = typeof element == "string" ?
  1761. document.getElementById(element) : element;
  1762. if(!dom){ return null;
  1763. }
  1764. var id = dom.id;
  1765. if(forceNew !== true && id && Ext.Element.cache[id]){ return Ext.Element.cache[id];
  1766. }
  1767. this.dom = dom;
  1768. this.id = id || Ext.id(dom);
  1769. };
  1770. var El = Ext.Element;
  1771. El.prototype = {
  1772. originalDisplay : "",
  1773. visibilityMode : 1,
  1774. defaultUnit : "px",
  1775. setVisibilityMode : function(visMode){
  1776. this.visibilityMode = visMode;
  1777. return this;
  1778. },
  1779. enableDisplayMode : function(display){
  1780. this.setVisibilityMode(El.DISPLAY);
  1781. if(typeof display != "undefined") this.originalDisplay = display;
  1782. return this;
  1783. },
  1784. findParent : function(simpleSelector, maxDepth, returnEl){
  1785. var p = this.dom, b = document.body, depth = 0, dq = Ext.DomQuery, stopEl;
  1786. maxDepth = maxDepth || 50;
  1787. if(typeof maxDepth != "number"){
  1788. stopEl = Ext.getDom(maxDepth);
  1789. maxDepth = 10;
  1790. }
  1791. while(p && p.nodeType == 1 && depth < maxDepth && p != b && p != stopEl){
  1792. if(dq.is(p, simpleSelector)){
  1793. return returnEl ? Ext.get(p) : p;
  1794. }
  1795. depth++;
  1796. p = p.parentNode;
  1797. }
  1798. return null;
  1799. },
  1800. findParentNode : function(simpleSelector, maxDepth, returnEl){
  1801. var p = Ext.fly(this.dom.parentNode, '_internal');
  1802. return p ? p.findParent(simpleSelector, maxDepth, returnEl) : null;
  1803. },
  1804. up : function(simpleSelector, maxDepth){
  1805. return this.findParentNode(simpleSelector, maxDepth, true);
  1806. },
  1807. is : function(simpleSelector){
  1808. return Ext.DomQuery.is(this.dom, simpleSelector);
  1809. },
  1810. animate : function(args, duration, onComplete, easing, animType){
  1811. this.anim(args, {duration: duration, callback: onComplete, easing: easing}, animType);
  1812. return this;
  1813. },
  1814. anim : function(args, opt, animType, defaultDur, defaultEase, cb){
  1815. animType = animType || 'run';
  1816. opt = opt || {};
  1817. var anim = Ext.lib.Anim[animType](
  1818. this.dom, args,
  1819. (opt.duration || defaultDur) || .35,
  1820. (opt.easing || defaultEase) || 'easeOut',
  1821. function(){
  1822. Ext.callback(cb, this);
  1823. Ext.callback(opt.callback, opt.scope || this, [this, opt]);
  1824. },
  1825. this
  1826. );
  1827. opt.anim = anim;
  1828. return anim;
  1829. },
  1830. preanim : function(a, i){
  1831. return !a[i] ? false : (typeof a[i] == "object" ? a[i]: {duration: a[i+1], callback: a[i+2], easing: a[i+3]});
  1832. },
  1833. clean : function(forceReclean){
  1834. if(this.isCleaned && forceReclean !== true){
  1835. return this;
  1836. }
  1837. var ns = /\S/;
  1838. var d = this.dom, n = d.firstChild, ni = -1;
  1839. while(n){
  1840. var nx = n.nextSibling;
  1841. if(n.nodeType == 3 && !ns.test(n.nodeValue)){
  1842. d.removeChild(n);
  1843. }else{
  1844. n.nodeIndex = ++ni;
  1845. }
  1846. n = nx;
  1847. }
  1848. this.isCleaned = true;
  1849. return this;
  1850. },
  1851. scrollIntoView : function(container, hscroll){
  1852. var c = Ext.getDom(container) || Ext.getBody().dom;
  1853. var el = this.dom;
  1854. var o = this.getOffsetsTo(c),
  1855. l = o[0] + c.scrollLeft,
  1856. t = o[1] + c.scrollTop,
  1857. b = t+el.offsetHeight,
  1858. r = l+el.offsetWidth;
  1859. var ch = c.clientHeight;
  1860. var ct = parseInt(c.scrollTop, 10);
  1861. var cl = parseInt(c.scrollLeft, 10);
  1862. var cb = ct + ch;
  1863. var cr = cl + c.clientWidth;
  1864. if(el.offsetHeight > ch || t < ct){
  1865. c.scrollTop = t;
  1866. }else if(b > cb){
  1867. c.scrollTop = b-ch;
  1868. }
  1869. c.scrollTop = c.scrollTop;
  1870. if(hscroll !== false){
  1871. if(el.offsetWidth > c.clientWidth || l < cl){
  1872. c.scrollLeft = l;
  1873. }else if(r > cr){
  1874. c.scrollLeft = r-c.clientWidth;
  1875. }
  1876. c.scrollLeft = c.scrollLeft;
  1877. }
  1878. return this;
  1879. },
  1880. scrollChildIntoView : function(child, hscroll){
  1881. Ext.fly(child, '_scrollChildIntoView').scrollIntoView(this, hscroll);
  1882. },
  1883. autoHeight : function(animate, duration, onComplete, easing){
  1884. var oldHeight = this.getHeight();
  1885. this.clip();
  1886. this.setHeight(1); setTimeout(function(){
  1887. var height = parseInt(this.dom.scrollHeight, 10); if(!animate){
  1888. this.setHeight(height);
  1889. this.unclip();
  1890. if(typeof onComplete == "function"){
  1891. onComplete();
  1892. }
  1893. }else{
  1894. this.setHeight(oldHeight); this.setHeight(height, animate, duration, function(){
  1895. this.unclip();
  1896. if(typeof onComplete == "function") onComplete();
  1897. }.createDelegate(this), easing);
  1898. }
  1899. }.createDelegate(this), 0);
  1900. return this;
  1901. },
  1902. contains : function(el){
  1903. if(!el){return false;}
  1904. try {
  1905. return D.isAncestor(this.dom, el.dom ? el.dom : el);
  1906. } catch(e){}
  1907. return false;
  1908. },
  1909. isVisible : function(deep) {
  1910. var vis = !(this.getStyle("visibility") == "hidden" || this.getStyle("display") == "none");
  1911. if(deep !== true || !vis){
  1912. return vis;
  1913. }
  1914. var p = this.dom.parentNode;
  1915. while(p && p.tagName.toLowerCase() != "body"){
  1916. if(!Ext.fly(p, '_isVisible').isVisible()){
  1917. return false;
  1918. }
  1919. p = p.parentNode;
  1920. }
  1921. return true;
  1922. },
  1923. select : function(selector, unique){
  1924. return El.select(selector, unique, this.dom);
  1925. },
  1926. query : function(selector, unique){
  1927. return Ext.DomQuery.select(selector, this.dom);
  1928. },
  1929. child : function(selector, returnDom){
  1930. var n = Ext.DomQuery.selectNode(selector, this.dom);
  1931. return returnDom ? n : Ext.get(n);
  1932. },
  1933. down : function(selector, returnDom){
  1934. var n = Ext.DomQuery.selectNode(" > " + selector, this.dom);
  1935. return returnDom ? n : Ext.get(n);
  1936. },
  1937. initDD : function(group, config, overrides){
  1938. var dd = new Ext.dd.DD(Ext.id(this.dom), group, config);
  1939. return Ext.apply(dd, overrides);
  1940. },
  1941. initDDProxy : function(group, config, overrides){
  1942. var dd = new Ext.dd.DDProxy(Ext.id(this.dom), group, config);
  1943. return Ext.apply(dd, overrides);
  1944. },
  1945. initDDTarget : function(group, config, overrides){
  1946. var dd = new Ext.dd.DDTarget(Ext.id(this.dom), group, config);
  1947. return Ext.apply(dd, overrides);
  1948. },
  1949. setVisible : function(visible, animate){
  1950. if(!animate || !A){
  1951. if(this.visibilityMode == El.DISPLAY){
  1952. this.setDisplayed(visible);
  1953. }else{
  1954. this.fixDisplay();
  1955. this.dom.style.visibility = visible ? "visible" : "hidden";
  1956. }
  1957. }else{
  1958. var dom = this.dom;
  1959. var visMode = this.visibilityMode;
  1960. if(visible){
  1961. this.setOpacity(.01);
  1962. this.setVisible(true);
  1963. }
  1964. this.anim({opacity: { to: (visible?1:0) }},
  1965. this.preanim(arguments, 1),
  1966. null, .35, 'easeIn', function(){
  1967. if(!visible){
  1968. if(visMode == El.DISPLAY){
  1969. dom.style.display = "none";
  1970. }else{
  1971. dom.style.visibility = "hidden";
  1972. }
  1973. Ext.get(dom).setOpacity(1);
  1974. }
  1975. });
  1976. }
  1977. return this;
  1978. },
  1979. isDisplayed : function() {
  1980. return this.getStyle("display") != "none";
  1981. },
  1982. toggle : function(animate){
  1983. this.setVisible(!this.isVisible(), this.preanim(arguments, 0));
  1984. return this;
  1985. },
  1986. setDisplayed : function(value) {
  1987. if(typeof value == "boolean"){
  1988. value = value ? this.originalDisplay : "none";
  1989. }
  1990. this.setStyle("display", value);
  1991. return this;
  1992. },
  1993. focus : function() {
  1994. try{
  1995. this.dom.focus();
  1996. }catch(e){}
  1997. return this;
  1998. },
  1999. blur : function() {
  2000. try{
  2001. this.dom.blur();
  2002. }catch(e){}
  2003. return this;
  2004. },
  2005. addClass : function(className){
  2006. if(Ext.isArray(className)){
  2007. for(var i = 0, len = className.length; i < len; i++) {
  2008. this.addClass(className[i]);
  2009. }
  2010. }else{
  2011. if(className && !this.hasClass(className)){
  2012. this.dom.className = this.dom.className + " " + className;
  2013. }
  2014. }
  2015. return this;
  2016. },
  2017. radioClass : function(className){
  2018. var siblings = this.dom.parentNode.childNodes;
  2019. for(var i = 0; i < siblings.length; i++) {
  2020. var s = siblings[i];
  2021. if(s.nodeType == 1){
  2022. Ext.get(s).removeClass(className);
  2023. }
  2024. }
  2025. this.addClass(className);
  2026. return this;
  2027. },
  2028. removeClass : function(className){
  2029. if(!className || !this.dom.className){
  2030. return this;
  2031. }
  2032. if(Ext.isArray(className)){
  2033. for(var i = 0, len = className.length; i < len; i++) {
  2034. this.removeClass(className[i]);
  2035. }
  2036. }else{
  2037. if(this.hasClass(className)){
  2038. var re = this.classReCache[className];
  2039. if (!re) {
  2040. re = new RegExp('(?:^|\\s+)' + className + '(?:\\s+|$)', "g");
  2041. this.classReCache[className] = re;
  2042. }
  2043. this.dom.className =
  2044. this.dom.className.replace(re, " ");
  2045. }
  2046. }
  2047. return this;
  2048. },
  2049. classReCache: {},
  2050. toggleClass : function(className){
  2051. if(this.hasClass(className)){
  2052. this.removeClass(className);
  2053. }else{
  2054. this.addClass(className);
  2055. }
  2056. return this;
  2057. },
  2058. hasClass : function(className){
  2059. return className && (' '+this.dom.className+' ').indexOf(' '+className+' ') != -1;
  2060. },
  2061. replaceClass : function(oldClassName, newClassName){
  2062. this.removeClass(oldClassName);
  2063. this.addClass(newClassName);
  2064. return this;
  2065. },
  2066. getStyles : function(){
  2067. var a = arguments, len = a.length, r = {};
  2068. for(var i = 0; i < len; i++){
  2069. r[a[i]] = this.getStyle(a[i]);
  2070. }
  2071. return r;
  2072. },
  2073. getStyle : function(){
  2074. return view && view.getComputedStyle ?
  2075. function(prop){
  2076. var el = this.dom, v, cs, camel;
  2077. if(prop == 'float'){
  2078. prop = "cssFloat";
  2079. }
  2080. if(v = el.style[prop]){
  2081. return v;
  2082. }
  2083. if(cs = view.getComputedStyle(el, "")){
  2084. if(!(camel = propCache[prop])){
  2085. camel = propCache[prop] = prop.replace(camelRe, camelFn);
  2086. }
  2087. return cs[camel];
  2088. }
  2089. return null;
  2090. } :
  2091. function(prop){
  2092. var el = this.dom, v, cs, camel;
  2093. if(prop == 'opacity'){
  2094. if(typeof el.style.filter == 'string'){
  2095. var m = el.style.filter.match(/alpha\(opacity=(.*)\)/i);
  2096. if(m){
  2097. var fv = parseFloat(m[1]);
  2098. if(!isNaN(fv)){
  2099. return fv ? fv / 100 : 0;
  2100. }
  2101. }
  2102. }
  2103. return 1;
  2104. }else if(prop == 'float'){
  2105. prop = "styleFloat";
  2106. }
  2107. if(!(camel = propCache[prop])){
  2108. camel = propCache[prop] = prop.replace(camelRe, camelFn);
  2109. }
  2110. if(v = el.style[camel]){
  2111. return v;
  2112. }
  2113. if(cs = el.currentStyle){
  2114. return cs[camel];
  2115. }
  2116. return null;
  2117. };
  2118. }(),
  2119. setStyle : function(prop, value){
  2120. if(typeof prop == "string"){
  2121. var camel;
  2122. if(!(camel = propCache[prop])){
  2123. camel = propCache[prop] = prop.replace(camelRe, camelFn);
  2124. }
  2125. if(camel == 'opacity') {
  2126. this.setOpacity(value);
  2127. }else{
  2128. this.dom.style[camel] = value;
  2129. }
  2130. }else{
  2131. for(var style in prop){
  2132. if(typeof prop[style] != "function"){
  2133. this.setStyle(style, prop[style]);
  2134. }
  2135. }
  2136. }
  2137. return this;
  2138. },
  2139. applyStyles : function(style){
  2140. Ext.DomHelper.applyStyles(this.dom, style);
  2141. return this;
  2142. },
  2143. getX : function(){
  2144. return D.getX(this.dom);
  2145. },
  2146. getY : function(){
  2147. return D.getY(this.dom);
  2148. },
  2149. getXY : function(){
  2150. return D.getXY(this.dom);
  2151. },
  2152. getOffsetsTo : function(el){
  2153. var o = this.getXY();
  2154. var e = Ext.fly(el, '_internal').getXY();
  2155. return [o[0]-e[0],o[1]-e[1]];
  2156. },
  2157. setX : function(x, animate){
  2158. if(!animate || !A){
  2159. D.setX(this.dom, x);
  2160. }else{
  2161. this.setXY([x, this.getY()], this.preanim(arguments, 1));
  2162. }
  2163. return this;
  2164. },
  2165. setY : function(y, animate){
  2166. if(!animate || !A){
  2167. D.setY(this.dom, y);
  2168. }else{
  2169. this.setXY([this.getX(), y], this.preanim(arguments, 1));
  2170. }
  2171. return this;
  2172. },
  2173. setLeft : function(left){
  2174. this.setStyle("left", this.addUnits(left));
  2175. return this;
  2176. },
  2177. setTop : function(top){
  2178. this.setStyle("top", this.addUnits(top));
  2179. return this;
  2180. },
  2181. setRight : function(right){
  2182. this.setStyle("right", this.addUnits(right));
  2183. return this;
  2184. },
  2185. setBottom : function(bottom){
  2186. this.setStyle("bottom", this.addUnits(bottom));
  2187. return this;
  2188. },
  2189. setXY : function(pos, animate){
  2190. if(!animate || !A){
  2191. D.setXY(this.dom, pos);
  2192. }else{
  2193. this.anim({points: {to: pos}}, this.preanim(arguments, 1), 'motion');
  2194. }
  2195. return this;
  2196. },
  2197. setLocation : function(x, y, animate){
  2198. this.setXY([x, y], this.preanim(arguments, 2));
  2199. return this;
  2200. },
  2201. moveTo : function(x, y, animate){
  2202. this.setXY([x, y], this.preanim(arguments, 2));
  2203. return this;
  2204. },
  2205. getRegion : function(){
  2206. return D.getRegion(this.dom);
  2207. },
  2208. getHeight : function(contentHeight){
  2209. var h = this.dom.offsetHeight || 0;
  2210. h = contentHeight !== true ? h : h-this.getBorderWidth("tb")-this.getPadding("tb");
  2211. return h < 0 ? 0 : h;
  2212. },
  2213. getWidth : function(contentWidth){
  2214. var w = this.dom.offsetWidth || 0;
  2215. w = contentWidth !== true ? w : w-this.getBorderWidth("lr")-this.getPadding("lr");
  2216. return w < 0 ? 0 : w;
  2217. },
  2218. getComputedHeight : function(){
  2219. var h = Math.max(this.dom.offsetHeight, this.dom.clientHeight);
  2220. if(!h){
  2221. h = parseInt(this.getStyle('height'), 10) || 0;
  2222. if(!this.isBorderBox()){
  2223. h += this.getFrameWidth('tb');
  2224. }
  2225. }
  2226. return h;
  2227. },
  2228. getComputedWidth : function(){
  2229. var w = Math.max(this.dom.offsetWidth, this.dom.clientWidth);
  2230. if(!w){
  2231. w = parseInt(this.getStyle('width'), 10) || 0;
  2232. if(!this.isBorderBox()){
  2233. w += this.getFrameWidth('lr');
  2234. }
  2235. }
  2236. return w;
  2237. },
  2238. getSize : function(contentSize){
  2239. return {width: this.getWidth(contentSize), height: this.getHeight(contentSize)};
  2240. },
  2241. getStyleSize : function(){
  2242. var w, h, d = this.dom, s = d.style;
  2243. if(s.width && s.width != 'auto'){
  2244. w = parseInt(s.width, 10);
  2245. if(Ext.isBorderBox){
  2246. w -= this.getFrameWidth('lr');
  2247. }
  2248. }
  2249. if(s.height && s.height != 'auto'){
  2250. h = parseInt(s.height, 10);
  2251. if(Ext.isBorderBox){
  2252. h -= this.getFrameWidth('tb');
  2253. }
  2254. }
  2255. return {width: w || this.getWidth(true), height: h || this.getHeight(true)};
  2256. },
  2257. getViewSize : function(){
  2258. var d = this.dom, doc = document, aw = 0, ah = 0;
  2259. if(d == doc || d == doc.body){
  2260. return {width : D.getViewWidth(), height: D.getViewHeight()};
  2261. }else{
  2262. return {
  2263. width : d.clientWidth,
  2264. height: d.clientHeight
  2265. };
  2266. }
  2267. },
  2268. getValue : function(asNumber){
  2269. return asNumber ? parseInt(this.dom.value, 10) : this.dom.value;
  2270. },
  2271. adjustWidth : function(width){
  2272. if(typeof width == "number"){
  2273. if(this.autoBoxAdjust && !this.isBorderBox()){
  2274. width -= (this.getBorderWidth("lr") + this.getPadding("lr"));
  2275. }
  2276. if(width < 0){
  2277. width = 0;
  2278. }
  2279. }
  2280. return width;
  2281. },
  2282. adjustHeight : function(height){
  2283. if(typeof height == "number"){
  2284. if(this.autoBoxAdjust && !this.isBorderBox()){
  2285. height -= (this.getBorderWidth("tb") + this.getPadding("tb"));
  2286. }
  2287. if(height < 0){
  2288. height = 0;
  2289. }
  2290. }
  2291. return height;
  2292. },
  2293. setWidth : function(width, animate){
  2294. width = this.adjustWidth(width);
  2295. if(!animate || !A){
  2296. this.dom.style.width = this.addUnits(width);
  2297. }else{
  2298. this.anim({width: {to: width}}, this.preanim(arguments, 1));
  2299. }
  2300. return this;
  2301. },
  2302. setHeight : function(height, animate){
  2303. height = this.adjustHeight(height);
  2304. if(!animate || !A){
  2305. this.dom.style.height = this.addUnits(height);
  2306. }else{
  2307. this.anim({height: {to: height}}, this.preanim(arguments, 1));
  2308. }
  2309. return this;
  2310. },
  2311. setSize : function(width, height, animate){
  2312. if(typeof width == "object"){ height = width.height; width = width.width;
  2313. }
  2314. width = this.adjustWidth(width); height = this.adjustHeight(height);
  2315. if(!animate || !A){
  2316. this.dom.style.width = this.addUnits(width);
  2317. this.dom.style.height = this.addUnits(height);
  2318. }else{
  2319. this.anim({width: {to: width}, height: {to: height}}, this.preanim(arguments, 2));
  2320. }
  2321. return this;
  2322. },
  2323. setBounds : function(x, y, width, height, animate){
  2324. if(!animate || !A){
  2325. this.setSize(width, height);
  2326. this.setLocation(x, y);
  2327. }else{
  2328. width = this.adjustWidth(width); height = this.adjustHeight(height);
  2329. this.anim({points: {to: [x, y]}, width: {to: width}, height: {to: height}},
  2330. this.preanim(arguments, 4), 'motion');
  2331. }
  2332. return this;
  2333. },
  2334. setRegion : function(region, animate){
  2335. this.setBounds(region.left, region.top, region.right-region.left, region.bottom-region.top, this.preanim(arguments, 1));
  2336. return this;
  2337. },
  2338. addListener : function(eventName, fn, scope, options){
  2339. Ext.EventManager.on(this.dom, eventName, fn, scope || this, options);
  2340. },
  2341. removeListener : function(eventName, fn){
  2342. Ext.EventManager.removeListener(this.dom, eventName, fn);
  2343. return this;
  2344. },
  2345. removeAllListeners : function(){
  2346. E.purgeElement(this.dom);
  2347. return this;
  2348. },
  2349. relayEvent : function(eventName, observable){
  2350. this.on(eventName, function(e){
  2351. observable.fireEvent(eventName, e);
  2352. });
  2353. },
  2354. setOpacity : function(opacity, animate){
  2355. if(!animate || !A){
  2356. var s = this.dom.style;
  2357. if(Ext.isIE){
  2358. s.zoom = 1;
  2359. s.filter = (s.filter || '').replace(/alpha\([^\)]*\)/gi,"") +
  2360. (opacity == 1 ? "" : " alpha(opacity=" + opacity * 100 + ")");
  2361. }else{
  2362. s.opacity = opacity;
  2363. }
  2364. }else{
  2365. this.anim({opacity: {to: opacity}}, this.preanim(arguments, 1), null, .35, 'easeIn');
  2366. }
  2367. return this;
  2368. },
  2369. getLeft : function(local){
  2370. if(!local){
  2371. return this.getX();
  2372. }else{
  2373. return parseInt(this.getStyle("left"), 10) || 0;
  2374. }
  2375. },
  2376. getRight : function(local){
  2377. if(!local){
  2378. return this.getX() + this.getWidth();
  2379. }else{
  2380. return (this.getLeft(true) + this.getWidth()) || 0;
  2381. }
  2382. },
  2383. getTop : function(local) {
  2384. if(!local){
  2385. return this.getY();
  2386. }else{
  2387. return parseInt(this.getStyle("top"), 10) || 0;
  2388. }
  2389. },
  2390. getBottom : function(local){
  2391. if(!local){
  2392. return this.getY() + this.getHeight();
  2393. }else{
  2394. return (this.getTop(true) + this.getHeight()) || 0;
  2395. }
  2396. },
  2397. position : function(pos, zIndex, x, y){
  2398. if(!pos){
  2399. if(this.getStyle('position') == 'static'){
  2400. this.setStyle('position', 'relative');
  2401. }
  2402. }else{
  2403. this.setStyle("position", pos);
  2404. }
  2405. if(zIndex){
  2406. this.setStyle("z-index", zIndex);
  2407. }
  2408. if(x !== undefined && y !== undefined){
  2409. this.setXY([x, y]);
  2410. }else if(x !== undefined){
  2411. this.setX(x);
  2412. }else if(y !== undefined){
  2413. this.setY(y);
  2414. }
  2415. },
  2416. clearPositioning : function(value){
  2417. value = value ||'';
  2418. this.setStyle({
  2419. "left": value,
  2420. "right": value,
  2421. "top": value,
  2422. "bottom": value,
  2423. "z-index": "",
  2424. "position" : "static"
  2425. });
  2426. return this;
  2427. },
  2428. getPositioning : function(){
  2429. var l = this.getStyle("left");
  2430. var t = this.getStyle("top");
  2431. return {
  2432. "position" : this.getStyle("position"),
  2433. "left" : l,
  2434. "right" : l ? "" : this.getStyle("right"),
  2435. "top" : t,
  2436. "bottom" : t ? "" : this.getStyle("bottom"),
  2437. "z-index" : this.getStyle("z-index")
  2438. };
  2439. },
  2440. getBorderWidth : function(side){
  2441. return this.addStyles(side, El.borders);
  2442. },
  2443. getPadding : function(side){
  2444. return this.addStyles(side, El.paddings);
  2445. },
  2446. setPositioning : function(pc){
  2447. this.applyStyles(pc);
  2448. if(pc.right == "auto"){
  2449. this.dom.style.right = "";
  2450. }
  2451. if(pc.bottom == "auto"){
  2452. this.dom.style.bottom = "";
  2453. }
  2454. return this;
  2455. },
  2456. fixDisplay : function(){
  2457. if(this.getStyle("display") == "none"){
  2458. this.setStyle("visibility", "hidden");
  2459. this.setStyle("display", this.originalDisplay); if(this.getStyle("display") == "none"){ this.setStyle("display", "block");
  2460. }
  2461. }
  2462. },
  2463. setOverflow : function(v){
  2464. if(v=='auto' && Ext.isMac && Ext.isGecko){ this.dom.style.overflow = 'hidden';
  2465. (function(){this.dom.style.overflow = 'auto';}).defer(1, this);
  2466. }else{
  2467. this.dom.style.overflow = v;
  2468. }
  2469. },
  2470. setLeftTop : function(left, top){
  2471. this.dom.style.left = this.addUnits(left);
  2472. this.dom.style.top = this.addUnits(top);
  2473. return this;
  2474. },
  2475. move : function(direction, distance, animate){
  2476. var xy = this.getXY();
  2477. direction = direction.toLowerCase();
  2478. switch(direction){
  2479. case "l":
  2480. case "left":
  2481. this.moveTo(xy[0]-distance, xy[1], this.preanim(arguments, 2));
  2482. break;
  2483. case "r":
  2484. case "right":
  2485. this.moveTo(xy[0]+distance, xy[1], this.preanim(arguments, 2));
  2486. break;
  2487. case "t":
  2488. case "top":
  2489. case "up":
  2490. this.moveTo(xy[0], xy[1]-distance, this.preanim(arguments, 2));
  2491. break;
  2492. case "b":
  2493. case "bottom":
  2494. case "down":
  2495. this.moveTo(xy[0], xy[1]+distance, this.preanim(arguments, 2));
  2496. break;
  2497. }
  2498. return this;
  2499. },
  2500. clip : function(){
  2501. if(!this.isClipped){
  2502. this.isClipped = true;
  2503. this.originalClip = {
  2504. "o": this.getStyle("overflow"),
  2505. "x": this.getStyle("overflow-x"),
  2506. "y": this.getStyle("overflow-y")
  2507. };
  2508. this.setStyle("overflow", "hidden");
  2509. this.setStyle("overflow-x", "hidden");
  2510. this.setStyle("overflow-y", "hidden");
  2511. }
  2512. return this;
  2513. },
  2514. unclip : function(){
  2515. if(this.isClipped){
  2516. this.isClipped = false;
  2517. var o = this.originalClip;
  2518. if(o.o){this.setStyle("overflow", o.o);}
  2519. if(o.x){this.setStyle("overflow-x", o.x);}
  2520. if(o.y){this.setStyle("overflow-y", o.y);}
  2521. }
  2522. return this;
  2523. },
  2524. getAnchorXY : function(anchor, local, s){
  2525. var w, h, vp = false;
  2526. if(!s){
  2527. var d = this.dom;
  2528. if(d == document.body || d == document){
  2529. vp = true;
  2530. w = D.getViewWidth(); h = D.getViewHeight();
  2531. }else{
  2532. w = this.getWidth(); h = this.getHeight();
  2533. }
  2534. }else{
  2535. w = s.width; h = s.height;
  2536. }
  2537. var x = 0, y = 0, r = Math.round;
  2538. switch((anchor || "tl").toLowerCase()){
  2539. case "c":
  2540. x = r(w*.5);
  2541. y = r(h*.5);
  2542. break;
  2543. case "t":
  2544. x = r(w*.5);
  2545. y = 0;
  2546. break;
  2547. case "l":
  2548. x = 0;
  2549. y = r(h*.5);
  2550. break;
  2551. case "r":
  2552. x = w;
  2553. y = r(h*.5);
  2554. break;
  2555. case "b":
  2556. x = r(w*.5);
  2557. y = h;
  2558. break;
  2559. case "tl":
  2560. x = 0;
  2561. y = 0;
  2562. break;
  2563. case "bl":
  2564. x = 0;
  2565. y = h;
  2566. break;
  2567. case "br":
  2568. x = w;
  2569. y = h;
  2570. break;
  2571. case "tr":
  2572. x = w;
  2573. y = 0;
  2574. break;
  2575. }
  2576. if(local === true){
  2577. return [x, y];
  2578. }
  2579. if(vp){
  2580. var sc = this.getScroll();
  2581. return [x + sc.left, y + sc.top];
  2582. }
  2583. var o = this.getXY();
  2584. return [x+o[0], y+o[1]];
  2585. },
  2586. getAlignToXY : function(el, p, o){
  2587. el = Ext.get(el);
  2588. if(!el || !el.dom){
  2589. throw "Element.alignToXY with an element that doesn't exist";
  2590. }
  2591. var d = this.dom;
  2592. var c = false; var p1 = "", p2 = "";
  2593. o = o || [0,0];
  2594. if(!p){
  2595. p = "tl-bl";
  2596. }else if(p == "?"){
  2597. p = "tl-bl?";
  2598. }else if(p.indexOf("-") == -1){
  2599. p = "tl-" + p;
  2600. }
  2601. p = p.toLowerCase();
  2602. var m = p.match(/^([a-z]+)-([a-z]+)(\?)?$/);
  2603. if(!m){
  2604. throw "Element.alignTo with an invalid alignment " + p;
  2605. }
  2606. p1 = m[1]; p2 = m[2]; c = !!m[3];
  2607. var a1 = this.getAnchorXY(p1, true);
  2608. var a2 = el.getAnchorXY(p2, false);
  2609. var x = a2[0] - a1[0] + o[0];
  2610. var y = a2[1] - a1[1] + o[1];
  2611. if(c){
  2612. var w = this.getWidth(), h = this.getHeight(), r = el.getRegion();
  2613. var dw = D.getViewWidth()-5, dh = D.getViewHeight()-5;
  2614. var p1y = p1.charAt(0), p1x = p1.charAt(p1.length-1);
  2615. var p2y = p2.charAt(0), p2x = p2.charAt(p2.length-1);
  2616. var swapY = ((p1y=="t" && p2y=="b") || (p1y=="b" && p2y=="t"));
  2617. var swapX = ((p1x=="r" && p2x=="l") || (p1x=="l" && p2x=="r"));
  2618. var doc = document;
  2619. var scrollX = (doc.documentElement.scrollLeft || doc.body.scrollLeft || 0)+5;
  2620. var scrollY = (doc.documentElement.scrollTop || doc.body.scrollTop || 0)+5;
  2621. if((x+w) > dw + scrollX){
  2622. x = swapX ? r.left-w : dw+scrollX-w;
  2623. }
  2624. if(x < scrollX){
  2625. x = swapX ? r.right : scrollX;
  2626. }
  2627. if((y+h) > dh + scrollY){
  2628. y = swapY ? r.top-h : dh+scrollY-h;
  2629. }
  2630. if (y < scrollY){
  2631. y = swapY ? r.bottom : scrollY;
  2632. }
  2633. }
  2634. return [x,y];
  2635. },
  2636. getConstrainToXY : function(){
  2637. var os = {top:0, left:0, bottom:0, right: 0};
  2638. return function(el, local, offsets, proposedXY){
  2639. el = Ext.get(el);
  2640. offsets = offsets ? Ext.applyIf(offsets, os) : os;
  2641. var vw, vh, vx = 0, vy = 0;
  2642. if(el.dom == document.body || el.dom == document){
  2643. vw = Ext.lib.Dom.getViewWidth();
  2644. vh = Ext.lib.Dom.getViewHeight();
  2645. }else{
  2646. vw = el.dom.clientWidth;
  2647. vh = el.dom.clientHeight;
  2648. if(!local){
  2649. var vxy = el.getXY();
  2650. vx = vxy[0];
  2651. vy = vxy[1];
  2652. }
  2653. }
  2654. var s = el.getScroll();
  2655. vx += offsets.left + s.left;
  2656. vy += offsets.top + s.top;
  2657. vw -= offsets.right;
  2658. vh -= offsets.bottom;
  2659. var vr = vx+vw;
  2660. var vb = vy+vh;
  2661. var xy = proposedXY || (!local ? this.getXY() : [this.getLeft(true), this.getTop(true)]);
  2662. var x = xy[0], y = xy[1];
  2663. var w = this.dom.offsetWidth, h = this.dom.offsetHeight;
  2664. var moved = false;
  2665. if((x + w) > vr){
  2666. x = vr - w;
  2667. moved = true;
  2668. }
  2669. if((y + h) > vb){
  2670. y = vb - h;
  2671. moved = true;
  2672. }
  2673. if(x < vx){
  2674. x = vx;
  2675. moved = true;
  2676. }
  2677. if(y < vy){
  2678. y = vy;
  2679. moved = true;
  2680. }
  2681. return moved ? [x, y] : false;
  2682. };
  2683. }(),
  2684. adjustForConstraints : function(xy, parent, offsets){
  2685. return this.getConstrainToXY(parent || document, false, offsets, xy) || xy;
  2686. },
  2687. alignTo : function(element, position, offsets, animate){
  2688. var xy = this.getAlignToXY(element, position, offsets);
  2689. this.setXY(xy, this.preanim(arguments, 3));
  2690. return this;
  2691. },
  2692. anchorTo : function(el, alignment, offsets, animate, monitorScroll, callback){
  2693. var action = function(){
  2694. this.alignTo(el, alignment, offsets, animate);
  2695. Ext.callback(callback, this);
  2696. };
  2697. Ext.EventManager.onWindowResize(action, this);
  2698. var tm = typeof monitorScroll;
  2699. if(tm != 'undefined'){
  2700. Ext.EventManager.on(window, 'scroll', action, this,
  2701. {buffer: tm == 'number' ? monitorScroll : 50});
  2702. }
  2703. action.call(this); return this;
  2704. },
  2705. clearOpacity : function(){
  2706. if (window.ActiveXObject) {
  2707. if(typeof this.dom.style.filter == 'string' && (/alpha/i).test(this.dom.style.filter)){
  2708. this.dom.style.filter = "";
  2709. }
  2710. } else {
  2711. this.dom.style.opacity = "";
  2712. this.dom.style["-moz-opacity"] = "";
  2713. this.dom.style["-khtml-opacity"] = "";
  2714. }
  2715. return this;
  2716. },
  2717. hide : function(animate){
  2718. this.setVisible(false, this.preanim(arguments, 0));
  2719. return this;
  2720. },
  2721. show : function(animate){
  2722. this.setVisible(true, this.preanim(arguments, 0));
  2723. return this;
  2724. },
  2725. addUnits : function(size){
  2726. return Ext.Element.addUnits(size, this.defaultUnit);
  2727. },
  2728. update : function(html, loadScripts, callback){
  2729. if(typeof html == "undefined"){
  2730. html = "";
  2731. }
  2732. if(loadScripts !== true){
  2733. this.dom.innerHTML = html;
  2734. if(typeof callback == "function"){
  2735. callback();
  2736. }
  2737. return this;
  2738. }
  2739. var id = Ext.id();
  2740. var dom = this.dom;
  2741. html += '<span id="' + id + '"></span>';
  2742. E.onAvailable(id, function(){
  2743. var hd = document.getElementsByTagName("head")[0];
  2744. var re = /(?:<script([^>]*)?>)((\n|\r|.)*?)(?:<\/script>)/ig;
  2745. var srcRe = /\ssrc=([\'\"])(.*?)\1/i;
  2746. var typeRe = /\stype=([\'\"])(.*?)\1/i;
  2747. var match;
  2748. while(match = re.exec(html)){
  2749. var attrs = match[1];
  2750. var srcMatch = attrs ? attrs.match(srcRe) : false;
  2751. if(srcMatch && srcMatch[2]){
  2752. var s = document.createElement("script");
  2753. s.src = srcMatch[2];
  2754. var typeMatch = attrs.match(typeRe);
  2755. if(typeMatch && typeMatch[2]){
  2756. s.type = typeMatch[2];
  2757. }
  2758. hd.appendChild(s);
  2759. }else if(match[2] && match[2].length > 0){
  2760. if(window.execScript) {
  2761. window.execScript(match[2]);
  2762. } else {
  2763. window.eval(match[2]);
  2764. }
  2765. }
  2766. }
  2767. var el = document.getElementById(id);
  2768. if(el){Ext.removeNode(el);}
  2769. if(typeof callback == "function"){
  2770. callback();
  2771. }
  2772. });
  2773. dom.innerHTML = html.replace(/(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)/ig, "");
  2774. return this;
  2775. },
  2776. load : function(){
  2777. var um = this.getUpdater();
  2778. um.update.apply(um, arguments);
  2779. return this;
  2780. },
  2781. getUpdater : function(){
  2782. if(!this.updateManager){
  2783. this.updateManager = new Ext.Updater(this);
  2784. }
  2785. return this.updateManager;
  2786. },
  2787. unselectable : function(){
  2788. this.dom.unselectable = "on";
  2789. this.swallowEvent("selectstart", true);
  2790. this.applyStyles("-moz-user-select:none;-khtml-user-select:none;");
  2791. this.addClass("x-unselectable");
  2792. return this;
  2793. },
  2794. getCenterXY : function(){
  2795. return this.getAlignToXY(document, 'c-c');
  2796. },
  2797. center : function(centerIn){
  2798. this.alignTo(centerIn || document, 'c-c');
  2799. return this;
  2800. },
  2801. isBorderBox : function(){
  2802. return noBoxAdjust[this.dom.tagName.toLowerCase()] || Ext.isBorderBox;
  2803. },
  2804. getBox : function(contentBox, local){
  2805. var xy;
  2806. if(!local){
  2807. xy = this.getXY();
  2808. }else{
  2809. var left = parseInt(this.getStyle("left"), 10) || 0;
  2810. var top = parseInt(this.getStyle("top"), 10) || 0;
  2811. xy = [left, top];
  2812. }
  2813. var el = this.dom, w = el.offsetWidth, h = el.offsetHeight, bx;
  2814. if(!contentBox){
  2815. bx = {x: xy[0], y: xy[1], 0: xy[0], 1: xy[1], width: w, height: h};
  2816. }else{
  2817. var l = this.getBorderWidth("l")+this.getPadding("l");
  2818. var r = this.getBorderWidth("r")+this.getPadding("r");
  2819. var t = this.getBorderWidth("t")+this.getPadding("t");
  2820. var b = this.getBorderWidth("b")+this.getPadding("b");
  2821. bx = {x: xy[0]+l, y: xy[1]+t, 0: xy[0]+l, 1: xy[1]+t, width: w-(l+r), height: h-(t+b)};
  2822. }
  2823. bx.right = bx.x + bx.width;
  2824. bx.bottom = bx.y + bx.height;
  2825. return bx;
  2826. },
  2827. getFrameWidth : function(sides, onlyContentBox){
  2828. return onlyContentBox && Ext.isBorderBox ? 0 : (this.getPadding(sides) + this.getBorderWidth(sides));
  2829. },
  2830. setBox : function(box, adjust, animate){
  2831. var w = box.width, h = box.height;
  2832. if((adjust && !this.autoBoxAdjust) && !this.isBorderBox()){
  2833. w -= (this.getBorderWidth("lr") + this.getPadding("lr"));
  2834. h -= (this.getBorderWidth("tb") + this.getPadding("tb"));
  2835. }
  2836. this.setBounds(box.x, box.y, w, h, this.preanim(arguments, 2));
  2837. return this;
  2838. },
  2839. repaint : function(){
  2840. var dom = this.dom;
  2841. this.addClass("x-repaint");
  2842. setTimeout(function(){
  2843. Ext.get(dom).removeClass("x-repaint");
  2844. }, 1);
  2845. return this;
  2846. },
  2847. getMargins : function(side){
  2848. if(!side){
  2849. return {
  2850. top: parseInt(this.getStyle("margin-top"), 10) || 0,
  2851. left: parseInt(this.getStyle("margin-left"), 10) || 0,
  2852. bottom: parseInt(this.getStyle("margin-bottom"), 10) || 0,
  2853. right: parseInt(this.getStyle("margin-right"), 10) || 0
  2854. };
  2855. }else{
  2856. return this.addStyles(side, El.margins);
  2857. }
  2858. },
  2859. addStyles : function(sides, styles){
  2860. var val = 0, v, w;
  2861. for(var i = 0, len = sides.length; i < len; i++){
  2862. v = this.getStyle(styles[sides.charAt(i)]);
  2863. if(v){
  2864. w = parseInt(v, 10);
  2865. if(w){ val += (w >= 0 ? w : -1 * w); }
  2866. }
  2867. }
  2868. return val;
  2869. },
  2870. createProxy : function(config, renderTo, matchBox){
  2871. config = typeof config == "object" ?
  2872. config : {tag : "div", cls: config};
  2873. var proxy;
  2874. if(renderTo){
  2875. proxy = Ext.DomHelper.append(renderTo, config, true);
  2876. }else {
  2877. proxy = Ext.DomHelper.insertBefore(this.dom, config, true);
  2878. }
  2879. if(matchBox){
  2880. proxy.setBox(this.getBox());
  2881. }
  2882. return proxy;
  2883. },
  2884. mask : function(msg, msgCls){
  2885. if(this.getStyle("position") == "static"){
  2886. this.setStyle("position", "relative");
  2887. }
  2888. if(this._maskMsg){
  2889. this._maskMsg.remove();
  2890. }
  2891. if(this._mask){
  2892. this._mask.remove();
  2893. }
  2894. this._mask = Ext.DomHelper.append(this.dom, {cls:"ext-el-mask"}, true);
  2895. this.addClass("x-masked");
  2896. this._mask.setDisplayed(true);
  2897. if(typeof msg == 'string'){
  2898. this._maskMsg = Ext.DomHelper.append(this.dom, {cls:"ext-el-mask-msg", cn:{tag:'div'}}, true);
  2899. var mm = this._maskMsg;
  2900. mm.dom.className = msgCls ? "ext-el-mask-msg " + msgCls : "ext-el-mask-msg";
  2901. mm.dom.firstChild.innerHTML = msg;
  2902. mm.setDisplayed(true);
  2903. mm.center(this);
  2904. }
  2905. if(Ext.isIE && !(Ext.isIE7 && Ext.isStrict) && this.getStyle('height') == 'auto'){ this._mask.setSize(this.dom.clientWidth, this.getHeight());
  2906. }
  2907. return this._mask;
  2908. },
  2909. unmask : function(){
  2910. if(this._mask){
  2911. if(this._maskMsg){
  2912. this._maskMsg.remove();
  2913. delete this._maskMsg;
  2914. }
  2915. this._mask.remove();
  2916. delete this._mask;
  2917. }
  2918. this.removeClass("x-masked");
  2919. },
  2920. isMasked : function(){
  2921. return this._mask && this._mask.isVisible();
  2922. },
  2923. createShim : function(){
  2924. var el = document.createElement('iframe');
  2925. el.frameBorder = 'no';
  2926. el.className = 'ext-shim';
  2927. if(Ext.isIE && Ext.isSecure){
  2928. el.src = Ext.SSL_SECURE_URL;
  2929. }
  2930. var shim = Ext.get(this.dom.parentNode.insertBefore(el, this.dom));
  2931. shim.autoBoxAdjust = false;
  2932. return shim;
  2933. },
  2934. remove : function(){
  2935. Ext.removeNode(this.dom);
  2936. delete El.cache[this.dom.id];
  2937. },
  2938. hover : function(overFn, outFn, scope){
  2939. var preOverFn = function(e){
  2940. if(!e.within(this, true)){
  2941. overFn.apply(scope || this, arguments);
  2942. }
  2943. };
  2944. var preOutFn = function(e){
  2945. if(!e.within(this, true)){
  2946. outFn.apply(scope || this, arguments);
  2947. }
  2948. };
  2949. this.on("mouseover", preOverFn, this.dom);
  2950. this.on("mouseout", preOutFn, this.dom);
  2951. return this;
  2952. },
  2953. addClassOnOver : function(className, preventFlicker){
  2954. this.hover(
  2955. function(){
  2956. Ext.fly(this, '_internal').addClass(className);
  2957. },
  2958. function(){
  2959. Ext.fly(this, '_internal').removeClass(className);
  2960. }
  2961. );
  2962. return this;
  2963. },
  2964. addClassOnFocus : function(className){
  2965. this.on("focus", function(){
  2966. Ext.fly(this, '_internal').addClass(className);
  2967. }, this.dom);
  2968. this.on("blur", function(){
  2969. Ext.fly(this, '_internal').removeClass(className);
  2970. }, this.dom);
  2971. return this;
  2972. },
  2973. addClassOnClick : function(className){
  2974. var dom = this.dom;
  2975. this.on("mousedown", function(){
  2976. Ext.fly(dom, '_internal').addClass(className);
  2977. var d = Ext.getDoc();
  2978. var fn = function(){
  2979. Ext.fly(dom, '_internal').removeClass(className);
  2980. d.removeListener("mouseup", fn);
  2981. };
  2982. d.on("mouseup", fn);
  2983. });
  2984. return this;
  2985. },
  2986. swallowEvent : function(eventName, preventDefault){
  2987. var fn = function(e){
  2988. e.stopPropagation();
  2989. if(preventDefault){
  2990. e.preventDefault();
  2991. }
  2992. };
  2993. if(Ext.isArray(eventName)){
  2994. for(var i = 0, len = eventName.length; i < len; i++){
  2995. this.on(eventName[i], fn);
  2996. }
  2997. return this;
  2998. }
  2999. this.on(eventName, fn);
  3000. return this;
  3001. },
  3002. parent : function(selector, returnDom){
  3003. return this.matchNode('parentNode', 'parentNode', selector, returnDom);
  3004. },
  3005. next : function(selector, returnDom){
  3006. return this.matchNode('nextSibling', 'nextSibling', selector, returnDom);
  3007. },
  3008. prev : function(selector, returnDom){
  3009. return this.matchNode('previousSibling', 'previousSibling', selector, returnDom);
  3010. },
  3011. first : function(selector, returnDom){
  3012. return this.matchNode('nextSibling', 'firstChild', selector, returnDom);
  3013. },
  3014. last : function(selector, returnDom){
  3015. return this.matchNode('previousSibling', 'lastChild', selector, returnDom);
  3016. },
  3017. matchNode : function(dir, start, selector, returnDom){
  3018. var n = this.dom[start];
  3019. while(n){
  3020. if(n.nodeType == 1 && (!selector || Ext.DomQuery.is(n, selector))){
  3021. return !returnDom ? Ext.get(n) : n;
  3022. }
  3023. n = n[dir];
  3024. }
  3025. return null;
  3026. },
  3027. appendChild: function(el){
  3028. el = Ext.get(el);
  3029. el.appendTo(this);
  3030. return this;
  3031. },
  3032. createChild: function(config, insertBefore, returnDom){
  3033. config = config || {tag:'div'};
  3034. if(insertBefore){
  3035. return Ext.DomHelper.insertBefore(insertBefore, config, returnDom !== true);
  3036. }
  3037. return Ext.DomHelper[!this.dom.firstChild ? 'overwrite' : 'append'](this.dom, config, returnDom !== true);
  3038. },
  3039. appendTo: function(el){
  3040. el = Ext.getDom(el);
  3041. el.appendChild(this.dom);
  3042. return this;
  3043. },
  3044. insertBefore: function(el){
  3045. el = Ext.getDom(el);
  3046. el.parentNode.insertBefore(this.dom, el);
  3047. return this;
  3048. },
  3049. insertAfter: function(el){
  3050. el = Ext.getDom(el);
  3051. el.parentNode.insertBefore(this.dom, el.nextSibling);
  3052. return this;
  3053. },
  3054. insertFirst: function(el, returnDom){
  3055. el = el || {};
  3056. if(typeof el == 'object' && !el.nodeType && !el.dom){ return this.createChild(el, this.dom.firstChild, returnDom);
  3057. }else{
  3058. el = Ext.getDom(el);
  3059. this.dom.insertBefore(el, this.dom.firstChild);
  3060. return !returnDom ? Ext.get(el) : el;
  3061. }
  3062. },
  3063. insertSibling: function(el, where, returnDom){
  3064. var rt;
  3065. if(Ext.isArray(el)){
  3066. for(var i = 0, len = el.length; i < len; i++){
  3067. rt = this.insertSibling(el[i], where, returnDom);
  3068. }
  3069. return rt;
  3070. }
  3071. where = where ? where.toLowerCase() : 'before';
  3072. el = el || {};
  3073. var refNode = where == 'before' ? this.dom : this.dom.nextSibling;
  3074. if(typeof el == 'object' && !el.nodeType && !el.dom){ if(where == 'after' && !this.dom.nextSibling){
  3075. rt = Ext.DomHelper.append(this.dom.parentNode, el, !returnDom);
  3076. }else{
  3077. rt = Ext.DomHelper[where == 'after' ? 'insertAfter' : 'insertBefore'](this.dom, el, !returnDom);
  3078. }
  3079. }else{
  3080. rt = this.dom.parentNode.insertBefore(Ext.getDom(el), refNode);
  3081. if(!returnDom){
  3082. rt = Ext.get(rt);
  3083. }
  3084. }
  3085. return rt;
  3086. },
  3087. wrap: function(config, returnDom){
  3088. if(!config){
  3089. config = {tag: "div"};
  3090. }
  3091. var newEl = Ext.DomHelper.insertBefore(this.dom, config, !returnDom);
  3092. newEl.dom ? newEl.dom.appendChild(this.dom) : newEl.appendChild(this.dom);
  3093. return newEl;
  3094. },
  3095. replace: function(el){
  3096. el = Ext.get(el);
  3097. this.insertBefore(el);
  3098. el.remove();
  3099. return this;
  3100. },
  3101. replaceWith: function(el){
  3102. if(typeof el == 'object' && !el.nodeType && !el.dom){ el = this.insertSibling(el, 'before');
  3103. }else{
  3104. el = Ext.getDom(el);
  3105. this.dom.parentNode.insertBefore(el, this.dom);
  3106. }
  3107. El.uncache(this.id);
  3108. this.dom.parentNode.removeChild(this.dom);
  3109. this.dom = el;
  3110. this.id = Ext.id(el);
  3111. El.cache[this.id] = this;
  3112. return this;
  3113. },
  3114. insertHtml : function(where, html, returnEl){
  3115. var el = Ext.DomHelper.insertHtml(where, this.dom, html);
  3116. return returnEl ? Ext.get(el) : el;
  3117. },
  3118. set : function(o, useSet){
  3119. var el = this.dom;
  3120. useSet = typeof useSet == 'undefined' ? (el.setAttribute ? true : false) : useSet;
  3121. for(var attr in o){
  3122. if(attr == "style" || typeof o[attr] == "function") continue;
  3123. if(attr=="cls"){
  3124. el.className = o["cls"];
  3125. }else if(o.hasOwnProperty(attr)){
  3126. if(useSet) el.setAttribute(attr, o[attr]);
  3127. else el[attr] = o[attr];
  3128. }
  3129. }
  3130. if(o.style){
  3131. Ext.DomHelper.applyStyles(el, o.style);
  3132. }
  3133. return this;
  3134. },
  3135. addKeyListener : function(key, fn, scope){
  3136. var config;
  3137. if(typeof key != "object" || Ext.isArray(key)){
  3138. config = {
  3139. key: key,
  3140. fn: fn,
  3141. scope: scope
  3142. };
  3143. }else{
  3144. config = {
  3145. key : key.key,
  3146. shift : key.shift,
  3147. ctrl : key.ctrl,
  3148. alt : key.alt,
  3149. fn: fn,
  3150. scope: scope
  3151. };
  3152. }
  3153. return new Ext.KeyMap(this, config);
  3154. },
  3155. addKeyMap : function(config){
  3156. return new Ext.KeyMap(this, config);
  3157. },
  3158. isScrollable : function(){
  3159. var dom = this.dom;
  3160. return dom.scrollHeight > dom.clientHeight || dom.scrollWidth > dom.clientWidth;
  3161. },
  3162. scrollTo : function(side, value, animate){
  3163. var prop = side.toLowerCase() == "left" ? "scrollLeft" : "scrollTop";
  3164. if(!animate || !A){
  3165. this.dom[prop] = value;
  3166. }else{
  3167. var to = prop == "scrollLeft" ? [value, this.dom.scrollTop] : [this.dom.scrollLeft, value];
  3168. this.anim({scroll: {"to": to}}, this.preanim(arguments, 2), 'scroll');
  3169. }
  3170. return this;
  3171. },
  3172. scroll : function(direction, distance, animate){
  3173. if(!this.isScrollable()){
  3174. return;
  3175. }
  3176. var el = this.dom;
  3177. var l = el.scrollLeft, t = el.scrollTop;
  3178. var w = el.scrollWidth, h = el.scrollHeight;
  3179. var cw = el.clientWidth, ch = el.clientHeight;
  3180. direction = direction.toLowerCase();
  3181. var scrolled = false;
  3182. var a = this.preanim(arguments, 2);
  3183. switch(direction){
  3184. case "l":
  3185. case "left":
  3186. if(w - l > cw){
  3187. var v = Math.min(l + distance, w-cw);
  3188. this.scrollTo("left", v, a);
  3189. scrolled = true;
  3190. }
  3191. break;
  3192. case "r":
  3193. case "right":
  3194. if(l > 0){
  3195. var v = Math.max(l - distance, 0);
  3196. this.scrollTo("left", v, a);
  3197. scrolled = true;
  3198. }
  3199. break;
  3200. case "t":
  3201. case "top":
  3202. case "up":
  3203. if(t > 0){
  3204. var v = Math.max(t - distance, 0);
  3205. this.scrollTo("top", v, a);
  3206. scrolled = true;
  3207. }
  3208. break;
  3209. case "b":
  3210. case "bottom":
  3211. case "down":
  3212. if(h - t > ch){
  3213. var v = Math.min(t + distance, h-ch);
  3214. this.scrollTo("top", v, a);
  3215. scrolled = true;
  3216. }
  3217. break;
  3218. }
  3219. return scrolled;
  3220. },
  3221. translatePoints : function(x, y){
  3222. if(typeof x == 'object' || Ext.isArray(x)){
  3223. y = x[1]; x = x[0];
  3224. }
  3225. var p = this.getStyle('position');
  3226. var o = this.getXY();
  3227. var l = parseInt(this.getStyle('left'), 10);
  3228. var t = parseInt(this.getStyle('top'), 10);
  3229. if(isNaN(l)){
  3230. l = (p == "relative") ? 0 : this.dom.offsetLeft;
  3231. }
  3232. if(isNaN(t)){
  3233. t = (p == "relative") ? 0 : this.dom.offsetTop;
  3234. }
  3235. return {left: (x - o[0] + l), top: (y - o[1] + t)};
  3236. },
  3237. getScroll : function(){
  3238. var d = this.dom, doc = document;
  3239. if(d == doc || d == doc.body){
  3240. var l, t;
  3241. if(Ext.isIE && Ext.isStrict){
  3242. l = doc.documentElement.scrollLeft || (doc.body.scrollLeft || 0);
  3243. t = doc.documentElement.scrollTop || (doc.body.scrollTop || 0);
  3244. }else{
  3245. l = window.pageXOffset || (doc.body.scrollLeft || 0);
  3246. t = window.pageYOffset || (doc.body.scrollTop || 0);
  3247. }
  3248. return {left: l, top: t};
  3249. }else{
  3250. return {left: d.scrollLeft, top: d.scrollTop};
  3251. }
  3252. },
  3253. getColor : function(attr, defaultValue, prefix){
  3254. var v = this.getStyle(attr);
  3255. if(!v || v == "transparent" || v == "inherit") {
  3256. return defaultValue;
  3257. }
  3258. var color = typeof prefix == "undefined" ? "#" : prefix;
  3259. if(v.substr(0, 4) == "rgb("){
  3260. var rvs = v.slice(4, v.length -1).split(",");
  3261. for(var i = 0; i < 3; i++){
  3262. var h = parseInt(rvs[i]);
  3263. var s = h.toString(16);
  3264. if(h < 16){
  3265. s = "0" + s;
  3266. }
  3267. color += s;
  3268. }
  3269. } else {
  3270. if(v.substr(0, 1) == "#"){
  3271. if(v.length == 4) {
  3272. for(var i = 1; i < 4; i++){
  3273. var c = v.charAt(i);
  3274. color += c + c;
  3275. }
  3276. }else if(v.length == 7){
  3277. color += v.substr(1);
  3278. }
  3279. }
  3280. }
  3281. return(color.length > 5 ? color.toLowerCase() : defaultValue);
  3282. },
  3283. boxWrap : function(cls){
  3284. cls = cls || 'x-box';
  3285. var el = Ext.get(this.insertHtml('beforeBegin', String.format('<div class="{0}">'+El.boxMarkup+'</div>', cls)));
  3286. el.child('.'+cls+'-mc').dom.appendChild(this.dom);
  3287. return el;
  3288. },
  3289. getAttributeNS : Ext.isIE ? function(ns, name){
  3290. var d = this.dom;
  3291. var type = typeof d[ns+":"+name];
  3292. if(type != 'undefined' && type != 'unknown'){
  3293. return d[ns+":"+name];
  3294. }
  3295. return d[name];
  3296. } : function(ns, name){
  3297. var d = this.dom;
  3298. return d.getAttributeNS(ns, name) || d.getAttribute(ns+":"+name) || d.getAttribute(name) || d[name];
  3299. },
  3300. getTextWidth : function(text, min, max){
  3301. return (Ext.util.TextMetrics.measure(this.dom, Ext.value(text, this.dom.innerHTML, true)).width).constrain(min || 0, max || 1000000);
  3302. }
  3303. };
  3304. var ep = El.prototype;
  3305. ep.on = ep.addListener;
  3306. ep.mon = ep.addListener;
  3307. ep.getUpdateManager = ep.getUpdater;
  3308. ep.un = ep.removeListener;
  3309. ep.autoBoxAdjust = true;
  3310. El.unitPattern = /\d+(px|em|%|en|ex|pt|in|cm|mm|pc)$/i;
  3311. El.addUnits = function(v, defaultUnit){
  3312. if(v === "" || v == "auto"){
  3313. return v;
  3314. }
  3315. if(v === undefined){
  3316. return '';
  3317. }
  3318. if(typeof v == "number" || !El.unitPattern.test(v)){
  3319. return v + (defaultUnit || 'px');
  3320. }
  3321. return v;
  3322. };
  3323. El.boxMarkup = '<div class="{0}-tl"><div class="{0}-tr"><div class="{0}-tc"></div></div></div><div class="{0}-ml"><div class="{0}-mr"><div class="{0}-mc"></div></div></div><div class="{0}-bl"><div class="{0}-br"><div class="{0}-bc"></div></div></div>';
  3324. El.VISIBILITY = 1;
  3325. El.DISPLAY = 2;
  3326. El.borders = {l: "border-left-width", r: "border-right-width", t: "border-top-width", b: "border-bottom-width"};
  3327. El.paddings = {l: "padding-left", r: "padding-right", t: "padding-top", b: "padding-bottom"};
  3328. El.margins = {l: "margin-left", r: "margin-right", t: "margin-top", b: "margin-bottom"};
  3329. El.cache = {};
  3330. var docEl;
  3331. El.get = function(el){
  3332. var ex, elm, id;
  3333. if(!el){ return null; }
  3334. if(typeof el == "string"){ if(!(elm = document.getElementById(el))){
  3335. return null;
  3336. }
  3337. if(ex = El.cache[el]){
  3338. ex.dom = elm;
  3339. }else{
  3340. ex = El.cache[el] = new El(elm);
  3341. }
  3342. return ex;
  3343. }else if(el.tagName){ if(!(id = el.id)){
  3344. id = Ext.id(el);
  3345. }
  3346. if(ex = El.cache[id]){
  3347. ex.dom = el;
  3348. }else{
  3349. ex = El.cache[id] = new El(el);
  3350. }
  3351. return ex;
  3352. }else if(el instanceof El){
  3353. if(el != docEl){
  3354. el.dom = document.getElementById(el.id) || el.dom; El.cache[el.id] = el; }
  3355. return el;
  3356. }else if(el.isComposite){
  3357. return el;
  3358. }else if(Ext.isArray(el)){
  3359. return El.select(el);
  3360. }else if(el == document){
  3361. if(!docEl){
  3362. var f = function(){};
  3363. f.prototype = El.prototype;
  3364. docEl = new f();
  3365. docEl.dom = document;
  3366. }
  3367. return docEl;
  3368. }
  3369. return null;
  3370. };
  3371. El.uncache = function(el){
  3372. for(var i = 0, a = arguments, len = a.length; i < len; i++) {
  3373. if(a[i]){
  3374. delete El.cache[a[i].id || a[i]];
  3375. }
  3376. }
  3377. };
  3378. El.garbageCollect = function(){
  3379. if(!Ext.enableGarbageCollector){
  3380. clearInterval(El.collectorThread);
  3381. return;
  3382. }
  3383. for(var eid in El.cache){
  3384. var el = El.cache[eid], d = el.dom;
  3385. if(!d || !d.parentNode || (!d.offsetParent && !document.getElementById(eid))){
  3386. delete El.cache[eid];
  3387. if(d && Ext.enableListenerCollection){
  3388. E.purgeElement(d);
  3389. }
  3390. }
  3391. }
  3392. }
  3393. El.collectorThreadId = setInterval(El.garbageCollect, 30000);
  3394. var flyFn = function(){};
  3395. flyFn.prototype = El.prototype;
  3396. var _cls = new flyFn();
  3397. El.Flyweight = function(dom){
  3398. this.dom = dom;
  3399. };
  3400. El.Flyweight.prototype = _cls;
  3401. El.Flyweight.prototype.isFlyweight = true;
  3402. El._flyweights = {};
  3403. El.fly = function(el, named){
  3404. named = named || '_global';
  3405. el = Ext.getDom(el);
  3406. if(!el){
  3407. return null;
  3408. }
  3409. if(!El._flyweights[named]){
  3410. El._flyweights[named] = new El.Flyweight();
  3411. }
  3412. El._flyweights[named].dom = el;
  3413. return El._flyweights[named];
  3414. };
  3415. Ext.get = El.get;
  3416. Ext.fly = El.fly;
  3417. var noBoxAdjust = Ext.isStrict ? {
  3418. select:1
  3419. } : {
  3420. input:1, select:1, textarea:1
  3421. };
  3422. if(Ext.isIE || Ext.isGecko){
  3423. noBoxAdjust['button'] = 1;
  3424. }
  3425. Ext.EventManager.on(window, 'unload', function(){
  3426. delete El.cache;
  3427. delete El._flyweights;
  3428. });
  3429. })();
  3430. Ext.enableFx = true;
  3431. Ext.Fx = {
  3432. slideIn : function(anchor, o){
  3433. var el = this.getFxEl();
  3434. o = o || {};
  3435. el.queueFx(o, function(){
  3436. anchor = anchor || "t";
  3437. this.fixDisplay();
  3438. var r = this.getFxRestore();
  3439. var b = this.getBox();
  3440. this.setSize(b);
  3441. var wrap = this.fxWrap(r.pos, o, "hidden");
  3442. var st = this.dom.style;
  3443. st.visibility = "visible";
  3444. st.position = "absolute";
  3445. var after = function(){
  3446. el.fxUnwrap(wrap, r.pos, o);
  3447. st.width = r.width;
  3448. st.height = r.height;
  3449. el.afterFx(o);
  3450. };
  3451. var a, pt = {to: [b.x, b.y]}, bw = {to: b.width}, bh = {to: b.height};
  3452. switch(anchor.toLowerCase()){
  3453. case "t":
  3454. wrap.setSize(b.width, 0);
  3455. st.left = st.bottom = "0";
  3456. a = {height: bh};
  3457. break;
  3458. case "l":
  3459. wrap.setSize(0, b.height);
  3460. st.right = st.top = "0";
  3461. a = {width: bw};
  3462. break;
  3463. case "r":
  3464. wrap.setSize(0, b.height);
  3465. wrap.setX(b.right);
  3466. st.left = st.top = "0";
  3467. a = {width: bw, points: pt};
  3468. break;
  3469. case "b":
  3470. wrap.setSize(b.width, 0);
  3471. wrap.setY(b.bottom);
  3472. st.left = st.top = "0";
  3473. a = {height: bh, points: pt};
  3474. break;
  3475. case "tl":
  3476. wrap.setSize(0, 0);
  3477. st.right = st.bottom = "0";
  3478. a = {width: bw, height: bh};
  3479. break;
  3480. case "bl":
  3481. wrap.setSize(0, 0);
  3482. wrap.setY(b.y+b.height);
  3483. st.right = st.top = "0";
  3484. a = {width: bw, height: bh, points: pt};
  3485. break;
  3486. case "br":
  3487. wrap.setSize(0, 0);
  3488. wrap.setXY([b.right, b.bottom]);
  3489. st.left = st.top = "0";
  3490. a = {width: bw, height: bh, points: pt};
  3491. break;
  3492. case "tr":
  3493. wrap.setSize(0, 0);
  3494. wrap.setX(b.x+b.width);
  3495. st.left = st.bottom = "0";
  3496. a = {width: bw, height: bh, points: pt};
  3497. break;
  3498. }
  3499. this.dom.style.visibility = "visible";
  3500. wrap.show();
  3501. arguments.callee.anim = wrap.fxanim(a,
  3502. o,
  3503. 'motion',
  3504. .5,
  3505. 'easeOut', after);
  3506. });
  3507. return this;
  3508. },
  3509. slideOut : function(anchor, o){
  3510. var el = this.getFxEl();
  3511. o = o || {};
  3512. el.queueFx(o, function(){
  3513. anchor = anchor || "t";
  3514. var r = this.getFxRestore();
  3515. var b = this.getBox();
  3516. this.setSize(b);
  3517. var wrap = this.fxWrap(r.pos, o, "visible");
  3518. var st = this.dom.style;
  3519. st.visibility = "visible";
  3520. st.position = "absolute";
  3521. wrap.setSize(b);
  3522. var after = function(){
  3523. if(o.useDisplay){
  3524. el.setDisplayed(false);
  3525. }else{
  3526. el.hide();
  3527. }
  3528. el.fxUnwrap(wrap, r.pos, o);
  3529. st.width = r.width;
  3530. st.height = r.height;
  3531. el.afterFx(o);
  3532. };
  3533. var a, zero = {to: 0};
  3534. switch(anchor.toLowerCase()){
  3535. case "t":
  3536. st.left = st.bottom = "0";
  3537. a = {height: zero};
  3538. break;
  3539. case "l":
  3540. st.right = st.top = "0";
  3541. a = {width: zero};
  3542. break;
  3543. case "r":
  3544. st.left = st.top = "0";
  3545. a = {width: zero, points: {to:[b.right, b.y]}};
  3546. break;
  3547. case "b":
  3548. st.left = st.top = "0";
  3549. a = {height: zero, points: {to:[b.x, b.bottom]}};
  3550. break;
  3551. case "tl":
  3552. st.right = st.bottom = "0";
  3553. a = {width: zero, height: zero};
  3554. break;
  3555. case "bl":
  3556. st.right = st.top = "0";
  3557. a = {width: zero, height: zero, points: {to:[b.x, b.bottom]}};
  3558. break;
  3559. case "br":
  3560. st.left = st.top = "0";
  3561. a = {width: zero, height: zero, points: {to:[b.x+b.width, b.bottom]}};
  3562. break;
  3563. case "tr":
  3564. st.left = st.bottom = "0";
  3565. a = {width: zero, height: zero, points: {to:[b.right, b.y]}};
  3566. break;
  3567. }
  3568. arguments.callee.anim = wrap.fxanim(a,
  3569. o,
  3570. 'motion',
  3571. .5,
  3572. "easeOut", after);
  3573. });
  3574. return this;
  3575. },
  3576. puff : function(o){
  3577. var el = this.getFxEl();
  3578. o = o || {};
  3579. el.queueFx(o, function(){
  3580. this.clearOpacity();
  3581. this.show();
  3582. var r = this.getFxRestore();
  3583. var st = this.dom.style;
  3584. var after = function(){
  3585. if(o.useDisplay){
  3586. el.setDisplayed(false);
  3587. }else{
  3588. el.hide();
  3589. }
  3590. el.clearOpacity();
  3591. el.setPositioning(r.pos);
  3592. st.width = r.width;
  3593. st.height = r.height;
  3594. st.fontSize = '';
  3595. el.afterFx(o);
  3596. };
  3597. var width = this.getWidth();
  3598. var height = this.getHeight();
  3599. arguments.callee.anim = this.fxanim({
  3600. width : {to: this.adjustWidth(width * 2)},
  3601. height : {to: this.adjustHeight(height * 2)},
  3602. points : {by: [-(width * .5), -(height * .5)]},
  3603. opacity : {to: 0},
  3604. fontSize: {to:200, unit: "%"}
  3605. },
  3606. o,
  3607. 'motion',
  3608. .5,
  3609. "easeOut", after);
  3610. });
  3611. return this;
  3612. },
  3613. switchOff : function(o){
  3614. var el = this.getFxEl();
  3615. o = o || {};
  3616. el.queueFx(o, function(){
  3617. this.clearOpacity();
  3618. this.clip();
  3619. var r = this.getFxRestore();
  3620. var st = this.dom.style;
  3621. var after = function(){
  3622. if(o.useDisplay){
  3623. el.setDisplayed(false);
  3624. }else{
  3625. el.hide();
  3626. }
  3627. el.clearOpacity();
  3628. el.setPositioning(r.pos);
  3629. st.width = r.width;
  3630. st.height = r.height;
  3631. el.afterFx(o);
  3632. };
  3633. this.fxanim({opacity:{to:0.3}}, null, null, .1, null, function(){
  3634. this.clearOpacity();
  3635. (function(){
  3636. this.fxanim({
  3637. height:{to:1},
  3638. points:{by:[0, this.getHeight() * .5]}
  3639. }, o, 'motion', 0.3, 'easeIn', after);
  3640. }).defer(100, this);
  3641. });
  3642. });
  3643. return this;
  3644. },
  3645. highlight : function(color, o){
  3646. var el = this.getFxEl();
  3647. o = o || {};
  3648. el.queueFx(o, function(){
  3649. color = color || "ffff9c";
  3650. var attr = o.attr || "backgroundColor";
  3651. this.clearOpacity();
  3652. this.show();
  3653. var origColor = this.getColor(attr);
  3654. var restoreColor = this.dom.style[attr];
  3655. var endColor = (o.endColor || origColor) || "ffffff";
  3656. var after = function(){
  3657. el.dom.style[attr] = restoreColor;
  3658. el.afterFx(o);
  3659. };
  3660. var a = {};
  3661. a[attr] = {from: color, to: endColor};
  3662. arguments.callee.anim = this.fxanim(a,
  3663. o,
  3664. 'color',
  3665. 1,
  3666. 'easeIn', after);
  3667. });
  3668. return this;
  3669. },
  3670. frame : function(color, count, o){
  3671. var el = this.getFxEl();
  3672. o = o || {};
  3673. el.queueFx(o, function(){
  3674. color = color || "#C3DAF9";
  3675. if(color.length == 6){
  3676. color = "#" + color;
  3677. }
  3678. count = count || 1;
  3679. var duration = o.duration || 1;
  3680. this.show();
  3681. var b = this.getBox();
  3682. var animFn = function(){
  3683. var proxy = Ext.getBody().createChild({
  3684. style:{
  3685. visbility:"hidden",
  3686. position:"absolute",
  3687. "z-index":"35000", border:"0px solid " + color
  3688. }
  3689. });
  3690. var scale = Ext.isBorderBox ? 2 : 1;
  3691. proxy.animate({
  3692. top:{from:b.y, to:b.y - 20},
  3693. left:{from:b.x, to:b.x - 20},
  3694. borderWidth:{from:0, to:10},
  3695. opacity:{from:1, to:0},
  3696. height:{from:b.height, to:(b.height + (20*scale))},
  3697. width:{from:b.width, to:(b.width + (20*scale))}
  3698. }, duration, function(){
  3699. proxy.remove();
  3700. if(--count > 0){
  3701. animFn();
  3702. }else{
  3703. el.afterFx(o);
  3704. }
  3705. });
  3706. };
  3707. animFn.call(this);
  3708. });
  3709. return this;
  3710. },
  3711. pause : function(seconds){
  3712. var el = this.getFxEl();
  3713. var o = {};
  3714. el.queueFx(o, function(){
  3715. setTimeout(function(){
  3716. el.afterFx(o);
  3717. }, seconds * 1000);
  3718. });
  3719. return this;
  3720. },
  3721. fadeIn : function(o){
  3722. var el = this.getFxEl();
  3723. o = o || {};
  3724. el.queueFx(o, function(){
  3725. this.setOpacity(0);
  3726. this.fixDisplay();
  3727. this.dom.style.visibility = 'visible';
  3728. var to = o.endOpacity || 1;
  3729. arguments.callee.anim = this.fxanim({opacity:{to:to}},
  3730. o, null, .5, "easeOut", function(){
  3731. if(to == 1){
  3732. this.clearOpacity();
  3733. }
  3734. el.afterFx(o);
  3735. });
  3736. });
  3737. return this;
  3738. },
  3739. fadeOut : function(o){
  3740. var el = this.getFxEl();
  3741. o = o || {};
  3742. el.queueFx(o, function(){
  3743. arguments.callee.anim = this.fxanim({opacity:{to:o.endOpacity || 0}},
  3744. o, null, .5, "easeOut", function(){
  3745. if(this.visibilityMode == Ext.Element.DISPLAY || o.useDisplay){
  3746. this.dom.style.display = "none";
  3747. }else{
  3748. this.dom.style.visibility = "hidden";
  3749. }
  3750. this.clearOpacity();
  3751. el.afterFx(o);
  3752. });
  3753. });
  3754. return this;
  3755. },
  3756. scale : function(w, h, o){
  3757. this.shift(Ext.apply({}, o, {
  3758. width: w,
  3759. height: h
  3760. }));
  3761. return this;
  3762. },
  3763. shift : function(o){
  3764. var el = this.getFxEl();
  3765. o = o || {};
  3766. el.queueFx(o, function(){
  3767. var a = {}, w = o.width, h = o.height, x = o.x, y = o.y, op = o.opacity;
  3768. if(w !== undefined){
  3769. a.width = {to: this.adjustWidth(w)};
  3770. }
  3771. if(h !== undefined){
  3772. a.height = {to: this.adjustHeight(h)};
  3773. }
  3774. if(x !== undefined || y !== undefined){
  3775. a.points = {to: [
  3776. x !== undefined ? x : this.getX(),
  3777. y !== undefined ? y : this.getY()
  3778. ]};
  3779. }
  3780. if(op !== undefined){
  3781. a.opacity = {to: op};
  3782. }
  3783. if(o.xy !== undefined){
  3784. a.points = {to: o.xy};
  3785. }
  3786. arguments.callee.anim = this.fxanim(a,
  3787. o, 'motion', .35, "easeOut", function(){
  3788. el.afterFx(o);
  3789. });
  3790. });
  3791. return this;
  3792. },
  3793. ghost : function(anchor, o){
  3794. var el = this.getFxEl();
  3795. o = o || {};
  3796. el.queueFx(o, function(){
  3797. anchor = anchor || "b";
  3798. var r = this.getFxRestore();
  3799. var w = this.getWidth(),
  3800. h = this.getHeight();
  3801. var st = this.dom.style;
  3802. var after = function(){
  3803. if(o.useDisplay){
  3804. el.setDisplayed(false);
  3805. }else{
  3806. el.hide();
  3807. }
  3808. el.clearOpacity();
  3809. el.setPositioning(r.pos);
  3810. st.width = r.width;
  3811. st.height = r.height;
  3812. el.afterFx(o);
  3813. };
  3814. var a = {opacity: {to: 0}, points: {}}, pt = a.points;
  3815. switch(anchor.toLowerCase()){
  3816. case "t":
  3817. pt.by = [0, -h];
  3818. break;
  3819. case "l":
  3820. pt.by = [-w, 0];
  3821. break;
  3822. case "r":
  3823. pt.by = [w, 0];
  3824. break;
  3825. case "b":
  3826. pt.by = [0, h];
  3827. break;
  3828. case "tl":
  3829. pt.by = [-w, -h];
  3830. break;
  3831. case "bl":
  3832. pt.by = [-w, h];
  3833. break;
  3834. case "br":
  3835. pt.by = [w, h];
  3836. break;
  3837. case "tr":
  3838. pt.by = [w, -h];
  3839. break;
  3840. }
  3841. arguments.callee.anim = this.fxanim(a,
  3842. o,
  3843. 'motion',
  3844. .5,
  3845. "easeOut", after);
  3846. });
  3847. return this;
  3848. },
  3849. syncFx : function(){
  3850. this.fxDefaults = Ext.apply(this.fxDefaults || {}, {
  3851. block : false,
  3852. concurrent : true,
  3853. stopFx : false
  3854. });
  3855. return this;
  3856. },
  3857. sequenceFx : function(){
  3858. this.fxDefaults = Ext.apply(this.fxDefaults || {}, {
  3859. block : false,
  3860. concurrent : false,
  3861. stopFx : false
  3862. });
  3863. return this;
  3864. },
  3865. nextFx : function(){
  3866. var ef = this.fxQueue[0];
  3867. if(ef){
  3868. ef.call(this);
  3869. }
  3870. },
  3871. hasActiveFx : function(){
  3872. return this.fxQueue && this.fxQueue[0];
  3873. },
  3874. stopFx : function(){
  3875. if(this.hasActiveFx()){
  3876. var cur = this.fxQueue[0];
  3877. if(cur && cur.anim && cur.anim.isAnimated()){
  3878. this.fxQueue = [cur]; cur.anim.stop(true);
  3879. }
  3880. }
  3881. return this;
  3882. },
  3883. beforeFx : function(o){
  3884. if(this.hasActiveFx() && !o.concurrent){
  3885. if(o.stopFx){
  3886. this.stopFx();
  3887. return true;
  3888. }
  3889. return false;
  3890. }
  3891. return true;
  3892. },
  3893. hasFxBlock : function(){
  3894. var q = this.fxQueue;
  3895. return q && q[0] && q[0].block;
  3896. },
  3897. queueFx : function(o, fn){
  3898. if(!this.fxQueue){
  3899. this.fxQueue = [];
  3900. }
  3901. if(!this.hasFxBlock()){
  3902. Ext.applyIf(o, this.fxDefaults);
  3903. if(!o.concurrent){
  3904. var run = this.beforeFx(o);
  3905. fn.block = o.block;
  3906. this.fxQueue.push(fn);
  3907. if(run){
  3908. this.nextFx();
  3909. }
  3910. }else{
  3911. fn.call(this);
  3912. }
  3913. }
  3914. return this;
  3915. },
  3916. fxWrap : function(pos, o, vis){
  3917. var wrap;
  3918. if(!o.wrap || !(wrap = Ext.get(o.wrap))){
  3919. var wrapXY;
  3920. if(o.fixPosition){
  3921. wrapXY = this.getXY();
  3922. }
  3923. var div = document.createElement("div");
  3924. div.style.visibility = vis;
  3925. wrap = Ext.get(this.dom.parentNode.insertBefore(div, this.dom));
  3926. wrap.setPositioning(pos);
  3927. if(wrap.getStyle("position") == "static"){
  3928. wrap.position("relative");
  3929. }
  3930. this.clearPositioning('auto');
  3931. wrap.clip();
  3932. wrap.dom.appendChild(this.dom);
  3933. if(wrapXY){
  3934. wrap.setXY(wrapXY);
  3935. }
  3936. }
  3937. return wrap;
  3938. },
  3939. fxUnwrap : function(wrap, pos, o){
  3940. this.clearPositioning();
  3941. this.setPositioning(pos);
  3942. if(!o.wrap){
  3943. wrap.dom.parentNode.insertBefore(this.dom, wrap.dom);
  3944. wrap.remove();
  3945. }
  3946. },
  3947. getFxRestore : function(){
  3948. var st = this.dom.style;
  3949. return {pos: this.getPositioning(), width: st.width, height : st.height};
  3950. },
  3951. afterFx : function(o){
  3952. if(o.afterStyle){
  3953. this.applyStyles(o.afterStyle);
  3954. }
  3955. if(o.afterCls){
  3956. this.addClass(o.afterCls);
  3957. }
  3958. if(o.remove === true){
  3959. this.remove();
  3960. }
  3961. Ext.callback(o.callback, o.scope, [this]);
  3962. if(!o.concurrent){
  3963. this.fxQueue.shift();
  3964. this.nextFx();
  3965. }
  3966. },
  3967. getFxEl : function(){ return Ext.get(this.dom);
  3968. },
  3969. fxanim : function(args, opt, animType, defaultDur, defaultEase, cb){
  3970. animType = animType || 'run';
  3971. opt = opt || {};
  3972. var anim = Ext.lib.Anim[animType](
  3973. this.dom, args,
  3974. (opt.duration || defaultDur) || .35,
  3975. (opt.easing || defaultEase) || 'easeOut',
  3976. function(){
  3977. Ext.callback(cb, this);
  3978. },
  3979. this
  3980. );
  3981. opt.anim = anim;
  3982. return anim;
  3983. }
  3984. };
  3985. Ext.Fx.resize = Ext.Fx.scale;
  3986. Ext.apply(Ext.Element.prototype, Ext.Fx);
  3987. Ext.CompositeElement = function(els){
  3988. this.elements = [];
  3989. this.addElements(els);
  3990. };
  3991. Ext.CompositeElement.prototype = {
  3992. isComposite: true,
  3993. addElements : function(els){
  3994. if(!els) return this;
  3995. if(typeof els == "string"){
  3996. els = Ext.Element.selectorFunction(els);
  3997. }
  3998. var yels = this.elements;
  3999. var index = yels.length-1;
  4000. for(var i = 0, len = els.length; i < len; i++) {
  4001. yels[++index] = Ext.get(els[i]);
  4002. }
  4003. return this;
  4004. },
  4005. fill : function(els){
  4006. this.elements = [];
  4007. this.add(els);
  4008. return this;
  4009. },
  4010. filter : function(selector){
  4011. var els = [];
  4012. this.each(function(el){
  4013. if(el.is(selector)){
  4014. els[els.length] = el.dom;
  4015. }
  4016. });
  4017. this.fill(els);
  4018. return this;
  4019. },
  4020. invoke : function(fn, args){
  4021. var els = this.elements;
  4022. for(var i = 0, len = els.length; i < len; i++) {
  4023. Ext.Element.prototype[fn].apply(els[i], args);
  4024. }
  4025. return this;
  4026. },
  4027. add : function(els){
  4028. if(typeof els == "string"){
  4029. this.addElements(Ext.Element.selectorFunction(els));
  4030. }else if(els.length !== undefined){
  4031. this.addElements(els);
  4032. }else{
  4033. this.addElements([els]);
  4034. }
  4035. return this;
  4036. },
  4037. each : function(fn, scope){
  4038. var els = this.elements;
  4039. for(var i = 0, len = els.length; i < len; i++){
  4040. if(fn.call(scope || els[i], els[i], this, i) === false) {
  4041. break;
  4042. }
  4043. }
  4044. return this;
  4045. },
  4046. item : function(index){
  4047. return this.elements[index] || null;
  4048. },
  4049. first : function(){
  4050. return this.item(0);
  4051. },
  4052. last : function(){
  4053. return this.item(this.elements.length-1);
  4054. },
  4055. getCount : function(){
  4056. return this.elements.length;
  4057. },
  4058. contains : function(el){
  4059. return this.indexOf(el) !== -1;
  4060. },
  4061. indexOf : function(el){
  4062. return this.elements.indexOf(Ext.get(el));
  4063. },
  4064. removeElement : function(el, removeDom){
  4065. if(Ext.isArray(el)){
  4066. for(var i = 0, len = el.length; i < len; i++){
  4067. this.removeElement(el[i]);
  4068. }
  4069. return this;
  4070. }
  4071. var index = typeof el == 'number' ? el : this.indexOf(el);
  4072. if(index !== -1 && this.elements[index]){
  4073. if(removeDom){
  4074. var d = this.elements[index];
  4075. if(d.dom){
  4076. d.remove();
  4077. }else{
  4078. Ext.removeNode(d);
  4079. }
  4080. }
  4081. this.elements.splice(index, 1);
  4082. }
  4083. return this;
  4084. },
  4085. replaceElement : function(el, replacement, domReplace){
  4086. var index = typeof el == 'number' ? el : this.indexOf(el);
  4087. if(index !== -1){
  4088. if(domReplace){
  4089. this.elements[index].replaceWith(replacement);
  4090. }else{
  4091. this.elements.splice(index, 1, Ext.get(replacement))
  4092. }
  4093. }
  4094. return this;
  4095. },
  4096. clear : function(){
  4097. this.elements = [];
  4098. }
  4099. };
  4100. (function(){
  4101. Ext.CompositeElement.createCall = function(proto, fnName){
  4102. if(!proto[fnName]){
  4103. proto[fnName] = function(){
  4104. return this.invoke(fnName, arguments);
  4105. };
  4106. }
  4107. };
  4108. for(var fnName in Ext.Element.prototype){
  4109. if(typeof Ext.Element.prototype[fnName] == "function"){
  4110. Ext.CompositeElement.createCall(Ext.CompositeElement.prototype, fnName);
  4111. }
  4112. };
  4113. })();
  4114. Ext.CompositeElementLite = function(els){
  4115. Ext.CompositeElementLite.superclass.constructor.call(this, els);
  4116. this.el = new Ext.Element.Flyweight();
  4117. };
  4118. Ext.extend(Ext.CompositeElementLite, Ext.CompositeElement, {
  4119. addElements : function(els){
  4120. if(els){
  4121. if(Ext.isArray(els)){
  4122. this.elements = this.elements.concat(els);
  4123. }else{
  4124. var yels = this.elements;
  4125. var index = yels.length-1;
  4126. for(var i = 0, len = els.length; i < len; i++) {
  4127. yels[++index] = els[i];
  4128. }
  4129. }
  4130. }
  4131. return this;
  4132. },
  4133. invoke : function(fn, args){
  4134. var els = this.elements;
  4135. var el = this.el;
  4136. for(var i = 0, len = els.length; i < len; i++) {
  4137. el.dom = els[i];
  4138. Ext.Element.prototype[fn].apply(el, args);
  4139. }
  4140. return this;
  4141. },
  4142. item : function(index){
  4143. if(!this.elements[index]){
  4144. return null;
  4145. }
  4146. this.el.dom = this.elements[index];
  4147. return this.el;
  4148. },
  4149. addListener : function(eventName, handler, scope, opt){
  4150. var els = this.elements;
  4151. for(var i = 0, len = els.length; i < len; i++) {
  4152. Ext.EventManager.on(els[i], eventName, handler, scope || els[i], opt);
  4153. }
  4154. return this;
  4155. },
  4156. each : function(fn, scope){
  4157. var els = this.elements;
  4158. var el = this.el;
  4159. for(var i = 0, len = els.length; i < len; i++){
  4160. el.dom = els[i];
  4161. if(fn.call(scope || el, el, this, i) === false){
  4162. break;
  4163. }
  4164. }
  4165. return this;
  4166. },
  4167. indexOf : function(el){
  4168. return this.elements.indexOf(Ext.getDom(el));
  4169. },
  4170. replaceElement : function(el, replacement, domReplace){
  4171. var index = typeof el == 'number' ? el : this.indexOf(el);
  4172. if(index !== -1){
  4173. replacement = Ext.getDom(replacement);
  4174. if(domReplace){
  4175. var d = this.elements[index];
  4176. d.parentNode.insertBefore(replacement, d);
  4177. Ext.removeNode(d);
  4178. }
  4179. this.elements.splice(index, 1, replacement);
  4180. }
  4181. return this;
  4182. }
  4183. });
  4184. Ext.CompositeElementLite.prototype.on = Ext.CompositeElementLite.prototype.addListener;
  4185. if(Ext.DomQuery){
  4186. Ext.Element.selectorFunction = Ext.DomQuery.select;
  4187. }
  4188. Ext.Element.select = function(selector, unique, root){
  4189. var els;
  4190. if(typeof selector == "string"){
  4191. els = Ext.Element.selectorFunction(selector, root);
  4192. }else if(selector.length !== undefined){
  4193. els = selector;
  4194. }else{
  4195. throw "Invalid selector";
  4196. }
  4197. if(unique === true){
  4198. return new Ext.CompositeElement(els);
  4199. }else{
  4200. return new Ext.CompositeElementLite(els);
  4201. }
  4202. };
  4203. Ext.select = Ext.Element.select;
  4204. Ext.data.Connection = function(config){
  4205. Ext.apply(this, config);
  4206. this.addEvents(
  4207. "beforerequest",
  4208. "requestcomplete",
  4209. "requestexception"
  4210. );
  4211. Ext.data.Connection.superclass.constructor.call(this);
  4212. };
  4213. Ext.extend(Ext.data.Connection, Ext.util.Observable, {
  4214. timeout : 30000,
  4215. autoAbort:false,
  4216. disableCaching: true,
  4217. request : function(o){
  4218. if(this.fireEvent("beforerequest", this, o) !== false){
  4219. var p = o.params;
  4220. if(typeof p == "function"){
  4221. p = p.call(o.scope||window, o);
  4222. }
  4223. if(typeof p == "object"){
  4224. p = Ext.urlEncode(p);
  4225. }
  4226. if(this.extraParams){
  4227. var extras = Ext.urlEncode(this.extraParams);
  4228. p = p ? (p + '&' + extras) : extras;
  4229. }
  4230. var url = o.url || this.url;
  4231. if(typeof url == 'function'){
  4232. url = url.call(o.scope||window, o);
  4233. }
  4234. if(o.form){
  4235. var form = Ext.getDom(o.form);
  4236. url = url || form.action;
  4237. var enctype = form.getAttribute("enctype");
  4238. if(o.isUpload || (enctype && enctype.toLowerCase() == 'multipart/form-data')){
  4239. return this.doFormUpload(o, p, url);
  4240. }
  4241. var f = Ext.lib.Ajax.serializeForm(form);
  4242. p = p ? (p + '&' + f) : f;
  4243. }
  4244. var hs = o.headers;
  4245. if(this.defaultHeaders){
  4246. hs = Ext.apply(hs || {}, this.defaultHeaders);
  4247. if(!o.headers){
  4248. o.headers = hs;
  4249. }
  4250. }
  4251. var cb = {
  4252. success: this.handleResponse,
  4253. failure: this.handleFailure,
  4254. scope: this,
  4255. argument: {options: o},
  4256. timeout : o.timeout || this.timeout
  4257. };
  4258. var method = o.method||this.method||(p ? "POST" : "GET");
  4259. if(method == 'GET' && (this.disableCaching && o.disableCaching !== false) || o.disableCaching === true){
  4260. url += (url.indexOf('?') != -1 ? '&' : '?') + '_dc=' + (new Date().getTime());
  4261. }
  4262. if(typeof o.autoAbort == 'boolean'){
  4263. if(o.autoAbort){
  4264. this.abort();
  4265. }
  4266. }else if(this.autoAbort !== false){
  4267. this.abort();
  4268. }
  4269. if((method == 'GET' && p) || o.xmlData || o.jsonData){
  4270. url += (url.indexOf('?') != -1 ? '&' : '?') + p;
  4271. p = '';
  4272. }
  4273. this.transId = Ext.lib.Ajax.request(method, url, cb, p, o);
  4274. return this.transId;
  4275. }else{
  4276. Ext.callback(o.callback, o.scope, [o, null, null]);
  4277. return null;
  4278. }
  4279. },
  4280. isLoading : function(transId){
  4281. if(transId){
  4282. return Ext.lib.Ajax.isCallInProgress(transId);
  4283. }else{
  4284. return this.transId ? true : false;
  4285. }
  4286. },
  4287. abort : function(transId){
  4288. if(transId || this.isLoading()){
  4289. Ext.lib.Ajax.abort(transId || this.transId);
  4290. }
  4291. },
  4292. handleResponse : function(response){
  4293. this.transId = false;
  4294. var options = response.argument.options;
  4295. response.argument = options ? options.argument : null;
  4296. this.fireEvent("requestcomplete", this, response, options);
  4297. Ext.callback(options.success, options.scope, [response, options]);
  4298. Ext.callback(options.callback, options.scope, [options, true, response]);
  4299. },
  4300. handleFailure : function(response, e){
  4301. this.transId = false;
  4302. var options = response.argument.options;
  4303. response.argument = options ? options.argument : null;
  4304. this.fireEvent("requestexception", this, response, options, e);
  4305. Ext.callback(options.failure, options.scope, [response, options]);
  4306. Ext.callback(options.callback, options.scope, [options, false, response]);
  4307. },
  4308. doFormUpload : function(o, ps, url){
  4309. var id = Ext.id();
  4310. var frame = document.createElement('iframe');
  4311. frame.id = id;
  4312. frame.name = id;
  4313. frame.className = 'x-hidden';
  4314. if(Ext.isIE){
  4315. frame.src = Ext.SSL_SECURE_URL;
  4316. }
  4317. document.body.appendChild(frame);
  4318. if(Ext.isIE){
  4319. document.frames[id].name = id;
  4320. }
  4321. var form = Ext.getDom(o.form);
  4322. form.target = id;
  4323. form.method = 'POST';
  4324. form.enctype = form.encoding = 'multipart/form-data';
  4325. if(url){
  4326. form.action = url;
  4327. }
  4328. var hiddens, hd;
  4329. if(ps){
  4330. hiddens = [];
  4331. ps = Ext.urlDecode(ps, false);
  4332. for(var k in ps){
  4333. if(ps.hasOwnProperty(k)){
  4334. hd = document.createElement('input');
  4335. hd.type = 'hidden';
  4336. hd.name = k;
  4337. hd.value = ps[k];
  4338. form.appendChild(hd);
  4339. hiddens.push(hd);
  4340. }
  4341. }
  4342. }
  4343. function cb(){
  4344. var r = {
  4345. responseText : '',
  4346. responseXML : null
  4347. };
  4348. r.argument = o ? o.argument : null;
  4349. try {
  4350. var doc;
  4351. if(Ext.isIE){
  4352. doc = frame.contentWindow.document;
  4353. }else {
  4354. doc = (frame.contentDocument || window.frames[id].document);
  4355. }
  4356. if(doc && doc.body){
  4357. r.responseText = doc.body.innerHTML;
  4358. }
  4359. if(doc && doc.XMLDocument){
  4360. r.responseXML = doc.XMLDocument;
  4361. }else {
  4362. r.responseXML = doc;
  4363. }
  4364. }
  4365. catch(e) {
  4366. }
  4367. Ext.EventManager.removeListener(frame, 'load', cb, this);
  4368. this.fireEvent("requestcomplete", this, r, o);
  4369. Ext.callback(o.success, o.scope, [r, o]);
  4370. Ext.callback(o.callback, o.scope, [o, true, r]);
  4371. setTimeout(function(){Ext.removeNode(frame);}, 100);
  4372. }
  4373. Ext.EventManager.on(frame, 'load', cb, this);
  4374. form.submit();
  4375. if(hiddens){
  4376. for(var i = 0, len = hiddens.length; i < len; i++){
  4377. Ext.removeNode(hiddens[i]);
  4378. }
  4379. }
  4380. }
  4381. });
  4382. Ext.Ajax = new Ext.data.Connection({
  4383. autoAbort : false,
  4384. serializeForm : function(form){
  4385. return Ext.lib.Ajax.serializeForm(form);
  4386. }
  4387. });
  4388. Ext.Updater = function(el, forceNew){
  4389. el = Ext.get(el);
  4390. if(!forceNew && el.updateManager){
  4391. return el.updateManager;
  4392. }
  4393. this.el = el;
  4394. this.defaultUrl = null;
  4395. this.addEvents(
  4396. "beforeupdate",
  4397. "update",
  4398. "failure"
  4399. );
  4400. var d = Ext.Updater.defaults;
  4401. this.sslBlankUrl = d.sslBlankUrl;
  4402. this.disableCaching = d.disableCaching;
  4403. this.indicatorText = d.indicatorText;
  4404. this.showLoadIndicator = d.showLoadIndicator;
  4405. this.timeout = d.timeout;
  4406. this.loadScripts = d.loadScripts;
  4407. this.transaction = null;
  4408. this.autoRefreshProcId = null;
  4409. this.refreshDelegate = this.refresh.createDelegate(this);
  4410. this.updateDelegate = this.update.createDelegate(this);
  4411. this.formUpdateDelegate = this.formUpdate.createDelegate(this);
  4412. if(!this.renderer){
  4413. this.renderer = new Ext.Updater.BasicRenderer();
  4414. }
  4415. Ext.Updater.superclass.constructor.call(this);
  4416. };
  4417. Ext.extend(Ext.Updater, Ext.util.Observable, {
  4418. getEl : function(){
  4419. return this.el;
  4420. },
  4421. update : function(url, params, callback, discardUrl){
  4422. if(this.fireEvent("beforeupdate", this.el, url, params) !== false){
  4423. var method = this.method, cfg, callerScope;
  4424. if(typeof url == "object"){
  4425. cfg = url;
  4426. url = cfg.url;
  4427. params = params || cfg.params;
  4428. callback = callback || cfg.callback;
  4429. discardUrl = discardUrl || cfg.discardUrl;
  4430. callerScope = cfg.scope;
  4431. if(typeof cfg.method != "undefined"){method = cfg.method;};
  4432. if(typeof cfg.nocache != "undefined"){this.disableCaching = cfg.nocache;};
  4433. if(typeof cfg.text != "undefined"){this.indicatorText = '<div class="loading-indicator">'+cfg.text+"</div>";};
  4434. if(typeof cfg.scripts != "undefined"){this.loadScripts = cfg.scripts;};
  4435. if(typeof cfg.timeout != "undefined"){this.timeout = cfg.timeout;};
  4436. }
  4437. this.showLoading();
  4438. if(!discardUrl){
  4439. this.defaultUrl = url;
  4440. }
  4441. if(typeof url == "function"){
  4442. url = url.call(this);
  4443. }
  4444. method = method || (params ? "POST" : "GET");
  4445. if(method == "GET"){
  4446. url = this.prepareUrl(url);
  4447. }
  4448. var o = Ext.apply(cfg ||{}, {
  4449. url : url,
  4450. params: (typeof params == "function" && callerScope) ? params.createDelegate(callerScope) : params,
  4451. success: this.processSuccess,
  4452. failure: this.processFailure,
  4453. scope: this,
  4454. callback: undefined,
  4455. timeout: (this.timeout*1000),
  4456. argument: {
  4457. "options": cfg,
  4458. "url": url,
  4459. "form": null,
  4460. "callback": callback,
  4461. "scope": callerScope || window,
  4462. "params": params
  4463. }
  4464. });
  4465. this.transaction = Ext.Ajax.request(o);
  4466. }
  4467. },
  4468. formUpdate : function(form, url, reset, callback){
  4469. if(this.fireEvent("beforeupdate", this.el, form, url) !== false){
  4470. if(typeof url == "function"){
  4471. url = url.call(this);
  4472. }
  4473. form = Ext.getDom(form)
  4474. this.transaction = Ext.Ajax.request({
  4475. form: form,
  4476. url:url,
  4477. success: this.processSuccess,
  4478. failure: this.processFailure,
  4479. scope: this,
  4480. timeout: (this.timeout*1000),
  4481. argument: {
  4482. "url": url,
  4483. "form": form,
  4484. "callback": callback,
  4485. "reset": reset
  4486. }
  4487. });
  4488. this.showLoading.defer(1, this);
  4489. }
  4490. },
  4491. refresh : function(callback){
  4492. if(this.defaultUrl == null){
  4493. return;
  4494. }
  4495. this.update(this.defaultUrl, null, callback, true);
  4496. },
  4497. startAutoRefresh : function(interval, url, params, callback, refreshNow){
  4498. if(refreshNow){
  4499. this.update(url || this.defaultUrl, params, callback, true);
  4500. }
  4501. if(this.autoRefreshProcId){
  4502. clearInterval(this.autoRefreshProcId);
  4503. }
  4504. this.autoRefreshProcId = setInterval(this.update.createDelegate(this, [url || this.defaultUrl, params, callback, true]), interval*1000);
  4505. },
  4506. stopAutoRefresh : function(){
  4507. if(this.autoRefreshProcId){
  4508. clearInterval(this.autoRefreshProcId);
  4509. delete this.autoRefreshProcId;
  4510. }
  4511. },
  4512. isAutoRefreshing : function(){
  4513. return this.autoRefreshProcId ? true : false;
  4514. },
  4515. showLoading : function(){
  4516. if(this.showLoadIndicator){
  4517. this.el.update(this.indicatorText);
  4518. }
  4519. },
  4520. prepareUrl : function(url){
  4521. if(this.disableCaching){
  4522. var append = "_dc=" + (new Date().getTime());
  4523. if(url.indexOf("?") !== -1){
  4524. url += "&" + append;
  4525. }else{
  4526. url += "?" + append;
  4527. }
  4528. }
  4529. return url;
  4530. },
  4531. processSuccess : function(response){
  4532. this.transaction = null;
  4533. if(response.argument.form && response.argument.reset){
  4534. try{
  4535. response.argument.form.reset();
  4536. }catch(e){}
  4537. }
  4538. if(this.loadScripts){
  4539. this.renderer.render(this.el, response, this,
  4540. this.updateComplete.createDelegate(this, [response]));
  4541. }else{
  4542. this.renderer.render(this.el, response, this);
  4543. this.updateComplete(response);
  4544. }
  4545. },
  4546. updateComplete : function(response){
  4547. this.fireEvent("update", this.el, response);
  4548. if(typeof response.argument.callback == "function"){
  4549. response.argument.callback.call(response.argument.scope, this.el, true, response, response.argument.options);
  4550. }
  4551. },
  4552. processFailure : function(response){
  4553. this.transaction = null;
  4554. this.fireEvent("failure", this.el, response);
  4555. if(typeof response.argument.callback == "function"){
  4556. response.argument.callback.call(response.argument.scope, this.el, false, response, response.argument.options);
  4557. }
  4558. },
  4559. setRenderer : function(renderer){
  4560. this.renderer = renderer;
  4561. },
  4562. getRenderer : function(){
  4563. return this.renderer;
  4564. },
  4565. setDefaultUrl : function(defaultUrl){
  4566. this.defaultUrl = defaultUrl;
  4567. },
  4568. abort : function(){
  4569. if(this.transaction){
  4570. Ext.Ajax.abort(this.transaction);
  4571. }
  4572. },
  4573. isUpdating : function(){
  4574. if(this.transaction){
  4575. return Ext.Ajax.isLoading(this.transaction);
  4576. }
  4577. return false;
  4578. }
  4579. });
  4580. Ext.Updater.defaults = {
  4581. timeout : 30,
  4582. loadScripts : false,
  4583. sslBlankUrl : (Ext.SSL_SECURE_URL || "javascript:false"),
  4584. disableCaching : false,
  4585. showLoadIndicator : true,
  4586. indicatorText : '<div class="loading-indicator">Loading...</div>'
  4587. };
  4588. Ext.Updater.updateElement = function(el, url, params, options){
  4589. var um = Ext.get(el).getUpdater();
  4590. Ext.apply(um, options);
  4591. um.update(url, params, options ? options.callback : null);
  4592. };
  4593. Ext.Updater.update = Ext.Updater.updateElement;
  4594. Ext.Updater.BasicRenderer = function(){};
  4595. Ext.Updater.BasicRenderer.prototype = {
  4596. render : function(el, response, updateManager, callback){
  4597. el.update(response.responseText, updateManager.loadScripts, callback);
  4598. }
  4599. };
  4600. Ext.UpdateManager = Ext.Updater;
  4601. Date.parseFunctions = {count:0};
  4602. Date.parseRegexes = [];
  4603. Date.formatFunctions = {count:0};
  4604. Date.prototype.dateFormat = function(format) {
  4605. if (Date.formatFunctions[format] == null) {
  4606. Date.createNewFormat(format);
  4607. }
  4608. var func = Date.formatFunctions[format];
  4609. return this[func]();
  4610. };
  4611. Date.prototype.format = Date.prototype.dateFormat;
  4612. Date.createNewFormat = function(format) {
  4613. var funcName = "format" + Date.formatFunctions.count++;
  4614. Date.formatFunctions[format] = funcName;
  4615. var code = "Date.prototype." + funcName + " = function(){return ";
  4616. var special = false;
  4617. var ch = '';
  4618. for (var i = 0; i < format.length; ++i) {
  4619. ch = format.charAt(i);
  4620. if (!special && ch == "\\") {
  4621. special = true;
  4622. }
  4623. else if (special) {
  4624. special = false;
  4625. code += "'" + String.escape(ch) + "' + ";
  4626. }
  4627. else {
  4628. code += Date.getFormatCode(ch);
  4629. }
  4630. }
  4631. eval(code.substring(0, code.length - 3) + ";}");
  4632. };
  4633. Date.getFormatCode = function(character) {
  4634. switch (character) {
  4635. case "d":
  4636. return "String.leftPad(this.getDate(), 2, '0') + ";
  4637. case "D":
  4638. return "Date.getShortDayName(this.getDay()) + "; case "j":
  4639. return "this.getDate() + ";
  4640. case "l":
  4641. return "Date.dayNames[this.getDay()] + ";
  4642. case "N":
  4643. return "(this.getDay() ? this.getDay() : 7) + ";
  4644. case "S":
  4645. return "this.getSuffix() + ";
  4646. case "w":
  4647. return "this.getDay() + ";
  4648. case "z":
  4649. return "this.getDayOfYear() + ";
  4650. case "W":
  4651. return "String.leftPad(this.getWeekOfYear(), 2, '0') + ";
  4652. case "F":
  4653. return "Date.monthNames[this.getMonth()] + ";
  4654. case "m":
  4655. return "String.leftPad(this.getMonth() + 1, 2, '0') + ";
  4656. case "M":
  4657. return "Date.getShortMonthName(this.getMonth()) + "; case "n":
  4658. return "(this.getMonth() + 1) + ";
  4659. case "t":
  4660. return "this.getDaysInMonth() + ";
  4661. case "L":
  4662. return "(this.isLeapYear() ? 1 : 0) + ";
  4663. case "o":
  4664. return "(this.getFullYear() + (this.getWeekOfYear() == 1 && this.getMonth() > 0 ? +1 : (this.getWeekOfYear() >= 52 && this.getMonth() < 11 ? -1 : 0))) + ";
  4665. case "Y":
  4666. return "this.getFullYear() + ";
  4667. case "y":
  4668. return "('' + this.getFullYear()).substring(2, 4) + ";
  4669. case "a":
  4670. return "(this.getHours() < 12 ? 'am' : 'pm') + ";
  4671. case "A":
  4672. return "(this.getHours() < 12 ? 'AM' : 'PM') + ";
  4673. case "g":
  4674. return "((this.getHours() % 12) ? this.getHours() % 12 : 12) + ";
  4675. case "G":
  4676. return "this.getHours() + ";
  4677. case "h":
  4678. return "String.leftPad((this.getHours() % 12) ? this.getHours() % 12 : 12, 2, '0') + ";
  4679. case "H":
  4680. return "String.leftPad(this.getHours(), 2, '0') + ";
  4681. case "i":
  4682. return "String.leftPad(this.getMinutes(), 2, '0') + ";
  4683. case "s":
  4684. return "String.leftPad(this.getSeconds(), 2, '0') + ";
  4685. case "u":
  4686. return "String.leftPad(this.getMilliseconds(), 3, '0') + ";
  4687. case "O":
  4688. return "this.getGMTOffset() + ";
  4689. case "P":
  4690. return "this.getGMTOffset(true) + ";
  4691. case "T":
  4692. return "this.getTimezone() + ";
  4693. case "Z":
  4694. return "(this.getTimezoneOffset() * -60) + ";
  4695. case "c":
  4696. for (var df = Date.getFormatCode, c = "Y-m-dTH:i:sP", code = "", i = 0, l = c.length; i < l; ++i) {
  4697. var e = c.charAt(i);
  4698. code += e == "T" ? "'T' + " : df(e); }
  4699. return code;
  4700. case "U":
  4701. return "Math.round(this.getTime() / 1000) + ";
  4702. default:
  4703. return "'" + String.escape(character) + "' + ";
  4704. }
  4705. };
  4706. Date.parseDate = function(input, format) {
  4707. if (Date.parseFunctions[format] == null) {
  4708. Date.createParser(format);
  4709. }
  4710. var func = Date.parseFunctions[format];
  4711. return Date[func](input);
  4712. };
  4713. Date.createParser = function(format) {
  4714. var funcName = "parse" + Date.parseFunctions.count++;
  4715. var regexNum = Date.parseRegexes.length;
  4716. var currentGroup = 1;
  4717. Date.parseFunctions[format] = funcName;
  4718. var code = "Date." + funcName + " = function(input){\n"
  4719. + "var y = -1, m = -1, d = -1, h = -1, i = -1, s = -1, ms = -1, o, z, u, v;\n"
  4720. + "input = String(input);var d = new Date();\n"
  4721. + "y = d.getFullYear();\n"
  4722. + "m = d.getMonth();\n"
  4723. + "d = d.getDate();\n"
  4724. + "var results = input.match(Date.parseRegexes[" + regexNum + "]);\n"
  4725. + "if (results && results.length > 0) {";
  4726. var regex = "";
  4727. var special = false;
  4728. var ch = '';
  4729. for (var i = 0; i < format.length; ++i) {
  4730. ch = format.charAt(i);
  4731. if (!special && ch == "\\") {
  4732. special = true;
  4733. }
  4734. else if (special) {
  4735. special = false;
  4736. regex += String.escape(ch);
  4737. }
  4738. else {
  4739. var obj = Date.formatCodeToRegex(ch, currentGroup);
  4740. currentGroup += obj.g;
  4741. regex += obj.s;
  4742. if (obj.g && obj.c) {
  4743. code += obj.c;
  4744. }
  4745. }
  4746. }
  4747. code += "if (u)\n"
  4748. + "{v = new Date(u * 1000);}" + "else if (y >= 0 && m >= 0 && d > 0 && h >= 0 && i >= 0 && s >= 0 && ms >= 0)\n"
  4749. + "{v = new Date(y, m, d, h, i, s, ms);}\n"
  4750. + "else if (y >= 0 && m >= 0 && d > 0 && h >= 0 && i >= 0 && s >= 0)\n"
  4751. + "{v = new Date(y, m, d, h, i, s);}\n"
  4752. + "else if (y >= 0 && m >= 0 && d > 0 && h >= 0 && i >= 0)\n"
  4753. + "{v = new Date(y, m, d, h, i);}\n"
  4754. + "else if (y >= 0 && m >= 0 && d > 0 && h >= 0)\n"
  4755. + "{v = new Date(y, m, d, h);}\n"
  4756. + "else if (y >= 0 && m >= 0 && d > 0)\n"
  4757. + "{v = new Date(y, m, d);}\n"
  4758. + "else if (y >= 0 && m >= 0)\n"
  4759. + "{v = new Date(y, m);}\n"
  4760. + "else if (y >= 0)\n"
  4761. + "{v = new Date(y);}\n"
  4762. + "}return (v && (z || o))?\n" + " (z ? v.add(Date.SECOND, (v.getTimezoneOffset() * 60) + (z*1)) :\n" + " v.add(Date.HOUR, (v.getGMTOffset() / 100) + (o / -100))) : v\n" + ";}";
  4763. Date.parseRegexes[regexNum] = new RegExp("^" + regex + "$", "i");
  4764. eval(code);
  4765. };
  4766. Date.formatCodeToRegex = function(character, currentGroup) {
  4767. switch (character) {
  4768. case "d":
  4769. return {g:1,
  4770. c:"d = parseInt(results[" + currentGroup + "], 10);\n",
  4771. s:"(\\d{2})"}; case "D":
  4772. for (var a = [], i = 0; i < 7; a.push(Date.getShortDayName(i)), ++i); return {g:0,
  4773. c:null,
  4774. s:"(?:" + a.join("|") +")"};
  4775. case "j":
  4776. return {g:1,
  4777. c:"d = parseInt(results[" + currentGroup + "], 10);\n",
  4778. s:"(\\d{1,2})"}; case "l":
  4779. return {g:0,
  4780. c:null,
  4781. s:"(?:" + Date.dayNames.join("|") + ")"};
  4782. case "N":
  4783. return {g:0,
  4784. c:null,
  4785. s:"[1-7]"}; case "S":
  4786. return {g:0,
  4787. c:null,
  4788. s:"(?:st|nd|rd|th)"};
  4789. case "w":
  4790. return {g:0,
  4791. c:null,
  4792. s:"[0-6]"}; case "z":
  4793. return {g:0,
  4794. c:null,
  4795. s:"(?:\\d{1,3}"}; case "W":
  4796. return {g:0,
  4797. c:null,
  4798. s:"(?:\\d{2})"}; case "F":
  4799. return {g:1,
  4800. c:"m = parseInt(Date.getMonthNumber(results[" + currentGroup + "]), 10);\n", s:"(" + Date.monthNames.join("|") + ")"};
  4801. case "m":
  4802. return {g:1,
  4803. c:"m = parseInt(results[" + currentGroup + "], 10) - 1;\n",
  4804. s:"(\\d{2})"}; case "M":
  4805. for (var a = [], i = 0; i < 12; a.push(Date.getShortMonthName(i)), ++i); return {g:1,
  4806. c:"m = parseInt(Date.getMonthNumber(results[" + currentGroup + "]), 10);\n", s:"(" + a.join("|") + ")"};
  4807. case "n":
  4808. return {g:1,
  4809. c:"m = parseInt(results[" + currentGroup + "], 10) - 1;\n",
  4810. s:"(\\d{1,2})"}; case "t":
  4811. return {g:0,
  4812. c:null,
  4813. s:"(?:\\d{2})"}; case "L":
  4814. return {g:0,
  4815. c:null,
  4816. s:"(?:1|0)"};
  4817. case "o":
  4818. case "Y":
  4819. return {g:1,
  4820. c:"y = parseInt(results[" + currentGroup + "], 10);\n",
  4821. s:"(\\d{4})"}; case "y":
  4822. return {g:1,
  4823. c:"var ty = parseInt(results[" + currentGroup + "], 10);\n"
  4824. + "y = ty > Date.y2kYear ? 1900 + ty : 2000 + ty;\n",
  4825. s:"(\\d{1,2})"}; case "a":
  4826. return {g:1,
  4827. c:"if (results[" + currentGroup + "] == 'am') {\n"
  4828. + "if (h == 12) { h = 0; }\n"
  4829. + "} else { if (h < 12) { h += 12; }}",
  4830. s:"(am|pm)"};
  4831. case "A":
  4832. return {g:1,
  4833. c:"if (results[" + currentGroup + "] == 'AM') {\n"
  4834. + "if (h == 12) { h = 0; }\n"
  4835. + "} else { if (h < 12) { h += 12; }}",
  4836. s:"(AM|PM)"};
  4837. case "g":
  4838. case "G":
  4839. return {g:1,
  4840. c:"h = parseInt(results[" + currentGroup + "], 10);\n",
  4841. s:"(\\d{1,2})"}; case "h":
  4842. case "H":
  4843. return {g:1,
  4844. c:"h = parseInt(results[" + currentGroup + "], 10);\n",
  4845. s:"(\\d{2})"}; case "i":
  4846. return {g:1,
  4847. c:"i = parseInt(results[" + currentGroup + "], 10);\n",
  4848. s:"(\\d{2})"}; case "s":
  4849. return {g:1,
  4850. c:"s = parseInt(results[" + currentGroup + "], 10);\n",
  4851. s:"(\\d{2})"}; case "u":
  4852. return {g:1,
  4853. c:"ms = parseInt(results[" + currentGroup + "], 10);\n",
  4854. s:"(\\d{3})"}; case "O":
  4855. return {g:1,
  4856. c:[
  4857. "o = results[", currentGroup, "];\n",
  4858. "var sn = o.substring(0,1);\n", "var hr = o.substring(1,3)*1 + Math.floor(o.substring(3,5) / 60);\n", "var mn = o.substring(3,5) % 60;\n", "o = ((-12 <= (hr*60 + mn)/60) && ((hr*60 + mn)/60 <= 14))?\n", " (sn + String.leftPad(hr, 2, '0') + String.leftPad(mn, 2, '0')) : null;\n"
  4859. ].join(""),
  4860. s: "([+\-]\\d{4})"}; case "P":
  4861. return {g:1,
  4862. c:[
  4863. "o = results[", currentGroup, "];\n",
  4864. "var sn = o.substring(0,1);\n", "var hr = o.substring(1,3)*1 + Math.floor(o.substring(4,6) / 60);\n", "var mn = o.substring(4,6) % 60;\n", "o = ((-12 <= (hr*60 + mn)/60) && ((hr*60 + mn)/60 <= 14))?\n", " (sn + String.leftPad(hr, 2, '0') + String.leftPad(mn, 2, '0')) : null;\n"
  4865. ].join(""),
  4866. s: "([+\-]\\d{2}:\\d{2})"}; case "T":
  4867. return {g:0,
  4868. c:null,
  4869. s:"[A-Z]{1,4}"}; case "Z":
  4870. return {g:1,
  4871. c:"z = results[" + currentGroup + "] * 1;\n" + "z = (-43200 <= z && z <= 50400)? z : null;\n",
  4872. s:"([+\-]?\\d{1,5})"}; case "c":
  4873. var df = Date.formatCodeToRegex, calc = [];
  4874. var arr = [df("Y", 1), df("m", 2), df("d", 3), df("h", 4), df("i", 5), df("s", 6), df("P", 7)];
  4875. for (var i = 0, l = arr.length; i < l; ++i) {
  4876. calc.push(arr[i].c);
  4877. }
  4878. return {g:1,
  4879. c:calc.join(""),
  4880. s:arr[0].s + "-" + arr[1].s + "-" + arr[2].s + "T" + arr[3].s + ":" + arr[4].s + ":" + arr[5].s + arr[6].s};
  4881. case "U":
  4882. return {g:1,
  4883. c:"u = parseInt(results[" + currentGroup + "], 10);\n",
  4884. s:"(-?\\d+)"}; default:
  4885. return {g:0,
  4886. c:null,
  4887. s:Ext.escapeRe(character)};
  4888. }
  4889. };
  4890. Date.prototype.getTimezone = function() {
  4891. return this.toString().replace(/^.* (?:\((.*)\)|([A-Z]{1,4})(?:[\-+][0-9]{4})?(?: -?\d+)?)$/, "$1$2").replace(/[^A-Z]/g, "");
  4892. };
  4893. Date.prototype.getGMTOffset = function(colon) {
  4894. return (this.getTimezoneOffset() > 0 ? "-" : "+")
  4895. + String.leftPad(Math.abs(Math.floor(this.getTimezoneOffset() / 60)), 2, "0")
  4896. + (colon ? ":" : "")
  4897. + String.leftPad(this.getTimezoneOffset() % 60, 2, "0");
  4898. };
  4899. Date.prototype.getDayOfYear = function() {
  4900. var num = 0;
  4901. Date.daysInMonth[1] = this.isLeapYear() ? 29 : 28;
  4902. for (var i = 0; i < this.getMonth(); ++i) {
  4903. num += Date.daysInMonth[i];
  4904. }
  4905. return num + this.getDate() - 1;
  4906. };
  4907. Date.prototype.getWeekOfYear = function() {
  4908. var ms1d = 864e5; var ms7d = 7 * ms1d; var DC3 = Date.UTC(this.getFullYear(), this.getMonth(), this.getDate() + 3) / ms1d; var AWN = Math.floor(DC3 / 7); var Wyr = new Date(AWN * ms7d).getUTCFullYear();
  4909. return AWN - Math.floor(Date.UTC(Wyr, 0, 7) / ms7d) + 1;
  4910. };
  4911. Date.prototype.isLeapYear = function() {
  4912. var year = this.getFullYear();
  4913. return !!((year & 3) == 0 && (year % 100 || (year % 400 == 0 && year)));
  4914. };
  4915. Date.prototype.getFirstDayOfMonth = function() {
  4916. var day = (this.getDay() - (this.getDate() - 1)) % 7;
  4917. return (day < 0) ? (day + 7) : day;
  4918. };
  4919. Date.prototype.getLastDayOfMonth = function() {
  4920. var day = (this.getDay() + (Date.daysInMonth[this.getMonth()] - this.getDate())) % 7;
  4921. return (day < 0) ? (day + 7) : day;
  4922. };
  4923. Date.prototype.getFirstDateOfMonth = function() {
  4924. return new Date(this.getFullYear(), this.getMonth(), 1);
  4925. };
  4926. Date.prototype.getLastDateOfMonth = function() {
  4927. return new Date(this.getFullYear(), this.getMonth(), this.getDaysInMonth());
  4928. };
  4929. Date.prototype.getDaysInMonth = function() {
  4930. Date.daysInMonth[1] = this.isLeapYear() ? 29 : 28;
  4931. return Date.daysInMonth[this.getMonth()];
  4932. };
  4933. Date.prototype.getSuffix = function() {
  4934. switch (this.getDate()) {
  4935. case 1:
  4936. case 21:
  4937. case 31:
  4938. return "st";
  4939. case 2:
  4940. case 22:
  4941. return "nd";
  4942. case 3:
  4943. case 23:
  4944. return "rd";
  4945. default:
  4946. return "th";
  4947. }
  4948. };
  4949. Date.daysInMonth = [31,28,31,30,31,30,31,31,30,31,30,31];
  4950. Date.monthNames =
  4951. ["January",
  4952. "February",
  4953. "March",
  4954. "April",
  4955. "May",
  4956. "June",
  4957. "July",
  4958. "August",
  4959. "September",
  4960. "October",
  4961. "November",
  4962. "December"];
  4963. Date.getShortMonthName = function(month) {
  4964. return Date.monthNames[month].substring(0, 3);
  4965. }
  4966. Date.dayNames =
  4967. ["Sunday",
  4968. "Monday",
  4969. "Tuesday",
  4970. "Wednesday",
  4971. "Thursday",
  4972. "Friday",
  4973. "Saturday"];
  4974. Date.getShortDayName = function(day) {
  4975. return Date.dayNames[day].substring(0, 3);
  4976. }
  4977. Date.y2kYear = 50;
  4978. Date.monthNumbers = {
  4979. Jan:0,
  4980. Feb:1,
  4981. Mar:2,
  4982. Apr:3,
  4983. May:4,
  4984. Jun:5,
  4985. Jul:6,
  4986. Aug:7,
  4987. Sep:8,
  4988. Oct:9,
  4989. Nov:10,
  4990. Dec:11};
  4991. Date.getMonthNumber = function(name) {
  4992. return Date.monthNumbers[name.substring(0, 1).toUpperCase() + name.substring(1, 3).toLowerCase()];
  4993. }
  4994. Date.prototype.clone = function() {
  4995. return new Date(this.getTime());
  4996. };
  4997. Date.prototype.clearTime = function(clone){
  4998. if(clone){
  4999. return this.clone().clearTime();
  5000. }
  5001. this.setHours(0);
  5002. this.setMinutes(0);
  5003. this.setSeconds(0);
  5004. this.setMilliseconds(0);
  5005. return this;
  5006. };
  5007. if(Ext.isSafari){
  5008. Date.brokenSetMonth = Date.prototype.setMonth;
  5009. Date.prototype.setMonth = function(num){
  5010. if(num <= -1){
  5011. var n = Math.ceil(-num);
  5012. var back_year = Math.ceil(n/12);
  5013. var month = (n % 12) ? 12 - n % 12 : 0 ;
  5014. this.setFullYear(this.getFullYear() - back_year);
  5015. return Date.brokenSetMonth.call(this, month);
  5016. } else {
  5017. return Date.brokenSetMonth.apply(this, arguments);
  5018. }
  5019. };
  5020. }
  5021. Date.MILLI = "ms";
  5022. Date.SECOND = "s";
  5023. Date.MINUTE = "mi";
  5024. Date.HOUR = "h";
  5025. Date.DAY = "d";
  5026. Date.MONTH = "mo";
  5027. Date.YEAR = "y";
  5028. Date.prototype.add = function(interval, value){
  5029. var d = this.clone();
  5030. if (!interval || value === 0) return d;
  5031. switch(interval.toLowerCase()){
  5032. case Date.MILLI:
  5033. d.setMilliseconds(this.getMilliseconds() + value);
  5034. break;
  5035. case Date.SECOND:
  5036. d.setSeconds(this.getSeconds() + value);
  5037. break;
  5038. case Date.MINUTE:
  5039. d.setMinutes(this.getMinutes() + value);
  5040. break;
  5041. case Date.HOUR:
  5042. d.setHours(this.getHours() + value);
  5043. break;
  5044. case Date.DAY:
  5045. d.setDate(this.getDate() + value);
  5046. break;
  5047. case Date.MONTH:
  5048. var day = this.getDate();
  5049. if(day > 28){
  5050. day = Math.min(day, this.getFirstDateOfMonth().add('mo', value).getLastDateOfMonth().getDate());
  5051. }
  5052. d.setDate(day);
  5053. d.setMonth(this.getMonth() + value);
  5054. break;
  5055. case Date.YEAR:
  5056. d.setFullYear(this.getFullYear() + value);
  5057. break;
  5058. }
  5059. return d;
  5060. };
  5061. Date.prototype.between = function(start, end){
  5062. var t = this.getTime();
  5063. return start.getTime() <= t && t <= end.getTime();
  5064. }
  5065. Ext.util.DelayedTask = function(fn, scope, args){
  5066. var id = null, d, t;
  5067. var call = function(){
  5068. var now = new Date().getTime();
  5069. if(now - t >= d){
  5070. clearInterval(id);
  5071. id = null;
  5072. fn.apply(scope, args || []);
  5073. }
  5074. };
  5075. this.delay = function(delay, newFn, newScope, newArgs){
  5076. if(id && delay != d){
  5077. this.cancel();
  5078. }
  5079. d = delay;
  5080. t = new Date().getTime();
  5081. fn = newFn || fn;
  5082. scope = newScope || scope;
  5083. args = newArgs || args;
  5084. if(!id){
  5085. id = setInterval(call, d);
  5086. }
  5087. };
  5088. this.cancel = function(){
  5089. if(id){
  5090. clearInterval(id);
  5091. id = null;
  5092. }
  5093. };
  5094. };
  5095. Ext.util.TaskRunner = function(interval){
  5096. interval = interval || 10;
  5097. var tasks = [], removeQueue = [];
  5098. var id = 0;
  5099. var running = false;
  5100. var stopThread = function(){
  5101. running = false;
  5102. clearInterval(id);
  5103. id = 0;
  5104. };
  5105. var startThread = function(){
  5106. if(!running){
  5107. running = true;
  5108. id = setInterval(runTasks, interval);
  5109. }
  5110. };
  5111. var removeTask = function(t){
  5112. removeQueue.push(t);
  5113. if(t.onStop){
  5114. t.onStop.apply(t.scope || t);
  5115. }
  5116. };
  5117. var runTasks = function(){
  5118. if(removeQueue.length > 0){
  5119. for(var i = 0, len = removeQueue.length; i < len; i++){
  5120. tasks.remove(removeQueue[i]);
  5121. }
  5122. removeQueue = [];
  5123. if(tasks.length < 1){
  5124. stopThread();
  5125. return;
  5126. }
  5127. }
  5128. var now = new Date().getTime();
  5129. for(var i = 0, len = tasks.length; i < len; ++i){
  5130. var t = tasks[i];
  5131. var itime = now - t.taskRunTime;
  5132. if(t.interval <= itime){
  5133. var rt = t.run.apply(t.scope || t, t.args || [++t.taskRunCount]);
  5134. t.taskRunTime = now;
  5135. if(rt === false || t.taskRunCount === t.repeat){
  5136. removeTask(t);
  5137. return;
  5138. }
  5139. }
  5140. if(t.duration && t.duration <= (now - t.taskStartTime)){
  5141. removeTask(t);
  5142. }
  5143. }
  5144. };
  5145. this.start = function(task){
  5146. tasks.push(task);
  5147. task.taskStartTime = new Date().getTime();
  5148. task.taskRunTime = 0;
  5149. task.taskRunCount = 0;
  5150. startThread();
  5151. return task;
  5152. };
  5153. this.stop = function(task){
  5154. removeTask(task);
  5155. return task;
  5156. };
  5157. this.stopAll = function(){
  5158. stopThread();
  5159. for(var i = 0, len = tasks.length; i < len; i++){
  5160. if(tasks[i].onStop){
  5161. tasks[i].onStop();
  5162. }
  5163. }
  5164. tasks = [];
  5165. removeQueue = [];
  5166. };
  5167. };
  5168. Ext.TaskMgr = new Ext.util.TaskRunner();
  5169. Ext.util.MixedCollection = function(allowFunctions, keyFn){
  5170. this.items = [];
  5171. this.map = {};
  5172. this.keys = [];
  5173. this.length = 0;
  5174. this.addEvents(
  5175. "clear",
  5176. "add",
  5177. "replace",
  5178. "remove",
  5179. "sort"
  5180. );
  5181. this.allowFunctions = allowFunctions === true;
  5182. if(keyFn){
  5183. this.getKey = keyFn;
  5184. }
  5185. Ext.util.MixedCollection.superclass.constructor.call(this);
  5186. };
  5187. Ext.extend(Ext.util.MixedCollection, Ext.util.Observable, {
  5188. allowFunctions : false,
  5189. add : function(key, o){
  5190. if(arguments.length == 1){
  5191. o = arguments[0];
  5192. key = this.getKey(o);
  5193. }
  5194. if(typeof key == "undefined" || key === null){
  5195. this.length++;
  5196. this.items.push(o);
  5197. this.keys.push(null);
  5198. }else{
  5199. var old = this.map[key];
  5200. if(old){
  5201. return this.replace(key, o);
  5202. }
  5203. this.length++;
  5204. this.items.push(o);
  5205. this.map[key] = o;
  5206. this.keys.push(key);
  5207. }
  5208. this.fireEvent("add", this.length-1, o, key);
  5209. return o;
  5210. },
  5211. getKey : function(o){
  5212. return o.id;
  5213. },
  5214. replace : function(key, o){
  5215. if(arguments.length == 1){
  5216. o = arguments[0];
  5217. key = this.getKey(o);
  5218. }
  5219. var old = this.item(key);
  5220. if(typeof key == "undefined" || key === null || typeof old == "undefined"){
  5221. return this.add(key, o);
  5222. }
  5223. var index = this.indexOfKey(key);
  5224. this.items[index] = o;
  5225. this.map[key] = o;
  5226. this.fireEvent("replace", key, old, o);
  5227. return o;
  5228. },
  5229. addAll : function(objs){
  5230. if(arguments.length > 1 || Ext.isArray(objs)){
  5231. var args = arguments.length > 1 ? arguments : objs;
  5232. for(var i = 0, len = args.length; i < len; i++){
  5233. this.add(args[i]);
  5234. }
  5235. }else{
  5236. for(var key in objs){
  5237. if(this.allowFunctions || typeof objs[key] != "function"){
  5238. this.add(key, objs[key]);
  5239. }
  5240. }
  5241. }
  5242. },
  5243. each : function(fn, scope){
  5244. var items = [].concat(this.items);
  5245. for(var i = 0, len = items.length; i < len; i++){
  5246. if(fn.call(scope || items[i], items[i], i, len) === false){
  5247. break;
  5248. }
  5249. }
  5250. },
  5251. eachKey : function(fn, scope){
  5252. for(var i = 0, len = this.keys.length; i < len; i++){
  5253. fn.call(scope || window, this.keys[i], this.items[i], i, len);
  5254. }
  5255. },
  5256. find : function(fn, scope){
  5257. for(var i = 0, len = this.items.length; i < len; i++){
  5258. if(fn.call(scope || window, this.items[i], this.keys[i])){
  5259. return this.items[i];
  5260. }
  5261. }
  5262. return null;
  5263. },
  5264. insert : function(index, key, o){
  5265. if(arguments.length == 2){
  5266. o = arguments[1];
  5267. key = this.getKey(o);
  5268. }
  5269. if(index >= this.length){
  5270. return this.add(key, o);
  5271. }
  5272. this.length++;
  5273. this.items.splice(index, 0, o);
  5274. if(typeof key != "undefined" && key != null){
  5275. this.map[key] = o;
  5276. }
  5277. this.keys.splice(index, 0, key);
  5278. this.fireEvent("add", index, o, key);
  5279. return o;
  5280. },
  5281. remove : function(o){
  5282. return this.removeAt(this.indexOf(o));
  5283. },
  5284. removeAt : function(index){
  5285. if(index < this.length && index >= 0){
  5286. this.length--;
  5287. var o = this.items[index];
  5288. this.items.splice(index, 1);
  5289. var key = this.keys[index];
  5290. if(typeof key != "undefined"){
  5291. delete this.map[key];
  5292. }
  5293. this.keys.splice(index, 1);
  5294. this.fireEvent("remove", o, key);
  5295. return o;
  5296. }
  5297. return false;
  5298. },
  5299. removeKey : function(key){
  5300. return this.removeAt(this.indexOfKey(key));
  5301. },
  5302. getCount : function(){
  5303. return this.length;
  5304. },
  5305. indexOf : function(o){
  5306. return this.items.indexOf(o);
  5307. },
  5308. indexOfKey : function(key){
  5309. return this.keys.indexOf(key);
  5310. },
  5311. item : function(key){
  5312. var item = typeof this.map[key] != "undefined" ? this.map[key] : this.items[key];
  5313. return typeof item != 'function' || this.allowFunctions ? item : null;
  5314. },
  5315. itemAt : function(index){
  5316. return this.items[index];
  5317. },
  5318. key : function(key){
  5319. return this.map[key];
  5320. },
  5321. contains : function(o){
  5322. return this.indexOf(o) != -1;
  5323. },
  5324. containsKey : function(key){
  5325. return typeof this.map[key] != "undefined";
  5326. },
  5327. clear : function(){
  5328. this.length = 0;
  5329. this.items = [];
  5330. this.keys = [];
  5331. this.map = {};
  5332. this.fireEvent("clear");
  5333. },
  5334. first : function(){
  5335. return this.items[0];
  5336. },
  5337. last : function(){
  5338. return this.items[this.length-1];
  5339. },
  5340. _sort : function(property, dir, fn){
  5341. var dsc = String(dir).toUpperCase() == "DESC" ? -1 : 1;
  5342. fn = fn || function(a, b){
  5343. return a-b;
  5344. };
  5345. var c = [], k = this.keys, items = this.items;
  5346. for(var i = 0, len = items.length; i < len; i++){
  5347. c[c.length] = {key: k[i], value: items[i], index: i};
  5348. }
  5349. c.sort(function(a, b){
  5350. var v = fn(a[property], b[property]) * dsc;
  5351. if(v == 0){
  5352. v = (a.index < b.index ? -1 : 1);
  5353. }
  5354. return v;
  5355. });
  5356. for(var i = 0, len = c.length; i < len; i++){
  5357. items[i] = c[i].value;
  5358. k[i] = c[i].key;
  5359. }
  5360. this.fireEvent("sort", this);
  5361. },
  5362. sort : function(dir, fn){
  5363. this._sort("value", dir, fn);
  5364. },
  5365. keySort : function(dir, fn){
  5366. this._sort("key", dir, fn || function(a, b){
  5367. return String(a).toUpperCase()-String(b).toUpperCase();
  5368. });
  5369. },
  5370. getRange : function(start, end){
  5371. var items = this.items;
  5372. if(items.length < 1){
  5373. return [];
  5374. }
  5375. start = start || 0;
  5376. end = Math.min(typeof end == "undefined" ? this.length-1 : end, this.length-1);
  5377. var r = [];
  5378. if(start <= end){
  5379. for(var i = start; i <= end; i++) {
  5380. r[r.length] = items[i];
  5381. }
  5382. }else{
  5383. for(var i = start; i >= end; i--) {
  5384. r[r.length] = items[i];
  5385. }
  5386. }
  5387. return r;
  5388. },
  5389. filter : function(property, value, anyMatch, caseSensitive){
  5390. if(Ext.isEmpty(value, false)){
  5391. return this.clone();
  5392. }
  5393. value = this.createValueMatcher(value, anyMatch, caseSensitive);
  5394. return this.filterBy(function(o){
  5395. return o && value.test(o[property]);
  5396. });
  5397. },
  5398. filterBy : function(fn, scope){
  5399. var r = new Ext.util.MixedCollection();
  5400. r.getKey = this.getKey;
  5401. var k = this.keys, it = this.items;
  5402. for(var i = 0, len = it.length; i < len; i++){
  5403. if(fn.call(scope||this, it[i], k[i])){
  5404. r.add(k[i], it[i]);
  5405. }
  5406. }
  5407. return r;
  5408. },
  5409. findIndex : function(property, value, start, anyMatch, caseSensitive){
  5410. if(Ext.isEmpty(value, false)){
  5411. return -1;
  5412. }
  5413. value = this.createValueMatcher(value, anyMatch, caseSensitive);
  5414. return this.findIndexBy(function(o){
  5415. return o && value.test(o[property]);
  5416. }, null, start);
  5417. },
  5418. findIndexBy : function(fn, scope, start){
  5419. var k = this.keys, it = this.items;
  5420. for(var i = (start||0), len = it.length; i < len; i++){
  5421. if(fn.call(scope||this, it[i], k[i])){
  5422. return i;
  5423. }
  5424. }
  5425. if(typeof start == 'number' && start > 0){
  5426. for(var i = 0; i < start; i++){
  5427. if(fn.call(scope||this, it[i], k[i])){
  5428. return i;
  5429. }
  5430. }
  5431. }
  5432. return -1;
  5433. },
  5434. createValueMatcher : function(value, anyMatch, caseSensitive){
  5435. if(!value.exec){
  5436. value = String(value);
  5437. value = new RegExp((anyMatch === true ? '' : '^') + Ext.escapeRe(value), caseSensitive ? '' : 'i');
  5438. }
  5439. return value;
  5440. },
  5441. clone : function(){
  5442. var r = new Ext.util.MixedCollection();
  5443. var k = this.keys, it = this.items;
  5444. for(var i = 0, len = it.length; i < len; i++){
  5445. r.add(k[i], it[i]);
  5446. }
  5447. r.getKey = this.getKey;
  5448. return r;
  5449. }
  5450. });
  5451. Ext.util.MixedCollection.prototype.get = Ext.util.MixedCollection.prototype.item;
  5452. Ext.util.JSON = new (function(){
  5453. var useHasOwn = {}.hasOwnProperty ? true : false;
  5454. var pad = function(n) {
  5455. return n < 10 ? "0" + n : n;
  5456. };
  5457. var m = {
  5458. "\b": '\\b',
  5459. "\t": '\\t',
  5460. "\n": '\\n',
  5461. "\f": '\\f',
  5462. "\r": '\\r',
  5463. '"' : '\\"',
  5464. "\\": '\\\\'
  5465. };
  5466. var encodeString = function(s){
  5467. if (/["\\\x00-\x1f]/.test(s)) {
  5468. return '"' + s.replace(/([\x00-\x1f\\"])/g, function(a, b) {
  5469. var c = m[b];
  5470. if(c){
  5471. return c;
  5472. }
  5473. c = b.charCodeAt();
  5474. return "\\u00" +
  5475. Math.floor(c / 16).toString(16) +
  5476. (c % 16).toString(16);
  5477. }) + '"';
  5478. }
  5479. return '"' + s + '"';
  5480. };
  5481. var encodeArray = function(o){
  5482. var a = ["["], b, i, l = o.length, v;
  5483. for (i = 0; i < l; i += 1) {
  5484. v = o[i];
  5485. switch (typeof v) {
  5486. case "undefined":
  5487. case "function":
  5488. case "unknown":
  5489. break;
  5490. default:
  5491. if (b) {
  5492. a.push(',');
  5493. }
  5494. a.push(v === null ? "null" : Ext.util.JSON.encode(v));
  5495. b = true;
  5496. }
  5497. }
  5498. a.push("]");
  5499. return a.join("");
  5500. };
  5501. var encodeDate = function(o){
  5502. return '"' + o.getFullYear() + "-" +
  5503. pad(o.getMonth() + 1) + "-" +
  5504. pad(o.getDate()) + "T" +
  5505. pad(o.getHours()) + ":" +
  5506. pad(o.getMinutes()) + ":" +
  5507. pad(o.getSeconds()) + '"';
  5508. };
  5509. this.encode = function(o){
  5510. if(typeof o == "undefined" || o === null){
  5511. return "null";
  5512. }else if(Ext.isArray(o)){
  5513. return encodeArray(o);
  5514. }else if(Ext.isDate(o)){
  5515. return encodeDate(o);
  5516. }else if(typeof o == "string"){
  5517. return encodeString(o);
  5518. }else if(typeof o == "number"){
  5519. return isFinite(o) ? String(o) : "null";
  5520. }else if(typeof o == "boolean"){
  5521. return String(o);
  5522. }else {
  5523. var a = ["{"], b, i, v;
  5524. for (i in o) {
  5525. if(!useHasOwn || o.hasOwnProperty(i)) {
  5526. v = o[i];
  5527. switch (typeof v) {
  5528. case "undefined":
  5529. case "function":
  5530. case "unknown":
  5531. break;
  5532. default:
  5533. if(b){
  5534. a.push(',');
  5535. }
  5536. a.push(this.encode(i), ":",
  5537. v === null ? "null" : this.encode(v));
  5538. b = true;
  5539. }
  5540. }
  5541. }
  5542. a.push("}");
  5543. return a.join("");
  5544. }
  5545. };
  5546. this.decode = function(json){
  5547. return eval("(" + json + ')');
  5548. };
  5549. })();
  5550. Ext.encode = Ext.util.JSON.encode;
  5551. Ext.decode = Ext.util.JSON.decode;
  5552. Ext.util.Format = function(){
  5553. var trimRe = /^\s+|\s+$/g;
  5554. return {
  5555. ellipsis : function(value, len){
  5556. if(value && value.length > len){
  5557. return value.substr(0, len-3)+"...";
  5558. }
  5559. return value;
  5560. },
  5561. undef : function(value){
  5562. return value !== undefined ? value : "";
  5563. },
  5564. defaultValue : function(value, defaultValue){
  5565. return value !== undefined && value !== '' ? value : defaultValue;
  5566. },
  5567. htmlEncode : function(value){
  5568. return !value ? value : String(value).replace(/&/g, "&amp;").replace(/>/g, "&gt;").replace(/</g, "&lt;").replace(/"/g, "&quot;");
  5569. },
  5570. htmlDecode : function(value){
  5571. return !value ? value : String(value).replace(/&amp;/g, "&").replace(/&gt;/g, ">").replace(/&lt;/g, "<").replace(/&quot;/g, '"');
  5572. },
  5573. trim : function(value){
  5574. return String(value).replace(trimRe, "");
  5575. },
  5576. substr : function(value, start, length){
  5577. return String(value).substr(start, length);
  5578. },
  5579. lowercase : function(value){
  5580. return String(value).toLowerCase();
  5581. },
  5582. uppercase : function(value){
  5583. return String(value).toUpperCase();
  5584. },
  5585. capitalize : function(value){
  5586. return !value ? value : value.charAt(0).toUpperCase() + value.substr(1).toLowerCase();
  5587. },
  5588. call : function(value, fn){
  5589. if(arguments.length > 2){
  5590. var args = Array.prototype.slice.call(arguments, 2);
  5591. args.unshift(value);
  5592. return eval(fn).apply(window, args);
  5593. }else{
  5594. return eval(fn).call(window, value);
  5595. }
  5596. },
  5597. usMoney : function(v){
  5598. v = (Math.round((v-0)*100))/100;
  5599. v = (v == Math.floor(v)) ? v + ".00" : ((v*10 == Math.floor(v*10)) ? v + "0" : v);
  5600. v = String(v);
  5601. var ps = v.split('.');
  5602. var whole = ps[0];
  5603. var sub = ps[1] ? '.'+ ps[1] : '.00';
  5604. var r = /(\d+)(\d{3})/;
  5605. while (r.test(whole)) {
  5606. whole = whole.replace(r, '$1' + ',' + '$2');
  5607. }
  5608. v = whole + sub;
  5609. if(v.charAt(0) == '-'){
  5610. return '-$' + v.substr(1);
  5611. }
  5612. return "$" + v;
  5613. },
  5614. date : function(v, format){
  5615. if(!v){
  5616. return "";
  5617. }
  5618. if(!Ext.isDate(v)){
  5619. v = new Date(Date.parse(v));
  5620. }
  5621. return v.dateFormat(format || "m/d/Y");
  5622. },
  5623. dateRenderer : function(format){
  5624. return function(v){
  5625. return Ext.util.Format.date(v, format);
  5626. };
  5627. },
  5628. stripTagsRE : /<\/?[^>]+>/gi,
  5629. stripTags : function(v){
  5630. return !v ? v : String(v).replace(this.stripTagsRE, "");
  5631. },
  5632. stripScriptsRe : /(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)/ig,
  5633. stripScripts : function(v){
  5634. return !v ? v : String(v).replace(this.stripScriptsRe, "");
  5635. },
  5636. fileSize : function(size){
  5637. if(size < 1024) {
  5638. return size + " bytes";
  5639. } else if(size < 1048576) {
  5640. return (Math.round(((size*10) / 1024))/10) + " KB";
  5641. } else {
  5642. return (Math.round(((size*10) / 1048576))/10) + " MB";
  5643. }
  5644. },
  5645. math : function(){
  5646. var fns = {};
  5647. return function(v, a){
  5648. if(!fns[a]){
  5649. fns[a] = new Function('v', 'return v ' + a + ';');
  5650. }
  5651. return fns[a](v);
  5652. }
  5653. }()
  5654. };
  5655. }();
  5656. Ext.XTemplate = function(){
  5657. Ext.XTemplate.superclass.constructor.apply(this, arguments);
  5658. var s = this.html;
  5659. s = ['<tpl>', s, '</tpl>'].join('');
  5660. var re = /<tpl\b[^>]*>((?:(?=([^<]+))\2|<(?!tpl\b[^>]*>))*?)<\/tpl>/;
  5661. var nameRe = /^<tpl\b[^>]*?for="(.*?)"/;
  5662. var ifRe = /^<tpl\b[^>]*?if="(.*?)"/;
  5663. var execRe = /^<tpl\b[^>]*?exec="(.*?)"/;
  5664. var m, id = 0;
  5665. var tpls = [];
  5666. while(m = s.match(re)){
  5667. var m2 = m[0].match(nameRe);
  5668. var m3 = m[0].match(ifRe);
  5669. var m4 = m[0].match(execRe);
  5670. var exp = null, fn = null, exec = null;
  5671. var name = m2 && m2[1] ? m2[1] : '';
  5672. if(m3){
  5673. exp = m3 && m3[1] ? m3[1] : null;
  5674. if(exp){
  5675. fn = new Function('values', 'parent', 'xindex', 'xcount', 'with(values){ return '+(Ext.util.Format.htmlDecode(exp))+'; }');
  5676. }
  5677. }
  5678. if(m4){
  5679. exp = m4 && m4[1] ? m4[1] : null;
  5680. if(exp){
  5681. exec = new Function('values', 'parent', 'xindex', 'xcount', 'with(values){ '+(Ext.util.Format.htmlDecode(exp))+'; }');
  5682. }
  5683. }
  5684. if(name){
  5685. switch(name){
  5686. case '.': name = new Function('values', 'parent', 'with(values){ return values; }'); break;
  5687. case '..': name = new Function('values', 'parent', 'with(values){ return parent; }'); break;
  5688. default: name = new Function('values', 'parent', 'with(values){ return '+name+'; }');
  5689. }
  5690. }
  5691. tpls.push({
  5692. id: id,
  5693. target: name,
  5694. exec: exec,
  5695. test: fn,
  5696. body: m[1]||''
  5697. });
  5698. s = s.replace(m[0], '{xtpl'+ id + '}');
  5699. ++id;
  5700. }
  5701. for(var i = tpls.length-1; i >= 0; --i){
  5702. this.compileTpl(tpls[i]);
  5703. }
  5704. this.master = tpls[tpls.length-1];
  5705. this.tpls = tpls;
  5706. };
  5707. Ext.extend(Ext.XTemplate, Ext.Template, {
  5708. re : /\{([\w-\.\#]+)(?:\:([\w\.]*)(?:\((.*?)?\))?)?(\s?[\+\-\*\\]\s?[\d\.\+\-\*\\\(\)]+)?\}/g,
  5709. codeRe : /\{\[((?:\\\]|.|\n)*?)\]\}/g,
  5710. applySubTemplate : function(id, values, parent, xindex, xcount){
  5711. var t = this.tpls[id];
  5712. if(t.test && !t.test.call(this, values, parent, xindex, xcount)){
  5713. return '';
  5714. }
  5715. if(t.exec && t.exec.call(this, values, parent, xindex, xcount)){
  5716. return '';
  5717. }
  5718. var vs = t.target ? t.target.call(this, values, parent) : values;
  5719. parent = t.target ? values : parent;
  5720. if(t.target && Ext.isArray(vs)){
  5721. var buf = [];
  5722. for(var i = 0, len = vs.length; i < len; i++){
  5723. buf[buf.length] = t.compiled.call(this, vs[i], parent, i+1, len);
  5724. }
  5725. return buf.join('');
  5726. }
  5727. return t.compiled.call(this, vs, parent, xindex, xcount);
  5728. },
  5729. compileTpl : function(tpl){
  5730. var fm = Ext.util.Format;
  5731. var useF = this.disableFormats !== true;
  5732. var sep = Ext.isGecko ? "+" : ",";
  5733. var fn = function(m, name, format, args, math){
  5734. if(name.substr(0, 4) == 'xtpl'){
  5735. return "'"+ sep +'this.applySubTemplate('+name.substr(4)+', values, parent, xindex, xcount)'+sep+"'";
  5736. }
  5737. var v;
  5738. if(name === '.'){
  5739. v = 'values';
  5740. }else if(name === '#'){
  5741. v = 'xindex';
  5742. }else if(name.indexOf('.') != -1){
  5743. v = name;
  5744. }else{
  5745. v = "values['" + name + "']";
  5746. }
  5747. if(math){
  5748. v = '(' + v + math + ')';
  5749. }
  5750. if(format && useF){
  5751. args = args ? ',' + args : "";
  5752. if(format.substr(0, 5) != "this."){
  5753. format = "fm." + format + '(';
  5754. }else{
  5755. format = 'this.call("'+ format.substr(5) + '", ';
  5756. args = ", values";
  5757. }
  5758. }else{
  5759. args= ''; format = "("+v+" === undefined ? '' : ";
  5760. }
  5761. return "'"+ sep + format + v + args + ")"+sep+"'";
  5762. };
  5763. var codeFn = function(m, code){
  5764. return "'"+ sep +'('+code+')'+sep+"'";
  5765. };
  5766. var body;
  5767. if(Ext.isGecko){
  5768. body = "tpl.compiled = function(values, parent, xindex, xcount){ return '" +
  5769. tpl.body.replace(/(\r\n|\n)/g, '\\n').replace(/'/g, "\\'").replace(this.re, fn).replace(this.codeRe, codeFn) +
  5770. "';};";
  5771. }else{
  5772. body = ["tpl.compiled = function(values, parent, xindex, xcount){ return ['"];
  5773. body.push(tpl.body.replace(/(\r\n|\n)/g, '\\n').replace(/'/g, "\\'").replace(this.re, fn).replace(this.codeRe, codeFn));
  5774. body.push("'].join('');};");
  5775. body = body.join('');
  5776. }
  5777. eval(body);
  5778. return this;
  5779. },
  5780. apply : function(values){
  5781. return this.master.compiled.call(this, values, {}, 1, 1);
  5782. },
  5783. applyTemplate : function(values){
  5784. return this.master.compiled.call(this, values, {}, 1, 1);
  5785. },
  5786. compile : function(){return this;}
  5787. });
  5788. Ext.XTemplate.from = function(el){
  5789. el = Ext.getDom(el);
  5790. return new Ext.XTemplate(el.value || el.innerHTML);
  5791. };
  5792. Ext.util.CSS = function(){
  5793. var rules = null;
  5794. var doc = document;
  5795. var camelRe = /(-[a-z])/gi;
  5796. var camelFn = function(m, a){ return a.charAt(1).toUpperCase(); };
  5797. return {
  5798. createStyleSheet : function(cssText, id){
  5799. var ss;
  5800. var head = doc.getElementsByTagName("head")[0];
  5801. var rules = doc.createElement("style");
  5802. rules.setAttribute("type", "text/css");
  5803. if(id){
  5804. rules.setAttribute("id", id);
  5805. }
  5806. if(Ext.isIE){
  5807. head.appendChild(rules);
  5808. ss = rules.styleSheet;
  5809. ss.cssText = cssText;
  5810. }else{
  5811. try{
  5812. rules.appendChild(doc.createTextNode(cssText));
  5813. }catch(e){
  5814. rules.cssText = cssText;
  5815. }
  5816. head.appendChild(rules);
  5817. ss = rules.styleSheet ? rules.styleSheet : (rules.sheet || doc.styleSheets[doc.styleSheets.length-1]);
  5818. }
  5819. this.cacheStyleSheet(ss);
  5820. return ss;
  5821. },
  5822. removeStyleSheet : function(id){
  5823. var existing = doc.getElementById(id);
  5824. if(existing){
  5825. existing.parentNode.removeChild(existing);
  5826. }
  5827. },
  5828. swapStyleSheet : function(id, url){
  5829. this.removeStyleSheet(id);
  5830. var ss = doc.createElement("link");
  5831. ss.setAttribute("rel", "stylesheet");
  5832. ss.setAttribute("type", "text/css");
  5833. ss.setAttribute("id", id);
  5834. ss.setAttribute("href", url);
  5835. doc.getElementsByTagName("head")[0].appendChild(ss);
  5836. },
  5837. refreshCache : function(){
  5838. return this.getRules(true);
  5839. },
  5840. cacheStyleSheet : function(ss){
  5841. if(!rules){
  5842. rules = {};
  5843. }
  5844. try{
  5845. var ssRules = ss.cssRules || ss.rules;
  5846. for(var j = ssRules.length-1; j >= 0; --j){
  5847. rules[ssRules[j].selectorText] = ssRules[j];
  5848. }
  5849. }catch(e){}
  5850. },
  5851. getRules : function(refreshCache){
  5852. if(rules == null || refreshCache){
  5853. rules = {};
  5854. var ds = doc.styleSheets;
  5855. for(var i =0, len = ds.length; i < len; i++){
  5856. try{
  5857. this.cacheStyleSheet(ds[i]);
  5858. }catch(e){}
  5859. }
  5860. }
  5861. return rules;
  5862. },
  5863. getRule : function(selector, refreshCache){
  5864. var rs = this.getRules(refreshCache);
  5865. if(!Ext.isArray(selector)){
  5866. return rs[selector];
  5867. }
  5868. for(var i = 0; i < selector.length; i++){
  5869. if(rs[selector[i]]){
  5870. return rs[selector[i]];
  5871. }
  5872. }
  5873. return null;
  5874. },
  5875. updateRule : function(selector, property, value){
  5876. if(!Ext.isArray(selector)){
  5877. var rule = this.getRule(selector);
  5878. if(rule){
  5879. rule.style[property.replace(camelRe, camelFn)] = value;
  5880. return true;
  5881. }
  5882. }else{
  5883. for(var i = 0; i < selector.length; i++){
  5884. if(this.updateRule(selector[i], property, value)){
  5885. return true;
  5886. }
  5887. }
  5888. }
  5889. return false;
  5890. }
  5891. };
  5892. }();
  5893. Ext.util.ClickRepeater = function(el, config)
  5894. {
  5895. this.el = Ext.get(el);
  5896. this.el.unselectable();
  5897. Ext.apply(this, config);
  5898. this.addEvents(
  5899. "mousedown",
  5900. "click",
  5901. "mouseup"
  5902. );
  5903. this.el.on("mousedown", this.handleMouseDown, this);
  5904. if(this.preventDefault || this.stopDefault){
  5905. this.el.on("click", function(e){
  5906. if(this.preventDefault){
  5907. e.preventDefault();
  5908. }
  5909. if(this.stopDefault){
  5910. e.stopEvent();
  5911. }
  5912. }, this);
  5913. }
  5914. if(this.handler){
  5915. this.on("click", this.handler, this.scope || this);
  5916. }
  5917. Ext.util.ClickRepeater.superclass.constructor.call(this);
  5918. };
  5919. Ext.extend(Ext.util.ClickRepeater, Ext.util.Observable, {
  5920. interval : 20,
  5921. delay: 250,
  5922. preventDefault : true,
  5923. stopDefault : false,
  5924. timer : 0,
  5925. handleMouseDown : function(){
  5926. clearTimeout(this.timer);
  5927. this.el.blur();
  5928. if(this.pressClass){
  5929. this.el.addClass(this.pressClass);
  5930. }
  5931. this.mousedownTime = new Date();
  5932. Ext.getDoc().on("mouseup", this.handleMouseUp, this);
  5933. this.el.on("mouseout", this.handleMouseOut, this);
  5934. this.fireEvent("mousedown", this);
  5935. this.fireEvent("click", this);
  5936. if (this.accelerate) {
  5937. this.delay = 400;
  5938. }
  5939. this.timer = this.click.defer(this.delay || this.interval, this);
  5940. },
  5941. click : function(){
  5942. this.fireEvent("click", this);
  5943. this.timer = this.click.defer(this.accelerate ?
  5944. this.easeOutExpo(this.mousedownTime.getElapsed(),
  5945. 400,
  5946. -390,
  5947. 12000) :
  5948. this.interval, this);
  5949. },
  5950. easeOutExpo : function (t, b, c, d) {
  5951. return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b;
  5952. },
  5953. handleMouseOut : function(){
  5954. clearTimeout(this.timer);
  5955. if(this.pressClass){
  5956. this.el.removeClass(this.pressClass);
  5957. }
  5958. this.el.on("mouseover", this.handleMouseReturn, this);
  5959. },
  5960. handleMouseReturn : function(){
  5961. this.el.un("mouseover", this.handleMouseReturn);
  5962. if(this.pressClass){
  5963. this.el.addClass(this.pressClass);
  5964. }
  5965. this.click();
  5966. },
  5967. handleMouseUp : function(){
  5968. clearTimeout(this.timer);
  5969. this.el.un("mouseover", this.handleMouseReturn);
  5970. this.el.un("mouseout", this.handleMouseOut);
  5971. Ext.getDoc().un("mouseup", this.handleMouseUp);
  5972. this.el.removeClass(this.pressClass);
  5973. this.fireEvent("mouseup", this);
  5974. }
  5975. });
  5976. Ext.KeyNav = function(el, config){
  5977. this.el = Ext.get(el);
  5978. Ext.apply(this, config);
  5979. if(!this.disabled){
  5980. this.disabled = true;
  5981. this.enable();
  5982. }
  5983. };
  5984. Ext.KeyNav.prototype = {
  5985. disabled : false,
  5986. defaultEventAction: "stopEvent",
  5987. forceKeyDown : false,
  5988. prepareEvent : function(e){
  5989. var k = e.getKey();
  5990. var h = this.keyToHandler[k];
  5991. if(Ext.isSafari && h && k >= 37 && k <= 40){
  5992. e.stopEvent();
  5993. }
  5994. },
  5995. relay : function(e){
  5996. var k = e.getKey();
  5997. var h = this.keyToHandler[k];
  5998. if(h && this[h]){
  5999. if(this.doRelay(e, this[h], h) !== true){
  6000. e[this.defaultEventAction]();
  6001. }
  6002. }
  6003. },
  6004. doRelay : function(e, h, hname){
  6005. return h.call(this.scope || this, e);
  6006. },
  6007. enter : false,
  6008. left : false,
  6009. right : false,
  6010. up : false,
  6011. down : false,
  6012. tab : false,
  6013. esc : false,
  6014. pageUp : false,
  6015. pageDown : false,
  6016. del : false,
  6017. home : false,
  6018. end : false,
  6019. keyToHandler : {
  6020. 37 : "left",
  6021. 39 : "right",
  6022. 38 : "up",
  6023. 40 : "down",
  6024. 33 : "pageUp",
  6025. 34 : "pageDown",
  6026. 46 : "del",
  6027. 36 : "home",
  6028. 35 : "end",
  6029. 13 : "enter",
  6030. 27 : "esc",
  6031. 9 : "tab"
  6032. },
  6033. enable: function(){
  6034. if(this.disabled){
  6035. if(this.forceKeyDown || Ext.isIE || Ext.isAir){
  6036. this.el.on("keydown", this.relay, this);
  6037. }else{
  6038. this.el.on("keydown", this.prepareEvent, this);
  6039. this.el.on("keypress", this.relay, this);
  6040. }
  6041. this.disabled = false;
  6042. }
  6043. },
  6044. disable: function(){
  6045. if(!this.disabled){
  6046. if(this.forceKeyDown || Ext.isIE || Ext.isAir){
  6047. this.el.un("keydown", this.relay);
  6048. }else{
  6049. this.el.un("keydown", this.prepareEvent);
  6050. this.el.un("keypress", this.relay);
  6051. }
  6052. this.disabled = true;
  6053. }
  6054. }
  6055. };
  6056. Ext.KeyMap = function(el, config, eventName){
  6057. this.el = Ext.get(el);
  6058. this.eventName = eventName || "keydown";
  6059. this.bindings = [];
  6060. if(config){
  6061. this.addBinding(config);
  6062. }
  6063. this.enable();
  6064. };
  6065. Ext.KeyMap.prototype = {
  6066. stopEvent : false,
  6067. addBinding : function(config){
  6068. if(Ext.isArray(config)){
  6069. for(var i = 0, len = config.length; i < len; i++){
  6070. this.addBinding(config[i]);
  6071. }
  6072. return;
  6073. }
  6074. var keyCode = config.key,
  6075. shift = config.shift,
  6076. ctrl = config.ctrl,
  6077. alt = config.alt,
  6078. fn = config.fn || config.handler,
  6079. scope = config.scope;
  6080. if(typeof keyCode == "string"){
  6081. var ks = [];
  6082. var keyString = keyCode.toUpperCase();
  6083. for(var j = 0, len = keyString.length; j < len; j++){
  6084. ks.push(keyString.charCodeAt(j));
  6085. }
  6086. keyCode = ks;
  6087. }
  6088. var keyArray = Ext.isArray(keyCode);
  6089. var handler = function(e){
  6090. if((!shift || e.shiftKey) && (!ctrl || e.ctrlKey) && (!alt || e.altKey)){
  6091. var k = e.getKey();
  6092. if(keyArray){
  6093. for(var i = 0, len = keyCode.length; i < len; i++){
  6094. if(keyCode[i] == k){
  6095. if(this.stopEvent){
  6096. e.stopEvent();
  6097. }
  6098. fn.call(scope || window, k, e);
  6099. return;
  6100. }
  6101. }
  6102. }else{
  6103. if(k == keyCode){
  6104. if(this.stopEvent){
  6105. e.stopEvent();
  6106. }
  6107. fn.call(scope || window, k, e);
  6108. }
  6109. }
  6110. }
  6111. };
  6112. this.bindings.push(handler);
  6113. },
  6114. on : function(key, fn, scope){
  6115. var keyCode, shift, ctrl, alt;
  6116. if(typeof key == "object" && !Ext.isArray(key)){
  6117. keyCode = key.key;
  6118. shift = key.shift;
  6119. ctrl = key.ctrl;
  6120. alt = key.alt;
  6121. }else{
  6122. keyCode = key;
  6123. }
  6124. this.addBinding({
  6125. key: keyCode,
  6126. shift: shift,
  6127. ctrl: ctrl,
  6128. alt: alt,
  6129. fn: fn,
  6130. scope: scope
  6131. })
  6132. },
  6133. handleKeyDown : function(e){
  6134. if(this.enabled){
  6135. var b = this.bindings;
  6136. for(var i = 0, len = b.length; i < len; i++){
  6137. b[i].call(this, e);
  6138. }
  6139. }
  6140. },
  6141. isEnabled : function(){
  6142. return this.enabled;
  6143. },
  6144. enable: function(){
  6145. if(!this.enabled){
  6146. this.el.on(this.eventName, this.handleKeyDown, this);
  6147. this.enabled = true;
  6148. }
  6149. },
  6150. disable: function(){
  6151. if(this.enabled){
  6152. this.el.removeListener(this.eventName, this.handleKeyDown, this);
  6153. this.enabled = false;
  6154. }
  6155. }
  6156. };
  6157. Ext.util.TextMetrics = function(){
  6158. var shared;
  6159. return {
  6160. measure : function(el, text, fixedWidth){
  6161. if(!shared){
  6162. shared = Ext.util.TextMetrics.Instance(el, fixedWidth);
  6163. }
  6164. shared.bind(el);
  6165. shared.setFixedWidth(fixedWidth || 'auto');
  6166. return shared.getSize(text);
  6167. },
  6168. createInstance : function(el, fixedWidth){
  6169. return Ext.util.TextMetrics.Instance(el, fixedWidth);
  6170. }
  6171. };
  6172. }();
  6173. Ext.util.TextMetrics.Instance = function(bindTo, fixedWidth){
  6174. var ml = new Ext.Element(document.createElement('div'));
  6175. document.body.appendChild(ml.dom);
  6176. ml.position('absolute');
  6177. ml.setLeftTop(-1000, -1000);
  6178. ml.hide();
  6179. if(fixedWidth){
  6180. ml.setWidth(fixedWidth);
  6181. }
  6182. var instance = {
  6183. getSize : function(text){
  6184. ml.update(text);
  6185. var s = ml.getSize();
  6186. ml.update('');
  6187. return s;
  6188. },
  6189. bind : function(el){
  6190. ml.setStyle(
  6191. Ext.fly(el).getStyles('font-size','font-style', 'font-weight', 'font-family','line-height')
  6192. );
  6193. },
  6194. setFixedWidth : function(width){
  6195. ml.setWidth(width);
  6196. },
  6197. getWidth : function(text){
  6198. ml.dom.style.width = 'auto';
  6199. return this.getSize(text).width;
  6200. },
  6201. getHeight : function(text){
  6202. return this.getSize(text).height;
  6203. }
  6204. };
  6205. instance.bind(bindTo);
  6206. return instance;
  6207. };
  6208. Ext.Element.measureText = Ext.util.TextMetrics.measure;
  6209. (function() {
  6210. var Event=Ext.EventManager;
  6211. var Dom=Ext.lib.Dom;
  6212. Ext.dd.DragDrop = function(id, sGroup, config) {
  6213. if(id) {
  6214. this.init(id, sGroup, config);
  6215. }
  6216. };
  6217. Ext.dd.DragDrop.prototype = {
  6218. id: null,
  6219. config: null,
  6220. dragElId: null,
  6221. handleElId: null,
  6222. invalidHandleTypes: null,
  6223. invalidHandleIds: null,
  6224. invalidHandleClasses: null,
  6225. startPageX: 0,
  6226. startPageY: 0,
  6227. groups: null,
  6228. locked: false,
  6229. lock: function() { this.locked = true; },
  6230. unlock: function() { this.locked = false; },
  6231. isTarget: true,
  6232. padding: null,
  6233. _domRef: null,
  6234. __ygDragDrop: true,
  6235. constrainX: false,
  6236. constrainY: false,
  6237. minX: 0,
  6238. maxX: 0,
  6239. minY: 0,
  6240. maxY: 0,
  6241. maintainOffset: false,
  6242. xTicks: null,
  6243. yTicks: null,
  6244. primaryButtonOnly: true,
  6245. available: false,
  6246. hasOuterHandles: false,
  6247. b4StartDrag: function(x, y) { },
  6248. startDrag: function(x, y) { },
  6249. b4Drag: function(e) { },
  6250. onDrag: function(e) { },
  6251. onDragEnter: function(e, id) { },
  6252. b4DragOver: function(e) { },
  6253. onDragOver: function(e, id) { },
  6254. b4DragOut: function(e) { },
  6255. onDragOut: function(e, id) { },
  6256. b4DragDrop: function(e) { },
  6257. onDragDrop: function(e, id) { },
  6258. onInvalidDrop: function(e) { },
  6259. b4EndDrag: function(e) { },
  6260. endDrag: function(e) { },
  6261. b4MouseDown: function(e) { },
  6262. onMouseDown: function(e) { },
  6263. onMouseUp: function(e) { },
  6264. onAvailable: function () {
  6265. },
  6266. defaultPadding : {left:0, right:0, top:0, bottom:0},
  6267. constrainTo : function(constrainTo, pad, inContent){
  6268. if(typeof pad == "number"){
  6269. pad = {left: pad, right:pad, top:pad, bottom:pad};
  6270. }
  6271. pad = pad || this.defaultPadding;
  6272. var b = Ext.get(this.getEl()).getBox();
  6273. var ce = Ext.get(constrainTo);
  6274. var s = ce.getScroll();
  6275. var c, cd = ce.dom;
  6276. if(cd == document.body){
  6277. c = { x: s.left, y: s.top, width: Ext.lib.Dom.getViewWidth(), height: Ext.lib.Dom.getViewHeight()};
  6278. }else{
  6279. var xy = ce.getXY();
  6280. c = {x : xy[0]+s.left, y: xy[1]+s.top, width: cd.clientWidth, height: cd.clientHeight};
  6281. }
  6282. var topSpace = b.y - c.y;
  6283. var leftSpace = b.x - c.x;
  6284. this.resetConstraints();
  6285. this.setXConstraint(leftSpace - (pad.left||0),
  6286. c.width - leftSpace - b.width - (pad.right||0),
  6287. this.xTickSize
  6288. );
  6289. this.setYConstraint(topSpace - (pad.top||0),
  6290. c.height - topSpace - b.height - (pad.bottom||0),
  6291. this.yTickSize
  6292. );
  6293. },
  6294. getEl: function() {
  6295. if (!this._domRef) {
  6296. this._domRef = Ext.getDom(this.id);
  6297. }
  6298. return this._domRef;
  6299. },
  6300. getDragEl: function() {
  6301. return Ext.getDom(this.dragElId);
  6302. },
  6303. init: function(id, sGroup, config) {
  6304. this.initTarget(id, sGroup, config);
  6305. Event.on(this.id, "mousedown", this.handleMouseDown, this);
  6306. },
  6307. initTarget: function(id, sGroup, config) {
  6308. this.config = config || {};
  6309. this.DDM = Ext.dd.DDM;
  6310. this.groups = {};
  6311. if (typeof id !== "string") {
  6312. id = Ext.id(id);
  6313. }
  6314. this.id = id;
  6315. this.addToGroup((sGroup) ? sGroup : "default");
  6316. this.handleElId = id;
  6317. this.setDragElId(id);
  6318. this.invalidHandleTypes = { A: "A" };
  6319. this.invalidHandleIds = {};
  6320. this.invalidHandleClasses = [];
  6321. this.applyConfig();
  6322. this.handleOnAvailable();
  6323. },
  6324. applyConfig: function() {
  6325. this.padding = this.config.padding || [0, 0, 0, 0];
  6326. this.isTarget = (this.config.isTarget !== false);
  6327. this.maintainOffset = (this.config.maintainOffset);
  6328. this.primaryButtonOnly = (this.config.primaryButtonOnly !== false);
  6329. },
  6330. handleOnAvailable: function() {
  6331. this.available = true;
  6332. this.resetConstraints();
  6333. this.onAvailable();
  6334. },
  6335. setPadding: function(iTop, iRight, iBot, iLeft) {
  6336. if (!iRight && 0 !== iRight) {
  6337. this.padding = [iTop, iTop, iTop, iTop];
  6338. } else if (!iBot && 0 !== iBot) {
  6339. this.padding = [iTop, iRight, iTop, iRight];
  6340. } else {
  6341. this.padding = [iTop, iRight, iBot, iLeft];
  6342. }
  6343. },
  6344. setInitPosition: function(diffX, diffY) {
  6345. var el = this.getEl();
  6346. if (!this.DDM.verifyEl(el)) {
  6347. return;
  6348. }
  6349. var dx = diffX || 0;
  6350. var dy = diffY || 0;
  6351. var p = Dom.getXY( el );
  6352. this.initPageX = p[0] - dx;
  6353. this.initPageY = p[1] - dy;
  6354. this.lastPageX = p[0];
  6355. this.lastPageY = p[1];
  6356. this.setStartPosition(p);
  6357. },
  6358. setStartPosition: function(pos) {
  6359. var p = pos || Dom.getXY( this.getEl() );
  6360. this.deltaSetXY = null;
  6361. this.startPageX = p[0];
  6362. this.startPageY = p[1];
  6363. },
  6364. addToGroup: function(sGroup) {
  6365. this.groups[sGroup] = true;
  6366. this.DDM.regDragDrop(this, sGroup);
  6367. },
  6368. removeFromGroup: function(sGroup) {
  6369. if (this.groups[sGroup]) {
  6370. delete this.groups[sGroup];
  6371. }
  6372. this.DDM.removeDDFromGroup(this, sGroup);
  6373. },
  6374. setDragElId: function(id) {
  6375. this.dragElId = id;
  6376. },
  6377. setHandleElId: function(id) {
  6378. if (typeof id !== "string") {
  6379. id = Ext.id(id);
  6380. }
  6381. this.handleElId = id;
  6382. this.DDM.regHandle(this.id, id);
  6383. },
  6384. setOuterHandleElId: function(id) {
  6385. if (typeof id !== "string") {
  6386. id = Ext.id(id);
  6387. }
  6388. Event.on(id, "mousedown",
  6389. this.handleMouseDown, this);
  6390. this.setHandleElId(id);
  6391. this.hasOuterHandles = true;
  6392. },
  6393. unreg: function() {
  6394. Event.un(this.id, "mousedown",
  6395. this.handleMouseDown);
  6396. this._domRef = null;
  6397. this.DDM._remove(this);
  6398. },
  6399. destroy : function(){
  6400. this.unreg();
  6401. },
  6402. isLocked: function() {
  6403. return (this.DDM.isLocked() || this.locked);
  6404. },
  6405. handleMouseDown: function(e, oDD){
  6406. if (this.primaryButtonOnly && e.button != 0) {
  6407. return;
  6408. }
  6409. if (this.isLocked()) {
  6410. return;
  6411. }
  6412. this.DDM.refreshCache(this.groups);
  6413. var pt = new Ext.lib.Point(Ext.lib.Event.getPageX(e), Ext.lib.Event.getPageY(e));
  6414. if (!this.hasOuterHandles && !this.DDM.isOverTarget(pt, this) ) {
  6415. } else {
  6416. if (this.clickValidator(e)) {
  6417. this.setStartPosition();
  6418. this.b4MouseDown(e);
  6419. this.onMouseDown(e);
  6420. this.DDM.handleMouseDown(e, this);
  6421. this.DDM.stopEvent(e);
  6422. } else {
  6423. }
  6424. }
  6425. },
  6426. clickValidator: function(e) {
  6427. var target = e.getTarget();
  6428. return ( this.isValidHandleChild(target) &&
  6429. (this.id == this.handleElId ||
  6430. this.DDM.handleWasClicked(target, this.id)) );
  6431. },
  6432. addInvalidHandleType: function(tagName) {
  6433. var type = tagName.toUpperCase();
  6434. this.invalidHandleTypes[type] = type;
  6435. },
  6436. addInvalidHandleId: function(id) {
  6437. if (typeof id !== "string") {
  6438. id = Ext.id(id);
  6439. }
  6440. this.invalidHandleIds[id] = id;
  6441. },
  6442. addInvalidHandleClass: function(cssClass) {
  6443. this.invalidHandleClasses.push(cssClass);
  6444. },
  6445. removeInvalidHandleType: function(tagName) {
  6446. var type = tagName.toUpperCase();
  6447. delete this.invalidHandleTypes[type];
  6448. },
  6449. removeInvalidHandleId: function(id) {
  6450. if (typeof id !== "string") {
  6451. id = Ext.id(id);
  6452. }
  6453. delete this.invalidHandleIds[id];
  6454. },
  6455. removeInvalidHandleClass: function(cssClass) {
  6456. for (var i=0, len=this.invalidHandleClasses.length; i<len; ++i) {
  6457. if (this.invalidHandleClasses[i] == cssClass) {
  6458. delete this.invalidHandleClasses[i];
  6459. }
  6460. }
  6461. },
  6462. isValidHandleChild: function(node) {
  6463. var valid = true;
  6464. var nodeName;
  6465. try {
  6466. nodeName = node.nodeName.toUpperCase();
  6467. } catch(e) {
  6468. nodeName = node.nodeName;
  6469. }
  6470. valid = valid && !this.invalidHandleTypes[nodeName];
  6471. valid = valid && !this.invalidHandleIds[node.id];
  6472. for (var i=0, len=this.invalidHandleClasses.length; valid && i<len; ++i) {
  6473. valid = !Dom.hasClass(node, this.invalidHandleClasses[i]);
  6474. }
  6475. return valid;
  6476. },
  6477. setXTicks: function(iStartX, iTickSize) {
  6478. this.xTicks = [];
  6479. this.xTickSize = iTickSize;
  6480. var tickMap = {};
  6481. for (var i = this.initPageX; i >= this.minX; i = i - iTickSize) {
  6482. if (!tickMap[i]) {
  6483. this.xTicks[this.xTicks.length] = i;
  6484. tickMap[i] = true;
  6485. }
  6486. }
  6487. for (i = this.initPageX; i <= this.maxX; i = i + iTickSize) {
  6488. if (!tickMap[i]) {
  6489. this.xTicks[this.xTicks.length] = i;
  6490. tickMap[i] = true;
  6491. }
  6492. }
  6493. this.xTicks.sort(this.DDM.numericSort) ;
  6494. },
  6495. setYTicks: function(iStartY, iTickSize) {
  6496. this.yTicks = [];
  6497. this.yTickSize = iTickSize;
  6498. var tickMap = {};
  6499. for (var i = this.initPageY; i >= this.minY; i = i - iTickSize) {
  6500. if (!tickMap[i]) {
  6501. this.yTicks[this.yTicks.length] = i;
  6502. tickMap[i] = true;
  6503. }
  6504. }
  6505. for (i = this.initPageY; i <= this.maxY; i = i + iTickSize) {
  6506. if (!tickMap[i]) {
  6507. this.yTicks[this.yTicks.length] = i;
  6508. tickMap[i] = true;
  6509. }
  6510. }
  6511. this.yTicks.sort(this.DDM.numericSort) ;
  6512. },
  6513. setXConstraint: function(iLeft, iRight, iTickSize) {
  6514. this.leftConstraint = iLeft;
  6515. this.rightConstraint = iRight;
  6516. this.minX = this.initPageX - iLeft;
  6517. this.maxX = this.initPageX + iRight;
  6518. if (iTickSize) { this.setXTicks(this.initPageX, iTickSize); }
  6519. this.constrainX = true;
  6520. },
  6521. clearConstraints: function() {
  6522. this.constrainX = false;
  6523. this.constrainY = false;
  6524. this.clearTicks();
  6525. },
  6526. clearTicks: function() {
  6527. this.xTicks = null;
  6528. this.yTicks = null;
  6529. this.xTickSize = 0;
  6530. this.yTickSize = 0;
  6531. },
  6532. setYConstraint: function(iUp, iDown, iTickSize) {
  6533. this.topConstraint = iUp;
  6534. this.bottomConstraint = iDown;
  6535. this.minY = this.initPageY - iUp;
  6536. this.maxY = this.initPageY + iDown;
  6537. if (iTickSize) { this.setYTicks(this.initPageY, iTickSize); }
  6538. this.constrainY = true;
  6539. },
  6540. resetConstraints: function() {
  6541. if (this.initPageX || this.initPageX === 0) {
  6542. var dx = (this.maintainOffset) ? this.lastPageX - this.initPageX : 0;
  6543. var dy = (this.maintainOffset) ? this.lastPageY - this.initPageY : 0;
  6544. this.setInitPosition(dx, dy);
  6545. } else {
  6546. this.setInitPosition();
  6547. }
  6548. if (this.constrainX) {
  6549. this.setXConstraint( this.leftConstraint,
  6550. this.rightConstraint,
  6551. this.xTickSize );
  6552. }
  6553. if (this.constrainY) {
  6554. this.setYConstraint( this.topConstraint,
  6555. this.bottomConstraint,
  6556. this.yTickSize );
  6557. }
  6558. },
  6559. getTick: function(val, tickArray) {
  6560. if (!tickArray) {
  6561. return val;
  6562. } else if (tickArray[0] >= val) {
  6563. return tickArray[0];
  6564. } else {
  6565. for (var i=0, len=tickArray.length; i<len; ++i) {
  6566. var next = i + 1;
  6567. if (tickArray[next] && tickArray[next] >= val) {
  6568. var diff1 = val - tickArray[i];
  6569. var diff2 = tickArray[next] - val;
  6570. return (diff2 > diff1) ? tickArray[i] : tickArray[next];
  6571. }
  6572. }
  6573. return tickArray[tickArray.length - 1];
  6574. }
  6575. },
  6576. toString: function() {
  6577. return ("DragDrop " + this.id);
  6578. }
  6579. };
  6580. })();
  6581. if (!Ext.dd.DragDropMgr) {
  6582. Ext.dd.DragDropMgr = function() {
  6583. var Event = Ext.EventManager;
  6584. return {
  6585. ids: {},
  6586. handleIds: {},
  6587. dragCurrent: null,
  6588. dragOvers: {},
  6589. deltaX: 0,
  6590. deltaY: 0,
  6591. preventDefault: true,
  6592. stopPropagation: true,
  6593. initalized: false,
  6594. locked: false,
  6595. init: function() {
  6596. this.initialized = true;
  6597. },
  6598. POINT: 0,
  6599. INTERSECT: 1,
  6600. mode: 0,
  6601. _execOnAll: function(sMethod, args) {
  6602. for (var i in this.ids) {
  6603. for (var j in this.ids[i]) {
  6604. var oDD = this.ids[i][j];
  6605. if (! this.isTypeOfDD(oDD)) {
  6606. continue;
  6607. }
  6608. oDD[sMethod].apply(oDD, args);
  6609. }
  6610. }
  6611. },
  6612. _onLoad: function() {
  6613. this.init();
  6614. Event.on(document, "mouseup", this.handleMouseUp, this, true);
  6615. Event.on(document, "mousemove", this.handleMouseMove, this, true);
  6616. Event.on(window, "unload", this._onUnload, this, true);
  6617. Event.on(window, "resize", this._onResize, this, true);
  6618. },
  6619. _onResize: function(e) {
  6620. this._execOnAll("resetConstraints", []);
  6621. },
  6622. lock: function() { this.locked = true; },
  6623. unlock: function() { this.locked = false; },
  6624. isLocked: function() { return this.locked; },
  6625. locationCache: {},
  6626. useCache: true,
  6627. clickPixelThresh: 3,
  6628. clickTimeThresh: 350,
  6629. dragThreshMet: false,
  6630. clickTimeout: null,
  6631. startX: 0,
  6632. startY: 0,
  6633. regDragDrop: function(oDD, sGroup) {
  6634. if (!this.initialized) { this.init(); }
  6635. if (!this.ids[sGroup]) {
  6636. this.ids[sGroup] = {};
  6637. }
  6638. this.ids[sGroup][oDD.id] = oDD;
  6639. },
  6640. removeDDFromGroup: function(oDD, sGroup) {
  6641. if (!this.ids[sGroup]) {
  6642. this.ids[sGroup] = {};
  6643. }
  6644. var obj = this.ids[sGroup];
  6645. if (obj && obj[oDD.id]) {
  6646. delete obj[oDD.id];
  6647. }
  6648. },
  6649. _remove: function(oDD) {
  6650. for (var g in oDD.groups) {
  6651. if (g && this.ids[g][oDD.id]) {
  6652. delete this.ids[g][oDD.id];
  6653. }
  6654. }
  6655. delete this.handleIds[oDD.id];
  6656. },
  6657. regHandle: function(sDDId, sHandleId) {
  6658. if (!this.handleIds[sDDId]) {
  6659. this.handleIds[sDDId] = {};
  6660. }
  6661. this.handleIds[sDDId][sHandleId] = sHandleId;
  6662. },
  6663. isDragDrop: function(id) {
  6664. return ( this.getDDById(id) ) ? true : false;
  6665. },
  6666. getRelated: function(p_oDD, bTargetsOnly) {
  6667. var oDDs = [];
  6668. for (var i in p_oDD.groups) {
  6669. for (j in this.ids[i]) {
  6670. var dd = this.ids[i][j];
  6671. if (! this.isTypeOfDD(dd)) {
  6672. continue;
  6673. }
  6674. if (!bTargetsOnly || dd.isTarget) {
  6675. oDDs[oDDs.length] = dd;
  6676. }
  6677. }
  6678. }
  6679. return oDDs;
  6680. },
  6681. isLegalTarget: function (oDD, oTargetDD) {
  6682. var targets = this.getRelated(oDD, true);
  6683. for (var i=0, len=targets.length;i<len;++i) {
  6684. if (targets[i].id == oTargetDD.id) {
  6685. return true;
  6686. }
  6687. }
  6688. return false;
  6689. },
  6690. isTypeOfDD: function (oDD) {
  6691. return (oDD && oDD.__ygDragDrop);
  6692. },
  6693. isHandle: function(sDDId, sHandleId) {
  6694. return ( this.handleIds[sDDId] &&
  6695. this.handleIds[sDDId][sHandleId] );
  6696. },
  6697. getDDById: function(id) {
  6698. for (var i in this.ids) {
  6699. if (this.ids[i][id]) {
  6700. return this.ids[i][id];
  6701. }
  6702. }
  6703. return null;
  6704. },
  6705. handleMouseDown: function(e, oDD) {
  6706. if(Ext.QuickTips){
  6707. Ext.QuickTips.disable();
  6708. }
  6709. this.currentTarget = e.getTarget();
  6710. this.dragCurrent = oDD;
  6711. var el = oDD.getEl();
  6712. this.startX = e.getPageX();
  6713. this.startY = e.getPageY();
  6714. this.deltaX = this.startX - el.offsetLeft;
  6715. this.deltaY = this.startY - el.offsetTop;
  6716. this.dragThreshMet = false;
  6717. this.clickTimeout = setTimeout(
  6718. function() {
  6719. var DDM = Ext.dd.DDM;
  6720. DDM.startDrag(DDM.startX, DDM.startY);
  6721. },
  6722. this.clickTimeThresh );
  6723. },
  6724. startDrag: function(x, y) {
  6725. clearTimeout(this.clickTimeout);
  6726. if (this.dragCurrent) {
  6727. this.dragCurrent.b4StartDrag(x, y);
  6728. this.dragCurrent.startDrag(x, y);
  6729. }
  6730. this.dragThreshMet = true;
  6731. },
  6732. handleMouseUp: function(e) {
  6733. if(Ext.QuickTips){
  6734. Ext.QuickTips.enable();
  6735. }
  6736. if (! this.dragCurrent) {
  6737. return;
  6738. }
  6739. clearTimeout(this.clickTimeout);
  6740. if (this.dragThreshMet) {
  6741. this.fireEvents(e, true);
  6742. } else {
  6743. }
  6744. this.stopDrag(e);
  6745. this.stopEvent(e);
  6746. },
  6747. stopEvent: function(e){
  6748. if(this.stopPropagation) {
  6749. e.stopPropagation();
  6750. }
  6751. if (this.preventDefault) {
  6752. e.preventDefault();
  6753. }
  6754. },
  6755. stopDrag: function(e) {
  6756. if (this.dragCurrent) {
  6757. if (this.dragThreshMet) {
  6758. this.dragCurrent.b4EndDrag(e);
  6759. this.dragCurrent.endDrag(e);
  6760. }
  6761. this.dragCurrent.onMouseUp(e);
  6762. }
  6763. this.dragCurrent = null;
  6764. this.dragOvers = {};
  6765. },
  6766. handleMouseMove: function(e) {
  6767. if (! this.dragCurrent) {
  6768. return true;
  6769. }
  6770. if (Ext.isIE && (e.button !== 0 && e.button !== 1 && e.button !== 2)) {
  6771. this.stopEvent(e);
  6772. return this.handleMouseUp(e);
  6773. }
  6774. if (!this.dragThreshMet) {
  6775. var diffX = Math.abs(this.startX - e.getPageX());
  6776. var diffY = Math.abs(this.startY - e.getPageY());
  6777. if (diffX > this.clickPixelThresh ||
  6778. diffY > this.clickPixelThresh) {
  6779. this.startDrag(this.startX, this.startY);
  6780. }
  6781. }
  6782. if (this.dragThreshMet) {
  6783. this.dragCurrent.b4Drag(e);
  6784. this.dragCurrent.onDrag(e);
  6785. if(!this.dragCurrent.moveOnly){
  6786. this.fireEvents(e, false);
  6787. }
  6788. }
  6789. this.stopEvent(e);
  6790. return true;
  6791. },
  6792. fireEvents: function(e, isDrop) {
  6793. var dc = this.dragCurrent;
  6794. if (!dc || dc.isLocked()) {
  6795. return;
  6796. }
  6797. var pt = e.getPoint();
  6798. var oldOvers = [];
  6799. var outEvts = [];
  6800. var overEvts = [];
  6801. var dropEvts = [];
  6802. var enterEvts = [];
  6803. for (var i in this.dragOvers) {
  6804. var ddo = this.dragOvers[i];
  6805. if (! this.isTypeOfDD(ddo)) {
  6806. continue;
  6807. }
  6808. if (! this.isOverTarget(pt, ddo, this.mode)) {
  6809. outEvts.push( ddo );
  6810. }
  6811. oldOvers[i] = true;
  6812. delete this.dragOvers[i];
  6813. }
  6814. for (var sGroup in dc.groups) {
  6815. if ("string" != typeof sGroup) {
  6816. continue;
  6817. }
  6818. for (i in this.ids[sGroup]) {
  6819. var oDD = this.ids[sGroup][i];
  6820. if (! this.isTypeOfDD(oDD)) {
  6821. continue;
  6822. }
  6823. if (oDD.isTarget && !oDD.isLocked() && oDD != dc) {
  6824. if (this.isOverTarget(pt, oDD, this.mode)) {
  6825. if (isDrop) {
  6826. dropEvts.push( oDD );
  6827. } else {
  6828. if (!oldOvers[oDD.id]) {
  6829. enterEvts.push( oDD );
  6830. } else {
  6831. overEvts.push( oDD );
  6832. }
  6833. this.dragOvers[oDD.id] = oDD;
  6834. }
  6835. }
  6836. }
  6837. }
  6838. }
  6839. if (this.mode) {
  6840. if (outEvts.length) {
  6841. dc.b4DragOut(e, outEvts);
  6842. dc.onDragOut(e, outEvts);
  6843. }
  6844. if (enterEvts.length) {
  6845. dc.onDragEnter(e, enterEvts);
  6846. }
  6847. if (overEvts.length) {
  6848. dc.b4DragOver(e, overEvts);
  6849. dc.onDragOver(e, overEvts);
  6850. }
  6851. if (dropEvts.length) {
  6852. dc.b4DragDrop(e, dropEvts);
  6853. dc.onDragDrop(e, dropEvts);
  6854. }
  6855. } else {
  6856. var len = 0;
  6857. for (i=0, len=outEvts.length; i<len; ++i) {
  6858. dc.b4DragOut(e, outEvts[i].id);
  6859. dc.onDragOut(e, outEvts[i].id);
  6860. }
  6861. for (i=0,len=enterEvts.length; i<len; ++i) {
  6862. dc.onDragEnter(e, enterEvts[i].id);
  6863. }
  6864. for (i=0,len=overEvts.length; i<len; ++i) {
  6865. dc.b4DragOver(e, overEvts[i].id);
  6866. dc.onDragOver(e, overEvts[i].id);
  6867. }
  6868. for (i=0, len=dropEvts.length; i<len; ++i) {
  6869. dc.b4DragDrop(e, dropEvts[i].id);
  6870. dc.onDragDrop(e, dropEvts[i].id);
  6871. }
  6872. }
  6873. if (isDrop && !dropEvts.length) {
  6874. dc.onInvalidDrop(e);
  6875. }
  6876. },
  6877. getBestMatch: function(dds) {
  6878. var winner = null;
  6879. var len = dds.length;
  6880. if (len == 1) {
  6881. winner = dds[0];
  6882. } else {
  6883. for (var i=0; i<len; ++i) {
  6884. var dd = dds[i];
  6885. if (dd.cursorIsOver) {
  6886. winner = dd;
  6887. break;
  6888. } else {
  6889. if (!winner ||
  6890. winner.overlap.getArea() < dd.overlap.getArea()) {
  6891. winner = dd;
  6892. }
  6893. }
  6894. }
  6895. }
  6896. return winner;
  6897. },
  6898. refreshCache: function(groups) {
  6899. for (var sGroup in groups) {
  6900. if ("string" != typeof sGroup) {
  6901. continue;
  6902. }
  6903. for (var i in this.ids[sGroup]) {
  6904. var oDD = this.ids[sGroup][i];
  6905. if (this.isTypeOfDD(oDD)) {
  6906. var loc = this.getLocation(oDD);
  6907. if (loc) {
  6908. this.locationCache[oDD.id] = loc;
  6909. } else {
  6910. delete this.locationCache[oDD.id];
  6911. }
  6912. }
  6913. }
  6914. }
  6915. },
  6916. verifyEl: function(el) {
  6917. if (el) {
  6918. var parent;
  6919. if(Ext.isIE){
  6920. try{
  6921. parent = el.offsetParent;
  6922. }catch(e){}
  6923. }else{
  6924. parent = el.offsetParent;
  6925. }
  6926. if (parent) {
  6927. return true;
  6928. }
  6929. }
  6930. return false;
  6931. },
  6932. getLocation: function(oDD) {
  6933. if (! this.isTypeOfDD(oDD)) {
  6934. return null;
  6935. }
  6936. var el = oDD.getEl(), pos, x1, x2, y1, y2, t, r, b, l;
  6937. try {
  6938. pos= Ext.lib.Dom.getXY(el);
  6939. } catch (e) { }
  6940. if (!pos) {
  6941. return null;
  6942. }
  6943. x1 = pos[0];
  6944. x2 = x1 + el.offsetWidth;
  6945. y1 = pos[1];
  6946. y2 = y1 + el.offsetHeight;
  6947. t = y1 - oDD.padding[0];
  6948. r = x2 + oDD.padding[1];
  6949. b = y2 + oDD.padding[2];
  6950. l = x1 - oDD.padding[3];
  6951. return new Ext.lib.Region( t, r, b, l );
  6952. },
  6953. isOverTarget: function(pt, oTarget, intersect) {
  6954. var loc = this.locationCache[oTarget.id];
  6955. if (!loc || !this.useCache) {
  6956. loc = this.getLocation(oTarget);
  6957. this.locationCache[oTarget.id] = loc;
  6958. }
  6959. if (!loc) {
  6960. return false;
  6961. }
  6962. oTarget.cursorIsOver = loc.contains( pt );
  6963. var dc = this.dragCurrent;
  6964. if (!dc || !dc.getTargetCoord ||
  6965. (!intersect && !dc.constrainX && !dc.constrainY)) {
  6966. return oTarget.cursorIsOver;
  6967. }
  6968. oTarget.overlap = null;
  6969. var pos = dc.getTargetCoord(pt.x, pt.y);
  6970. var el = dc.getDragEl();
  6971. var curRegion = new Ext.lib.Region( pos.y,
  6972. pos.x + el.offsetWidth,
  6973. pos.y + el.offsetHeight,
  6974. pos.x );
  6975. var overlap = curRegion.intersect(loc);
  6976. if (overlap) {
  6977. oTarget.overlap = overlap;
  6978. return (intersect) ? true : oTarget.cursorIsOver;
  6979. } else {
  6980. return false;
  6981. }
  6982. },
  6983. _onUnload: function(e, me) {
  6984. Ext.dd.DragDropMgr.unregAll();
  6985. },
  6986. unregAll: function() {
  6987. if (this.dragCurrent) {
  6988. this.stopDrag();
  6989. this.dragCurrent = null;
  6990. }
  6991. this._execOnAll("unreg", []);
  6992. for (var i in this.elementCache) {
  6993. delete this.elementCache[i];
  6994. }
  6995. this.elementCache = {};
  6996. this.ids = {};
  6997. },
  6998. elementCache: {},
  6999. getElWrapper: function(id) {
  7000. var oWrapper = this.elementCache[id];
  7001. if (!oWrapper || !oWrapper.el) {
  7002. oWrapper = this.elementCache[id] =
  7003. new this.ElementWrapper(Ext.getDom(id));
  7004. }
  7005. return oWrapper;
  7006. },
  7007. getElement: function(id) {
  7008. return Ext.getDom(id);
  7009. },
  7010. getCss: function(id) {
  7011. var el = Ext.getDom(id);
  7012. return (el) ? el.style : null;
  7013. },
  7014. ElementWrapper: function(el) {
  7015. this.el = el || null;
  7016. this.id = this.el && el.id;
  7017. this.css = this.el && el.style;
  7018. },
  7019. getPosX: function(el) {
  7020. return Ext.lib.Dom.getX(el);
  7021. },
  7022. getPosY: function(el) {
  7023. return Ext.lib.Dom.getY(el);
  7024. },
  7025. swapNode: function(n1, n2) {
  7026. if (n1.swapNode) {
  7027. n1.swapNode(n2);
  7028. } else {
  7029. var p = n2.parentNode;
  7030. var s = n2.nextSibling;
  7031. if (s == n1) {
  7032. p.insertBefore(n1, n2);
  7033. } else if (n2 == n1.nextSibling) {
  7034. p.insertBefore(n2, n1);
  7035. } else {
  7036. n1.parentNode.replaceChild(n2, n1);
  7037. p.insertBefore(n1, s);
  7038. }
  7039. }
  7040. },
  7041. getScroll: function () {
  7042. var t, l, dde=document.documentElement, db=document.body;
  7043. if (dde && (dde.scrollTop || dde.scrollLeft)) {
  7044. t = dde.scrollTop;
  7045. l = dde.scrollLeft;
  7046. } else if (db) {
  7047. t = db.scrollTop;
  7048. l = db.scrollLeft;
  7049. } else {
  7050. }
  7051. return { top: t, left: l };
  7052. },
  7053. getStyle: function(el, styleProp) {
  7054. return Ext.fly(el).getStyle(styleProp);
  7055. },
  7056. getScrollTop: function () { return this.getScroll().top; },
  7057. getScrollLeft: function () { return this.getScroll().left; },
  7058. moveToEl: function (moveEl, targetEl) {
  7059. var aCoord = Ext.lib.Dom.getXY(targetEl);
  7060. Ext.lib.Dom.setXY(moveEl, aCoord);
  7061. },
  7062. numericSort: function(a, b) { return (a - b); },
  7063. _timeoutCount: 0,
  7064. _addListeners: function() {
  7065. var DDM = Ext.dd.DDM;
  7066. if ( Ext.lib.Event && document ) {
  7067. DDM._onLoad();
  7068. } else {
  7069. if (DDM._timeoutCount > 2000) {
  7070. } else {
  7071. setTimeout(DDM._addListeners, 10);
  7072. if (document && document.body) {
  7073. DDM._timeoutCount += 1;
  7074. }
  7075. }
  7076. }
  7077. },
  7078. handleWasClicked: function(node, id) {
  7079. if (this.isHandle(id, node.id)) {
  7080. return true;
  7081. } else {
  7082. var p = node.parentNode;
  7083. while (p) {
  7084. if (this.isHandle(id, p.id)) {
  7085. return true;
  7086. } else {
  7087. p = p.parentNode;
  7088. }
  7089. }
  7090. }
  7091. return false;
  7092. }
  7093. };
  7094. }();
  7095. Ext.dd.DDM = Ext.dd.DragDropMgr;
  7096. Ext.dd.DDM._addListeners();
  7097. }
  7098. Ext.dd.DD = function(id, sGroup, config) {
  7099. if (id) {
  7100. this.init(id, sGroup, config);
  7101. }
  7102. };
  7103. Ext.extend(Ext.dd.DD, Ext.dd.DragDrop, {
  7104. scroll: true,
  7105. autoOffset: function(iPageX, iPageY) {
  7106. var x = iPageX - this.startPageX;
  7107. var y = iPageY - this.startPageY;
  7108. this.setDelta(x, y);
  7109. },
  7110. setDelta: function(iDeltaX, iDeltaY) {
  7111. this.deltaX = iDeltaX;
  7112. this.deltaY = iDeltaY;
  7113. },
  7114. setDragElPos: function(iPageX, iPageY) {
  7115. var el = this.getDragEl();
  7116. this.alignElWithMouse(el, iPageX, iPageY);
  7117. },
  7118. alignElWithMouse: function(el, iPageX, iPageY) {
  7119. var oCoord = this.getTargetCoord(iPageX, iPageY);
  7120. var fly = el.dom ? el : Ext.fly(el, '_dd');
  7121. if (!this.deltaSetXY) {
  7122. var aCoord = [oCoord.x, oCoord.y];
  7123. fly.setXY(aCoord);
  7124. var newLeft = fly.getLeft(true);
  7125. var newTop = fly.getTop(true);
  7126. this.deltaSetXY = [ newLeft - oCoord.x, newTop - oCoord.y ];
  7127. } else {
  7128. fly.setLeftTop(oCoord.x + this.deltaSetXY[0], oCoord.y + this.deltaSetXY[1]);
  7129. }
  7130. this.cachePosition(oCoord.x, oCoord.y);
  7131. this.autoScroll(oCoord.x, oCoord.y, el.offsetHeight, el.offsetWidth);
  7132. return oCoord;
  7133. },
  7134. cachePosition: function(iPageX, iPageY) {
  7135. if (iPageX) {
  7136. this.lastPageX = iPageX;
  7137. this.lastPageY = iPageY;
  7138. } else {
  7139. var aCoord = Ext.lib.Dom.getXY(this.getEl());
  7140. this.lastPageX = aCoord[0];
  7141. this.lastPageY = aCoord[1];
  7142. }
  7143. },
  7144. autoScroll: function(x, y, h, w) {
  7145. if (this.scroll) {
  7146. var clientH = Ext.lib.Dom.getViewHeight();
  7147. var clientW = Ext.lib.Dom.getViewWidth();
  7148. var st = this.DDM.getScrollTop();
  7149. var sl = this.DDM.getScrollLeft();
  7150. var bot = h + y;
  7151. var right = w + x;
  7152. var toBot = (clientH + st - y - this.deltaY);
  7153. var toRight = (clientW + sl - x - this.deltaX);
  7154. var thresh = 40;
  7155. var scrAmt = (document.all) ? 80 : 30;
  7156. if ( bot > clientH && toBot < thresh ) {
  7157. window.scrollTo(sl, st + scrAmt);
  7158. }
  7159. if ( y < st && st > 0 && y - st < thresh ) {
  7160. window.scrollTo(sl, st - scrAmt);
  7161. }
  7162. if ( right > clientW && toRight < thresh ) {
  7163. window.scrollTo(sl + scrAmt, st);
  7164. }
  7165. if ( x < sl && sl > 0 && x - sl < thresh ) {
  7166. window.scrollTo(sl - scrAmt, st);
  7167. }
  7168. }
  7169. },
  7170. getTargetCoord: function(iPageX, iPageY) {
  7171. var x = iPageX - this.deltaX;
  7172. var y = iPageY - this.deltaY;
  7173. if (this.constrainX) {
  7174. if (x < this.minX) { x = this.minX; }
  7175. if (x > this.maxX) { x = this.maxX; }
  7176. }
  7177. if (this.constrainY) {
  7178. if (y < this.minY) { y = this.minY; }
  7179. if (y > this.maxY) { y = this.maxY; }
  7180. }
  7181. x = this.getTick(x, this.xTicks);
  7182. y = this.getTick(y, this.yTicks);
  7183. return {x:x, y:y};
  7184. },
  7185. applyConfig: function() {
  7186. Ext.dd.DD.superclass.applyConfig.call(this);
  7187. this.scroll = (this.config.scroll !== false);
  7188. },
  7189. b4MouseDown: function(e) {
  7190. this.autoOffset(e.getPageX(),
  7191. e.getPageY());
  7192. },
  7193. b4Drag: function(e) {
  7194. this.setDragElPos(e.getPageX(),
  7195. e.getPageY());
  7196. },
  7197. toString: function() {
  7198. return ("DD " + this.id);
  7199. }
  7200. });
  7201. Ext.dd.DDProxy = function(id, sGroup, config) {
  7202. if (id) {
  7203. this.init(id, sGroup, config);
  7204. this.initFrame();
  7205. }
  7206. };
  7207. Ext.dd.DDProxy.dragElId = "ygddfdiv";
  7208. Ext.extend(Ext.dd.DDProxy, Ext.dd.DD, {
  7209. resizeFrame: true,
  7210. centerFrame: false,
  7211. createFrame: function() {
  7212. var self = this;
  7213. var body = document.body;
  7214. if (!body || !body.firstChild) {
  7215. setTimeout( function() { self.createFrame(); }, 50 );
  7216. return;
  7217. }
  7218. var div = this.getDragEl();
  7219. if (!div) {
  7220. div = document.createElement("div");
  7221. div.id = this.dragElId;
  7222. var s = div.style;
  7223. s.position = "absolute";
  7224. s.visibility = "hidden";
  7225. s.cursor = "move";
  7226. s.border = "2px solid #aaa";
  7227. s.zIndex = 999;
  7228. body.insertBefore(div, body.firstChild);
  7229. }
  7230. },
  7231. initFrame: function() {
  7232. this.createFrame();
  7233. },
  7234. applyConfig: function() {
  7235. Ext.dd.DDProxy.superclass.applyConfig.call(this);
  7236. this.resizeFrame = (this.config.resizeFrame !== false);
  7237. this.centerFrame = (this.config.centerFrame);
  7238. this.setDragElId(this.config.dragElId || Ext.dd.DDProxy.dragElId);
  7239. },
  7240. showFrame: function(iPageX, iPageY) {
  7241. var el = this.getEl();
  7242. var dragEl = this.getDragEl();
  7243. var s = dragEl.style;
  7244. this._resizeProxy();
  7245. if (this.centerFrame) {
  7246. this.setDelta( Math.round(parseInt(s.width, 10)/2),
  7247. Math.round(parseInt(s.height, 10)/2) );
  7248. }
  7249. this.setDragElPos(iPageX, iPageY);
  7250. Ext.fly(dragEl).show();
  7251. },
  7252. _resizeProxy: function() {
  7253. if (this.resizeFrame) {
  7254. var el = this.getEl();
  7255. Ext.fly(this.getDragEl()).setSize(el.offsetWidth, el.offsetHeight);
  7256. }
  7257. },
  7258. b4MouseDown: function(e) {
  7259. var x = e.getPageX();
  7260. var y = e.getPageY();
  7261. this.autoOffset(x, y);
  7262. this.setDragElPos(x, y);
  7263. },
  7264. b4StartDrag: function(x, y) {
  7265. this.showFrame(x, y);
  7266. },
  7267. b4EndDrag: function(e) {
  7268. Ext.fly(this.getDragEl()).hide();
  7269. },
  7270. endDrag: function(e) {
  7271. var lel = this.getEl();
  7272. var del = this.getDragEl();
  7273. del.style.visibility = "";
  7274. this.beforeMove();
  7275. lel.style.visibility = "hidden";
  7276. Ext.dd.DDM.moveToEl(lel, del);
  7277. del.style.visibility = "hidden";
  7278. lel.style.visibility = "";
  7279. this.afterDrag();
  7280. },
  7281. beforeMove : function(){
  7282. },
  7283. afterDrag : function(){
  7284. },
  7285. toString: function() {
  7286. return ("DDProxy " + this.id);
  7287. }
  7288. });
  7289. Ext.dd.DDTarget = function(id, sGroup, config) {
  7290. if (id) {
  7291. this.initTarget(id, sGroup, config);
  7292. }
  7293. };
  7294. Ext.extend(Ext.dd.DDTarget, Ext.dd.DragDrop, {
  7295. toString: function() {
  7296. return ("DDTarget " + this.id);
  7297. }
  7298. });
  7299. Ext.dd.DragTracker = function(config){
  7300. Ext.apply(this, config);
  7301. this.addEvents(
  7302. 'mousedown',
  7303. 'mouseup',
  7304. 'mousemove',
  7305. 'dragstart',
  7306. 'dragend',
  7307. 'drag'
  7308. );
  7309. this.dragRegion = new Ext.lib.Region(0,0,0,0);
  7310. if(this.el){
  7311. this.initEl(this.el);
  7312. }
  7313. }
  7314. Ext.extend(Ext.dd.DragTracker, Ext.util.Observable, {
  7315. active: false,
  7316. tolerance: 5,
  7317. autoStart: false,
  7318. initEl: function(el){
  7319. this.el = Ext.get(el);
  7320. el.on('mousedown', this.onMouseDown, this,
  7321. this.delegate ? {delegate: this.delegate} : undefined);
  7322. },
  7323. destroy : function(){
  7324. this.el.un('mousedown', this.onMouseDown, this);
  7325. },
  7326. onMouseDown: function(e, target){
  7327. if(this.fireEvent('mousedown', this, e) !== false && this.onBeforeStart(e) !== false){
  7328. this.startXY = this.lastXY = e.getXY();
  7329. this.dragTarget = this.delegate ? target : this.el.dom;
  7330. e.preventDefault();
  7331. var doc = Ext.getDoc();
  7332. doc.on('mouseup', this.onMouseUp, this);
  7333. doc.on('mousemove', this.onMouseMove, this);
  7334. doc.on('selectstart', this.stopSelect, this);
  7335. if(this.autoStart){
  7336. this.timer = this.triggerStart.defer(this.autoStart === true ? 1000 : this.autoStart, this);
  7337. }
  7338. }
  7339. },
  7340. onMouseMove: function(e, target){
  7341. e.preventDefault();
  7342. var xy = e.getXY(), s = this.startXY;
  7343. this.lastXY = xy;
  7344. if(!this.active){
  7345. if(Math.abs(s[0]-xy[0]) > this.tolerance || Math.abs(s[1]-xy[1]) > this.tolerance){
  7346. this.triggerStart();
  7347. }else{
  7348. return;
  7349. }
  7350. }
  7351. this.fireEvent('mousemove', this, e);
  7352. this.onDrag(e);
  7353. this.fireEvent('drag', this, e);
  7354. },
  7355. onMouseUp: function(e){
  7356. var doc = Ext.getDoc();
  7357. doc.un('mousemove', this.onMouseMove, this);
  7358. doc.un('mouseup', this.onMouseUp, this);
  7359. doc.un('selectstart', this.stopSelect, this);
  7360. e.preventDefault();
  7361. this.clearStart();
  7362. this.active = false;
  7363. delete this.elRegion;
  7364. this.fireEvent('mouseup', this, e);
  7365. this.onEnd(e);
  7366. this.fireEvent('dragend', this, e);
  7367. },
  7368. triggerStart: function(isTimer){
  7369. this.clearStart();
  7370. this.active = true;
  7371. this.onStart(this.startXY);
  7372. this.fireEvent('dragstart', this, this.startXY);
  7373. },
  7374. clearStart : function(){
  7375. if(this.timer){
  7376. clearTimeout(this.timer);
  7377. delete this.timer;
  7378. }
  7379. },
  7380. stopSelect : function(e){
  7381. e.stopEvent();
  7382. return false;
  7383. },
  7384. onBeforeStart : function(e){
  7385. },
  7386. onStart : function(xy){
  7387. },
  7388. onDrag : function(e){
  7389. },
  7390. onEnd : function(e){
  7391. },
  7392. getDragTarget : function(){
  7393. return this.dragTarget;
  7394. },
  7395. getDragCt : function(){
  7396. return this.el;
  7397. },
  7398. getXY : function(constrain){
  7399. return constrain ?
  7400. this.constrainModes[constrain].call(this, this.lastXY) : this.lastXY;
  7401. },
  7402. getOffset : function(constrain){
  7403. var xy = this.getXY(constrain);
  7404. var s = this.startXY;
  7405. return [s[0]-xy[0], s[1]-xy[1]];
  7406. },
  7407. constrainModes: {
  7408. 'point' : function(xy){
  7409. if(!this.elRegion){
  7410. this.elRegion = this.getDragCt().getRegion();
  7411. }
  7412. var dr = this.dragRegion;
  7413. dr.left = xy[0];
  7414. dr.top = xy[1];
  7415. dr.right = xy[0];
  7416. dr.bottom = xy[1];
  7417. dr.constrainTo(this.elRegion);
  7418. return [dr.left, dr.top];
  7419. }
  7420. }
  7421. });
  7422. Ext.dd.ScrollManager = function(){
  7423. var ddm = Ext.dd.DragDropMgr;
  7424. var els = {};
  7425. var dragEl = null;
  7426. var proc = {};
  7427. var onStop = function(e){
  7428. dragEl = null;
  7429. clearProc();
  7430. };
  7431. var triggerRefresh = function(){
  7432. if(ddm.dragCurrent){
  7433. ddm.refreshCache(ddm.dragCurrent.groups);
  7434. }
  7435. };
  7436. var doScroll = function(){
  7437. if(ddm.dragCurrent){
  7438. var dds = Ext.dd.ScrollManager;
  7439. var inc = proc.el.ddScrollConfig ?
  7440. proc.el.ddScrollConfig.increment : dds.increment;
  7441. if(!dds.animate){
  7442. if(proc.el.scroll(proc.dir, inc)){
  7443. triggerRefresh();
  7444. }
  7445. }else{
  7446. proc.el.scroll(proc.dir, inc, true, dds.animDuration, triggerRefresh);
  7447. }
  7448. }
  7449. };
  7450. var clearProc = function(){
  7451. if(proc.id){
  7452. clearInterval(proc.id);
  7453. }
  7454. proc.id = 0;
  7455. proc.el = null;
  7456. proc.dir = "";
  7457. };
  7458. var startProc = function(el, dir){
  7459. clearProc();
  7460. proc.el = el;
  7461. proc.dir = dir;
  7462. proc.id = setInterval(doScroll, Ext.dd.ScrollManager.frequency);
  7463. };
  7464. var onFire = function(e, isDrop){
  7465. if(isDrop || !ddm.dragCurrent){ return; }
  7466. var dds = Ext.dd.ScrollManager;
  7467. if(!dragEl || dragEl != ddm.dragCurrent){
  7468. dragEl = ddm.dragCurrent;
  7469. dds.refreshCache();
  7470. }
  7471. var xy = Ext.lib.Event.getXY(e);
  7472. var pt = new Ext.lib.Point(xy[0], xy[1]);
  7473. for(var id in els){
  7474. var el = els[id], r = el._region;
  7475. var c = el.ddScrollConfig ? el.ddScrollConfig : dds;
  7476. if(r && r.contains(pt) && el.isScrollable()){
  7477. if(r.bottom - pt.y <= c.vthresh){
  7478. if(proc.el != el){
  7479. startProc(el, "down");
  7480. }
  7481. return;
  7482. }else if(r.right - pt.x <= c.hthresh){
  7483. if(proc.el != el){
  7484. startProc(el, "left");
  7485. }
  7486. return;
  7487. }else if(pt.y - r.top <= c.vthresh){
  7488. if(proc.el != el){
  7489. startProc(el, "up");
  7490. }
  7491. return;
  7492. }else if(pt.x - r.left <= c.hthresh){
  7493. if(proc.el != el){
  7494. startProc(el, "right");
  7495. }
  7496. return;
  7497. }
  7498. }
  7499. }
  7500. clearProc();
  7501. };
  7502. ddm.fireEvents = ddm.fireEvents.createSequence(onFire, ddm);
  7503. ddm.stopDrag = ddm.stopDrag.createSequence(onStop, ddm);
  7504. return {
  7505. register : function(el){
  7506. if(Ext.isArray(el)){
  7507. for(var i = 0, len = el.length; i < len; i++) {
  7508. this.register(el[i]);
  7509. }
  7510. }else{
  7511. el = Ext.get(el);
  7512. els[el.id] = el;
  7513. }
  7514. },
  7515. unregister : function(el){
  7516. if(Ext.isArray(el)){
  7517. for(var i = 0, len = el.length; i < len; i++) {
  7518. this.unregister(el[i]);
  7519. }
  7520. }else{
  7521. el = Ext.get(el);
  7522. delete els[el.id];
  7523. }
  7524. },
  7525. vthresh : 25,
  7526. hthresh : 25,
  7527. increment : 100,
  7528. frequency : 500,
  7529. animate: true,
  7530. animDuration: .4,
  7531. refreshCache : function(){
  7532. for(var id in els){
  7533. if(typeof els[id] == 'object'){
  7534. els[id]._region = els[id].getRegion();
  7535. }
  7536. }
  7537. }
  7538. };
  7539. }();
  7540. Ext.dd.Registry = function(){
  7541. var elements = {};
  7542. var handles = {};
  7543. var autoIdSeed = 0;
  7544. var getId = function(el, autogen){
  7545. if(typeof el == "string"){
  7546. return el;
  7547. }
  7548. var id = el.id;
  7549. if(!id && autogen !== false){
  7550. id = "extdd-" + (++autoIdSeed);
  7551. el.id = id;
  7552. }
  7553. return id;
  7554. };
  7555. return {
  7556. register : function(el, data){
  7557. data = data || {};
  7558. if(typeof el == "string"){
  7559. el = document.getElementById(el);
  7560. }
  7561. data.ddel = el;
  7562. elements[getId(el)] = data;
  7563. if(data.isHandle !== false){
  7564. handles[data.ddel.id] = data;
  7565. }
  7566. if(data.handles){
  7567. var hs = data.handles;
  7568. for(var i = 0, len = hs.length; i < len; i++){
  7569. handles[getId(hs[i])] = data;
  7570. }
  7571. }
  7572. },
  7573. unregister : function(el){
  7574. var id = getId(el, false);
  7575. var data = elements[id];
  7576. if(data){
  7577. delete elements[id];
  7578. if(data.handles){
  7579. var hs = data.handles;
  7580. for(var i = 0, len = hs.length; i < len; i++){
  7581. delete handles[getId(hs[i], false)];
  7582. }
  7583. }
  7584. }
  7585. },
  7586. getHandle : function(id){
  7587. if(typeof id != "string"){
  7588. id = id.id;
  7589. }
  7590. return handles[id];
  7591. },
  7592. getHandleFromEvent : function(e){
  7593. var t = Ext.lib.Event.getTarget(e);
  7594. return t ? handles[t.id] : null;
  7595. },
  7596. getTarget : function(id){
  7597. if(typeof id != "string"){
  7598. id = id.id;
  7599. }
  7600. return elements[id];
  7601. },
  7602. getTargetFromEvent : function(e){
  7603. var t = Ext.lib.Event.getTarget(e);
  7604. return t ? elements[t.id] || handles[t.id] : null;
  7605. }
  7606. };
  7607. }();
  7608. Ext.dd.StatusProxy = function(config){
  7609. Ext.apply(this, config);
  7610. this.id = this.id || Ext.id();
  7611. this.el = new Ext.Layer({
  7612. dh: {
  7613. id: this.id, tag: "div", cls: "x-dd-drag-proxy "+this.dropNotAllowed, children: [
  7614. {tag: "div", cls: "x-dd-drop-icon"},
  7615. {tag: "div", cls: "x-dd-drag-ghost"}
  7616. ]
  7617. },
  7618. shadow: !config || config.shadow !== false
  7619. });
  7620. this.ghost = Ext.get(this.el.dom.childNodes[1]);
  7621. this.dropStatus = this.dropNotAllowed;
  7622. };
  7623. Ext.dd.StatusProxy.prototype = {
  7624. dropAllowed : "x-dd-drop-ok",
  7625. dropNotAllowed : "x-dd-drop-nodrop",
  7626. setStatus : function(cssClass){
  7627. cssClass = cssClass || this.dropNotAllowed;
  7628. if(this.dropStatus != cssClass){
  7629. this.el.replaceClass(this.dropStatus, cssClass);
  7630. this.dropStatus = cssClass;
  7631. }
  7632. },
  7633. reset : function(clearGhost){
  7634. this.el.dom.className = "x-dd-drag-proxy " + this.dropNotAllowed;
  7635. this.dropStatus = this.dropNotAllowed;
  7636. if(clearGhost){
  7637. this.ghost.update("");
  7638. }
  7639. },
  7640. update : function(html){
  7641. if(typeof html == "string"){
  7642. this.ghost.update(html);
  7643. }else{
  7644. this.ghost.update("");
  7645. html.style.margin = "0";
  7646. this.ghost.dom.appendChild(html);
  7647. }
  7648. },
  7649. getEl : function(){
  7650. return this.el;
  7651. },
  7652. getGhost : function(){
  7653. return this.ghost;
  7654. },
  7655. hide : function(clear){
  7656. this.el.hide();
  7657. if(clear){
  7658. this.reset(true);
  7659. }
  7660. },
  7661. stop : function(){
  7662. if(this.anim && this.anim.isAnimated && this.anim.isAnimated()){
  7663. this.anim.stop();
  7664. }
  7665. },
  7666. show : function(){
  7667. this.el.show();
  7668. },
  7669. sync : function(){
  7670. this.el.sync();
  7671. },
  7672. repair : function(xy, callback, scope){
  7673. this.callback = callback;
  7674. this.scope = scope;
  7675. if(xy && this.animRepair !== false){
  7676. this.el.addClass("x-dd-drag-repair");
  7677. this.el.hideUnders(true);
  7678. this.anim = this.el.shift({
  7679. duration: this.repairDuration || .5,
  7680. easing: 'easeOut',
  7681. xy: xy,
  7682. stopFx: true,
  7683. callback: this.afterRepair,
  7684. scope: this
  7685. });
  7686. }else{
  7687. this.afterRepair();
  7688. }
  7689. },
  7690. afterRepair : function(){
  7691. this.hide(true);
  7692. if(typeof this.callback == "function"){
  7693. this.callback.call(this.scope || this);
  7694. }
  7695. this.callback = null;
  7696. this.scope = null;
  7697. }
  7698. };
  7699. Ext.dd.DragSource = function(el, config){
  7700. this.el = Ext.get(el);
  7701. if(!this.dragData){
  7702. this.dragData = {};
  7703. }
  7704. Ext.apply(this, config);
  7705. if(!this.proxy){
  7706. this.proxy = new Ext.dd.StatusProxy();
  7707. }
  7708. Ext.dd.DragSource.superclass.constructor.call(this, this.el.dom, this.ddGroup || this.group,
  7709. {dragElId : this.proxy.id, resizeFrame: false, isTarget: false, scroll: this.scroll === true});
  7710. this.dragging = false;
  7711. };
  7712. Ext.extend(Ext.dd.DragSource, Ext.dd.DDProxy, {
  7713. dropAllowed : "x-dd-drop-ok",
  7714. dropNotAllowed : "x-dd-drop-nodrop",
  7715. getDragData : function(e){
  7716. return this.dragData;
  7717. },
  7718. onDragEnter : function(e, id){
  7719. var target = Ext.dd.DragDropMgr.getDDById(id);
  7720. this.cachedTarget = target;
  7721. if(this.beforeDragEnter(target, e, id) !== false){
  7722. if(target.isNotifyTarget){
  7723. var status = target.notifyEnter(this, e, this.dragData);
  7724. this.proxy.setStatus(status);
  7725. }else{
  7726. this.proxy.setStatus(this.dropAllowed);
  7727. }
  7728. if(this.afterDragEnter){
  7729. this.afterDragEnter(target, e, id);
  7730. }
  7731. }
  7732. },
  7733. beforeDragEnter : function(target, e, id){
  7734. return true;
  7735. },
  7736. alignElWithMouse: function() {
  7737. Ext.dd.DragSource.superclass.alignElWithMouse.apply(this, arguments);
  7738. this.proxy.sync();
  7739. },
  7740. onDragOver : function(e, id){
  7741. var target = this.cachedTarget || Ext.dd.DragDropMgr.getDDById(id);
  7742. if(this.beforeDragOver(target, e, id) !== false){
  7743. if(target.isNotifyTarget){
  7744. var status = target.notifyOver(this, e, this.dragData);
  7745. this.proxy.setStatus(status);
  7746. }
  7747. if(this.afterDragOver){
  7748. this.afterDragOver(target, e, id);
  7749. }
  7750. }
  7751. },
  7752. beforeDragOver : function(target, e, id){
  7753. return true;
  7754. },
  7755. onDragOut : function(e, id){
  7756. var target = this.cachedTarget || Ext.dd.DragDropMgr.getDDById(id);
  7757. if(this.beforeDragOut(target, e, id) !== false){
  7758. if(target.isNotifyTarget){
  7759. target.notifyOut(this, e, this.dragData);
  7760. }
  7761. this.proxy.reset();
  7762. if(this.afterDragOut){
  7763. this.afterDragOut(target, e, id);
  7764. }
  7765. }
  7766. this.cachedTarget = null;
  7767. },
  7768. beforeDragOut : function(target, e, id){
  7769. return true;
  7770. },
  7771. onDragDrop : function(e, id){
  7772. var target = this.cachedTarget || Ext.dd.DragDropMgr.getDDById(id);
  7773. if(this.beforeDragDrop(target, e, id) !== false){
  7774. if(target.isNotifyTarget){
  7775. if(target.notifyDrop(this, e, this.dragData)){
  7776. this.onValidDrop(target, e, id);
  7777. }else{
  7778. this.onInvalidDrop(target, e, id);
  7779. }
  7780. }else{
  7781. this.onValidDrop(target, e, id);
  7782. }
  7783. if(this.afterDragDrop){
  7784. this.afterDragDrop(target, e, id);
  7785. }
  7786. }
  7787. delete this.cachedTarget;
  7788. },
  7789. beforeDragDrop : function(target, e, id){
  7790. return true;
  7791. },
  7792. onValidDrop : function(target, e, id){
  7793. this.hideProxy();
  7794. if(this.afterValidDrop){
  7795. this.afterValidDrop(target, e, id);
  7796. }
  7797. },
  7798. getRepairXY : function(e, data){
  7799. return this.el.getXY();
  7800. },
  7801. onInvalidDrop : function(target, e, id){
  7802. this.beforeInvalidDrop(target, e, id);
  7803. if(this.cachedTarget){
  7804. if(this.cachedTarget.isNotifyTarget){
  7805. this.cachedTarget.notifyOut(this, e, this.dragData);
  7806. }
  7807. this.cacheTarget = null;
  7808. }
  7809. this.proxy.repair(this.getRepairXY(e, this.dragData), this.afterRepair, this);
  7810. if(this.afterInvalidDrop){
  7811. this.afterInvalidDrop(e, id);
  7812. }
  7813. },
  7814. afterRepair : function(){
  7815. if(Ext.enableFx){
  7816. this.el.highlight(this.hlColor || "c3daf9");
  7817. }
  7818. this.dragging = false;
  7819. },
  7820. beforeInvalidDrop : function(target, e, id){
  7821. return true;
  7822. },
  7823. handleMouseDown : function(e){
  7824. if(this.dragging) {
  7825. return;
  7826. }
  7827. var data = this.getDragData(e);
  7828. if(data && this.onBeforeDrag(data, e) !== false){
  7829. this.dragData = data;
  7830. this.proxy.stop();
  7831. Ext.dd.DragSource.superclass.handleMouseDown.apply(this, arguments);
  7832. }
  7833. },
  7834. onBeforeDrag : function(data, e){
  7835. return true;
  7836. },
  7837. onStartDrag : Ext.emptyFn,
  7838. startDrag : function(x, y){
  7839. this.proxy.reset();
  7840. this.dragging = true;
  7841. this.proxy.update("");
  7842. this.onInitDrag(x, y);
  7843. this.proxy.show();
  7844. },
  7845. onInitDrag : function(x, y){
  7846. var clone = this.el.dom.cloneNode(true);
  7847. clone.id = Ext.id();
  7848. this.proxy.update(clone);
  7849. this.onStartDrag(x, y);
  7850. return true;
  7851. },
  7852. getProxy : function(){
  7853. return this.proxy;
  7854. },
  7855. hideProxy : function(){
  7856. this.proxy.hide();
  7857. this.proxy.reset(true);
  7858. this.dragging = false;
  7859. },
  7860. triggerCacheRefresh : function(){
  7861. Ext.dd.DDM.refreshCache(this.groups);
  7862. },
  7863. b4EndDrag: function(e) {
  7864. },
  7865. endDrag : function(e){
  7866. this.onEndDrag(this.dragData, e);
  7867. },
  7868. onEndDrag : function(data, e){
  7869. },
  7870. autoOffset : function(x, y) {
  7871. this.setDelta(-12, -20);
  7872. }
  7873. });
  7874. Ext.dd.DropTarget = function(el, config){
  7875. this.el = Ext.get(el);
  7876. Ext.apply(this, config);
  7877. if(this.containerScroll){
  7878. Ext.dd.ScrollManager.register(this.el);
  7879. }
  7880. Ext.dd.DropTarget.superclass.constructor.call(this, this.el.dom, this.ddGroup || this.group,
  7881. {isTarget: true});
  7882. };
  7883. Ext.extend(Ext.dd.DropTarget, Ext.dd.DDTarget, {
  7884. dropAllowed : "x-dd-drop-ok",
  7885. dropNotAllowed : "x-dd-drop-nodrop",
  7886. isTarget : true,
  7887. isNotifyTarget : true,
  7888. notifyEnter : function(dd, e, data){
  7889. if(this.overClass){
  7890. this.el.addClass(this.overClass);
  7891. }
  7892. return this.dropAllowed;
  7893. },
  7894. notifyOver : function(dd, e, data){
  7895. return this.dropAllowed;
  7896. },
  7897. notifyOut : function(dd, e, data){
  7898. if(this.overClass){
  7899. this.el.removeClass(this.overClass);
  7900. }
  7901. },
  7902. notifyDrop : function(dd, e, data){
  7903. return false;
  7904. }
  7905. });
  7906. Ext.dd.DragZone = function(el, config){
  7907. Ext.dd.DragZone.superclass.constructor.call(this, el, config);
  7908. if(this.containerScroll){
  7909. Ext.dd.ScrollManager.register(this.el);
  7910. }
  7911. };
  7912. Ext.extend(Ext.dd.DragZone, Ext.dd.DragSource, {
  7913. getDragData : function(e){
  7914. return Ext.dd.Registry.getHandleFromEvent(e);
  7915. },
  7916. onInitDrag : function(x, y){
  7917. this.proxy.update(this.dragData.ddel.cloneNode(true));
  7918. this.onStartDrag(x, y);
  7919. return true;
  7920. },
  7921. afterRepair : function(){
  7922. if(Ext.enableFx){
  7923. Ext.Element.fly(this.dragData.ddel).highlight(this.hlColor || "c3daf9");
  7924. }
  7925. this.dragging = false;
  7926. },
  7927. getRepairXY : function(e){
  7928. return Ext.Element.fly(this.dragData.ddel).getXY();
  7929. }
  7930. });
  7931. Ext.dd.DropZone = function(el, config){
  7932. Ext.dd.DropZone.superclass.constructor.call(this, el, config);
  7933. };
  7934. Ext.extend(Ext.dd.DropZone, Ext.dd.DropTarget, {
  7935. getTargetFromEvent : function(e){
  7936. return Ext.dd.Registry.getTargetFromEvent(e);
  7937. },
  7938. onNodeEnter : function(n, dd, e, data){
  7939. },
  7940. onNodeOver : function(n, dd, e, data){
  7941. return this.dropAllowed;
  7942. },
  7943. onNodeOut : function(n, dd, e, data){
  7944. },
  7945. onNodeDrop : function(n, dd, e, data){
  7946. return false;
  7947. },
  7948. onContainerOver : function(dd, e, data){
  7949. return this.dropNotAllowed;
  7950. },
  7951. onContainerDrop : function(dd, e, data){
  7952. return false;
  7953. },
  7954. notifyEnter : function(dd, e, data){
  7955. return this.dropNotAllowed;
  7956. },
  7957. notifyOver : function(dd, e, data){
  7958. var n = this.getTargetFromEvent(e);
  7959. if(!n){
  7960. if(this.lastOverNode){
  7961. this.onNodeOut(this.lastOverNode, dd, e, data);
  7962. this.lastOverNode = null;
  7963. }
  7964. return this.onContainerOver(dd, e, data);
  7965. }
  7966. if(this.lastOverNode != n){
  7967. if(this.lastOverNode){
  7968. this.onNodeOut(this.lastOverNode, dd, e, data);
  7969. }
  7970. this.onNodeEnter(n, dd, e, data);
  7971. this.lastOverNode = n;
  7972. }
  7973. return this.onNodeOver(n, dd, e, data);
  7974. },
  7975. notifyOut : function(dd, e, data){
  7976. if(this.lastOverNode){
  7977. this.onNodeOut(this.lastOverNode, dd, e, data);
  7978. this.lastOverNode = null;
  7979. }
  7980. },
  7981. notifyDrop : function(dd, e, data){
  7982. if(this.lastOverNode){
  7983. this.onNodeOut(this.lastOverNode, dd, e, data);
  7984. this.lastOverNode = null;
  7985. }
  7986. var n = this.getTargetFromEvent(e);
  7987. return n ?
  7988. this.onNodeDrop(n, dd, e, data) :
  7989. this.onContainerDrop(dd, e, data);
  7990. },
  7991. triggerCacheRefresh : function(){
  7992. Ext.dd.DDM.refreshCache(this.groups);
  7993. }
  7994. });
  7995. Ext.data.SortTypes = {
  7996. none : function(s){
  7997. return s;
  7998. },
  7999. stripTagsRE : /<\/?[^>]+>/gi,
  8000. asText : function(s){
  8001. return String(s).replace(this.stripTagsRE, "");
  8002. },
  8003. asUCText : function(s){
  8004. return String(s).toUpperCase().replace(this.stripTagsRE, "");
  8005. },
  8006. asUCString : function(s) {
  8007. return String(s).toUpperCase();
  8008. },
  8009. asDate : function(s) {
  8010. if(!s){
  8011. return 0;
  8012. }
  8013. if(Ext.isDate(s)){
  8014. return s.getTime();
  8015. }
  8016. return Date.parse(String(s));
  8017. },
  8018. asFloat : function(s) {
  8019. var val = parseFloat(String(s).replace(/,/g, ""));
  8020. if(isNaN(val)) val = 0;
  8021. return val;
  8022. },
  8023. asInt : function(s) {
  8024. var val = parseInt(String(s).replace(/,/g, ""));
  8025. if(isNaN(val)) val = 0;
  8026. return val;
  8027. }
  8028. };
  8029. Ext.data.Record = function(data, id){
  8030. this.id = (id || id === 0) ? id : ++Ext.data.Record.AUTO_ID;
  8031. this.data = data;
  8032. };
  8033. Ext.data.Record.create = function(o){
  8034. var f = Ext.extend(Ext.data.Record, {});
  8035. var p = f.prototype;
  8036. p.fields = new Ext.util.MixedCollection(false, function(field){
  8037. return field.name;
  8038. });
  8039. for(var i = 0, len = o.length; i < len; i++){
  8040. p.fields.add(new Ext.data.Field(o[i]));
  8041. }
  8042. f.getField = function(name){
  8043. return p.fields.get(name);
  8044. };
  8045. return f;
  8046. };
  8047. Ext.data.Record.AUTO_ID = 1000;
  8048. Ext.data.Record.EDIT = 'edit';
  8049. Ext.data.Record.REJECT = 'reject';
  8050. Ext.data.Record.COMMIT = 'commit';
  8051. Ext.data.Record.prototype = {
  8052. dirty : false,
  8053. editing : false,
  8054. error: null,
  8055. modified: null,
  8056. join : function(store){
  8057. this.store = store;
  8058. },
  8059. set : function(name, value){
  8060. if(String(this.data[name]) == String(value)){
  8061. return;
  8062. }
  8063. this.dirty = true;
  8064. if(!this.modified){
  8065. this.modified = {};
  8066. }
  8067. if(typeof this.modified[name] == 'undefined'){
  8068. this.modified[name] = this.data[name];
  8069. }
  8070. this.data[name] = value;
  8071. if(!this.editing && this.store){
  8072. this.store.afterEdit(this);
  8073. }
  8074. },
  8075. get : function(name){
  8076. return this.data[name];
  8077. },
  8078. beginEdit : function(){
  8079. this.editing = true;
  8080. this.modified = {};
  8081. },
  8082. cancelEdit : function(){
  8083. this.editing = false;
  8084. delete this.modified;
  8085. },
  8086. endEdit : function(){
  8087. this.editing = false;
  8088. if(this.dirty && this.store){
  8089. this.store.afterEdit(this);
  8090. }
  8091. },
  8092. reject : function(silent){
  8093. var m = this.modified;
  8094. for(var n in m){
  8095. if(typeof m[n] != "function"){
  8096. this.data[n] = m[n];
  8097. }
  8098. }
  8099. this.dirty = false;
  8100. delete this.modified;
  8101. this.editing = false;
  8102. if(this.store && silent !== true){
  8103. this.store.afterReject(this);
  8104. }
  8105. },
  8106. commit : function(silent){
  8107. this.dirty = false;
  8108. delete this.modified;
  8109. this.editing = false;
  8110. if(this.store && silent !== true){
  8111. this.store.afterCommit(this);
  8112. }
  8113. },
  8114. getChanges : function(){
  8115. var m = this.modified, cs = {};
  8116. for(var n in m){
  8117. if(m.hasOwnProperty(n)){
  8118. cs[n] = this.data[n];
  8119. }
  8120. }
  8121. return cs;
  8122. },
  8123. hasError : function(){
  8124. return this.error != null;
  8125. },
  8126. clearError : function(){
  8127. this.error = null;
  8128. },
  8129. copy : function(newId) {
  8130. return new this.constructor(Ext.apply({}, this.data), newId || this.id);
  8131. },
  8132. isModified : function(fieldName){
  8133. return this.modified && this.modified.hasOwnProperty(fieldName);
  8134. }
  8135. };
  8136. Ext.StoreMgr = Ext.apply(new Ext.util.MixedCollection(), {
  8137. register : function(){
  8138. for(var i = 0, s; s = arguments[i]; i++){
  8139. this.add(s);
  8140. }
  8141. },
  8142. unregister : function(){
  8143. for(var i = 0, s; s = arguments[i]; i++){
  8144. this.remove(this.lookup(s));
  8145. }
  8146. },
  8147. lookup : function(id){
  8148. return typeof id == "object" ? id : this.get(id);
  8149. },
  8150. getKey : function(o){
  8151. return o.storeId || o.id;
  8152. }
  8153. });
  8154. Ext.data.Store = function(config){
  8155. this.data = new Ext.util.MixedCollection(false);
  8156. this.data.getKey = function(o){
  8157. return o.id;
  8158. };
  8159. this.baseParams = {};
  8160. this.paramNames = {
  8161. "start" : "start",
  8162. "limit" : "limit",
  8163. "sort" : "sort",
  8164. "dir" : "dir"
  8165. };
  8166. if(config && config.data){
  8167. this.inlineData = config.data;
  8168. delete config.data;
  8169. }
  8170. Ext.apply(this, config);
  8171. if(this.url && !this.proxy){
  8172. this.proxy = new Ext.data.HttpProxy({url: this.url});
  8173. }
  8174. if(this.reader){
  8175. if(!this.recordType){
  8176. this.recordType = this.reader.recordType;
  8177. }
  8178. if(this.reader.onMetaChange){
  8179. this.reader.onMetaChange = this.onMetaChange.createDelegate(this);
  8180. }
  8181. }
  8182. if(this.recordType){
  8183. this.fields = this.recordType.prototype.fields;
  8184. }
  8185. this.modified = [];
  8186. this.addEvents(
  8187. 'datachanged',
  8188. 'metachange',
  8189. 'add',
  8190. 'remove',
  8191. 'update',
  8192. 'clear',
  8193. 'beforeload',
  8194. 'load',
  8195. 'loadexception'
  8196. );
  8197. if(this.proxy){
  8198. this.relayEvents(this.proxy, ["loadexception"]);
  8199. }
  8200. this.sortToggle = {};
  8201. if(this.sortInfo){
  8202. this.setDefaultSort(this.sortInfo.field, this.sortInfo.direction);
  8203. }
  8204. Ext.data.Store.superclass.constructor.call(this);
  8205. if(this.storeId || this.id){
  8206. Ext.StoreMgr.register(this);
  8207. }
  8208. if(this.inlineData){
  8209. this.loadData(this.inlineData);
  8210. delete this.inlineData;
  8211. }else if(this.autoLoad){
  8212. this.load.defer(10, this, [
  8213. typeof this.autoLoad == 'object' ?
  8214. this.autoLoad : undefined]);
  8215. }
  8216. };
  8217. Ext.extend(Ext.data.Store, Ext.util.Observable, {
  8218. remoteSort : false,
  8219. pruneModifiedRecords : false,
  8220. lastOptions : null,
  8221. destroy : function(){
  8222. if(this.id){
  8223. Ext.StoreMgr.unregister(this);
  8224. }
  8225. this.data = null;
  8226. this.purgeListeners();
  8227. },
  8228. add : function(records){
  8229. records = [].concat(records);
  8230. if(records.length < 1){
  8231. return;
  8232. }
  8233. for(var i = 0, len = records.length; i < len; i++){
  8234. records[i].join(this);
  8235. }
  8236. var index = this.data.length;
  8237. this.data.addAll(records);
  8238. if(this.snapshot){
  8239. this.snapshot.addAll(records);
  8240. }
  8241. this.fireEvent("add", this, records, index);
  8242. },
  8243. addSorted : function(record){
  8244. var index = this.findInsertIndex(record);
  8245. this.insert(index, record);
  8246. },
  8247. remove : function(record){
  8248. var index = this.data.indexOf(record);
  8249. this.data.removeAt(index);
  8250. if(this.pruneModifiedRecords){
  8251. this.modified.remove(record);
  8252. }
  8253. if(this.snapshot){
  8254. this.snapshot.remove(record);
  8255. }
  8256. this.fireEvent("remove", this, record, index);
  8257. },
  8258. removeAll : function(){
  8259. this.data.clear();
  8260. if(this.snapshot){
  8261. this.snapshot.clear();
  8262. }
  8263. if(this.pruneModifiedRecords){
  8264. this.modified = [];
  8265. }
  8266. this.fireEvent("clear", this);
  8267. },
  8268. insert : function(index, records){
  8269. records = [].concat(records);
  8270. for(var i = 0, len = records.length; i < len; i++){
  8271. this.data.insert(index, records[i]);
  8272. records[i].join(this);
  8273. }
  8274. this.fireEvent("add", this, records, index);
  8275. },
  8276. indexOf : function(record){
  8277. return this.data.indexOf(record);
  8278. },
  8279. indexOfId : function(id){
  8280. return this.data.indexOfKey(id);
  8281. },
  8282. getById : function(id){
  8283. return this.data.key(id);
  8284. },
  8285. getAt : function(index){
  8286. return this.data.itemAt(index);
  8287. },
  8288. getRange : function(start, end){
  8289. return this.data.getRange(start, end);
  8290. },
  8291. storeOptions : function(o){
  8292. o = Ext.apply({}, o);
  8293. delete o.callback;
  8294. delete o.scope;
  8295. this.lastOptions = o;
  8296. },
  8297. load : function(options){
  8298. options = options || {};
  8299. if(this.fireEvent("beforeload", this, options) !== false){
  8300. this.storeOptions(options);
  8301. var p = Ext.apply(options.params || {}, this.baseParams);
  8302. if(this.sortInfo && this.remoteSort){
  8303. var pn = this.paramNames;
  8304. p[pn["sort"]] = this.sortInfo.field;
  8305. p[pn["dir"]] = this.sortInfo.direction;
  8306. }
  8307. this.proxy.load(p, this.reader, this.loadRecords, this, options);
  8308. return true;
  8309. } else {
  8310. return false;
  8311. }
  8312. },
  8313. reload : function(options){
  8314. this.load(Ext.applyIf(options||{}, this.lastOptions));
  8315. },
  8316. loadRecords : function(o, options, success){
  8317. if(!o || success === false){
  8318. if(success !== false){
  8319. this.fireEvent("load", this, [], options);
  8320. }
  8321. if(options.callback){
  8322. options.callback.call(options.scope || this, [], options, false);
  8323. }
  8324. return;
  8325. }
  8326. var r = o.records, t = o.totalRecords || r.length;
  8327. if(!options || options.add !== true){
  8328. if(this.pruneModifiedRecords){
  8329. this.modified = [];
  8330. }
  8331. for(var i = 0, len = r.length; i < len; i++){
  8332. r[i].join(this);
  8333. }
  8334. if(this.snapshot){
  8335. this.data = this.snapshot;
  8336. delete this.snapshot;
  8337. }
  8338. this.data.clear();
  8339. this.data.addAll(r);
  8340. this.totalLength = t;
  8341. this.applySort();
  8342. this.fireEvent("datachanged", this);
  8343. }else{
  8344. this.totalLength = Math.max(t, this.data.length+r.length);
  8345. this.add(r);
  8346. }
  8347. this.fireEvent("load", this, r, options);
  8348. if(options.callback){
  8349. options.callback.call(options.scope || this, r, options, true);
  8350. }
  8351. },
  8352. loadData : function(o, append){
  8353. var r = this.reader.readRecords(o);
  8354. this.loadRecords(r, {add: append}, true);
  8355. },
  8356. getCount : function(){
  8357. return this.data.length || 0;
  8358. },
  8359. getTotalCount : function(){
  8360. return this.totalLength || 0;
  8361. },
  8362. getSortState : function(){
  8363. return this.sortInfo;
  8364. },
  8365. applySort : function(){
  8366. if(this.sortInfo && !this.remoteSort){
  8367. var s = this.sortInfo, f = s.field;
  8368. this.sortData(f, s.direction);
  8369. }
  8370. },
  8371. sortData : function(f, direction){
  8372. direction = direction || 'ASC';
  8373. var st = this.fields.get(f).sortType;
  8374. var fn = function(r1, r2){
  8375. var v1 = st(r1.data[f]), v2 = st(r2.data[f]);
  8376. return v1 > v2 ? 1 : (v1 < v2 ? -1 : 0);
  8377. };
  8378. this.data.sort(direction, fn);
  8379. if(this.snapshot && this.snapshot != this.data){
  8380. this.snapshot.sort(direction, fn);
  8381. }
  8382. },
  8383. setDefaultSort : function(field, dir){
  8384. dir = dir ? dir.toUpperCase() : "ASC";
  8385. this.sortInfo = {field: field, direction: dir};
  8386. this.sortToggle[field] = dir;
  8387. },
  8388. sort : function(fieldName, dir){
  8389. var f = this.fields.get(fieldName);
  8390. if(!f){
  8391. return false;
  8392. }
  8393. if(!dir){
  8394. if(this.sortInfo && this.sortInfo.field == f.name){
  8395. dir = (this.sortToggle[f.name] || "ASC").toggle("ASC", "DESC");
  8396. }else{
  8397. dir = f.sortDir;
  8398. }
  8399. }
  8400. var st = (this.sortToggle) ? this.sortToggle[f.name] : null;
  8401. var si = (this.sortInfo) ? this.sortInfo : null;
  8402. this.sortToggle[f.name] = dir;
  8403. this.sortInfo = {field: f.name, direction: dir};
  8404. if(!this.remoteSort){
  8405. this.applySort();
  8406. this.fireEvent("datachanged", this);
  8407. }else{
  8408. if (!this.load(this.lastOptions)) {
  8409. if (st) {
  8410. this.sortToggle[f.name] = st;
  8411. }
  8412. if (si) {
  8413. this.sortInfo = si;
  8414. }
  8415. }
  8416. }
  8417. },
  8418. each : function(fn, scope){
  8419. this.data.each(fn, scope);
  8420. },
  8421. getModifiedRecords : function(){
  8422. return this.modified;
  8423. },
  8424. createFilterFn : function(property, value, anyMatch, caseSensitive){
  8425. if(Ext.isEmpty(value, false)){
  8426. return false;
  8427. }
  8428. value = this.data.createValueMatcher(value, anyMatch, caseSensitive);
  8429. return function(r){
  8430. return value.test(r.data[property]);
  8431. };
  8432. },
  8433. sum : function(property, start, end){
  8434. var rs = this.data.items, v = 0;
  8435. start = start || 0;
  8436. end = (end || end === 0) ? end : rs.length-1;
  8437. for(var i = start; i <= end; i++){
  8438. v += (rs[i].data[property] || 0);
  8439. }
  8440. return v;
  8441. },
  8442. filter : function(property, value, anyMatch, caseSensitive){
  8443. var fn = this.createFilterFn(property, value, anyMatch, caseSensitive);
  8444. return fn ? this.filterBy(fn) : this.clearFilter();
  8445. },
  8446. filterBy : function(fn, scope){
  8447. this.snapshot = this.snapshot || this.data;
  8448. this.data = this.queryBy(fn, scope||this);
  8449. this.fireEvent("datachanged", this);
  8450. },
  8451. query : function(property, value, anyMatch, caseSensitive){
  8452. var fn = this.createFilterFn(property, value, anyMatch, caseSensitive);
  8453. return fn ? this.queryBy(fn) : this.data.clone();
  8454. },
  8455. queryBy : function(fn, scope){
  8456. var data = this.snapshot || this.data;
  8457. return data.filterBy(fn, scope||this);
  8458. },
  8459. find : function(property, value, start, anyMatch, caseSensitive){
  8460. var fn = this.createFilterFn(property, value, anyMatch, caseSensitive);
  8461. return fn ? this.data.findIndexBy(fn, null, start) : -1;
  8462. },
  8463. findBy : function(fn, scope, start){
  8464. return this.data.findIndexBy(fn, scope, start);
  8465. },
  8466. collect : function(dataIndex, allowNull, bypassFilter){
  8467. var d = (bypassFilter === true && this.snapshot) ?
  8468. this.snapshot.items : this.data.items;
  8469. var v, sv, r = [], l = {};
  8470. for(var i = 0, len = d.length; i < len; i++){
  8471. v = d[i].data[dataIndex];
  8472. sv = String(v);
  8473. if((allowNull || !Ext.isEmpty(v)) && !l[sv]){
  8474. l[sv] = true;
  8475. r[r.length] = v;
  8476. }
  8477. }
  8478. return r;
  8479. },
  8480. clearFilter : function(suppressEvent){
  8481. if(this.isFiltered()){
  8482. this.data = this.snapshot;
  8483. delete this.snapshot;
  8484. if(suppressEvent !== true){
  8485. this.fireEvent("datachanged", this);
  8486. }
  8487. }
  8488. },
  8489. isFiltered : function(){
  8490. return this.snapshot && this.snapshot != this.data;
  8491. },
  8492. afterEdit : function(record){
  8493. if(this.modified.indexOf(record) == -1){
  8494. this.modified.push(record);
  8495. }
  8496. this.fireEvent("update", this, record, Ext.data.Record.EDIT);
  8497. },
  8498. afterReject : function(record){
  8499. this.modified.remove(record);
  8500. this.fireEvent("update", this, record, Ext.data.Record.REJECT);
  8501. },
  8502. afterCommit : function(record){
  8503. this.modified.remove(record);
  8504. this.fireEvent("update", this, record, Ext.data.Record.COMMIT);
  8505. },
  8506. commitChanges : function(){
  8507. var m = this.modified.slice(0);
  8508. this.modified = [];
  8509. for(var i = 0, len = m.length; i < len; i++){
  8510. m[i].commit();
  8511. }
  8512. },
  8513. rejectChanges : function(){
  8514. var m = this.modified.slice(0);
  8515. this.modified = [];
  8516. for(var i = 0, len = m.length; i < len; i++){
  8517. m[i].reject();
  8518. }
  8519. },
  8520. onMetaChange : function(meta, rtype, o){
  8521. this.recordType = rtype;
  8522. this.fields = rtype.prototype.fields;
  8523. delete this.snapshot;
  8524. this.sortInfo = meta.sortInfo;
  8525. this.modified = [];
  8526. this.fireEvent('metachange', this, this.reader.meta);
  8527. },
  8528. findInsertIndex : function(record){
  8529. this.suspendEvents();
  8530. var data = this.data.clone();
  8531. this.data.add(record);
  8532. this.applySort();
  8533. var index = this.data.indexOf(record);
  8534. this.data = data;
  8535. this.resumeEvents();
  8536. return index;
  8537. }
  8538. });
  8539. Ext.data.SimpleStore = function(config){
  8540. Ext.data.SimpleStore.superclass.constructor.call(this, Ext.apply(config, {
  8541. reader: new Ext.data.ArrayReader({
  8542. id: config.id
  8543. },
  8544. Ext.data.Record.create(config.fields)
  8545. )
  8546. }));
  8547. };
  8548. Ext.extend(Ext.data.SimpleStore, Ext.data.Store, {
  8549. loadData : function(data, append){
  8550. if(this.expandData === true){
  8551. var r = [];
  8552. for(var i = 0, len = data.length; i < len; i++){
  8553. r[r.length] = [data[i]];
  8554. }
  8555. data = r;
  8556. }
  8557. Ext.data.SimpleStore.superclass.loadData.call(this, data, append);
  8558. }
  8559. });
  8560. Ext.data.JsonStore = function(c){
  8561. Ext.data.JsonStore.superclass.constructor.call(this, Ext.apply(c, {
  8562. proxy: !c.data ? new Ext.data.HttpProxy({url: c.url}) : undefined,
  8563. reader: new Ext.data.JsonReader(c, c.fields)
  8564. }));
  8565. };
  8566. Ext.extend(Ext.data.JsonStore, Ext.data.Store);
  8567. Ext.data.Field = function(config){
  8568. if(typeof config == "string"){
  8569. config = {name: config};
  8570. }
  8571. Ext.apply(this, config);
  8572. if(!this.type){
  8573. this.type = "auto";
  8574. }
  8575. var st = Ext.data.SortTypes;
  8576. if(typeof this.sortType == "string"){
  8577. this.sortType = st[this.sortType];
  8578. }
  8579. if(!this.sortType){
  8580. switch(this.type){
  8581. case "string":
  8582. this.sortType = st.asUCString;
  8583. break;
  8584. case "date":
  8585. this.sortType = st.asDate;
  8586. break;
  8587. default:
  8588. this.sortType = st.none;
  8589. }
  8590. }
  8591. var stripRe = /[\$,%]/g;
  8592. if(!this.convert){
  8593. var cv, dateFormat = this.dateFormat;
  8594. switch(this.type){
  8595. case "":
  8596. case "auto":
  8597. case undefined:
  8598. cv = function(v){ return v; };
  8599. break;
  8600. case "string":
  8601. cv = function(v){ return (v === undefined || v === null) ? '' : String(v); };
  8602. break;
  8603. case "int":
  8604. cv = function(v){
  8605. return v !== undefined && v !== null && v !== '' ?
  8606. parseInt(String(v).replace(stripRe, ""), 10) : '';
  8607. };
  8608. break;
  8609. case "float":
  8610. cv = function(v){
  8611. return v !== undefined && v !== null && v !== '' ?
  8612. parseFloat(String(v).replace(stripRe, ""), 10) : '';
  8613. };
  8614. break;
  8615. case "bool":
  8616. case "boolean":
  8617. cv = function(v){ return v === true || v === "true" || v == 1; };
  8618. break;
  8619. case "date":
  8620. cv = function(v){
  8621. if(!v){
  8622. return '';
  8623. }
  8624. if(Ext.isDate(v)){
  8625. return v;
  8626. }
  8627. if(dateFormat){
  8628. if(dateFormat == "timestamp"){
  8629. return new Date(v*1000);
  8630. }
  8631. if(dateFormat == "time"){
  8632. return new Date(parseInt(v, 10));
  8633. }
  8634. return Date.parseDate(v, dateFormat);
  8635. }
  8636. var parsed = Date.parse(v);
  8637. return parsed ? new Date(parsed) : null;
  8638. };
  8639. break;
  8640. }
  8641. this.convert = cv;
  8642. }
  8643. };
  8644. Ext.data.Field.prototype = {
  8645. dateFormat: null,
  8646. defaultValue: "",
  8647. mapping: null,
  8648. sortType : null,
  8649. sortDir : "ASC"
  8650. };
  8651. Ext.data.DataReader = function(meta, recordType){
  8652. this.meta = meta;
  8653. this.recordType = Ext.isArray(recordType) ?
  8654. Ext.data.Record.create(recordType) : recordType;
  8655. };
  8656. Ext.data.DataReader.prototype = {
  8657. };
  8658. Ext.data.DataProxy = function(){
  8659. this.addEvents(
  8660. 'beforeload',
  8661. 'load',
  8662. 'loadexception'
  8663. );
  8664. Ext.data.DataProxy.superclass.constructor.call(this);
  8665. };
  8666. Ext.extend(Ext.data.DataProxy, Ext.util.Observable);
  8667. Ext.data.MemoryProxy = function(data){
  8668. Ext.data.MemoryProxy.superclass.constructor.call(this);
  8669. this.data = data;
  8670. };
  8671. Ext.extend(Ext.data.MemoryProxy, Ext.data.DataProxy, {
  8672. load : function(params, reader, callback, scope, arg){
  8673. params = params || {};
  8674. var result;
  8675. try {
  8676. result = reader.readRecords(this.data);
  8677. }catch(e){
  8678. this.fireEvent("loadexception", this, arg, null, e);
  8679. callback.call(scope, null, arg, false);
  8680. return;
  8681. }
  8682. callback.call(scope, result, arg, true);
  8683. },
  8684. update : function(params, records){
  8685. }
  8686. });
  8687. Ext.data.HttpProxy = function(conn){
  8688. Ext.data.HttpProxy.superclass.constructor.call(this);
  8689. this.conn = conn;
  8690. this.useAjax = !conn || !conn.events;
  8691. };
  8692. Ext.extend(Ext.data.HttpProxy, Ext.data.DataProxy, {
  8693. getConnection : function(){
  8694. return this.useAjax ? Ext.Ajax : this.conn;
  8695. },
  8696. load : function(params, reader, callback, scope, arg){
  8697. if(this.fireEvent("beforeload", this, params) !== false){
  8698. var o = {
  8699. params : params || {},
  8700. request: {
  8701. callback : callback,
  8702. scope : scope,
  8703. arg : arg
  8704. },
  8705. reader: reader,
  8706. callback : this.loadResponse,
  8707. scope: this
  8708. };
  8709. if(this.useAjax){
  8710. Ext.applyIf(o, this.conn);
  8711. if(this.activeRequest){
  8712. Ext.Ajax.abort(this.activeRequest);
  8713. }
  8714. this.activeRequest = Ext.Ajax.request(o);
  8715. }else{
  8716. this.conn.request(o);
  8717. }
  8718. }else{
  8719. callback.call(scope||this, null, arg, false);
  8720. }
  8721. },
  8722. loadResponse : function(o, success, response){
  8723. delete this.activeRequest;
  8724. if(!success){
  8725. this.fireEvent("loadexception", this, o, response);
  8726. o.request.callback.call(o.request.scope, null, o.request.arg, false);
  8727. return;
  8728. }
  8729. var result;
  8730. try {
  8731. result = o.reader.read(response);
  8732. }catch(e){
  8733. this.fireEvent("loadexception", this, o, response, e);
  8734. o.request.callback.call(o.request.scope, null, o.request.arg, false);
  8735. return;
  8736. }
  8737. this.fireEvent("load", this, o, o.request.arg);
  8738. o.request.callback.call(o.request.scope, result, o.request.arg, true);
  8739. },
  8740. update : function(dataSet){
  8741. },
  8742. updateResponse : function(dataSet){
  8743. }
  8744. });
  8745. Ext.data.ScriptTagProxy = function(config){
  8746. Ext.data.ScriptTagProxy.superclass.constructor.call(this);
  8747. Ext.apply(this, config);
  8748. this.head = document.getElementsByTagName("head")[0];
  8749. };
  8750. Ext.data.ScriptTagProxy.TRANS_ID = 1000;
  8751. Ext.extend(Ext.data.ScriptTagProxy, Ext.data.DataProxy, {
  8752. timeout : 30000,
  8753. callbackParam : "callback",
  8754. nocache : true,
  8755. load : function(params, reader, callback, scope, arg){
  8756. if(this.fireEvent("beforeload", this, params) !== false){
  8757. var p = Ext.urlEncode(Ext.apply(params, this.extraParams));
  8758. var url = this.url;
  8759. url += (url.indexOf("?") != -1 ? "&" : "?") + p;
  8760. if(this.nocache){
  8761. url += "&_dc=" + (new Date().getTime());
  8762. }
  8763. var transId = ++Ext.data.ScriptTagProxy.TRANS_ID;
  8764. var trans = {
  8765. id : transId,
  8766. cb : "stcCallback"+transId,
  8767. scriptId : "stcScript"+transId,
  8768. params : params,
  8769. arg : arg,
  8770. url : url,
  8771. callback : callback,
  8772. scope : scope,
  8773. reader : reader
  8774. };
  8775. var conn = this;
  8776. window[trans.cb] = function(o){
  8777. conn.handleResponse(o, trans);
  8778. };
  8779. url += String.format("&{0}={1}", this.callbackParam, trans.cb);
  8780. if(this.autoAbort !== false){
  8781. this.abort();
  8782. }
  8783. trans.timeoutId = this.handleFailure.defer(this.timeout, this, [trans]);
  8784. var script = document.createElement("script");
  8785. script.setAttribute("src", url);
  8786. script.setAttribute("type", "text/javascript");
  8787. script.setAttribute("id", trans.scriptId);
  8788. this.head.appendChild(script);
  8789. this.trans = trans;
  8790. }else{
  8791. callback.call(scope||this, null, arg, false);
  8792. }
  8793. },
  8794. isLoading : function(){
  8795. return this.trans ? true : false;
  8796. },
  8797. abort : function(){
  8798. if(this.isLoading()){
  8799. this.destroyTrans(this.trans);
  8800. }
  8801. },
  8802. destroyTrans : function(trans, isLoaded){
  8803. this.head.removeChild(document.getElementById(trans.scriptId));
  8804. clearTimeout(trans.timeoutId);
  8805. if(isLoaded){
  8806. window[trans.cb] = undefined;
  8807. try{
  8808. delete window[trans.cb];
  8809. }catch(e){}
  8810. }else{
  8811. window[trans.cb] = function(){
  8812. window[trans.cb] = undefined;
  8813. try{
  8814. delete window[trans.cb];
  8815. }catch(e){}
  8816. };
  8817. }
  8818. },
  8819. handleResponse : function(o, trans){
  8820. this.trans = false;
  8821. this.destroyTrans(trans, true);
  8822. var result;
  8823. try {
  8824. result = trans.reader.readRecords(o);
  8825. }catch(e){
  8826. this.fireEvent("loadexception", this, o, trans.arg, e);
  8827. trans.callback.call(trans.scope||window, null, trans.arg, false);
  8828. return;
  8829. }
  8830. this.fireEvent("load", this, o, trans.arg);
  8831. trans.callback.call(trans.scope||window, result, trans.arg, true);
  8832. },
  8833. handleFailure : function(trans){
  8834. this.trans = false;
  8835. this.destroyTrans(trans, false);
  8836. this.fireEvent("loadexception", this, null, trans.arg);
  8837. trans.callback.call(trans.scope||window, null, trans.arg, false);
  8838. }
  8839. });
  8840. Ext.data.JsonReader = function(meta, recordType){
  8841. meta = meta || {};
  8842. Ext.data.JsonReader.superclass.constructor.call(this, meta, recordType || meta.fields);
  8843. };
  8844. Ext.extend(Ext.data.JsonReader, Ext.data.DataReader, {
  8845. read : function(response){
  8846. var json = response.responseText;
  8847. var o = eval("("+json+")");
  8848. if(!o) {
  8849. throw {message: "JsonReader.read: Json object not found"};
  8850. }
  8851. if(o.metaData){
  8852. delete this.ef;
  8853. this.meta = o.metaData;
  8854. this.recordType = Ext.data.Record.create(o.metaData.fields);
  8855. this.onMetaChange(this.meta, this.recordType, o);
  8856. }
  8857. return this.readRecords(o);
  8858. },
  8859. onMetaChange : function(meta, recordType, o){
  8860. },
  8861. simpleAccess: function(obj, subsc) {
  8862. return obj[subsc];
  8863. },
  8864. getJsonAccessor: function(){
  8865. var re = /[\[\.]/;
  8866. return function(expr) {
  8867. try {
  8868. return(re.test(expr))
  8869. ? new Function("obj", "return obj." + expr)
  8870. : function(obj){
  8871. return obj[expr];
  8872. };
  8873. } catch(e){}
  8874. return Ext.emptyFn;
  8875. };
  8876. }(),
  8877. readRecords : function(o){
  8878. this.jsonData = o;
  8879. var s = this.meta, Record = this.recordType,
  8880. f = Record.prototype.fields, fi = f.items, fl = f.length;
  8881. if (!this.ef) {
  8882. if(s.totalProperty) {
  8883. this.getTotal = this.getJsonAccessor(s.totalProperty);
  8884. }
  8885. if(s.successProperty) {
  8886. this.getSuccess = this.getJsonAccessor(s.successProperty);
  8887. }
  8888. this.getRoot = s.root ? this.getJsonAccessor(s.root) : function(p){return p;};
  8889. if (s.id) {
  8890. var g = this.getJsonAccessor(s.id);
  8891. this.getId = function(rec) {
  8892. var r = g(rec);
  8893. return (r === undefined || r === "") ? null : r;
  8894. };
  8895. } else {
  8896. this.getId = function(){return null;};
  8897. }
  8898. this.ef = [];
  8899. for(var i = 0; i < fl; i++){
  8900. f = fi[i];
  8901. var map = (f.mapping !== undefined && f.mapping !== null) ? f.mapping : f.name;
  8902. this.ef[i] = this.getJsonAccessor(map);
  8903. }
  8904. }
  8905. var root = this.getRoot(o), c = root.length, totalRecords = c, success = true;
  8906. if(s.totalProperty){
  8907. var v = parseInt(this.getTotal(o), 10);
  8908. if(!isNaN(v)){
  8909. totalRecords = v;
  8910. }
  8911. }
  8912. if(s.successProperty){
  8913. var v = this.getSuccess(o);
  8914. if(v === false || v === 'false'){
  8915. success = false;
  8916. }
  8917. }
  8918. var records = [];
  8919. for(var i = 0; i < c; i++){
  8920. var n = root[i];
  8921. var values = {};
  8922. var id = this.getId(n);
  8923. for(var j = 0; j < fl; j++){
  8924. f = fi[j];
  8925. var v = this.ef[j](n);
  8926. values[f.name] = f.convert((v !== undefined) ? v : f.defaultValue, n);
  8927. }
  8928. var record = new Record(values, id);
  8929. record.json = n;
  8930. records[i] = record;
  8931. }
  8932. return {
  8933. success : success,
  8934. records : records,
  8935. totalRecords : totalRecords
  8936. };
  8937. }
  8938. });
  8939. Ext.data.XmlReader = function(meta, recordType){
  8940. meta = meta || {};
  8941. Ext.data.XmlReader.superclass.constructor.call(this, meta, recordType || meta.fields);
  8942. };
  8943. Ext.extend(Ext.data.XmlReader, Ext.data.DataReader, {
  8944. read : function(response){
  8945. var doc = response.responseXML;
  8946. if(!doc) {
  8947. throw {message: "XmlReader.read: XML Document not available"};
  8948. }
  8949. return this.readRecords(doc);
  8950. },
  8951. readRecords : function(doc){
  8952. this.xmlData = doc;
  8953. var root = doc.documentElement || doc;
  8954. var q = Ext.DomQuery;
  8955. var recordType = this.recordType, fields = recordType.prototype.fields;
  8956. var sid = this.meta.id;
  8957. var totalRecords = 0, success = true;
  8958. if(this.meta.totalRecords){
  8959. totalRecords = q.selectNumber(this.meta.totalRecords, root, 0);
  8960. }
  8961. if(this.meta.success){
  8962. var sv = q.selectValue(this.meta.success, root, true);
  8963. success = sv !== false && sv !== 'false';
  8964. }
  8965. var records = [];
  8966. var ns = q.select(this.meta.record, root);
  8967. for(var i = 0, len = ns.length; i < len; i++) {
  8968. var n = ns[i];
  8969. var values = {};
  8970. var id = sid ? q.selectValue(sid, n) : undefined;
  8971. for(var j = 0, jlen = fields.length; j < jlen; j++){
  8972. var f = fields.items[j];
  8973. var v = q.selectValue(f.mapping || f.name, n, f.defaultValue);
  8974. v = f.convert(v, n);
  8975. values[f.name] = v;
  8976. }
  8977. var record = new recordType(values, id);
  8978. record.node = n;
  8979. records[records.length] = record;
  8980. }
  8981. return {
  8982. success : success,
  8983. records : records,
  8984. totalRecords : totalRecords || records.length
  8985. };
  8986. }
  8987. });
  8988. Ext.data.ArrayReader = Ext.extend(Ext.data.JsonReader, {
  8989. readRecords : function(o){
  8990. var sid = this.meta ? this.meta.id : null;
  8991. var recordType = this.recordType, fields = recordType.prototype.fields;
  8992. var records = [];
  8993. var root = o;
  8994. for(var i = 0; i < root.length; i++){
  8995. var n = root[i];
  8996. var values = {};
  8997. var id = ((sid || sid === 0) && n[sid] !== undefined && n[sid] !== "" ? n[sid] : null);
  8998. for(var j = 0, jlen = fields.length; j < jlen; j++){
  8999. var f = fields.items[j];
  9000. var k = f.mapping !== undefined && f.mapping !== null ? f.mapping : j;
  9001. var v = n[k] !== undefined ? n[k] : f.defaultValue;
  9002. v = f.convert(v, n);
  9003. values[f.name] = v;
  9004. }
  9005. var record = new recordType(values, id);
  9006. record.json = n;
  9007. records[records.length] = record;
  9008. }
  9009. return {
  9010. records : records,
  9011. totalRecords : records.length
  9012. };
  9013. }
  9014. });
  9015. Ext.data.Tree = function(root){
  9016. this.nodeHash = {};
  9017. this.root = null;
  9018. if(root){
  9019. this.setRootNode(root);
  9020. }
  9021. this.addEvents(
  9022. "append",
  9023. "remove",
  9024. "move",
  9025. "insert",
  9026. "beforeappend",
  9027. "beforeremove",
  9028. "beforemove",
  9029. "beforeinsert"
  9030. );
  9031. Ext.data.Tree.superclass.constructor.call(this);
  9032. };
  9033. Ext.extend(Ext.data.Tree, Ext.util.Observable, {
  9034. pathSeparator: "/",
  9035. proxyNodeEvent : function(){
  9036. return this.fireEvent.apply(this, arguments);
  9037. },
  9038. getRootNode : function(){
  9039. return this.root;
  9040. },
  9041. setRootNode : function(node){
  9042. this.root = node;
  9043. node.ownerTree = this;
  9044. node.isRoot = true;
  9045. this.registerNode(node);
  9046. return node;
  9047. },
  9048. getNodeById : function(id){
  9049. return this.nodeHash[id];
  9050. },
  9051. registerNode : function(node){
  9052. this.nodeHash[node.id] = node;
  9053. },
  9054. unregisterNode : function(node){
  9055. delete this.nodeHash[node.id];
  9056. },
  9057. toString : function(){
  9058. return "[Tree"+(this.id?" "+this.id:"")+"]";
  9059. }
  9060. });
  9061. Ext.data.Node = function(attributes){
  9062. this.attributes = attributes || {};
  9063. this.leaf = this.attributes.leaf;
  9064. this.id = this.attributes.id;
  9065. if(!this.id){
  9066. this.id = Ext.id(null, "ynode-");
  9067. this.attributes.id = this.id;
  9068. }
  9069. this.childNodes = [];
  9070. if(!this.childNodes.indexOf){
  9071. this.childNodes.indexOf = function(o){
  9072. for(var i = 0, len = this.length; i < len; i++){
  9073. if(this[i] == o) return i;
  9074. }
  9075. return -1;
  9076. };
  9077. }
  9078. this.parentNode = null;
  9079. this.firstChild = null;
  9080. this.lastChild = null;
  9081. this.previousSibling = null;
  9082. this.nextSibling = null;
  9083. this.addEvents({
  9084. "append" : true,
  9085. "remove" : true,
  9086. "move" : true,
  9087. "insert" : true,
  9088. "beforeappend" : true,
  9089. "beforeremove" : true,
  9090. "beforemove" : true,
  9091. "beforeinsert" : true
  9092. });
  9093. this.listeners = this.attributes.listeners;
  9094. Ext.data.Node.superclass.constructor.call(this);
  9095. };
  9096. Ext.extend(Ext.data.Node, Ext.util.Observable, {
  9097. fireEvent : function(evtName){
  9098. if(Ext.data.Node.superclass.fireEvent.apply(this, arguments) === false){
  9099. return false;
  9100. }
  9101. var ot = this.getOwnerTree();
  9102. if(ot){
  9103. if(ot.proxyNodeEvent.apply(ot, arguments) === false){
  9104. return false;
  9105. }
  9106. }
  9107. return true;
  9108. },
  9109. isLeaf : function(){
  9110. return this.leaf === true;
  9111. },
  9112. setFirstChild : function(node){
  9113. this.firstChild = node;
  9114. },
  9115. setLastChild : function(node){
  9116. this.lastChild = node;
  9117. },
  9118. isLast : function(){
  9119. return (!this.parentNode ? true : this.parentNode.lastChild == this);
  9120. },
  9121. isFirst : function(){
  9122. return (!this.parentNode ? true : this.parentNode.firstChild == this);
  9123. },
  9124. hasChildNodes : function(){
  9125. return !this.isLeaf() && this.childNodes.length > 0;
  9126. },
  9127. appendChild : function(node){
  9128. var multi = false;
  9129. if(Ext.isArray(node)){
  9130. multi = node;
  9131. }else if(arguments.length > 1){
  9132. multi = arguments;
  9133. }
  9134. if(multi){
  9135. for(var i = 0, len = multi.length; i < len; i++) {
  9136. this.appendChild(multi[i]);
  9137. }
  9138. }else{
  9139. if(this.fireEvent("beforeappend", this.ownerTree, this, node) === false){
  9140. return false;
  9141. }
  9142. var index = this.childNodes.length;
  9143. var oldParent = node.parentNode;
  9144. if(oldParent){
  9145. if(node.fireEvent("beforemove", node.getOwnerTree(), node, oldParent, this, index) === false){
  9146. return false;
  9147. }
  9148. oldParent.removeChild(node);
  9149. }
  9150. index = this.childNodes.length;
  9151. if(index == 0){
  9152. this.setFirstChild(node);
  9153. }
  9154. this.childNodes.push(node);
  9155. node.parentNode = this;
  9156. var ps = this.childNodes[index-1];
  9157. if(ps){
  9158. node.previousSibling = ps;
  9159. ps.nextSibling = node;
  9160. }else{
  9161. node.previousSibling = null;
  9162. }
  9163. node.nextSibling = null;
  9164. this.setLastChild(node);
  9165. node.setOwnerTree(this.getOwnerTree());
  9166. this.fireEvent("append", this.ownerTree, this, node, index);
  9167. if(oldParent){
  9168. node.fireEvent("move", this.ownerTree, node, oldParent, this, index);
  9169. }
  9170. return node;
  9171. }
  9172. },
  9173. removeChild : function(node){
  9174. var index = this.childNodes.indexOf(node);
  9175. if(index == -1){
  9176. return false;
  9177. }
  9178. if(this.fireEvent("beforeremove", this.ownerTree, this, node) === false){
  9179. return false;
  9180. }
  9181. this.childNodes.splice(index, 1);
  9182. if(node.previousSibling){
  9183. node.previousSibling.nextSibling = node.nextSibling;
  9184. }
  9185. if(node.nextSibling){
  9186. node.nextSibling.previousSibling = node.previousSibling;
  9187. }
  9188. if(this.firstChild == node){
  9189. this.setFirstChild(node.nextSibling);
  9190. }
  9191. if(this.lastChild == node){
  9192. this.setLastChild(node.previousSibling);
  9193. }
  9194. node.setOwnerTree(null);
  9195. node.parentNode = null;
  9196. node.previousSibling = null;
  9197. node.nextSibling = null;
  9198. this.fireEvent("remove", this.ownerTree, this, node);
  9199. return node;
  9200. },
  9201. insertBefore : function(node, refNode){
  9202. if(!refNode){
  9203. return this.appendChild(node);
  9204. }
  9205. if(node == refNode){
  9206. return false;
  9207. }
  9208. if(this.fireEvent("beforeinsert", this.ownerTree, this, node, refNode) === false){
  9209. return false;
  9210. }
  9211. var index = this.childNodes.indexOf(refNode);
  9212. var oldParent = node.parentNode;
  9213. var refIndex = index;
  9214. if(oldParent == this && this.childNodes.indexOf(node) < index){
  9215. refIndex--;
  9216. }
  9217. if(oldParent){
  9218. if(node.fireEvent("beforemove", node.getOwnerTree(), node, oldParent, this, index, refNode) === false){
  9219. return false;
  9220. }
  9221. oldParent.removeChild(node);
  9222. }
  9223. if(refIndex == 0){
  9224. this.setFirstChild(node);
  9225. }
  9226. this.childNodes.splice(refIndex, 0, node);
  9227. node.parentNode = this;
  9228. var ps = this.childNodes[refIndex-1];
  9229. if(ps){
  9230. node.previousSibling = ps;
  9231. ps.nextSibling = node;
  9232. }else{
  9233. node.previousSibling = null;
  9234. }
  9235. node.nextSibling = refNode;
  9236. refNode.previousSibling = node;
  9237. node.setOwnerTree(this.getOwnerTree());
  9238. this.fireEvent("insert", this.ownerTree, this, node, refNode);
  9239. if(oldParent){
  9240. node.fireEvent("move", this.ownerTree, node, oldParent, this, refIndex, refNode);
  9241. }
  9242. return node;
  9243. },
  9244. remove : function(){
  9245. this.parentNode.removeChild(this);
  9246. return this;
  9247. },
  9248. item : function(index){
  9249. return this.childNodes[index];
  9250. },
  9251. replaceChild : function(newChild, oldChild){
  9252. this.insertBefore(newChild, oldChild);
  9253. this.removeChild(oldChild);
  9254. return oldChild;
  9255. },
  9256. indexOf : function(child){
  9257. return this.childNodes.indexOf(child);
  9258. },
  9259. getOwnerTree : function(){
  9260. if(!this.ownerTree){
  9261. var p = this;
  9262. while(p){
  9263. if(p.ownerTree){
  9264. this.ownerTree = p.ownerTree;
  9265. break;
  9266. }
  9267. p = p.parentNode;
  9268. }
  9269. }
  9270. return this.ownerTree;
  9271. },
  9272. getDepth : function(){
  9273. var depth = 0;
  9274. var p = this;
  9275. while(p.parentNode){
  9276. ++depth;
  9277. p = p.parentNode;
  9278. }
  9279. return depth;
  9280. },
  9281. setOwnerTree : function(tree){
  9282. if(tree != this.ownerTree){
  9283. if(this.ownerTree){
  9284. this.ownerTree.unregisterNode(this);
  9285. }
  9286. this.ownerTree = tree;
  9287. var cs = this.childNodes;
  9288. for(var i = 0, len = cs.length; i < len; i++) {
  9289. cs[i].setOwnerTree(tree);
  9290. }
  9291. if(tree){
  9292. tree.registerNode(this);
  9293. }
  9294. }
  9295. },
  9296. getPath : function(attr){
  9297. attr = attr || "id";
  9298. var p = this.parentNode;
  9299. var b = [this.attributes[attr]];
  9300. while(p){
  9301. b.unshift(p.attributes[attr]);
  9302. p = p.parentNode;
  9303. }
  9304. var sep = this.getOwnerTree().pathSeparator;
  9305. return sep + b.join(sep);
  9306. },
  9307. bubble : function(fn, scope, args){
  9308. var p = this;
  9309. while(p){
  9310. if(fn.apply(scope || p, args || [p]) === false){
  9311. break;
  9312. }
  9313. p = p.parentNode;
  9314. }
  9315. },
  9316. cascade : function(fn, scope, args){
  9317. if(fn.apply(scope || this, args || [this]) !== false){
  9318. var cs = this.childNodes;
  9319. for(var i = 0, len = cs.length; i < len; i++) {
  9320. cs[i].cascade(fn, scope, args);
  9321. }
  9322. }
  9323. },
  9324. eachChild : function(fn, scope, args){
  9325. var cs = this.childNodes;
  9326. for(var i = 0, len = cs.length; i < len; i++) {
  9327. if(fn.apply(scope || this, args || [cs[i]]) === false){
  9328. break;
  9329. }
  9330. }
  9331. },
  9332. findChild : function(attribute, value){
  9333. var cs = this.childNodes;
  9334. for(var i = 0, len = cs.length; i < len; i++) {
  9335. if(cs[i].attributes[attribute] == value){
  9336. return cs[i];
  9337. }
  9338. }
  9339. return null;
  9340. },
  9341. findChildBy : function(fn, scope){
  9342. var cs = this.childNodes;
  9343. for(var i = 0, len = cs.length; i < len; i++) {
  9344. if(fn.call(scope||cs[i], cs[i]) === true){
  9345. return cs[i];
  9346. }
  9347. }
  9348. return null;
  9349. },
  9350. sort : function(fn, scope){
  9351. var cs = this.childNodes;
  9352. var len = cs.length;
  9353. if(len > 0){
  9354. var sortFn = scope ? function(){fn.apply(scope, arguments);} : fn;
  9355. cs.sort(sortFn);
  9356. for(var i = 0; i < len; i++){
  9357. var n = cs[i];
  9358. n.previousSibling = cs[i-1];
  9359. n.nextSibling = cs[i+1];
  9360. if(i == 0){
  9361. this.setFirstChild(n);
  9362. }
  9363. if(i == len-1){
  9364. this.setLastChild(n);
  9365. }
  9366. }
  9367. }
  9368. },
  9369. contains : function(node){
  9370. return node.isAncestor(this);
  9371. },
  9372. isAncestor : function(node){
  9373. var p = this.parentNode;
  9374. while(p){
  9375. if(p == node){
  9376. return true;
  9377. }
  9378. p = p.parentNode;
  9379. }
  9380. return false;
  9381. },
  9382. toString : function(){
  9383. return "[Node"+(this.id?" "+this.id:"")+"]";
  9384. }
  9385. });
  9386. Ext.data.GroupingStore = Ext.extend(Ext.data.Store, {
  9387. remoteGroup : false,
  9388. groupOnSort:false,
  9389. clearGrouping : function(){
  9390. this.groupField = false;
  9391. if(this.remoteGroup){
  9392. if(this.baseParams){
  9393. delete this.baseParams.groupBy;
  9394. }
  9395. this.reload();
  9396. }else{
  9397. this.applySort();
  9398. this.fireEvent('datachanged', this);
  9399. }
  9400. },
  9401. groupBy : function(field, forceRegroup){
  9402. if(this.groupField == field && !forceRegroup){
  9403. return;
  9404. }
  9405. this.groupField = field;
  9406. if(this.remoteGroup){
  9407. if(!this.baseParams){
  9408. this.baseParams = {};
  9409. }
  9410. this.baseParams['groupBy'] = field;
  9411. }
  9412. if(this.groupOnSort){
  9413. this.sort(field);
  9414. return;
  9415. }
  9416. if(this.remoteGroup){
  9417. this.reload();
  9418. }else{
  9419. var si = this.sortInfo || {};
  9420. if(si.field != field){
  9421. this.applySort();
  9422. }else{
  9423. this.sortData(field);
  9424. }
  9425. this.fireEvent('datachanged', this);
  9426. }
  9427. },
  9428. applySort : function(){
  9429. Ext.data.GroupingStore.superclass.applySort.call(this);
  9430. if(!this.groupOnSort && !this.remoteGroup){
  9431. var gs = this.getGroupState();
  9432. if(gs && gs != this.sortInfo.field){
  9433. this.sortData(this.groupField);
  9434. }
  9435. }
  9436. },
  9437. applyGrouping : function(alwaysFireChange){
  9438. if(this.groupField !== false){
  9439. this.groupBy(this.groupField, true);
  9440. return true;
  9441. }else{
  9442. if(alwaysFireChange === true){
  9443. this.fireEvent('datachanged', this);
  9444. }
  9445. return false;
  9446. }
  9447. },
  9448. getGroupState : function(){
  9449. return this.groupOnSort && this.groupField !== false ?
  9450. (this.sortInfo ? this.sortInfo.field : undefined) : this.groupField;
  9451. }
  9452. });
  9453. Ext.ComponentMgr = function(){
  9454. var all = new Ext.util.MixedCollection();
  9455. var types = {};
  9456. return {
  9457. register : function(c){
  9458. all.add(c);
  9459. },
  9460. unregister : function(c){
  9461. all.remove(c);
  9462. },
  9463. get : function(id){
  9464. return all.get(id);
  9465. },
  9466. onAvailable : function(id, fn, scope){
  9467. all.on("add", function(index, o){
  9468. if(o.id == id){
  9469. fn.call(scope || o, o);
  9470. all.un("add", fn, scope);
  9471. }
  9472. });
  9473. },
  9474. all : all,
  9475. registerType : function(xtype, cls){
  9476. types[xtype] = cls;
  9477. cls.xtype = xtype;
  9478. },
  9479. create : function(config, defaultType){
  9480. return new types[config.xtype || defaultType](config);
  9481. }
  9482. };
  9483. }();
  9484. Ext.reg = Ext.ComponentMgr.registerType;
  9485. Ext.Component = function(config){
  9486. config = config || {};
  9487. if(config.initialConfig){
  9488. if(config.isAction){ this.baseAction = config;
  9489. }
  9490. config = config.initialConfig; }else if(config.tagName || config.dom || typeof config == "string"){ config = {applyTo: config, id: config.id || config};
  9491. }
  9492. this.initialConfig = config;
  9493. Ext.apply(this, config);
  9494. this.addEvents(
  9495. 'disable',
  9496. 'enable',
  9497. 'beforeshow',
  9498. 'show',
  9499. 'beforehide',
  9500. 'hide',
  9501. 'beforerender',
  9502. 'render',
  9503. 'beforedestroy',
  9504. 'destroy',
  9505. 'beforestaterestore',
  9506. 'staterestore',
  9507. 'beforestatesave',
  9508. 'statesave'
  9509. );
  9510. this.getId();
  9511. Ext.ComponentMgr.register(this);
  9512. Ext.Component.superclass.constructor.call(this);
  9513. if(this.baseAction){
  9514. this.baseAction.addComponent(this);
  9515. }
  9516. this.initComponent();
  9517. if(this.plugins){
  9518. if(Ext.isArray(this.plugins)){
  9519. for(var i = 0, len = this.plugins.length; i < len; i++){
  9520. this.plugins[i].init(this);
  9521. }
  9522. }else{
  9523. this.plugins.init(this);
  9524. }
  9525. }
  9526. if(this.stateful !== false){
  9527. this.initState(config);
  9528. }
  9529. if(this.applyTo){
  9530. this.applyToMarkup(this.applyTo);
  9531. delete this.applyTo;
  9532. }else if(this.renderTo){
  9533. this.render(this.renderTo);
  9534. delete this.renderTo;
  9535. }
  9536. };
  9537. Ext.Component.AUTO_ID = 1000;
  9538. Ext.extend(Ext.Component, Ext.util.Observable, {
  9539. disabledClass : "x-item-disabled",
  9540. allowDomMove : true,
  9541. autoShow : false,
  9542. hideMode: 'display',
  9543. hideParent: false,
  9544. hidden : false,
  9545. disabled : false,
  9546. rendered : false,
  9547. ctype : "Ext.Component",
  9548. actionMode : "el",
  9549. getActionEl : function(){
  9550. return this[this.actionMode];
  9551. },
  9552. initComponent : Ext.emptyFn,
  9553. render : function(container, position){
  9554. if(!this.rendered && this.fireEvent("beforerender", this) !== false){
  9555. if(!container && this.el){
  9556. this.el = Ext.get(this.el);
  9557. container = this.el.dom.parentNode;
  9558. this.allowDomMove = false;
  9559. }
  9560. this.container = Ext.get(container);
  9561. if(this.ctCls){
  9562. this.container.addClass(this.ctCls);
  9563. }
  9564. this.rendered = true;
  9565. if(position !== undefined){
  9566. if(typeof position == 'number'){
  9567. position = this.container.dom.childNodes[position];
  9568. }else{
  9569. position = Ext.getDom(position);
  9570. }
  9571. }
  9572. this.onRender(this.container, position || null);
  9573. if(this.autoShow){
  9574. this.el.removeClass(['x-hidden','x-hide-' + this.hideMode]);
  9575. }
  9576. if(this.cls){
  9577. this.el.addClass(this.cls);
  9578. delete this.cls;
  9579. }
  9580. if(this.style){
  9581. this.el.applyStyles(this.style);
  9582. delete this.style;
  9583. }
  9584. this.fireEvent("render", this);
  9585. this.afterRender(this.container);
  9586. if(this.hidden){
  9587. this.hide();
  9588. }
  9589. if(this.disabled){
  9590. this.disable();
  9591. }
  9592. this.initStateEvents();
  9593. }
  9594. return this;
  9595. },
  9596. initState : function(config){
  9597. if(Ext.state.Manager){
  9598. var state = Ext.state.Manager.get(this.stateId || this.id);
  9599. if(state){
  9600. if(this.fireEvent('beforestaterestore', this, state) !== false){
  9601. this.applyState(state);
  9602. this.fireEvent('staterestore', this, state);
  9603. }
  9604. }
  9605. }
  9606. },
  9607. initStateEvents : function(){
  9608. if(this.stateEvents){
  9609. for(var i = 0, e; e = this.stateEvents[i]; i++){
  9610. this.on(e, this.saveState, this, {delay:100});
  9611. }
  9612. }
  9613. },
  9614. applyState : function(state, config){
  9615. if(state){
  9616. Ext.apply(this, state);
  9617. }
  9618. },
  9619. getState : function(){
  9620. return null;
  9621. },
  9622. saveState : function(){
  9623. if(Ext.state.Manager){
  9624. var state = this.getState();
  9625. if(this.fireEvent('beforestatesave', this, state) !== false){
  9626. Ext.state.Manager.set(this.stateId || this.id, state);
  9627. this.fireEvent('statesave', this, state);
  9628. }
  9629. }
  9630. },
  9631. applyToMarkup : function(el){
  9632. this.allowDomMove = false;
  9633. this.el = Ext.get(el);
  9634. this.render(this.el.dom.parentNode);
  9635. },
  9636. addClass : function(cls){
  9637. if(this.el){
  9638. this.el.addClass(cls);
  9639. }else{
  9640. this.cls = this.cls ? this.cls + ' ' + cls : cls;
  9641. }
  9642. },
  9643. removeClass : function(cls){
  9644. if(this.el){
  9645. this.el.removeClass(cls);
  9646. }else if(this.cls){
  9647. this.cls = this.cls.split(' ').remove(cls).join(' ');
  9648. }
  9649. },
  9650. onRender : function(ct, position){
  9651. if(this.autoEl){
  9652. if(typeof this.autoEl == 'string'){
  9653. this.el = document.createElement(this.autoEl);
  9654. }else{
  9655. var div = document.createElement('div');
  9656. Ext.DomHelper.overwrite(div, this.autoEl);
  9657. this.el = div.firstChild;
  9658. }
  9659. if (!this.el.id) {
  9660. this.el.id = this.getId();
  9661. }
  9662. }
  9663. if(this.el){
  9664. this.el = Ext.get(this.el);
  9665. if(this.allowDomMove !== false){
  9666. ct.dom.insertBefore(this.el.dom, position);
  9667. }
  9668. }
  9669. },
  9670. getAutoCreate : function(){
  9671. var cfg = typeof this.autoCreate == "object" ?
  9672. this.autoCreate : Ext.apply({}, this.defaultAutoCreate);
  9673. if(this.id && !cfg.id){
  9674. cfg.id = this.id;
  9675. }
  9676. return cfg;
  9677. },
  9678. afterRender : Ext.emptyFn,
  9679. destroy : function(){
  9680. if(this.fireEvent("beforedestroy", this) !== false){
  9681. this.beforeDestroy();
  9682. if(this.rendered){
  9683. this.el.removeAllListeners();
  9684. this.el.remove();
  9685. if(this.actionMode == "container"){
  9686. this.container.remove();
  9687. }
  9688. }
  9689. this.onDestroy();
  9690. Ext.ComponentMgr.unregister(this);
  9691. this.fireEvent("destroy", this);
  9692. this.purgeListeners();
  9693. }
  9694. },
  9695. beforeDestroy : Ext.emptyFn,
  9696. onDestroy : Ext.emptyFn,
  9697. getEl : function(){
  9698. return this.el;
  9699. },
  9700. getId : function(){
  9701. return this.id || (this.id = "ext-comp-" + (++Ext.Component.AUTO_ID));
  9702. },
  9703. getItemId : function(){
  9704. return this.itemId || this.getId();
  9705. },
  9706. focus : function(selectText, delay){
  9707. if(delay){
  9708. this.focus.defer(typeof delay == 'number' ? delay : 10, this, [selectText, false]);
  9709. return;
  9710. }
  9711. if(this.rendered){
  9712. this.el.focus();
  9713. if(selectText === true){
  9714. this.el.dom.select();
  9715. }
  9716. }
  9717. return this;
  9718. },
  9719. blur : function(){
  9720. if(this.rendered){
  9721. this.el.blur();
  9722. }
  9723. return this;
  9724. },
  9725. disable : function(){
  9726. if(this.rendered){
  9727. this.onDisable();
  9728. }
  9729. this.disabled = true;
  9730. this.fireEvent("disable", this);
  9731. return this;
  9732. },
  9733. onDisable : function(){
  9734. this.getActionEl().addClass(this.disabledClass);
  9735. this.el.dom.disabled = true;
  9736. },
  9737. enable : function(){
  9738. if(this.rendered){
  9739. this.onEnable();
  9740. }
  9741. this.disabled = false;
  9742. this.fireEvent("enable", this);
  9743. return this;
  9744. },
  9745. onEnable : function(){
  9746. this.getActionEl().removeClass(this.disabledClass);
  9747. this.el.dom.disabled = false;
  9748. },
  9749. setDisabled : function(disabled){
  9750. this[disabled ? "disable" : "enable"]();
  9751. },
  9752. show: function(){
  9753. if(this.fireEvent("beforeshow", this) !== false){
  9754. this.hidden = false;
  9755. if(this.autoRender){
  9756. this.render(typeof this.autoRender == 'boolean' ? Ext.getBody() : this.autoRender);
  9757. }
  9758. if(this.rendered){
  9759. this.onShow();
  9760. }
  9761. this.fireEvent("show", this);
  9762. }
  9763. return this;
  9764. },
  9765. onShow : function(){
  9766. if(this.hideParent){
  9767. this.container.removeClass('x-hide-' + this.hideMode);
  9768. }else{
  9769. this.getActionEl().removeClass('x-hide-' + this.hideMode);
  9770. }
  9771. },
  9772. hide: function(){
  9773. if(this.fireEvent("beforehide", this) !== false){
  9774. this.hidden = true;
  9775. if(this.rendered){
  9776. this.onHide();
  9777. }
  9778. this.fireEvent("hide", this);
  9779. }
  9780. return this;
  9781. },
  9782. onHide : function(){
  9783. if(this.hideParent){
  9784. this.container.addClass('x-hide-' + this.hideMode);
  9785. }else{
  9786. this.getActionEl().addClass('x-hide-' + this.hideMode);
  9787. }
  9788. },
  9789. setVisible: function(visible){
  9790. if(visible) {
  9791. this.show();
  9792. }else{
  9793. this.hide();
  9794. }
  9795. return this;
  9796. },
  9797. isVisible : function(){
  9798. return this.rendered && this.getActionEl().isVisible();
  9799. },
  9800. cloneConfig : function(overrides){
  9801. overrides = overrides || {};
  9802. var id = overrides.id || Ext.id();
  9803. var cfg = Ext.applyIf(overrides, this.initialConfig);
  9804. cfg.id = id; return new this.constructor(cfg);
  9805. },
  9806. getXType : function(){
  9807. return this.constructor.xtype;
  9808. },
  9809. isXType : function(xtype, shallow){
  9810. return !shallow ?
  9811. ('/' + this.getXTypes() + '/').indexOf('/' + xtype + '/') != -1 :
  9812. this.constructor.xtype == xtype;
  9813. },
  9814. getXTypes : function(){
  9815. var tc = this.constructor;
  9816. if(!tc.xtypes){
  9817. var c = [], sc = this;
  9818. while(sc && sc.constructor.xtype){
  9819. c.unshift(sc.constructor.xtype);
  9820. sc = sc.constructor.superclass;
  9821. }
  9822. tc.xtypeChain = c;
  9823. tc.xtypes = c.join('/');
  9824. }
  9825. return tc.xtypes;
  9826. },
  9827. findParentBy: function(fn) {
  9828. for (var p = this.ownerCt; (p != null) && !fn(p, this); p = p.ownerCt);
  9829. return p || null;
  9830. },
  9831. findParentByType: function(xtype) {
  9832. return typeof xtype == 'function' ?
  9833. this.findParentBy(function(p){
  9834. return p.constructor === xtype;
  9835. }) :
  9836. this.findParentBy(function(p){
  9837. return p.constructor.xtype === xtype;
  9838. });
  9839. }
  9840. });
  9841. Ext.reg('component', Ext.Component);
  9842. Ext.Action = function(config){
  9843. this.initialConfig = config;
  9844. this.items = [];
  9845. }
  9846. Ext.Action.prototype = {
  9847. isAction : true,
  9848. setText : function(text){
  9849. this.initialConfig.text = text;
  9850. this.callEach('setText', [text]);
  9851. },
  9852. getText : function(){
  9853. return this.initialConfig.text;
  9854. },
  9855. setIconClass : function(cls){
  9856. this.initialConfig.iconCls = cls;
  9857. this.callEach('setIconClass', [cls]);
  9858. },
  9859. getIconClass : function(){
  9860. return this.initialConfig.iconCls;
  9861. },
  9862. setDisabled : function(v){
  9863. this.initialConfig.disabled = v;
  9864. this.callEach('setDisabled', [v]);
  9865. },
  9866. enable : function(){
  9867. this.setDisabled(false);
  9868. },
  9869. disable : function(){
  9870. this.setDisabled(true);
  9871. },
  9872. isDisabled : function(){
  9873. return this.initialConfig.disabled;
  9874. },
  9875. setHidden : function(v){
  9876. this.initialConfig.hidden = v;
  9877. this.callEach('setVisible', [!v]);
  9878. },
  9879. show : function(){
  9880. this.setHidden(false);
  9881. },
  9882. hide : function(){
  9883. this.setHidden(true);
  9884. },
  9885. isHidden : function(){
  9886. return this.initialConfig.hidden;
  9887. },
  9888. setHandler : function(fn, scope){
  9889. this.initialConfig.handler = fn;
  9890. this.initialConfig.scope = scope;
  9891. this.callEach('setHandler', [fn, scope]);
  9892. },
  9893. each : function(fn, scope){
  9894. Ext.each(this.items, fn, scope);
  9895. },
  9896. callEach : function(fnName, args){
  9897. var cs = this.items;
  9898. for(var i = 0, len = cs.length; i < len; i++){
  9899. cs[i][fnName].apply(cs[i], args);
  9900. }
  9901. },
  9902. addComponent : function(comp){
  9903. this.items.push(comp);
  9904. comp.on('destroy', this.removeComponent, this);
  9905. },
  9906. removeComponent : function(comp){
  9907. this.items.remove(comp);
  9908. },
  9909. execute : function(){
  9910. this.initialConfig.handler.apply(this.initialConfig.scope || window, arguments);
  9911. }
  9912. };
  9913. (function(){
  9914. Ext.Layer = function(config, existingEl){
  9915. config = config || {};
  9916. var dh = Ext.DomHelper;
  9917. var cp = config.parentEl, pel = cp ? Ext.getDom(cp) : document.body;
  9918. if(existingEl){
  9919. this.dom = Ext.getDom(existingEl);
  9920. }
  9921. if(!this.dom){
  9922. var o = config.dh || {tag: "div", cls: "x-layer"};
  9923. this.dom = dh.append(pel, o);
  9924. }
  9925. if(config.cls){
  9926. this.addClass(config.cls);
  9927. }
  9928. this.constrain = config.constrain !== false;
  9929. this.visibilityMode = Ext.Element.VISIBILITY;
  9930. if(config.id){
  9931. this.id = this.dom.id = config.id;
  9932. }else{
  9933. this.id = Ext.id(this.dom);
  9934. }
  9935. this.zindex = config.zindex || this.getZIndex();
  9936. this.position("absolute", this.zindex);
  9937. if(config.shadow){
  9938. this.shadowOffset = config.shadowOffset || 4;
  9939. this.shadow = new Ext.Shadow({
  9940. offset : this.shadowOffset,
  9941. mode : config.shadow
  9942. });
  9943. }else{
  9944. this.shadowOffset = 0;
  9945. }
  9946. this.useShim = config.shim !== false && Ext.useShims;
  9947. this.useDisplay = config.useDisplay;
  9948. this.hide();
  9949. };
  9950. var supr = Ext.Element.prototype;
  9951. var shims = [];
  9952. Ext.extend(Ext.Layer, Ext.Element, {
  9953. getZIndex : function(){
  9954. return this.zindex || parseInt(this.getStyle("z-index"), 10) || 11000;
  9955. },
  9956. getShim : function(){
  9957. if(!this.useShim){
  9958. return null;
  9959. }
  9960. if(this.shim){
  9961. return this.shim;
  9962. }
  9963. var shim = shims.shift();
  9964. if(!shim){
  9965. shim = this.createShim();
  9966. shim.enableDisplayMode('block');
  9967. shim.dom.style.display = 'none';
  9968. shim.dom.style.visibility = 'visible';
  9969. }
  9970. var pn = this.dom.parentNode;
  9971. if(shim.dom.parentNode != pn){
  9972. pn.insertBefore(shim.dom, this.dom);
  9973. }
  9974. shim.setStyle('z-index', this.getZIndex()-2);
  9975. this.shim = shim;
  9976. return shim;
  9977. },
  9978. hideShim : function(){
  9979. if(this.shim){
  9980. this.shim.setDisplayed(false);
  9981. shims.push(this.shim);
  9982. delete this.shim;
  9983. }
  9984. },
  9985. disableShadow : function(){
  9986. if(this.shadow){
  9987. this.shadowDisabled = true;
  9988. this.shadow.hide();
  9989. this.lastShadowOffset = this.shadowOffset;
  9990. this.shadowOffset = 0;
  9991. }
  9992. },
  9993. enableShadow : function(show){
  9994. if(this.shadow){
  9995. this.shadowDisabled = false;
  9996. this.shadowOffset = this.lastShadowOffset;
  9997. delete this.lastShadowOffset;
  9998. if(show){
  9999. this.sync(true);
  10000. }
  10001. }
  10002. },
  10003. sync : function(doShow){
  10004. var sw = this.shadow;
  10005. if(!this.updating && this.isVisible() && (sw || this.useShim)){
  10006. var sh = this.getShim();
  10007. var w = this.getWidth(),
  10008. h = this.getHeight();
  10009. var l = this.getLeft(true),
  10010. t = this.getTop(true);
  10011. if(sw && !this.shadowDisabled){
  10012. if(doShow && !sw.isVisible()){
  10013. sw.show(this);
  10014. }else{
  10015. sw.realign(l, t, w, h);
  10016. }
  10017. if(sh){
  10018. if(doShow){
  10019. sh.show();
  10020. }
  10021. var a = sw.adjusts, s = sh.dom.style;
  10022. s.left = (Math.min(l, l+a.l))+"px";
  10023. s.top = (Math.min(t, t+a.t))+"px";
  10024. s.width = (w+a.w)+"px";
  10025. s.height = (h+a.h)+"px";
  10026. }
  10027. }else if(sh){
  10028. if(doShow){
  10029. sh.show();
  10030. }
  10031. sh.setSize(w, h);
  10032. sh.setLeftTop(l, t);
  10033. }
  10034. }
  10035. },
  10036. destroy : function(){
  10037. this.hideShim();
  10038. if(this.shadow){
  10039. this.shadow.hide();
  10040. }
  10041. this.removeAllListeners();
  10042. Ext.removeNode(this.dom);
  10043. Ext.Element.uncache(this.id);
  10044. },
  10045. remove : function(){
  10046. this.destroy();
  10047. },
  10048. beginUpdate : function(){
  10049. this.updating = true;
  10050. },
  10051. endUpdate : function(){
  10052. this.updating = false;
  10053. this.sync(true);
  10054. },
  10055. hideUnders : function(negOffset){
  10056. if(this.shadow){
  10057. this.shadow.hide();
  10058. }
  10059. this.hideShim();
  10060. },
  10061. constrainXY : function(){
  10062. if(this.constrain){
  10063. var vw = Ext.lib.Dom.getViewWidth(),
  10064. vh = Ext.lib.Dom.getViewHeight();
  10065. var s = Ext.getDoc().getScroll();
  10066. var xy = this.getXY();
  10067. var x = xy[0], y = xy[1];
  10068. var w = this.dom.offsetWidth+this.shadowOffset, h = this.dom.offsetHeight+this.shadowOffset;
  10069. var moved = false;
  10070. if((x + w) > vw+s.left){
  10071. x = vw - w - this.shadowOffset;
  10072. moved = true;
  10073. }
  10074. if((y + h) > vh+s.top){
  10075. y = vh - h - this.shadowOffset;
  10076. moved = true;
  10077. }
  10078. if(x < s.left){
  10079. x = s.left;
  10080. moved = true;
  10081. }
  10082. if(y < s.top){
  10083. y = s.top;
  10084. moved = true;
  10085. }
  10086. if(moved){
  10087. if(this.avoidY){
  10088. var ay = this.avoidY;
  10089. if(y <= ay && (y+h) >= ay){
  10090. y = ay-h-5;
  10091. }
  10092. }
  10093. xy = [x, y];
  10094. this.storeXY(xy);
  10095. supr.setXY.call(this, xy);
  10096. this.sync();
  10097. }
  10098. }
  10099. },
  10100. isVisible : function(){
  10101. return this.visible;
  10102. },
  10103. showAction : function(){
  10104. this.visible = true;
  10105. if(this.useDisplay === true){
  10106. this.setDisplayed("");
  10107. }else if(this.lastXY){
  10108. supr.setXY.call(this, this.lastXY);
  10109. }else if(this.lastLT){
  10110. supr.setLeftTop.call(this, this.lastLT[0], this.lastLT[1]);
  10111. }
  10112. },
  10113. hideAction : function(){
  10114. this.visible = false;
  10115. if(this.useDisplay === true){
  10116. this.setDisplayed(false);
  10117. }else{
  10118. this.setLeftTop(-10000,-10000);
  10119. }
  10120. },
  10121. setVisible : function(v, a, d, c, e){
  10122. if(v){
  10123. this.showAction();
  10124. }
  10125. if(a && v){
  10126. var cb = function(){
  10127. this.sync(true);
  10128. if(c){
  10129. c();
  10130. }
  10131. }.createDelegate(this);
  10132. supr.setVisible.call(this, true, true, d, cb, e);
  10133. }else{
  10134. if(!v){
  10135. this.hideUnders(true);
  10136. }
  10137. var cb = c;
  10138. if(a){
  10139. cb = function(){
  10140. this.hideAction();
  10141. if(c){
  10142. c();
  10143. }
  10144. }.createDelegate(this);
  10145. }
  10146. supr.setVisible.call(this, v, a, d, cb, e);
  10147. if(v){
  10148. this.sync(true);
  10149. }else if(!a){
  10150. this.hideAction();
  10151. }
  10152. }
  10153. },
  10154. storeXY : function(xy){
  10155. delete this.lastLT;
  10156. this.lastXY = xy;
  10157. },
  10158. storeLeftTop : function(left, top){
  10159. delete this.lastXY;
  10160. this.lastLT = [left, top];
  10161. },
  10162. beforeFx : function(){
  10163. this.beforeAction();
  10164. return Ext.Layer.superclass.beforeFx.apply(this, arguments);
  10165. },
  10166. afterFx : function(){
  10167. Ext.Layer.superclass.afterFx.apply(this, arguments);
  10168. this.sync(this.isVisible());
  10169. },
  10170. beforeAction : function(){
  10171. if(!this.updating && this.shadow){
  10172. this.shadow.hide();
  10173. }
  10174. },
  10175. setLeft : function(left){
  10176. this.storeLeftTop(left, this.getTop(true));
  10177. supr.setLeft.apply(this, arguments);
  10178. this.sync();
  10179. },
  10180. setTop : function(top){
  10181. this.storeLeftTop(this.getLeft(true), top);
  10182. supr.setTop.apply(this, arguments);
  10183. this.sync();
  10184. },
  10185. setLeftTop : function(left, top){
  10186. this.storeLeftTop(left, top);
  10187. supr.setLeftTop.apply(this, arguments);
  10188. this.sync();
  10189. },
  10190. setXY : function(xy, a, d, c, e){
  10191. this.fixDisplay();
  10192. this.beforeAction();
  10193. this.storeXY(xy);
  10194. var cb = this.createCB(c);
  10195. supr.setXY.call(this, xy, a, d, cb, e);
  10196. if(!a){
  10197. cb();
  10198. }
  10199. },
  10200. createCB : function(c){
  10201. var el = this;
  10202. return function(){
  10203. el.constrainXY();
  10204. el.sync(true);
  10205. if(c){
  10206. c();
  10207. }
  10208. };
  10209. },
  10210. setX : function(x, a, d, c, e){
  10211. this.setXY([x, this.getY()], a, d, c, e);
  10212. },
  10213. setY : function(y, a, d, c, e){
  10214. this.setXY([this.getX(), y], a, d, c, e);
  10215. },
  10216. setSize : function(w, h, a, d, c, e){
  10217. this.beforeAction();
  10218. var cb = this.createCB(c);
  10219. supr.setSize.call(this, w, h, a, d, cb, e);
  10220. if(!a){
  10221. cb();
  10222. }
  10223. },
  10224. setWidth : function(w, a, d, c, e){
  10225. this.beforeAction();
  10226. var cb = this.createCB(c);
  10227. supr.setWidth.call(this, w, a, d, cb, e);
  10228. if(!a){
  10229. cb();
  10230. }
  10231. },
  10232. setHeight : function(h, a, d, c, e){
  10233. this.beforeAction();
  10234. var cb = this.createCB(c);
  10235. supr.setHeight.call(this, h, a, d, cb, e);
  10236. if(!a){
  10237. cb();
  10238. }
  10239. },
  10240. setBounds : function(x, y, w, h, a, d, c, e){
  10241. this.beforeAction();
  10242. var cb = this.createCB(c);
  10243. if(!a){
  10244. this.storeXY([x, y]);
  10245. supr.setXY.call(this, [x, y]);
  10246. supr.setSize.call(this, w, h, a, d, cb, e);
  10247. cb();
  10248. }else{
  10249. supr.setBounds.call(this, x, y, w, h, a, d, cb, e);
  10250. }
  10251. return this;
  10252. },
  10253. setZIndex : function(zindex){
  10254. this.zindex = zindex;
  10255. this.setStyle("z-index", zindex + 2);
  10256. if(this.shadow){
  10257. this.shadow.setZIndex(zindex + 1);
  10258. }
  10259. if(this.shim){
  10260. this.shim.setStyle("z-index", zindex);
  10261. }
  10262. }
  10263. });
  10264. })();
  10265. Ext.Shadow = function(config){
  10266. Ext.apply(this, config);
  10267. if(typeof this.mode != "string"){
  10268. this.mode = this.defaultMode;
  10269. }
  10270. var o = this.offset, a = {h: 0};
  10271. var rad = Math.floor(this.offset/2);
  10272. switch(this.mode.toLowerCase()){ case "drop":
  10273. a.w = 0;
  10274. a.l = a.t = o;
  10275. a.t -= 1;
  10276. if(Ext.isIE){
  10277. a.l -= this.offset + rad;
  10278. a.t -= this.offset + rad;
  10279. a.w -= rad;
  10280. a.h -= rad;
  10281. a.t += 1;
  10282. }
  10283. break;
  10284. case "sides":
  10285. a.w = (o*2);
  10286. a.l = -o;
  10287. a.t = o-1;
  10288. if(Ext.isIE){
  10289. a.l -= (this.offset - rad);
  10290. a.t -= this.offset + rad;
  10291. a.l += 1;
  10292. a.w -= (this.offset - rad)*2;
  10293. a.w -= rad + 1;
  10294. a.h -= 1;
  10295. }
  10296. break;
  10297. case "frame":
  10298. a.w = a.h = (o*2);
  10299. a.l = a.t = -o;
  10300. a.t += 1;
  10301. a.h -= 2;
  10302. if(Ext.isIE){
  10303. a.l -= (this.offset - rad);
  10304. a.t -= (this.offset - rad);
  10305. a.l += 1;
  10306. a.w -= (this.offset + rad + 1);
  10307. a.h -= (this.offset + rad);
  10308. a.h += 1;
  10309. }
  10310. break;
  10311. };
  10312. this.adjusts = a;
  10313. };
  10314. Ext.Shadow.prototype = {
  10315. offset: 4,
  10316. defaultMode: "drop",
  10317. show : function(target){
  10318. target = Ext.get(target);
  10319. if(!this.el){
  10320. this.el = Ext.Shadow.Pool.pull();
  10321. if(this.el.dom.nextSibling != target.dom){
  10322. this.el.insertBefore(target);
  10323. }
  10324. }
  10325. this.el.setStyle("z-index", this.zIndex || parseInt(target.getStyle("z-index"), 10)-1);
  10326. if(Ext.isIE){
  10327. this.el.dom.style.filter="progid:DXImageTransform.Microsoft.alpha(opacity=50) progid:DXImageTransform.Microsoft.Blur(pixelradius="+(this.offset)+")";
  10328. }
  10329. this.realign(
  10330. target.getLeft(true),
  10331. target.getTop(true),
  10332. target.getWidth(),
  10333. target.getHeight()
  10334. );
  10335. this.el.dom.style.display = "block";
  10336. },
  10337. isVisible : function(){
  10338. return this.el ? true : false;
  10339. },
  10340. realign : function(l, t, w, h){
  10341. if(!this.el){
  10342. return;
  10343. }
  10344. var a = this.adjusts, d = this.el.dom, s = d.style;
  10345. var iea = 0;
  10346. s.left = (l+a.l)+"px";
  10347. s.top = (t+a.t)+"px";
  10348. var sw = (w+a.w), sh = (h+a.h), sws = sw +"px", shs = sh + "px";
  10349. if(s.width != sws || s.height != shs){
  10350. s.width = sws;
  10351. s.height = shs;
  10352. if(!Ext.isIE){
  10353. var cn = d.childNodes;
  10354. var sww = Math.max(0, (sw-12))+"px";
  10355. cn[0].childNodes[1].style.width = sww;
  10356. cn[1].childNodes[1].style.width = sww;
  10357. cn[2].childNodes[1].style.width = sww;
  10358. cn[1].style.height = Math.max(0, (sh-12))+"px";
  10359. }
  10360. }
  10361. },
  10362. hide : function(){
  10363. if(this.el){
  10364. this.el.dom.style.display = "none";
  10365. Ext.Shadow.Pool.push(this.el);
  10366. delete this.el;
  10367. }
  10368. },
  10369. setZIndex : function(z){
  10370. this.zIndex = z;
  10371. if(this.el){
  10372. this.el.setStyle("z-index", z);
  10373. }
  10374. }
  10375. };
  10376. Ext.Shadow.Pool = function(){
  10377. var p = [];
  10378. var markup = Ext.isIE ?
  10379. '<div class="x-ie-shadow"></div>' :
  10380. '<div class="x-shadow"><div class="xst"><div class="xstl"></div><div class="xstc"></div><div class="xstr"></div></div><div class="xsc"><div class="xsml"></div><div class="xsmc"></div><div class="xsmr"></div></div><div class="xsb"><div class="xsbl"></div><div class="xsbc"></div><div class="xsbr"></div></div></div>';
  10381. return {
  10382. pull : function(){
  10383. var sh = p.shift();
  10384. if(!sh){
  10385. sh = Ext.get(Ext.DomHelper.insertHtml("beforeBegin", document.body.firstChild, markup));
  10386. sh.autoBoxAdjust = false;
  10387. }
  10388. return sh;
  10389. },
  10390. push : function(sh){
  10391. p.push(sh);
  10392. }
  10393. };
  10394. }();
  10395. Ext.BoxComponent = Ext.extend(Ext.Component, {
  10396. initComponent : function(){
  10397. Ext.BoxComponent.superclass.initComponent.call(this);
  10398. this.addEvents(
  10399. 'resize',
  10400. 'move'
  10401. );
  10402. },
  10403. boxReady : false,
  10404. deferHeight: false,
  10405. setSize : function(w, h){
  10406. if(typeof w == 'object'){
  10407. h = w.height;
  10408. w = w.width;
  10409. }
  10410. if(!this.boxReady){
  10411. this.width = w;
  10412. this.height = h;
  10413. return this;
  10414. }
  10415. if(this.lastSize && this.lastSize.width == w && this.lastSize.height == h){
  10416. return this;
  10417. }
  10418. this.lastSize = {width: w, height: h};
  10419. var adj = this.adjustSize(w, h);
  10420. var aw = adj.width, ah = adj.height;
  10421. if(aw !== undefined || ah !== undefined){ var rz = this.getResizeEl();
  10422. if(!this.deferHeight && aw !== undefined && ah !== undefined){
  10423. rz.setSize(aw, ah);
  10424. }else if(!this.deferHeight && ah !== undefined){
  10425. rz.setHeight(ah);
  10426. }else if(aw !== undefined){
  10427. rz.setWidth(aw);
  10428. }
  10429. this.onResize(aw, ah, w, h);
  10430. this.fireEvent('resize', this, aw, ah, w, h);
  10431. }
  10432. return this;
  10433. },
  10434. setWidth : function(width){
  10435. return this.setSize(width);
  10436. },
  10437. setHeight : function(height){
  10438. return this.setSize(undefined, height);
  10439. },
  10440. getSize : function(){
  10441. return this.el.getSize();
  10442. },
  10443. getPosition : function(local){
  10444. if(local === true){
  10445. return [this.el.getLeft(true), this.el.getTop(true)];
  10446. }
  10447. return this.xy || this.el.getXY();
  10448. },
  10449. getBox : function(local){
  10450. var s = this.el.getSize();
  10451. if(local === true){
  10452. s.x = this.el.getLeft(true);
  10453. s.y = this.el.getTop(true);
  10454. }else{
  10455. var xy = this.xy || this.el.getXY();
  10456. s.x = xy[0];
  10457. s.y = xy[1];
  10458. }
  10459. return s;
  10460. },
  10461. updateBox : function(box){
  10462. this.setSize(box.width, box.height);
  10463. this.setPagePosition(box.x, box.y);
  10464. return this;
  10465. },
  10466. getResizeEl : function(){
  10467. return this.resizeEl || this.el;
  10468. },
  10469. getPositionEl : function(){
  10470. return this.positionEl || this.el;
  10471. },
  10472. setPosition : function(x, y){
  10473. if(x && typeof x[1] == 'number'){
  10474. y = x[1];
  10475. x = x[0];
  10476. }
  10477. this.x = x;
  10478. this.y = y;
  10479. if(!this.boxReady){
  10480. return this;
  10481. }
  10482. var adj = this.adjustPosition(x, y);
  10483. var ax = adj.x, ay = adj.y;
  10484. var el = this.getPositionEl();
  10485. if(ax !== undefined || ay !== undefined){
  10486. if(ax !== undefined && ay !== undefined){
  10487. el.setLeftTop(ax, ay);
  10488. }else if(ax !== undefined){
  10489. el.setLeft(ax);
  10490. }else if(ay !== undefined){
  10491. el.setTop(ay);
  10492. }
  10493. this.onPosition(ax, ay);
  10494. this.fireEvent('move', this, ax, ay);
  10495. }
  10496. return this;
  10497. },
  10498. setPagePosition : function(x, y){
  10499. if(x && typeof x[1] == 'number'){
  10500. y = x[1];
  10501. x = x[0];
  10502. }
  10503. this.pageX = x;
  10504. this.pageY = y;
  10505. if(!this.boxReady){
  10506. return;
  10507. }
  10508. if(x === undefined || y === undefined){ return;
  10509. }
  10510. var p = this.el.translatePoints(x, y);
  10511. this.setPosition(p.left, p.top);
  10512. return this;
  10513. },
  10514. onRender : function(ct, position){
  10515. Ext.BoxComponent.superclass.onRender.call(this, ct, position);
  10516. if(this.resizeEl){
  10517. this.resizeEl = Ext.get(this.resizeEl);
  10518. }
  10519. if(this.positionEl){
  10520. this.positionEl = Ext.get(this.positionEl);
  10521. }
  10522. },
  10523. afterRender : function(){
  10524. Ext.BoxComponent.superclass.afterRender.call(this);
  10525. this.boxReady = true;
  10526. this.setSize(this.width, this.height);
  10527. if(this.x || this.y){
  10528. this.setPosition(this.x, this.y);
  10529. }else if(this.pageX || this.pageY){
  10530. this.setPagePosition(this.pageX, this.pageY);
  10531. }
  10532. },
  10533. syncSize : function(){
  10534. delete this.lastSize;
  10535. this.setSize(this.autoWidth ? undefined : this.el.getWidth(), this.autoHeight ? undefined : this.el.getHeight());
  10536. return this;
  10537. },
  10538. onResize : function(adjWidth, adjHeight, rawWidth, rawHeight){
  10539. },
  10540. onPosition : function(x, y){
  10541. },
  10542. adjustSize : function(w, h){
  10543. if(this.autoWidth){
  10544. w = 'auto';
  10545. }
  10546. if(this.autoHeight){
  10547. h = 'auto';
  10548. }
  10549. return {width : w, height: h};
  10550. },
  10551. adjustPosition : function(x, y){
  10552. return {x : x, y: y};
  10553. }
  10554. });
  10555. Ext.reg('box', Ext.BoxComponent);
  10556. Ext.SplitBar = function(dragElement, resizingElement, orientation, placement, existingProxy){
  10557. this.el = Ext.get(dragElement, true);
  10558. this.el.dom.unselectable = "on";
  10559. this.resizingEl = Ext.get(resizingElement, true);
  10560. this.orientation = orientation || Ext.SplitBar.HORIZONTAL;
  10561. this.minSize = 0;
  10562. this.maxSize = 2000;
  10563. this.animate = false;
  10564. this.useShim = false;
  10565. this.shim = null;
  10566. if(!existingProxy){
  10567. this.proxy = Ext.SplitBar.createProxy(this.orientation);
  10568. }else{
  10569. this.proxy = Ext.get(existingProxy).dom;
  10570. }
  10571. this.dd = new Ext.dd.DDProxy(this.el.dom.id, "XSplitBars", {dragElId : this.proxy.id});
  10572. this.dd.b4StartDrag = this.onStartProxyDrag.createDelegate(this);
  10573. this.dd.endDrag = this.onEndProxyDrag.createDelegate(this);
  10574. this.dragSpecs = {};
  10575. this.adapter = new Ext.SplitBar.BasicLayoutAdapter();
  10576. this.adapter.init(this);
  10577. if(this.orientation == Ext.SplitBar.HORIZONTAL){
  10578. this.placement = placement || (this.el.getX() > this.resizingEl.getX() ? Ext.SplitBar.LEFT : Ext.SplitBar.RIGHT);
  10579. this.el.addClass("x-splitbar-h");
  10580. }else{
  10581. this.placement = placement || (this.el.getY() > this.resizingEl.getY() ? Ext.SplitBar.TOP : Ext.SplitBar.BOTTOM);
  10582. this.el.addClass("x-splitbar-v");
  10583. }
  10584. this.addEvents(
  10585. "resize",
  10586. "moved",
  10587. "beforeresize",
  10588. "beforeapply"
  10589. );
  10590. Ext.SplitBar.superclass.constructor.call(this);
  10591. };
  10592. Ext.extend(Ext.SplitBar, Ext.util.Observable, {
  10593. onStartProxyDrag : function(x, y){
  10594. this.fireEvent("beforeresize", this);
  10595. this.overlay = Ext.DomHelper.append(document.body, {cls: "x-drag-overlay", html: "&#160;"}, true);
  10596. this.overlay.unselectable();
  10597. this.overlay.setSize(Ext.lib.Dom.getViewWidth(true), Ext.lib.Dom.getViewHeight(true));
  10598. this.overlay.show();
  10599. Ext.get(this.proxy).setDisplayed("block");
  10600. var size = this.adapter.getElementSize(this);
  10601. this.activeMinSize = this.getMinimumSize();;
  10602. this.activeMaxSize = this.getMaximumSize();;
  10603. var c1 = size - this.activeMinSize;
  10604. var c2 = Math.max(this.activeMaxSize - size, 0);
  10605. if(this.orientation == Ext.SplitBar.HORIZONTAL){
  10606. this.dd.resetConstraints();
  10607. this.dd.setXConstraint(
  10608. this.placement == Ext.SplitBar.LEFT ? c1 : c2,
  10609. this.placement == Ext.SplitBar.LEFT ? c2 : c1
  10610. );
  10611. this.dd.setYConstraint(0, 0);
  10612. }else{
  10613. this.dd.resetConstraints();
  10614. this.dd.setXConstraint(0, 0);
  10615. this.dd.setYConstraint(
  10616. this.placement == Ext.SplitBar.TOP ? c1 : c2,
  10617. this.placement == Ext.SplitBar.TOP ? c2 : c1
  10618. );
  10619. }
  10620. this.dragSpecs.startSize = size;
  10621. this.dragSpecs.startPoint = [x, y];
  10622. Ext.dd.DDProxy.prototype.b4StartDrag.call(this.dd, x, y);
  10623. },
  10624. onEndProxyDrag : function(e){
  10625. Ext.get(this.proxy).setDisplayed(false);
  10626. var endPoint = Ext.lib.Event.getXY(e);
  10627. if(this.overlay){
  10628. this.overlay.remove();
  10629. delete this.overlay;
  10630. }
  10631. var newSize;
  10632. if(this.orientation == Ext.SplitBar.HORIZONTAL){
  10633. newSize = this.dragSpecs.startSize +
  10634. (this.placement == Ext.SplitBar.LEFT ?
  10635. endPoint[0] - this.dragSpecs.startPoint[0] :
  10636. this.dragSpecs.startPoint[0] - endPoint[0]
  10637. );
  10638. }else{
  10639. newSize = this.dragSpecs.startSize +
  10640. (this.placement == Ext.SplitBar.TOP ?
  10641. endPoint[1] - this.dragSpecs.startPoint[1] :
  10642. this.dragSpecs.startPoint[1] - endPoint[1]
  10643. );
  10644. }
  10645. newSize = Math.min(Math.max(newSize, this.activeMinSize), this.activeMaxSize);
  10646. if(newSize != this.dragSpecs.startSize){
  10647. if(this.fireEvent('beforeapply', this, newSize) !== false){
  10648. this.adapter.setElementSize(this, newSize);
  10649. this.fireEvent("moved", this, newSize);
  10650. this.fireEvent("resize", this, newSize);
  10651. }
  10652. }
  10653. },
  10654. getAdapter : function(){
  10655. return this.adapter;
  10656. },
  10657. setAdapter : function(adapter){
  10658. this.adapter = adapter;
  10659. this.adapter.init(this);
  10660. },
  10661. getMinimumSize : function(){
  10662. return this.minSize;
  10663. },
  10664. setMinimumSize : function(minSize){
  10665. this.minSize = minSize;
  10666. },
  10667. getMaximumSize : function(){
  10668. return this.maxSize;
  10669. },
  10670. setMaximumSize : function(maxSize){
  10671. this.maxSize = maxSize;
  10672. },
  10673. setCurrentSize : function(size){
  10674. var oldAnimate = this.animate;
  10675. this.animate = false;
  10676. this.adapter.setElementSize(this, size);
  10677. this.animate = oldAnimate;
  10678. },
  10679. destroy : function(removeEl){
  10680. if(this.shim){
  10681. this.shim.remove();
  10682. }
  10683. this.dd.unreg();
  10684. Ext.removeNode(this.proxy);
  10685. if(removeEl){
  10686. this.el.remove();
  10687. }
  10688. }
  10689. });
  10690. Ext.SplitBar.createProxy = function(dir){
  10691. var proxy = new Ext.Element(document.createElement("div"));
  10692. proxy.unselectable();
  10693. var cls = 'x-splitbar-proxy';
  10694. proxy.addClass(cls + ' ' + (dir == Ext.SplitBar.HORIZONTAL ? cls +'-h' : cls + '-v'));
  10695. document.body.appendChild(proxy.dom);
  10696. return proxy.dom;
  10697. };
  10698. Ext.SplitBar.BasicLayoutAdapter = function(){
  10699. };
  10700. Ext.SplitBar.BasicLayoutAdapter.prototype = {
  10701. init : function(s){
  10702. },
  10703. getElementSize : function(s){
  10704. if(s.orientation == Ext.SplitBar.HORIZONTAL){
  10705. return s.resizingEl.getWidth();
  10706. }else{
  10707. return s.resizingEl.getHeight();
  10708. }
  10709. },
  10710. setElementSize : function(s, newSize, onComplete){
  10711. if(s.orientation == Ext.SplitBar.HORIZONTAL){
  10712. if(!s.animate){
  10713. s.resizingEl.setWidth(newSize);
  10714. if(onComplete){
  10715. onComplete(s, newSize);
  10716. }
  10717. }else{
  10718. s.resizingEl.setWidth(newSize, true, .1, onComplete, 'easeOut');
  10719. }
  10720. }else{
  10721. if(!s.animate){
  10722. s.resizingEl.setHeight(newSize);
  10723. if(onComplete){
  10724. onComplete(s, newSize);
  10725. }
  10726. }else{
  10727. s.resizingEl.setHeight(newSize, true, .1, onComplete, 'easeOut');
  10728. }
  10729. }
  10730. }
  10731. };
  10732. Ext.SplitBar.AbsoluteLayoutAdapter = function(container){
  10733. this.basic = new Ext.SplitBar.BasicLayoutAdapter();
  10734. this.container = Ext.get(container);
  10735. };
  10736. Ext.SplitBar.AbsoluteLayoutAdapter.prototype = {
  10737. init : function(s){
  10738. this.basic.init(s);
  10739. },
  10740. getElementSize : function(s){
  10741. return this.basic.getElementSize(s);
  10742. },
  10743. setElementSize : function(s, newSize, onComplete){
  10744. this.basic.setElementSize(s, newSize, this.moveSplitter.createDelegate(this, [s]));
  10745. },
  10746. moveSplitter : function(s){
  10747. var yes = Ext.SplitBar;
  10748. switch(s.placement){
  10749. case yes.LEFT:
  10750. s.el.setX(s.resizingEl.getRight());
  10751. break;
  10752. case yes.RIGHT:
  10753. s.el.setStyle("right", (this.container.getWidth() - s.resizingEl.getLeft()) + "px");
  10754. break;
  10755. case yes.TOP:
  10756. s.el.setY(s.resizingEl.getBottom());
  10757. break;
  10758. case yes.BOTTOM:
  10759. s.el.setY(s.resizingEl.getTop() - s.el.getHeight());
  10760. break;
  10761. }
  10762. }
  10763. };
  10764. Ext.SplitBar.VERTICAL = 1;
  10765. Ext.SplitBar.HORIZONTAL = 2;
  10766. Ext.SplitBar.LEFT = 1;
  10767. Ext.SplitBar.RIGHT = 2;
  10768. Ext.SplitBar.TOP = 3;
  10769. Ext.SplitBar.BOTTOM = 4;
  10770. Ext.Container = Ext.extend(Ext.BoxComponent, {
  10771. autoDestroy: true,
  10772. defaultType: 'panel',
  10773. initComponent : function(){
  10774. Ext.Container.superclass.initComponent.call(this);
  10775. this.addEvents(
  10776. 'afterlayout',
  10777. 'beforeadd',
  10778. 'beforeremove',
  10779. 'add',
  10780. 'remove'
  10781. );
  10782. var items = this.items;
  10783. if(items){
  10784. delete this.items;
  10785. if(Ext.isArray(items)){
  10786. this.add.apply(this, items);
  10787. }else{
  10788. this.add(items);
  10789. }
  10790. }
  10791. },
  10792. initItems : function(){
  10793. if(!this.items){
  10794. this.items = new Ext.util.MixedCollection(false, this.getComponentId);
  10795. this.getLayout(); }
  10796. },
  10797. setLayout : function(layout){
  10798. if(this.layout && this.layout != layout){
  10799. this.layout.setContainer(null);
  10800. }
  10801. this.initItems();
  10802. this.layout = layout;
  10803. layout.setContainer(this);
  10804. },
  10805. render : function(){
  10806. Ext.Container.superclass.render.apply(this, arguments);
  10807. if(this.layout){
  10808. if(typeof this.layout == 'string'){
  10809. this.layout = new Ext.Container.LAYOUTS[this.layout.toLowerCase()](this.layoutConfig);
  10810. }
  10811. this.setLayout(this.layout);
  10812. if(this.activeItem !== undefined){
  10813. var item = this.activeItem;
  10814. delete this.activeItem;
  10815. this.layout.setActiveItem(item);
  10816. return;
  10817. }
  10818. }
  10819. if(!this.ownerCt){
  10820. this.doLayout();
  10821. }
  10822. if(this.monitorResize === true){
  10823. Ext.EventManager.onWindowResize(this.doLayout, this, [false]);
  10824. }
  10825. },
  10826. getLayoutTarget : function(){
  10827. return this.el;
  10828. },
  10829. getComponentId : function(comp){
  10830. return comp.itemId || comp.id;
  10831. },
  10832. add : function(comp){
  10833. if(!this.items){
  10834. this.initItems();
  10835. }
  10836. var a = arguments, len = a.length;
  10837. if(len > 1){
  10838. for(var i = 0; i < len; i++) {
  10839. this.add(a[i]);
  10840. }
  10841. return;
  10842. }
  10843. var c = this.lookupComponent(this.applyDefaults(comp));
  10844. var pos = this.items.length;
  10845. if(this.fireEvent('beforeadd', this, c, pos) !== false && this.onBeforeAdd(c) !== false){
  10846. this.items.add(c);
  10847. c.ownerCt = this;
  10848. this.fireEvent('add', this, c, pos);
  10849. }
  10850. return c;
  10851. },
  10852. insert : function(index, comp){
  10853. if(!this.items){
  10854. this.initItems();
  10855. }
  10856. var a = arguments, len = a.length;
  10857. if(len > 2){
  10858. for(var i = len-1; i >= 1; --i) {
  10859. this.insert(index, a[i]);
  10860. }
  10861. return;
  10862. }
  10863. var c = this.lookupComponent(this.applyDefaults(comp));
  10864. if(c.ownerCt == this && this.items.indexOf(c) < index){
  10865. --index;
  10866. }
  10867. if(this.fireEvent('beforeadd', this, c, index) !== false && this.onBeforeAdd(c) !== false){
  10868. this.items.insert(index, c);
  10869. c.ownerCt = this;
  10870. this.fireEvent('add', this, c, index);
  10871. }
  10872. return c;
  10873. },
  10874. applyDefaults : function(c){
  10875. if(this.defaults){
  10876. if(typeof c == 'string'){
  10877. c = Ext.ComponentMgr.get(c);
  10878. Ext.apply(c, this.defaults);
  10879. }else if(!c.events){
  10880. Ext.applyIf(c, this.defaults);
  10881. }else{
  10882. Ext.apply(c, this.defaults);
  10883. }
  10884. }
  10885. return c;
  10886. },
  10887. onBeforeAdd : function(item){
  10888. if(item.ownerCt){
  10889. item.ownerCt.remove(item, false);
  10890. }
  10891. if(this.hideBorders === true){
  10892. item.border = (item.border === true);
  10893. }
  10894. },
  10895. remove : function(comp, autoDestroy){
  10896. var c = this.getComponent(comp);
  10897. if(c && this.fireEvent('beforeremove', this, c) !== false){
  10898. this.items.remove(c);
  10899. delete c.ownerCt;
  10900. if(autoDestroy === true || (autoDestroy !== false && this.autoDestroy)){
  10901. c.destroy();
  10902. }
  10903. if(this.layout && this.layout.activeItem == c){
  10904. delete this.layout.activeItem;
  10905. }
  10906. this.fireEvent('remove', this, c);
  10907. }
  10908. return c;
  10909. },
  10910. getComponent : function(comp){
  10911. if(typeof comp == 'object'){
  10912. return comp;
  10913. }
  10914. return this.items.get(comp);
  10915. },
  10916. lookupComponent : function(comp){
  10917. if(typeof comp == 'string'){
  10918. return Ext.ComponentMgr.get(comp);
  10919. }else if(!comp.events){
  10920. return this.createComponent(comp);
  10921. }
  10922. return comp;
  10923. },
  10924. createComponent : function(config){
  10925. return Ext.ComponentMgr.create(config, this.defaultType);
  10926. },
  10927. doLayout : function(shallow){
  10928. if(this.rendered && this.layout){
  10929. this.layout.layout();
  10930. }
  10931. if(shallow !== false && this.items){
  10932. var cs = this.items.items;
  10933. for(var i = 0, len = cs.length; i < len; i++) {
  10934. var c = cs[i];
  10935. if(c.doLayout){
  10936. c.doLayout();
  10937. }
  10938. }
  10939. }
  10940. },
  10941. getLayout : function(){
  10942. if(!this.layout){
  10943. var layout = new Ext.layout.ContainerLayout(this.layoutConfig);
  10944. this.setLayout(layout);
  10945. }
  10946. return this.layout;
  10947. },
  10948. onDestroy : function(){
  10949. if(this.items){
  10950. var cs = this.items.items;
  10951. for(var i = 0, len = cs.length; i < len; i++) {
  10952. Ext.destroy(cs[i]);
  10953. }
  10954. }
  10955. if(this.monitorResize){
  10956. Ext.EventManager.removeResizeListener(this.doLayout, this);
  10957. }
  10958. Ext.Container.superclass.onDestroy.call(this);
  10959. },
  10960. bubble : function(fn, scope, args){
  10961. var p = this;
  10962. while(p){
  10963. if(fn.apply(scope || p, args || [p]) === false){
  10964. break;
  10965. }
  10966. p = p.ownerCt;
  10967. }
  10968. },
  10969. cascade : function(fn, scope, args){
  10970. if(fn.apply(scope || this, args || [this]) !== false){
  10971. if(this.items){
  10972. var cs = this.items.items;
  10973. for(var i = 0, len = cs.length; i < len; i++){
  10974. if(cs[i].cascade){
  10975. cs[i].cascade(fn, scope, args);
  10976. }else{
  10977. fn.apply(scope || this, args || [cs[i]]);
  10978. }
  10979. }
  10980. }
  10981. }
  10982. },
  10983. findById : function(id){
  10984. var m, ct = this;
  10985. this.cascade(function(c){
  10986. if(ct != c && c.id === id){
  10987. m = c;
  10988. return false;
  10989. }
  10990. });
  10991. return m || null;
  10992. },
  10993. findByType : function(xtype){
  10994. return typeof xtype == 'function' ?
  10995. this.findBy(function(c){
  10996. return c.constructor === xtype;
  10997. }) :
  10998. this.findBy(function(c){
  10999. return c.constructor.xtype === xtype;
  11000. });
  11001. },
  11002. find : function(prop, value){
  11003. return this.findBy(function(c){
  11004. return c[prop] === value;
  11005. });
  11006. },
  11007. findBy : function(fn, scope){
  11008. var m = [], ct = this;
  11009. this.cascade(function(c){
  11010. if(ct != c && fn.call(scope || c, c, ct) === true){
  11011. m.push(c);
  11012. }
  11013. });
  11014. return m;
  11015. }
  11016. });
  11017. Ext.Container.LAYOUTS = {};
  11018. Ext.reg('container', Ext.Container);
  11019. Ext.layout.ContainerLayout = function(config){
  11020. Ext.apply(this, config);
  11021. };
  11022. Ext.layout.ContainerLayout.prototype = {
  11023. monitorResize:false,
  11024. activeItem : null,
  11025. layout : function(){
  11026. var target = this.container.getLayoutTarget();
  11027. this.onLayout(this.container, target);
  11028. this.container.fireEvent('afterlayout', this.container, this);
  11029. },
  11030. onLayout : function(ct, target){
  11031. this.renderAll(ct, target);
  11032. },
  11033. isValidParent : function(c, target){
  11034. var el = c.getPositionEl ? c.getPositionEl() : c.getEl();
  11035. return el.dom.parentNode == target.dom;
  11036. },
  11037. renderAll : function(ct, target){
  11038. var items = ct.items.items;
  11039. for(var i = 0, len = items.length; i < len; i++) {
  11040. var c = items[i];
  11041. if(c && (!c.rendered || !this.isValidParent(c, target))){
  11042. this.renderItem(c, i, target);
  11043. }
  11044. }
  11045. },
  11046. renderItem : function(c, position, target){
  11047. if(c && !c.rendered){
  11048. c.render(target, position);
  11049. if(this.extraCls){
  11050. var t = c.getPositionEl ? c.getPositionEl() : c;
  11051. t.addClass(this.extraCls);
  11052. }
  11053. if (this.renderHidden && c != this.activeItem) {
  11054. c.hide();
  11055. }
  11056. }else if(c && !this.isValidParent(c, target)){
  11057. if(this.extraCls){
  11058. c.addClass(this.extraCls);
  11059. }
  11060. if(typeof position == 'number'){
  11061. position = target.dom.childNodes[position];
  11062. }
  11063. target.dom.insertBefore(c.getEl().dom, position || null);
  11064. if (this.renderHidden && c != this.activeItem) {
  11065. c.hide();
  11066. }
  11067. }
  11068. },
  11069. onResize: function(){
  11070. if(this.container.collapsed){
  11071. return;
  11072. }
  11073. var b = this.container.bufferResize;
  11074. if(b){
  11075. if(!this.resizeTask){
  11076. this.resizeTask = new Ext.util.DelayedTask(this.layout, this);
  11077. this.resizeBuffer = typeof b == 'number' ? b : 100;
  11078. }
  11079. this.resizeTask.delay(this.resizeBuffer);
  11080. }else{
  11081. this.layout();
  11082. }
  11083. },
  11084. setContainer : function(ct){
  11085. if(this.monitorResize && ct != this.container){
  11086. if(this.container){
  11087. this.container.un('resize', this.onResize, this);
  11088. }
  11089. if(ct){
  11090. ct.on('resize', this.onResize, this);
  11091. }
  11092. }
  11093. this.container = ct;
  11094. },
  11095. parseMargins : function(v){
  11096. var ms = v.split(' ');
  11097. var len = ms.length;
  11098. if(len == 1){
  11099. ms[1] = ms[0];
  11100. ms[2] = ms[0];
  11101. ms[3] = ms[0];
  11102. }
  11103. if(len == 2){
  11104. ms[2] = ms[0];
  11105. ms[3] = ms[1];
  11106. }
  11107. return {
  11108. top:parseInt(ms[0], 10) || 0,
  11109. right:parseInt(ms[1], 10) || 0,
  11110. bottom:parseInt(ms[2], 10) || 0,
  11111. left:parseInt(ms[3], 10) || 0
  11112. };
  11113. }
  11114. };
  11115. Ext.Container.LAYOUTS['auto'] = Ext.layout.ContainerLayout;
  11116. Ext.layout.FitLayout = Ext.extend(Ext.layout.ContainerLayout, {
  11117. monitorResize:true,
  11118. onLayout : function(ct, target){
  11119. Ext.layout.FitLayout.superclass.onLayout.call(this, ct, target);
  11120. if(!this.container.collapsed){
  11121. this.setItemSize(this.activeItem || ct.items.itemAt(0), target.getStyleSize());
  11122. }
  11123. },
  11124. setItemSize : function(item, size){
  11125. if(item && size.height > 0){
  11126. item.setSize(size);
  11127. }
  11128. }
  11129. });
  11130. Ext.Container.LAYOUTS['fit'] = Ext.layout.FitLayout;
  11131. Ext.layout.CardLayout = Ext.extend(Ext.layout.FitLayout, {
  11132. deferredRender : false,
  11133. renderHidden : true,
  11134. setActiveItem : function(item){
  11135. item = this.container.getComponent(item);
  11136. if(this.activeItem != item){
  11137. if(this.activeItem){
  11138. this.activeItem.hide();
  11139. }
  11140. this.activeItem = item;
  11141. item.show();
  11142. this.layout();
  11143. }
  11144. },
  11145. renderAll : function(ct, target){
  11146. if(this.deferredRender){
  11147. this.renderItem(this.activeItem, undefined, target);
  11148. }else{
  11149. Ext.layout.CardLayout.superclass.renderAll.call(this, ct, target);
  11150. }
  11151. }
  11152. });
  11153. Ext.Container.LAYOUTS['card'] = Ext.layout.CardLayout;
  11154. Ext.layout.AnchorLayout = Ext.extend(Ext.layout.ContainerLayout, {
  11155. monitorResize:true,
  11156. getAnchorViewSize : function(ct, target){
  11157. return target.dom == document.body ?
  11158. target.getViewSize() : target.getStyleSize();
  11159. },
  11160. onLayout : function(ct, target){
  11161. Ext.layout.AnchorLayout.superclass.onLayout.call(this, ct, target);
  11162. var size = this.getAnchorViewSize(ct, target);
  11163. var w = size.width, h = size.height;
  11164. if(w < 20 || h < 20){
  11165. return;
  11166. }
  11167. var aw, ah;
  11168. if(ct.anchorSize){
  11169. if(typeof ct.anchorSize == 'number'){
  11170. aw = ct.anchorSize;
  11171. }else{
  11172. aw = ct.anchorSize.width;
  11173. ah = ct.anchorSize.height;
  11174. }
  11175. }else{
  11176. aw = ct.initialConfig.width;
  11177. ah = ct.initialConfig.height;
  11178. }
  11179. var cs = ct.items.items, len = cs.length, i, c, a, cw, ch;
  11180. for(i = 0; i < len; i++){
  11181. c = cs[i];
  11182. if(c.anchor){
  11183. a = c.anchorSpec;
  11184. if(!a){
  11185. var vs = c.anchor.split(' ');
  11186. c.anchorSpec = a = {
  11187. right: this.parseAnchor(vs[0], c.initialConfig.width, aw),
  11188. bottom: this.parseAnchor(vs[1], c.initialConfig.height, ah)
  11189. };
  11190. }
  11191. cw = a.right ? this.adjustWidthAnchor(a.right(w), c) : undefined;
  11192. ch = a.bottom ? this.adjustHeightAnchor(a.bottom(h), c) : undefined;
  11193. if(cw || ch){
  11194. c.setSize(cw || undefined, ch || undefined);
  11195. }
  11196. }
  11197. }
  11198. },
  11199. parseAnchor : function(a, start, cstart){
  11200. if(a && a != 'none'){
  11201. var last;
  11202. if(/^(r|right|b|bottom)$/i.test(a)){
  11203. var diff = cstart - start;
  11204. return function(v){
  11205. if(v !== last){
  11206. last = v;
  11207. return v - diff;
  11208. }
  11209. }
  11210. }else if(a.indexOf('%') != -1){
  11211. var ratio = parseFloat(a.replace('%', ''))*.01;
  11212. return function(v){
  11213. if(v !== last){
  11214. last = v;
  11215. return Math.floor(v*ratio);
  11216. }
  11217. }
  11218. }else{
  11219. a = parseInt(a, 10);
  11220. if(!isNaN(a)){
  11221. return function(v){
  11222. if(v !== last){
  11223. last = v;
  11224. return v + a;
  11225. }
  11226. }
  11227. }
  11228. }
  11229. }
  11230. return false;
  11231. },
  11232. adjustWidthAnchor : function(value, comp){
  11233. return value;
  11234. },
  11235. adjustHeightAnchor : function(value, comp){
  11236. return value;
  11237. }
  11238. });
  11239. Ext.Container.LAYOUTS['anchor'] = Ext.layout.AnchorLayout;
  11240. Ext.layout.ColumnLayout = Ext.extend(Ext.layout.ContainerLayout, {
  11241. monitorResize:true,
  11242. extraCls: 'x-column',
  11243. scrollOffset : 0,
  11244. isValidParent : function(c, target){
  11245. return c.getEl().dom.parentNode == this.innerCt.dom;
  11246. },
  11247. onLayout : function(ct, target){
  11248. var cs = ct.items.items, len = cs.length, c, i;
  11249. if(!this.innerCt){
  11250. target.addClass('x-column-layout-ct');
  11251. this.innerCt = target.createChild({cls:'x-column-inner'});
  11252. this.innerCt.createChild({cls:'x-clear'});
  11253. }
  11254. this.renderAll(ct, this.innerCt);
  11255. var size = target.getViewSize();
  11256. if(size.width < 1 && size.height < 1){
  11257. return;
  11258. }
  11259. var w = size.width - target.getPadding('lr') - this.scrollOffset,
  11260. h = size.height - target.getPadding('tb'),
  11261. pw = w;
  11262. this.innerCt.setWidth(w);
  11263. for(i = 0; i < len; i++){
  11264. c = cs[i];
  11265. if(!c.columnWidth){
  11266. pw -= (c.getSize().width + c.getEl().getMargins('lr'));
  11267. }
  11268. }
  11269. pw = pw < 0 ? 0 : pw;
  11270. for(i = 0; i < len; i++){
  11271. c = cs[i];
  11272. if(c.columnWidth){
  11273. c.setSize(Math.floor(c.columnWidth*pw) - c.getEl().getMargins('lr'));
  11274. }
  11275. }
  11276. }
  11277. });
  11278. Ext.Container.LAYOUTS['column'] = Ext.layout.ColumnLayout;
  11279. Ext.layout.BorderLayout = Ext.extend(Ext.layout.ContainerLayout, {
  11280. monitorResize:true,
  11281. rendered : false,
  11282. onLayout : function(ct, target){
  11283. var collapsed;
  11284. if(!this.rendered){
  11285. target.position();
  11286. target.addClass('x-border-layout-ct');
  11287. var items = ct.items.items;
  11288. collapsed = [];
  11289. for(var i = 0, len = items.length; i < len; i++) {
  11290. var c = items[i];
  11291. var pos = c.region;
  11292. if(c.collapsed){
  11293. collapsed.push(c);
  11294. }
  11295. c.collapsed = false;
  11296. if(!c.rendered){
  11297. c.cls = c.cls ? c.cls +' x-border-panel' : 'x-border-panel';
  11298. c.render(target, i);
  11299. }
  11300. this[pos] = pos != 'center' && c.split ?
  11301. new Ext.layout.BorderLayout.SplitRegion(this, c.initialConfig, pos) :
  11302. new Ext.layout.BorderLayout.Region(this, c.initialConfig, pos);
  11303. this[pos].render(target, c);
  11304. }
  11305. this.rendered = true;
  11306. }
  11307. var size = target.getViewSize();
  11308. if(size.width < 20 || size.height < 20){ if(collapsed){
  11309. this.restoreCollapsed = collapsed;
  11310. }
  11311. return;
  11312. }else if(this.restoreCollapsed){
  11313. collapsed = this.restoreCollapsed;
  11314. delete this.restoreCollapsed;
  11315. }
  11316. var w = size.width, h = size.height;
  11317. var centerW = w, centerH = h, centerY = 0, centerX = 0;
  11318. var n = this.north, s = this.south, west = this.west, e = this.east, c = this.center;
  11319. if(!c){
  11320. throw 'No center region defined in BorderLayout ' + ct.id;
  11321. }
  11322. if(n && n.isVisible()){
  11323. var b = n.getSize();
  11324. var m = n.getMargins();
  11325. b.width = w - (m.left+m.right);
  11326. b.x = m.left;
  11327. b.y = m.top;
  11328. centerY = b.height + b.y + m.bottom;
  11329. centerH -= centerY;
  11330. n.applyLayout(b);
  11331. }
  11332. if(s && s.isVisible()){
  11333. var b = s.getSize();
  11334. var m = s.getMargins();
  11335. b.width = w - (m.left+m.right);
  11336. b.x = m.left;
  11337. var totalHeight = (b.height + m.top + m.bottom);
  11338. b.y = h - totalHeight + m.top;
  11339. centerH -= totalHeight;
  11340. s.applyLayout(b);
  11341. }
  11342. if(west && west.isVisible()){
  11343. var b = west.getSize();
  11344. var m = west.getMargins();
  11345. b.height = centerH - (m.top+m.bottom);
  11346. b.x = m.left;
  11347. b.y = centerY + m.top;
  11348. var totalWidth = (b.width + m.left + m.right);
  11349. centerX += totalWidth;
  11350. centerW -= totalWidth;
  11351. west.applyLayout(b);
  11352. }
  11353. if(e && e.isVisible()){
  11354. var b = e.getSize();
  11355. var m = e.getMargins();
  11356. b.height = centerH - (m.top+m.bottom);
  11357. var totalWidth = (b.width + m.left + m.right);
  11358. b.x = w - totalWidth + m.left;
  11359. b.y = centerY + m.top;
  11360. centerW -= totalWidth;
  11361. e.applyLayout(b);
  11362. }
  11363. var m = c.getMargins();
  11364. var centerBox = {
  11365. x: centerX + m.left,
  11366. y: centerY + m.top,
  11367. width: centerW - (m.left+m.right),
  11368. height: centerH - (m.top+m.bottom)
  11369. };
  11370. c.applyLayout(centerBox);
  11371. if(collapsed){
  11372. for(var i = 0, len = collapsed.length; i < len; i++){
  11373. collapsed[i].collapse(false);
  11374. }
  11375. }
  11376. if(Ext.isIE && Ext.isStrict){ target.repaint();
  11377. }
  11378. }
  11379. });
  11380. Ext.layout.BorderLayout.Region = function(layout, config, pos){
  11381. Ext.apply(this, config);
  11382. this.layout = layout;
  11383. this.position = pos;
  11384. this.state = {};
  11385. if(typeof this.margins == 'string'){
  11386. this.margins = this.layout.parseMargins(this.margins);
  11387. }
  11388. this.margins = Ext.applyIf(this.margins || {}, this.defaultMargins);
  11389. if(this.collapsible){
  11390. if(typeof this.cmargins == 'string'){
  11391. this.cmargins = this.layout.parseMargins(this.cmargins);
  11392. }
  11393. if(this.collapseMode == 'mini' && !this.cmargins){
  11394. this.cmargins = {left:0,top:0,right:0,bottom:0};
  11395. }else{
  11396. this.cmargins = Ext.applyIf(this.cmargins || {},
  11397. pos == 'north' || pos == 'south' ? this.defaultNSCMargins : this.defaultEWCMargins);
  11398. }
  11399. }
  11400. };
  11401. Ext.layout.BorderLayout.Region.prototype = {
  11402. collapsible : false,
  11403. split:false,
  11404. floatable: true,
  11405. minWidth:50,
  11406. minHeight:50,
  11407. defaultMargins : {left:0,top:0,right:0,bottom:0},
  11408. defaultNSCMargins : {left:5,top:5,right:5,bottom:5},
  11409. defaultEWCMargins : {left:5,top:0,right:5,bottom:0},
  11410. isCollapsed : false,
  11411. render : function(ct, p){
  11412. this.panel = p;
  11413. p.el.enableDisplayMode();
  11414. this.targetEl = ct;
  11415. this.el = p.el;
  11416. var gs = p.getState, ps = this.position;
  11417. p.getState = function(){
  11418. return Ext.apply(gs.call(p) || {}, this.state);
  11419. }.createDelegate(this);
  11420. if(ps != 'center'){
  11421. p.allowQueuedExpand = false;
  11422. p.on({
  11423. beforecollapse: this.beforeCollapse,
  11424. collapse: this.onCollapse,
  11425. beforeexpand: this.beforeExpand,
  11426. expand: this.onExpand,
  11427. hide: this.onHide,
  11428. show: this.onShow,
  11429. scope: this
  11430. });
  11431. if(this.collapsible){
  11432. p.collapseEl = 'el';
  11433. p.slideAnchor = this.getSlideAnchor();
  11434. }
  11435. if(p.tools && p.tools.toggle){
  11436. p.tools.toggle.addClass('x-tool-collapse-'+ps);
  11437. p.tools.toggle.addClassOnOver('x-tool-collapse-'+ps+'-over');
  11438. }
  11439. }
  11440. },
  11441. getCollapsedEl : function(){
  11442. if(!this.collapsedEl){
  11443. if(!this.toolTemplate){
  11444. var tt = new Ext.Template(
  11445. '<div class="x-tool x-tool-{id}">&#160;</div>'
  11446. );
  11447. tt.disableFormats = true;
  11448. tt.compile();
  11449. Ext.layout.BorderLayout.Region.prototype.toolTemplate = tt;
  11450. }
  11451. this.collapsedEl = this.targetEl.createChild({
  11452. cls: "x-layout-collapsed x-layout-collapsed-"+this.position,
  11453. id: this.panel.id + '-xcollapsed'
  11454. });
  11455. this.collapsedEl.enableDisplayMode('block');
  11456. if(this.collapseMode == 'mini'){
  11457. this.collapsedEl.addClass('x-layout-cmini-'+this.position);
  11458. this.miniCollapsedEl = this.collapsedEl.createChild({
  11459. cls: "x-layout-mini x-layout-mini-"+this.position, html: "&#160;"
  11460. });
  11461. this.miniCollapsedEl.addClassOnOver('x-layout-mini-over');
  11462. this.collapsedEl.addClassOnOver("x-layout-collapsed-over");
  11463. this.collapsedEl.on('click', this.onExpandClick, this, {stopEvent:true});
  11464. }else {
  11465. var t = this.toolTemplate.append(
  11466. this.collapsedEl.dom,
  11467. {id:'expand-'+this.position}, true);
  11468. t.addClassOnOver('x-tool-expand-'+this.position+'-over');
  11469. t.on('click', this.onExpandClick, this, {stopEvent:true});
  11470. if(this.floatable !== false){
  11471. this.collapsedEl.addClassOnOver("x-layout-collapsed-over");
  11472. this.collapsedEl.on("click", this.collapseClick, this);
  11473. }
  11474. }
  11475. }
  11476. return this.collapsedEl;
  11477. },
  11478. onExpandClick : function(e){
  11479. if(this.isSlid){
  11480. this.afterSlideIn();
  11481. this.panel.expand(false);
  11482. }else{
  11483. this.panel.expand();
  11484. }
  11485. },
  11486. onCollapseClick : function(e){
  11487. this.panel.collapse();
  11488. },
  11489. beforeCollapse : function(p, animate){
  11490. this.lastAnim = animate;
  11491. if(this.splitEl){
  11492. this.splitEl.hide();
  11493. }
  11494. this.getCollapsedEl().show();
  11495. this.panel.el.setStyle('z-index', 100);
  11496. this.isCollapsed = true;
  11497. this.layout.layout();
  11498. },
  11499. onCollapse : function(animate){
  11500. this.panel.el.setStyle('z-index', 1);
  11501. if(this.lastAnim === false || this.panel.animCollapse === false){
  11502. this.getCollapsedEl().dom.style.visibility = 'visible';
  11503. }else{
  11504. this.getCollapsedEl().slideIn(this.panel.slideAnchor, {duration:.2});
  11505. }
  11506. this.state.collapsed = true;
  11507. this.panel.saveState();
  11508. },
  11509. beforeExpand : function(animate){
  11510. var c = this.getCollapsedEl();
  11511. this.el.show();
  11512. if(this.position == 'east' || this.position == 'west'){
  11513. this.panel.setSize(undefined, c.getHeight());
  11514. }else{
  11515. this.panel.setSize(c.getWidth(), undefined);
  11516. }
  11517. c.hide();
  11518. c.dom.style.visibility = 'hidden';
  11519. this.panel.el.setStyle('z-index', 100);
  11520. },
  11521. onExpand : function(){
  11522. this.isCollapsed = false;
  11523. if(this.splitEl){
  11524. this.splitEl.show();
  11525. }
  11526. this.layout.layout();
  11527. this.panel.el.setStyle('z-index', 1);
  11528. this.state.collapsed = false;
  11529. this.panel.saveState();
  11530. },
  11531. collapseClick : function(e){
  11532. if(this.isSlid){
  11533. e.stopPropagation();
  11534. this.slideIn();
  11535. }else{
  11536. e.stopPropagation();
  11537. this.slideOut();
  11538. }
  11539. },
  11540. onHide : function(){
  11541. if(this.isCollapsed){
  11542. this.getCollapsedEl().hide();
  11543. }else if(this.splitEl){
  11544. this.splitEl.hide();
  11545. }
  11546. },
  11547. onShow : function(){
  11548. if(this.isCollapsed){
  11549. this.getCollapsedEl().show();
  11550. }else if(this.splitEl){
  11551. this.splitEl.show();
  11552. }
  11553. },
  11554. isVisible : function(){
  11555. return !this.panel.hidden;
  11556. },
  11557. getMargins : function(){
  11558. return this.isCollapsed && this.cmargins ? this.cmargins : this.margins;
  11559. },
  11560. getSize : function(){
  11561. return this.isCollapsed ? this.getCollapsedEl().getSize() : this.panel.getSize();
  11562. },
  11563. setPanel : function(panel){
  11564. this.panel = panel;
  11565. },
  11566. getMinWidth: function(){
  11567. return this.minWidth;
  11568. },
  11569. getMinHeight: function(){
  11570. return this.minHeight;
  11571. },
  11572. applyLayoutCollapsed : function(box){
  11573. var ce = this.getCollapsedEl();
  11574. ce.setLeftTop(box.x, box.y);
  11575. ce.setSize(box.width, box.height);
  11576. },
  11577. applyLayout : function(box){
  11578. if(this.isCollapsed){
  11579. this.applyLayoutCollapsed(box);
  11580. }else{
  11581. this.panel.setPosition(box.x, box.y);
  11582. this.panel.setSize(box.width, box.height);
  11583. }
  11584. },
  11585. beforeSlide: function(){
  11586. this.panel.beforeEffect();
  11587. },
  11588. afterSlide : function(){
  11589. this.panel.afterEffect();
  11590. },
  11591. initAutoHide : function(){
  11592. if(this.autoHide !== false){
  11593. if(!this.autoHideHd){
  11594. var st = new Ext.util.DelayedTask(this.slideIn, this);
  11595. this.autoHideHd = {
  11596. "mouseout": function(e){
  11597. if(!e.within(this.el, true)){
  11598. st.delay(500);
  11599. }
  11600. },
  11601. "mouseover" : function(e){
  11602. st.cancel();
  11603. },
  11604. scope : this
  11605. };
  11606. }
  11607. this.el.on(this.autoHideHd);
  11608. }
  11609. },
  11610. clearAutoHide : function(){
  11611. if(this.autoHide !== false){
  11612. this.el.un("mouseout", this.autoHideHd.mouseout);
  11613. this.el.un("mouseover", this.autoHideHd.mouseover);
  11614. }
  11615. },
  11616. clearMonitor : function(){
  11617. Ext.getDoc().un("click", this.slideInIf, this);
  11618. },
  11619. slideOut : function(){
  11620. if(this.isSlid || this.el.hasActiveFx()){
  11621. return;
  11622. }
  11623. this.isSlid = true;
  11624. var ts = this.panel.tools;
  11625. if(ts && ts.toggle){
  11626. ts.toggle.hide();
  11627. }
  11628. this.el.show();
  11629. if(this.position == 'east' || this.position == 'west'){
  11630. this.panel.setSize(undefined, this.collapsedEl.getHeight());
  11631. }else{
  11632. this.panel.setSize(this.collapsedEl.getWidth(), undefined);
  11633. }
  11634. this.restoreLT = [this.el.dom.style.left, this.el.dom.style.top];
  11635. this.el.alignTo(this.collapsedEl, this.getCollapseAnchor());
  11636. this.el.setStyle("z-index", 102);
  11637. if(this.animFloat !== false){
  11638. this.beforeSlide();
  11639. this.el.slideIn(this.getSlideAnchor(), {
  11640. callback: function(){
  11641. this.afterSlide();
  11642. this.initAutoHide();
  11643. Ext.getDoc().on("click", this.slideInIf, this);
  11644. },
  11645. scope: this,
  11646. block: true
  11647. });
  11648. }else{
  11649. this.initAutoHide();
  11650. Ext.getDoc().on("click", this.slideInIf, this);
  11651. }
  11652. },
  11653. afterSlideIn : function(){
  11654. this.clearAutoHide();
  11655. this.isSlid = false;
  11656. this.clearMonitor();
  11657. this.el.setStyle("z-index", "");
  11658. this.el.dom.style.left = this.restoreLT[0];
  11659. this.el.dom.style.top = this.restoreLT[1];
  11660. var ts = this.panel.tools;
  11661. if(ts && ts.toggle){
  11662. ts.toggle.show();
  11663. }
  11664. },
  11665. slideIn : function(cb){
  11666. if(!this.isSlid || this.el.hasActiveFx()){
  11667. Ext.callback(cb);
  11668. return;
  11669. }
  11670. this.isSlid = false;
  11671. if(this.animFloat !== false){
  11672. this.beforeSlide();
  11673. this.el.slideOut(this.getSlideAnchor(), {
  11674. callback: function(){
  11675. this.el.hide();
  11676. this.afterSlide();
  11677. this.afterSlideIn();
  11678. Ext.callback(cb);
  11679. },
  11680. scope: this,
  11681. block: true
  11682. });
  11683. }else{
  11684. this.el.hide();
  11685. this.afterSlideIn();
  11686. }
  11687. },
  11688. slideInIf : function(e){
  11689. if(!e.within(this.el)){
  11690. this.slideIn();
  11691. }
  11692. },
  11693. anchors : {
  11694. "west" : "left",
  11695. "east" : "right",
  11696. "north" : "top",
  11697. "south" : "bottom"
  11698. },
  11699. sanchors : {
  11700. "west" : "l",
  11701. "east" : "r",
  11702. "north" : "t",
  11703. "south" : "b"
  11704. },
  11705. canchors : {
  11706. "west" : "tl-tr",
  11707. "east" : "tr-tl",
  11708. "north" : "tl-bl",
  11709. "south" : "bl-tl"
  11710. },
  11711. getAnchor : function(){
  11712. return this.anchors[this.position];
  11713. },
  11714. getCollapseAnchor : function(){
  11715. return this.canchors[this.position];
  11716. },
  11717. getSlideAnchor : function(){
  11718. return this.sanchors[this.position];
  11719. },
  11720. getAlignAdj : function(){
  11721. var cm = this.cmargins;
  11722. switch(this.position){
  11723. case "west":
  11724. return [0, 0];
  11725. break;
  11726. case "east":
  11727. return [0, 0];
  11728. break;
  11729. case "north":
  11730. return [0, 0];
  11731. break;
  11732. case "south":
  11733. return [0, 0];
  11734. break;
  11735. }
  11736. },
  11737. getExpandAdj : function(){
  11738. var c = this.collapsedEl, cm = this.cmargins;
  11739. switch(this.position){
  11740. case "west":
  11741. return [-(cm.right+c.getWidth()+cm.left), 0];
  11742. break;
  11743. case "east":
  11744. return [cm.right+c.getWidth()+cm.left, 0];
  11745. break;
  11746. case "north":
  11747. return [0, -(cm.top+cm.bottom+c.getHeight())];
  11748. break;
  11749. case "south":
  11750. return [0, cm.top+cm.bottom+c.getHeight()];
  11751. break;
  11752. }
  11753. }
  11754. };
  11755. Ext.layout.BorderLayout.SplitRegion = function(layout, config, pos){
  11756. Ext.layout.BorderLayout.SplitRegion.superclass.constructor.call(this, layout, config, pos);
  11757. this.applyLayout = this.applyFns[pos];
  11758. };
  11759. Ext.extend(Ext.layout.BorderLayout.SplitRegion, Ext.layout.BorderLayout.Region, {
  11760. splitTip : "Drag to resize.",
  11761. collapsibleSplitTip : "Drag to resize. Double click to hide.",
  11762. useSplitTips : false,
  11763. splitSettings : {
  11764. north : {
  11765. orientation: Ext.SplitBar.VERTICAL,
  11766. placement: Ext.SplitBar.TOP,
  11767. maxFn : 'getVMaxSize',
  11768. minProp: 'minHeight',
  11769. maxProp: 'maxHeight'
  11770. },
  11771. south : {
  11772. orientation: Ext.SplitBar.VERTICAL,
  11773. placement: Ext.SplitBar.BOTTOM,
  11774. maxFn : 'getVMaxSize',
  11775. minProp: 'minHeight',
  11776. maxProp: 'maxHeight'
  11777. },
  11778. east : {
  11779. orientation: Ext.SplitBar.HORIZONTAL,
  11780. placement: Ext.SplitBar.RIGHT,
  11781. maxFn : 'getHMaxSize',
  11782. minProp: 'minWidth',
  11783. maxProp: 'maxWidth'
  11784. },
  11785. west : {
  11786. orientation: Ext.SplitBar.HORIZONTAL,
  11787. placement: Ext.SplitBar.LEFT,
  11788. maxFn : 'getHMaxSize',
  11789. minProp: 'minWidth',
  11790. maxProp: 'maxWidth'
  11791. }
  11792. },
  11793. applyFns : {
  11794. west : function(box){
  11795. if(this.isCollapsed){
  11796. return this.applyLayoutCollapsed(box);
  11797. }
  11798. var sd = this.splitEl.dom, s = sd.style;
  11799. this.panel.setPosition(box.x, box.y);
  11800. var sw = sd.offsetWidth;
  11801. s.left = (box.x+box.width-sw)+'px';
  11802. s.top = (box.y)+'px';
  11803. s.height = Math.max(0, box.height)+'px';
  11804. this.panel.setSize(box.width-sw, box.height);
  11805. },
  11806. east : function(box){
  11807. if(this.isCollapsed){
  11808. return this.applyLayoutCollapsed(box);
  11809. }
  11810. var sd = this.splitEl.dom, s = sd.style;
  11811. var sw = sd.offsetWidth;
  11812. this.panel.setPosition(box.x+sw, box.y);
  11813. s.left = (box.x)+'px';
  11814. s.top = (box.y)+'px';
  11815. s.height = Math.max(0, box.height)+'px';
  11816. this.panel.setSize(box.width-sw, box.height);
  11817. },
  11818. north : function(box){
  11819. if(this.isCollapsed){
  11820. return this.applyLayoutCollapsed(box);
  11821. }
  11822. var sd = this.splitEl.dom, s = sd.style;
  11823. var sh = sd.offsetHeight;
  11824. this.panel.setPosition(box.x, box.y);
  11825. s.left = (box.x)+'px';
  11826. s.top = (box.y+box.height-sh)+'px';
  11827. s.width = Math.max(0, box.width)+'px';
  11828. this.panel.setSize(box.width, box.height-sh);
  11829. },
  11830. south : function(box){
  11831. if(this.isCollapsed){
  11832. return this.applyLayoutCollapsed(box);
  11833. }
  11834. var sd = this.splitEl.dom, s = sd.style;
  11835. var sh = sd.offsetHeight;
  11836. this.panel.setPosition(box.x, box.y+sh);
  11837. s.left = (box.x)+'px';
  11838. s.top = (box.y)+'px';
  11839. s.width = Math.max(0, box.width)+'px';
  11840. this.panel.setSize(box.width, box.height-sh);
  11841. }
  11842. },
  11843. render : function(ct, p){
  11844. Ext.layout.BorderLayout.SplitRegion.superclass.render.call(this, ct, p);
  11845. var ps = this.position;
  11846. this.splitEl = ct.createChild({
  11847. cls: "x-layout-split x-layout-split-"+ps, html: "&#160;",
  11848. id: this.panel.id + '-xsplit'
  11849. });
  11850. if(this.collapseMode == 'mini'){
  11851. this.miniSplitEl = this.splitEl.createChild({
  11852. cls: "x-layout-mini x-layout-mini-"+ps, html: "&#160;"
  11853. });
  11854. this.miniSplitEl.addClassOnOver('x-layout-mini-over');
  11855. this.miniSplitEl.on('click', this.onCollapseClick, this, {stopEvent:true});
  11856. }
  11857. var s = this.splitSettings[ps];
  11858. this.split = new Ext.SplitBar(this.splitEl.dom, p.el, s.orientation);
  11859. this.split.placement = s.placement;
  11860. this.split.getMaximumSize = this[s.maxFn].createDelegate(this);
  11861. this.split.minSize = this.minSize || this[s.minProp];
  11862. this.split.on("beforeapply", this.onSplitMove, this);
  11863. this.split.useShim = this.useShim === true;
  11864. this.maxSize = this.maxSize || this[s.maxProp];
  11865. if(p.hidden){
  11866. this.splitEl.hide();
  11867. }
  11868. if(this.useSplitTips){
  11869. this.splitEl.dom.title = this.collapsible ? this.collapsibleSplitTip : this.splitTip;
  11870. }
  11871. if(this.collapsible){
  11872. this.splitEl.on("dblclick", this.onCollapseClick, this);
  11873. }
  11874. },
  11875. getSize : function(){
  11876. if(this.isCollapsed){
  11877. return this.collapsedEl.getSize();
  11878. }
  11879. var s = this.panel.getSize();
  11880. if(this.position == 'north' || this.position == 'south'){
  11881. s.height += this.splitEl.dom.offsetHeight;
  11882. }else{
  11883. s.width += this.splitEl.dom.offsetWidth;
  11884. }
  11885. return s;
  11886. },
  11887. getHMaxSize : function(){
  11888. var cmax = this.maxSize || 10000;
  11889. var center = this.layout.center;
  11890. return Math.min(cmax, (this.el.getWidth()+center.el.getWidth())-center.getMinWidth());
  11891. },
  11892. getVMaxSize : function(){
  11893. var cmax = this.maxSize || 10000;
  11894. var center = this.layout.center;
  11895. return Math.min(cmax, (this.el.getHeight()+center.el.getHeight())-center.getMinHeight());
  11896. },
  11897. onSplitMove : function(split, newSize){
  11898. var s = this.panel.getSize();
  11899. this.lastSplitSize = newSize;
  11900. if(this.position == 'north' || this.position == 'south'){
  11901. this.panel.setSize(s.width, newSize);
  11902. this.state.height = newSize;
  11903. }else{
  11904. this.panel.setSize(newSize, s.height);
  11905. this.state.width = newSize;
  11906. }
  11907. this.layout.layout();
  11908. this.panel.saveState();
  11909. return false;
  11910. },
  11911. getSplitBar : function(){
  11912. return this.split;
  11913. }
  11914. });
  11915. Ext.Container.LAYOUTS['border'] = Ext.layout.BorderLayout;
  11916. Ext.layout.FormLayout = Ext.extend(Ext.layout.AnchorLayout, {
  11917. labelSeparator : ':',
  11918. getAnchorViewSize : function(ct, target){
  11919. return ct.body.getStyleSize();
  11920. },
  11921. setContainer : function(ct){
  11922. Ext.layout.FormLayout.superclass.setContainer.call(this, ct);
  11923. if(ct.labelAlign){
  11924. ct.addClass('x-form-label-'+ct.labelAlign);
  11925. }
  11926. if(ct.hideLabels){
  11927. this.labelStyle = "display:none";
  11928. this.elementStyle = "padding-left:0;";
  11929. this.labelAdjust = 0;
  11930. }else{
  11931. this.labelSeparator = ct.labelSeparator || this.labelSeparator;
  11932. ct.labelWidth = ct.labelWidth || 100;
  11933. if(typeof ct.labelWidth == 'number'){
  11934. var pad = (typeof ct.labelPad == 'number' ? ct.labelPad : 5);
  11935. this.labelAdjust = ct.labelWidth+pad;
  11936. this.labelStyle = "width:"+ct.labelWidth+"px;";
  11937. this.elementStyle = "padding-left:"+(ct.labelWidth+pad)+'px';
  11938. }
  11939. if(ct.labelAlign == 'top'){
  11940. this.labelStyle = "width:auto;";
  11941. this.labelAdjust = 0;
  11942. this.elementStyle = "padding-left:0;";
  11943. }
  11944. }
  11945. if(!this.fieldTpl){
  11946. var t = new Ext.Template(
  11947. '<div class="x-form-item {5}" tabIndex="-1">',
  11948. '<label for="{0}" style="{2}" class="x-form-item-label">{1}{4}</label>',
  11949. '<div class="x-form-element" id="x-form-el-{0}" style="{3}">',
  11950. '</div><div class="{6}"></div>',
  11951. '</div>'
  11952. );
  11953. t.disableFormats = true;
  11954. t.compile();
  11955. Ext.layout.FormLayout.prototype.fieldTpl = t;
  11956. }
  11957. },
  11958. renderItem : function(c, position, target){
  11959. if(c && !c.rendered && c.isFormField && c.inputType != 'hidden'){
  11960. var args = [
  11961. c.id, c.fieldLabel,
  11962. c.labelStyle||this.labelStyle||'',
  11963. this.elementStyle||'',
  11964. typeof c.labelSeparator == 'undefined' ? this.labelSeparator : c.labelSeparator,
  11965. (c.itemCls||this.container.itemCls||'') + (c.hideLabel ? ' x-hide-label' : ''),
  11966. c.clearCls || 'x-form-clear-left'
  11967. ];
  11968. if(typeof position == 'number'){
  11969. position = target.dom.childNodes[position] || null;
  11970. }
  11971. if(position){
  11972. this.fieldTpl.insertBefore(position, args);
  11973. }else{
  11974. this.fieldTpl.append(target, args);
  11975. }
  11976. c.render('x-form-el-'+c.id);
  11977. }else {
  11978. Ext.layout.FormLayout.superclass.renderItem.apply(this, arguments);
  11979. }
  11980. },
  11981. adjustWidthAnchor : function(value, comp){
  11982. return value - (comp.isFormField ? (comp.hideLabel ? 0 : this.labelAdjust) : 0);
  11983. },
  11984. isValidParent : function(c, target){
  11985. return true;
  11986. }
  11987. });
  11988. Ext.Container.LAYOUTS['form'] = Ext.layout.FormLayout;
  11989. Ext.layout.Accordion = Ext.extend(Ext.layout.FitLayout, {
  11990. fill : true,
  11991. autoWidth : true,
  11992. titleCollapse : true,
  11993. hideCollapseTool : false,
  11994. collapseFirst : false,
  11995. animate : false,
  11996. sequence : false,
  11997. activeOnTop : false,
  11998. renderItem : function(c){
  11999. if(this.animate === false){
  12000. c.animCollapse = false;
  12001. }
  12002. c.collapsible = true;
  12003. if(this.autoWidth){
  12004. c.autoWidth = true;
  12005. }
  12006. if(this.titleCollapse){
  12007. c.titleCollapse = true;
  12008. }
  12009. if(this.hideCollapseTool){
  12010. c.hideCollapseTool = true;
  12011. }
  12012. if(this.collapseFirst !== undefined){
  12013. c.collapseFirst = this.collapseFirst;
  12014. }
  12015. if(!this.activeItem && !c.collapsed){
  12016. this.activeItem = c;
  12017. }else if(this.activeItem){
  12018. c.collapsed = true;
  12019. }
  12020. Ext.layout.Accordion.superclass.renderItem.apply(this, arguments);
  12021. c.header.addClass('x-accordion-hd');
  12022. c.on('beforeexpand', this.beforeExpand, this);
  12023. },
  12024. beforeExpand : function(p, anim){
  12025. var ai = this.activeItem;
  12026. if(ai){
  12027. if(this.sequence){
  12028. delete this.activeItem;
  12029. ai.collapse({callback:function(){
  12030. p.expand(anim || true);
  12031. }, scope: this});
  12032. return false;
  12033. }else{
  12034. ai.collapse(this.animate);
  12035. }
  12036. }
  12037. this.activeItem = p;
  12038. if(this.activeOnTop){
  12039. p.el.dom.parentNode.insertBefore(p.el.dom, p.el.dom.parentNode.firstChild);
  12040. }
  12041. this.layout();
  12042. },
  12043. setItemSize : function(item, size){
  12044. if(this.fill && item){
  12045. var items = this.container.items.items;
  12046. var hh = 0;
  12047. for(var i = 0, len = items.length; i < len; i++){
  12048. var p = items[i];
  12049. if(p != item){
  12050. hh += (p.getSize().height - p.bwrap.getHeight());
  12051. }
  12052. }
  12053. size.height -= hh;
  12054. item.setSize(size);
  12055. }
  12056. }
  12057. });
  12058. Ext.Container.LAYOUTS['accordion'] = Ext.layout.Accordion;
  12059. Ext.layout.TableLayout = Ext.extend(Ext.layout.ContainerLayout, {
  12060. monitorResize:false,
  12061. setContainer : function(ct){
  12062. Ext.layout.TableLayout.superclass.setContainer.call(this, ct);
  12063. this.currentRow = 0;
  12064. this.currentColumn = 0;
  12065. this.cells = [];
  12066. },
  12067. onLayout : function(ct, target){
  12068. var cs = ct.items.items, len = cs.length, c, i;
  12069. if(!this.table){
  12070. target.addClass('x-table-layout-ct');
  12071. this.table = target.createChild(
  12072. {tag:'table', cls:'x-table-layout', cellspacing: 0, cn: {tag: 'tbody'}}, null, true);
  12073. this.renderAll(ct, target);
  12074. }
  12075. },
  12076. getRow : function(index){
  12077. var row = this.table.tBodies[0].childNodes[index];
  12078. if(!row){
  12079. row = document.createElement('tr');
  12080. this.table.tBodies[0].appendChild(row);
  12081. }
  12082. return row;
  12083. },
  12084. getNextCell : function(c){
  12085. var cell = this.getNextNonSpan(this.currentColumn, this.currentRow);
  12086. var curCol = this.currentColumn = cell[0], curRow = this.currentRow = cell[1];
  12087. for(var rowIndex = curRow; rowIndex < curRow + (c.rowspan || 1); rowIndex++){
  12088. if(!this.cells[rowIndex]){
  12089. this.cells[rowIndex] = [];
  12090. }
  12091. for(var colIndex = curCol; colIndex < curCol + (c.colspan || 1); colIndex++){
  12092. this.cells[rowIndex][colIndex] = true;
  12093. }
  12094. }
  12095. var td = document.createElement('td');
  12096. if(c.cellId){
  12097. td.id = c.cellId;
  12098. }
  12099. var cls = 'x-table-layout-cell';
  12100. if(c.cellCls){
  12101. cls += ' ' + c.cellCls;
  12102. }
  12103. td.className = cls;
  12104. if(c.colspan){
  12105. td.colSpan = c.colspan;
  12106. }
  12107. if(c.rowspan){
  12108. td.rowSpan = c.rowspan;
  12109. }
  12110. this.getRow(curRow).appendChild(td);
  12111. return td;
  12112. },
  12113. getNextNonSpan: function(colIndex, rowIndex){
  12114. var cols = this.columns;
  12115. while((cols && colIndex >= cols) || (this.cells[rowIndex] && this.cells[rowIndex][colIndex])) {
  12116. if(cols && colIndex >= cols){
  12117. rowIndex++;
  12118. colIndex = 0;
  12119. }else{
  12120. colIndex++;
  12121. }
  12122. }
  12123. return [colIndex, rowIndex];
  12124. },
  12125. renderItem : function(c, position, target){
  12126. if(c && !c.rendered){
  12127. c.render(this.getNextCell(c));
  12128. }
  12129. },
  12130. isValidParent : function(c, target){
  12131. return true;
  12132. }
  12133. });
  12134. Ext.Container.LAYOUTS['table'] = Ext.layout.TableLayout;
  12135. Ext.layout.AbsoluteLayout = Ext.extend(Ext.layout.AnchorLayout, {
  12136. extraCls: 'x-abs-layout-item',
  12137. isForm: false,
  12138. setContainer : function(ct){
  12139. Ext.layout.AbsoluteLayout.superclass.setContainer.call(this, ct);
  12140. if(ct.isXType('form')){
  12141. this.isForm = true;
  12142. }
  12143. },
  12144. onLayout : function(ct, target){
  12145. if(this.isForm){ ct.body.position(); } else { target.position(); }
  12146. Ext.layout.AbsoluteLayout.superclass.onLayout.call(this, ct, target);
  12147. },
  12148. getAnchorViewSize : function(ct, target){
  12149. return this.isForm ? ct.body.getStyleSize() : Ext.layout.AbsoluteLayout.superclass.getAnchorViewSize.call(this, ct, target);
  12150. },
  12151. isValidParent : function(c, target){
  12152. return this.isForm ? true : Ext.layout.AbsoluteLayout.superclass.isValidParent.call(this, c, target);
  12153. },
  12154. adjustWidthAnchor : function(value, comp){
  12155. return value ? value - comp.getPosition(true)[0] : value;
  12156. },
  12157. adjustHeightAnchor : function(value, comp){
  12158. return value ? value - comp.getPosition(true)[1] : value;
  12159. }
  12160. });
  12161. Ext.Container.LAYOUTS['absolute'] = Ext.layout.AbsoluteLayout;
  12162. Ext.Viewport = Ext.extend(Ext.Container, {
  12163. initComponent : function() {
  12164. Ext.Viewport.superclass.initComponent.call(this);
  12165. document.getElementsByTagName('html')[0].className += ' x-viewport';
  12166. this.el = Ext.getBody();
  12167. this.el.setHeight = Ext.emptyFn;
  12168. this.el.setWidth = Ext.emptyFn;
  12169. this.el.setSize = Ext.emptyFn;
  12170. this.el.dom.scroll = 'no';
  12171. this.allowDomMove = false;
  12172. this.autoWidth = true;
  12173. this.autoHeight = true;
  12174. Ext.EventManager.onWindowResize(this.fireResize, this);
  12175. this.renderTo = this.el;
  12176. },
  12177. fireResize : function(w, h){
  12178. this.fireEvent('resize', this, w, h, w, h);
  12179. }
  12180. });
  12181. Ext.reg('viewport', Ext.Viewport);
  12182. Ext.Panel = Ext.extend(Ext.Container, {
  12183. baseCls : 'x-panel',
  12184. collapsedCls : 'x-panel-collapsed',
  12185. maskDisabled: true,
  12186. animCollapse: Ext.enableFx,
  12187. headerAsText: true,
  12188. buttonAlign: 'right',
  12189. collapsed : false,
  12190. collapseFirst: true,
  12191. minButtonWidth:75,
  12192. elements : 'body',
  12193. toolTarget : 'header',
  12194. collapseEl : 'bwrap',
  12195. slideAnchor : 't',
  12196. deferHeight: true,
  12197. expandDefaults: {
  12198. duration:.25
  12199. },
  12200. collapseDefaults: {
  12201. duration:.25
  12202. },
  12203. initComponent : function(){
  12204. Ext.Panel.superclass.initComponent.call(this);
  12205. this.addEvents(
  12206. 'bodyresize',
  12207. 'titlechange',
  12208. 'collapse',
  12209. 'expand',
  12210. 'beforecollapse',
  12211. 'beforeexpand',
  12212. 'beforeclose',
  12213. 'close',
  12214. 'activate',
  12215. 'deactivate'
  12216. );
  12217. if(this.tbar){
  12218. this.elements += ',tbar';
  12219. if(typeof this.tbar == 'object'){
  12220. this.topToolbar = this.tbar;
  12221. }
  12222. delete this.tbar;
  12223. }
  12224. if(this.bbar){
  12225. this.elements += ',bbar';
  12226. if(typeof this.bbar == 'object'){
  12227. this.bottomToolbar = this.bbar;
  12228. }
  12229. delete this.bbar;
  12230. }
  12231. if(this.header === true){
  12232. this.elements += ',header';
  12233. delete this.header;
  12234. }else if(this.title && this.header !== false){
  12235. this.elements += ',header';
  12236. }
  12237. if(this.footer === true){
  12238. this.elements += ',footer';
  12239. delete this.footer;
  12240. }
  12241. if(this.buttons){
  12242. var btns = this.buttons;
  12243. this.buttons = [];
  12244. for(var i = 0, len = btns.length; i < len; i++) {
  12245. if(btns[i].render){ this.buttons.push(btns[i]);
  12246. }else{
  12247. this.addButton(btns[i]);
  12248. }
  12249. }
  12250. }
  12251. if(this.autoLoad){
  12252. this.on('render', this.doAutoLoad, this, {delay:10});
  12253. }
  12254. },
  12255. createElement : function(name, pnode){
  12256. if(this[name]){
  12257. pnode.appendChild(this[name].dom);
  12258. return;
  12259. }
  12260. if(name === 'bwrap' || this.elements.indexOf(name) != -1){
  12261. if(this[name+'Cfg']){
  12262. this[name] = Ext.fly(pnode).createChild(this[name+'Cfg']);
  12263. }else{
  12264. var el = document.createElement('div');
  12265. el.className = this[name+'Cls'];
  12266. this[name] = Ext.get(pnode.appendChild(el));
  12267. }
  12268. }
  12269. },
  12270. onRender : function(ct, position){
  12271. Ext.Panel.superclass.onRender.call(this, ct, position);
  12272. this.createClasses();
  12273. if(this.el){ this.el.addClass(this.baseCls);
  12274. this.header = this.el.down('.'+this.headerCls);
  12275. this.bwrap = this.el.down('.'+this.bwrapCls);
  12276. var cp = this.bwrap ? this.bwrap : this.el;
  12277. this.tbar = cp.down('.'+this.tbarCls);
  12278. this.body = cp.down('.'+this.bodyCls);
  12279. this.bbar = cp.down('.'+this.bbarCls);
  12280. this.footer = cp.down('.'+this.footerCls);
  12281. this.fromMarkup = true;
  12282. }else{
  12283. this.el = ct.createChild({
  12284. id: this.id,
  12285. cls: this.baseCls
  12286. }, position);
  12287. }
  12288. var el = this.el, d = el.dom;
  12289. if(this.cls){
  12290. this.el.addClass(this.cls);
  12291. }
  12292. if(this.buttons){
  12293. this.elements += ',footer';
  12294. }
  12295. if(this.frame){
  12296. el.insertHtml('afterBegin', String.format(Ext.Element.boxMarkup, this.baseCls));
  12297. this.createElement('header', d.firstChild.firstChild.firstChild);
  12298. this.createElement('bwrap', d);
  12299. var bw = this.bwrap.dom;
  12300. var ml = d.childNodes[1], bl = d.childNodes[2];
  12301. bw.appendChild(ml);
  12302. bw.appendChild(bl);
  12303. var mc = bw.firstChild.firstChild.firstChild;
  12304. this.createElement('tbar', mc);
  12305. this.createElement('body', mc);
  12306. this.createElement('bbar', mc);
  12307. this.createElement('footer', bw.lastChild.firstChild.firstChild);
  12308. if(!this.footer){
  12309. this.bwrap.dom.lastChild.className += ' x-panel-nofooter';
  12310. }
  12311. }else{
  12312. this.createElement('header', d);
  12313. this.createElement('bwrap', d);
  12314. var bw = this.bwrap.dom;
  12315. this.createElement('tbar', bw);
  12316. this.createElement('body', bw);
  12317. this.createElement('bbar', bw);
  12318. this.createElement('footer', bw);
  12319. if(!this.header){
  12320. this.body.addClass(this.bodyCls + '-noheader');
  12321. if(this.tbar){
  12322. this.tbar.addClass(this.tbarCls + '-noheader');
  12323. }
  12324. }
  12325. }
  12326. if(this.border === false){
  12327. this.el.addClass(this.baseCls + '-noborder');
  12328. this.body.addClass(this.bodyCls + '-noborder');
  12329. if(this.header){
  12330. this.header.addClass(this.headerCls + '-noborder');
  12331. }
  12332. if(this.footer){
  12333. this.footer.addClass(this.footerCls + '-noborder');
  12334. }
  12335. if(this.tbar){
  12336. this.tbar.addClass(this.tbarCls + '-noborder');
  12337. }
  12338. if(this.bbar){
  12339. this.bbar.addClass(this.bbarCls + '-noborder');
  12340. }
  12341. }
  12342. if(this.bodyBorder === false){
  12343. this.body.addClass(this.bodyCls + '-noborder');
  12344. }
  12345. if(this.bodyStyle){
  12346. this.body.applyStyles(this.bodyStyle);
  12347. }
  12348. this.bwrap.enableDisplayMode('block');
  12349. if(this.header){
  12350. this.header.unselectable();
  12351. if(this.headerAsText){
  12352. this.header.dom.innerHTML =
  12353. '<span class="' + this.headerTextCls + '">'+this.header.dom.innerHTML+'</span>';
  12354. if(this.iconCls){
  12355. this.setIconClass(this.iconCls);
  12356. }
  12357. }
  12358. }
  12359. if(this.floating){
  12360. this.makeFloating(this.floating);
  12361. }
  12362. if(this.collapsible){
  12363. this.tools = this.tools ? this.tools.slice(0) : [];
  12364. if(!this.hideCollapseTool){
  12365. this.tools[this.collapseFirst?'unshift':'push']({
  12366. id: 'toggle',
  12367. handler : this.toggleCollapse,
  12368. scope: this
  12369. });
  12370. }
  12371. if(this.titleCollapse && this.header){
  12372. this.header.on('click', this.toggleCollapse, this);
  12373. this.header.setStyle('cursor', 'pointer');
  12374. }
  12375. }
  12376. if(this.tools){
  12377. var ts = this.tools;
  12378. this.tools = {};
  12379. this.addTool.apply(this, ts);
  12380. }else{
  12381. this.tools = {};
  12382. }
  12383. if(this.buttons && this.buttons.length > 0){
  12384. var tb = this.footer.createChild({cls:'x-panel-btns-ct', cn: {
  12385. cls:"x-panel-btns x-panel-btns-"+this.buttonAlign,
  12386. html:'<table cellspacing="0"><tbody><tr></tr></tbody></table><div class="x-clear"></div>'
  12387. }}, null, true);
  12388. var tr = tb.getElementsByTagName('tr')[0];
  12389. for(var i = 0, len = this.buttons.length; i < len; i++) {
  12390. var b = this.buttons[i];
  12391. var td = document.createElement('td');
  12392. td.className = 'x-panel-btn-td';
  12393. b.render(tr.appendChild(td));
  12394. }
  12395. }
  12396. if(this.tbar && this.topToolbar){
  12397. if(Ext.isArray(this.topToolbar)){
  12398. this.topToolbar = new Ext.Toolbar(this.topToolbar);
  12399. }
  12400. this.topToolbar.render(this.tbar);
  12401. }
  12402. if(this.bbar && this.bottomToolbar){
  12403. if(Ext.isArray(this.bottomToolbar)){
  12404. this.bottomToolbar = new Ext.Toolbar(this.bottomToolbar);
  12405. }
  12406. this.bottomToolbar.render(this.bbar);
  12407. }
  12408. },
  12409. setIconClass : function(cls){
  12410. var old = this.iconCls;
  12411. this.iconCls = cls;
  12412. if(this.rendered && this.header){
  12413. if(this.frame){
  12414. this.header.addClass('x-panel-icon');
  12415. this.header.replaceClass(old, this.iconCls);
  12416. }else{
  12417. var hd = this.header.dom;
  12418. var img = hd.firstChild && String(hd.firstChild.tagName).toLowerCase() == 'img' ? hd.firstChild : null;
  12419. if(img){
  12420. Ext.fly(img).replaceClass(old, this.iconCls);
  12421. }else{
  12422. Ext.DomHelper.insertBefore(hd.firstChild, {
  12423. tag:'img', src: Ext.BLANK_IMAGE_URL, cls:'x-panel-inline-icon '+this.iconCls
  12424. });
  12425. }
  12426. }
  12427. }
  12428. },
  12429. makeFloating : function(cfg){
  12430. this.floating = true;
  12431. this.el = new Ext.Layer(
  12432. typeof cfg == 'object' ? cfg : {
  12433. shadow: this.shadow !== undefined ? this.shadow : 'sides',
  12434. shadowOffset: this.shadowOffset,
  12435. constrain:false,
  12436. shim: this.shim === false ? false : undefined
  12437. }, this.el
  12438. );
  12439. },
  12440. getTopToolbar : function(){
  12441. return this.topToolbar;
  12442. },
  12443. getBottomToolbar : function(){
  12444. return this.bottomToolbar;
  12445. },
  12446. addButton : function(config, handler, scope){
  12447. var bc = {
  12448. handler: handler,
  12449. scope: scope,
  12450. minWidth: this.minButtonWidth,
  12451. hideParent:true
  12452. };
  12453. if(typeof config == "string"){
  12454. bc.text = config;
  12455. }else{
  12456. Ext.apply(bc, config);
  12457. }
  12458. var btn = new Ext.Button(bc);
  12459. btn.ownerCt = this;
  12460. if(!this.buttons){
  12461. this.buttons = [];
  12462. }
  12463. this.buttons.push(btn);
  12464. return btn;
  12465. },
  12466. addTool : function(){
  12467. if(!this[this.toolTarget]) { return;
  12468. }
  12469. if(!this.toolTemplate){
  12470. var tt = new Ext.Template(
  12471. '<div class="x-tool x-tool-{id}">&#160;</div>'
  12472. );
  12473. tt.disableFormats = true;
  12474. tt.compile();
  12475. Ext.Panel.prototype.toolTemplate = tt;
  12476. }
  12477. for(var i = 0, a = arguments, len = a.length; i < len; i++) {
  12478. var tc = a[i], overCls = 'x-tool-'+tc.id+'-over';
  12479. var t = this.toolTemplate.insertFirst(this[this.toolTarget], tc, true);
  12480. this.tools[tc.id] = t;
  12481. t.enableDisplayMode('block');
  12482. t.on('click', this.createToolHandler(t, tc, overCls, this));
  12483. if(tc.on){
  12484. t.on(tc.on);
  12485. }
  12486. if(tc.hidden){
  12487. t.hide();
  12488. }
  12489. if(tc.qtip){
  12490. if(typeof tc.qtip == 'object'){
  12491. Ext.QuickTips.register(Ext.apply({
  12492. target: t.id
  12493. }, tc.qtip));
  12494. } else {
  12495. t.dom.qtip = tc.qtip;
  12496. }
  12497. }
  12498. t.addClassOnOver(overCls);
  12499. }
  12500. },
  12501. onShow : function(){
  12502. if(this.floating){
  12503. return this.el.show();
  12504. }
  12505. Ext.Panel.superclass.onShow.call(this);
  12506. },
  12507. onHide : function(){
  12508. if(this.floating){
  12509. return this.el.hide();
  12510. }
  12511. Ext.Panel.superclass.onHide.call(this);
  12512. },
  12513. createToolHandler : function(t, tc, overCls, panel){
  12514. return function(e){
  12515. t.removeClass(overCls);
  12516. e.stopEvent();
  12517. if(tc.handler){
  12518. tc.handler.call(tc.scope || t, e, t, panel);
  12519. }
  12520. };
  12521. },
  12522. afterRender : function(){
  12523. if(this.fromMarkup && this.height === undefined && !this.autoHeight){
  12524. this.height = this.el.getHeight();
  12525. }
  12526. if(this.floating && !this.hidden && !this.initHidden){
  12527. this.el.show();
  12528. }
  12529. if(this.title){
  12530. this.setTitle(this.title);
  12531. }
  12532. this.setAutoScroll();
  12533. if(this.html){
  12534. this.body.update(typeof this.html == 'object' ?
  12535. Ext.DomHelper.markup(this.html) :
  12536. this.html);
  12537. delete this.html;
  12538. }
  12539. if(this.contentEl){
  12540. var ce = Ext.getDom(this.contentEl);
  12541. Ext.fly(ce).removeClass(['x-hidden', 'x-hide-display']);
  12542. this.body.dom.appendChild(ce);
  12543. }
  12544. if(this.collapsed){
  12545. this.collapsed = false;
  12546. this.collapse(false);
  12547. }
  12548. Ext.Panel.superclass.afterRender.call(this); this.initEvents();
  12549. },
  12550. setAutoScroll : function(){
  12551. if(this.rendered && this.autoScroll){
  12552. this.body.setOverflow('auto');
  12553. }
  12554. },
  12555. getKeyMap : function(){
  12556. if(!this.keyMap){
  12557. this.keyMap = new Ext.KeyMap(this.el, this.keys);
  12558. }
  12559. return this.keyMap;
  12560. },
  12561. initEvents : function(){
  12562. if(this.keys){
  12563. this.getKeyMap();
  12564. }
  12565. if(this.draggable){
  12566. this.initDraggable();
  12567. }
  12568. },
  12569. initDraggable : function(){
  12570. this.dd = new Ext.Panel.DD(this, typeof this.draggable == 'boolean' ? null : this.draggable);
  12571. },
  12572. beforeEffect : function(){
  12573. if(this.floating){
  12574. this.el.beforeAction();
  12575. }
  12576. this.el.addClass('x-panel-animated');
  12577. },
  12578. afterEffect : function(){
  12579. this.syncShadow();
  12580. this.el.removeClass('x-panel-animated');
  12581. },
  12582. createEffect : function(a, cb, scope){
  12583. var o = {
  12584. scope:scope,
  12585. block:true
  12586. };
  12587. if(a === true){
  12588. o.callback = cb;
  12589. return o;
  12590. }else if(!a.callback){
  12591. o.callback = cb;
  12592. }else { o.callback = function(){
  12593. cb.call(scope);
  12594. Ext.callback(a.callback, a.scope);
  12595. };
  12596. }
  12597. return Ext.applyIf(o, a);
  12598. },
  12599. collapse : function(animate){
  12600. if(this.collapsed || this.el.hasFxBlock() || this.fireEvent('beforecollapse', this, animate) === false){
  12601. return;
  12602. }
  12603. var doAnim = animate === true || (animate !== false && this.animCollapse);
  12604. this.beforeEffect();
  12605. this.onCollapse(doAnim, animate);
  12606. return this;
  12607. },
  12608. onCollapse : function(doAnim, animArg){
  12609. if(doAnim){
  12610. this[this.collapseEl].slideOut(this.slideAnchor,
  12611. Ext.apply(this.createEffect(animArg||true, this.afterCollapse, this),
  12612. this.collapseDefaults));
  12613. }else{
  12614. this[this.collapseEl].hide();
  12615. this.afterCollapse();
  12616. }
  12617. },
  12618. afterCollapse : function(){
  12619. this.collapsed = true;
  12620. this.el.addClass(this.collapsedCls);
  12621. this.afterEffect();
  12622. this.fireEvent('collapse', this);
  12623. },
  12624. expand : function(animate){
  12625. if(!this.collapsed || this.el.hasFxBlock() || this.fireEvent('beforeexpand', this, animate) === false){
  12626. return;
  12627. }
  12628. var doAnim = animate === true || (animate !== false && this.animCollapse);
  12629. this.el.removeClass(this.collapsedCls);
  12630. this.beforeEffect();
  12631. this.onExpand(doAnim, animate);
  12632. return this;
  12633. },
  12634. onExpand : function(doAnim, animArg){
  12635. if(doAnim){
  12636. this[this.collapseEl].slideIn(this.slideAnchor,
  12637. Ext.apply(this.createEffect(animArg||true, this.afterExpand, this),
  12638. this.expandDefaults));
  12639. }else{
  12640. this[this.collapseEl].show();
  12641. this.afterExpand();
  12642. }
  12643. },
  12644. afterExpand : function(){
  12645. this.collapsed = false;
  12646. this.afterEffect();
  12647. this.fireEvent('expand', this);
  12648. },
  12649. toggleCollapse : function(animate){
  12650. this[this.collapsed ? 'expand' : 'collapse'](animate);
  12651. return this;
  12652. },
  12653. onDisable : function(){
  12654. if(this.rendered && this.maskDisabled){
  12655. this.el.mask();
  12656. }
  12657. Ext.Panel.superclass.onDisable.call(this);
  12658. },
  12659. onEnable : function(){
  12660. if(this.rendered && this.maskDisabled){
  12661. this.el.unmask();
  12662. }
  12663. Ext.Panel.superclass.onEnable.call(this);
  12664. },
  12665. onResize : function(w, h){
  12666. if(w !== undefined || h !== undefined){
  12667. if(!this.collapsed){
  12668. if(typeof w == 'number'){
  12669. this.body.setWidth(
  12670. this.adjustBodyWidth(w - this.getFrameWidth()));
  12671. }else if(w == 'auto'){
  12672. this.body.setWidth(w);
  12673. }
  12674. if(typeof h == 'number'){
  12675. this.body.setHeight(
  12676. this.adjustBodyHeight(h - this.getFrameHeight()));
  12677. }else if(h == 'auto'){
  12678. this.body.setHeight(h);
  12679. }
  12680. }else{
  12681. this.queuedBodySize = {width: w, height: h};
  12682. if(!this.queuedExpand && this.allowQueuedExpand !== false){
  12683. this.queuedExpand = true;
  12684. this.on('expand', function(){
  12685. delete this.queuedExpand;
  12686. this.onResize(this.queuedBodySize.width, this.queuedBodySize.height);
  12687. this.doLayout();
  12688. }, this, {single:true});
  12689. }
  12690. }
  12691. this.fireEvent('bodyresize', this, w, h);
  12692. }
  12693. this.syncShadow();
  12694. },
  12695. adjustBodyHeight : function(h){
  12696. return h;
  12697. },
  12698. adjustBodyWidth : function(w){
  12699. return w;
  12700. },
  12701. onPosition : function(){
  12702. this.syncShadow();
  12703. },
  12704. onDestroy : function(){
  12705. if(this.tools){
  12706. for(var k in this.tools){
  12707. Ext.destroy(this.tools[k]);
  12708. }
  12709. }
  12710. if(this.buttons){
  12711. for(var b in this.buttons){
  12712. Ext.destroy(this.buttons[b]);
  12713. }
  12714. }
  12715. Ext.destroy(
  12716. this.topToolbar,
  12717. this.bottomToolbar
  12718. );
  12719. Ext.Panel.superclass.onDestroy.call(this);
  12720. },
  12721. getFrameWidth : function(){
  12722. var w = this.el.getFrameWidth('lr');
  12723. if(this.frame){
  12724. var l = this.bwrap.dom.firstChild;
  12725. w += (Ext.fly(l).getFrameWidth('l') + Ext.fly(l.firstChild).getFrameWidth('r'));
  12726. var mc = this.bwrap.dom.firstChild.firstChild.firstChild;
  12727. w += Ext.fly(mc).getFrameWidth('lr');
  12728. }
  12729. return w;
  12730. },
  12731. getFrameHeight : function(){
  12732. var h = this.el.getFrameWidth('tb');
  12733. h += (this.tbar ? this.tbar.getHeight() : 0) +
  12734. (this.bbar ? this.bbar.getHeight() : 0);
  12735. if(this.frame){
  12736. var hd = this.el.dom.firstChild;
  12737. var ft = this.bwrap.dom.lastChild;
  12738. h += (hd.offsetHeight + ft.offsetHeight);
  12739. var mc = this.bwrap.dom.firstChild.firstChild.firstChild;
  12740. h += Ext.fly(mc).getFrameWidth('tb');
  12741. }else{
  12742. h += (this.header ? this.header.getHeight() : 0) +
  12743. (this.footer ? this.footer.getHeight() : 0);
  12744. }
  12745. return h;
  12746. },
  12747. getInnerWidth : function(){
  12748. return this.getSize().width - this.getFrameWidth();
  12749. },
  12750. getInnerHeight : function(){
  12751. return this.getSize().height - this.getFrameHeight();
  12752. },
  12753. syncShadow : function(){
  12754. if(this.floating){
  12755. this.el.sync(true);
  12756. }
  12757. },
  12758. getLayoutTarget : function(){
  12759. return this.body;
  12760. },
  12761. setTitle : function(title, iconCls){
  12762. this.title = title;
  12763. if(this.header && this.headerAsText){
  12764. this.header.child('span').update(title);
  12765. }
  12766. if(iconCls){
  12767. this.setIconClass(iconCls);
  12768. }
  12769. this.fireEvent('titlechange', this, title);
  12770. return this;
  12771. },
  12772. getUpdater : function(){
  12773. return this.body.getUpdater();
  12774. },
  12775. load : function(){
  12776. var um = this.body.getUpdater();
  12777. um.update.apply(um, arguments);
  12778. return this;
  12779. },
  12780. beforeDestroy : function(){
  12781. Ext.Element.uncache(
  12782. this.header,
  12783. this.tbar,
  12784. this.bbar,
  12785. this.footer,
  12786. this.body
  12787. );
  12788. },
  12789. createClasses : function(){
  12790. this.headerCls = this.baseCls + '-header';
  12791. this.headerTextCls = this.baseCls + '-header-text';
  12792. this.bwrapCls = this.baseCls + '-bwrap';
  12793. this.tbarCls = this.baseCls + '-tbar';
  12794. this.bodyCls = this.baseCls + '-body';
  12795. this.bbarCls = this.baseCls + '-bbar';
  12796. this.footerCls = this.baseCls + '-footer';
  12797. },
  12798. createGhost : function(cls, useShim, appendTo){
  12799. var el = document.createElement('div');
  12800. el.className = 'x-panel-ghost ' + (cls ? cls : '');
  12801. if(this.header){
  12802. el.appendChild(this.el.dom.firstChild.cloneNode(true));
  12803. }
  12804. Ext.fly(el.appendChild(document.createElement('ul'))).setHeight(this.bwrap.getHeight());
  12805. el.style.width = this.el.dom.offsetWidth + 'px';;
  12806. if(!appendTo){
  12807. this.container.dom.appendChild(el);
  12808. }else{
  12809. Ext.getDom(appendTo).appendChild(el);
  12810. }
  12811. if(useShim !== false && this.el.useShim !== false){
  12812. var layer = new Ext.Layer({shadow:false, useDisplay:true, constrain:false}, el);
  12813. layer.show();
  12814. return layer;
  12815. }else{
  12816. return new Ext.Element(el);
  12817. }
  12818. },
  12819. doAutoLoad : function(){
  12820. this.body.load(
  12821. typeof this.autoLoad == 'object' ?
  12822. this.autoLoad : {url: this.autoLoad});
  12823. }
  12824. });
  12825. Ext.reg('panel', Ext.Panel);
  12826. Ext.Window = Ext.extend(Ext.Panel, {
  12827. baseCls : 'x-window',
  12828. resizable:true,
  12829. draggable:true,
  12830. closable : true,
  12831. constrain:false,
  12832. constrainHeader:false,
  12833. plain:false,
  12834. minimizable : false,
  12835. maximizable : false,
  12836. minHeight: 100,
  12837. minWidth: 200,
  12838. expandOnShow: true,
  12839. closeAction: 'close',
  12840. collapsible:false,
  12841. initHidden : true,
  12842. monitorResize : true,
  12843. elements: 'header,body',
  12844. frame:true,
  12845. floating:true,
  12846. initComponent : function(){
  12847. Ext.Window.superclass.initComponent.call(this);
  12848. this.addEvents(
  12849. 'resize',
  12850. 'maximize',
  12851. 'minimize',
  12852. 'restore'
  12853. );
  12854. },
  12855. getState : function(){
  12856. return Ext.apply(Ext.Window.superclass.getState.call(this) || {}, this.getBox());
  12857. },
  12858. onRender : function(ct, position){
  12859. Ext.Window.superclass.onRender.call(this, ct, position);
  12860. if(this.plain){
  12861. this.el.addClass('x-window-plain');
  12862. }
  12863. this.focusEl = this.el.createChild({
  12864. tag: "a", href:"#", cls:"x-dlg-focus",
  12865. tabIndex:"-1", html: "&#160;"});
  12866. this.focusEl.swallowEvent('click', true);
  12867. this.proxy = this.el.createProxy("x-window-proxy");
  12868. this.proxy.enableDisplayMode('block');
  12869. if(this.modal){
  12870. this.mask = this.container.createChild({cls:"ext-el-mask"}, this.el.dom);
  12871. this.mask.enableDisplayMode("block");
  12872. this.mask.hide();
  12873. }
  12874. },
  12875. initEvents : function(){
  12876. Ext.Window.superclass.initEvents.call(this);
  12877. if(this.animateTarget){
  12878. this.setAnimateTarget(this.animateTarget);
  12879. }
  12880. if(this.resizable){
  12881. this.resizer = new Ext.Resizable(this.el, {
  12882. minWidth: this.minWidth,
  12883. minHeight:this.minHeight,
  12884. handles: this.resizeHandles || "all",
  12885. pinned: true,
  12886. resizeElement : this.resizerAction
  12887. });
  12888. this.resizer.window = this;
  12889. this.resizer.on("beforeresize", this.beforeResize, this);
  12890. }
  12891. if(this.draggable){
  12892. this.header.addClass("x-window-draggable");
  12893. }
  12894. this.initTools();
  12895. this.el.on("mousedown", this.toFront, this);
  12896. this.manager = this.manager || Ext.WindowMgr;
  12897. this.manager.register(this);
  12898. this.hidden = true;
  12899. if(this.maximized){
  12900. this.maximized = false;
  12901. this.maximize();
  12902. }
  12903. if(this.closable){
  12904. var km = this.getKeyMap();
  12905. km.on(27, this.onEsc, this);
  12906. km.disable();
  12907. }
  12908. },
  12909. initDraggable : function(){
  12910. this.dd = new Ext.Window.DD(this);
  12911. },
  12912. onEsc : function(){
  12913. this[this.closeAction]();
  12914. },
  12915. beforeDestroy : function(){
  12916. Ext.destroy(
  12917. this.resizer,
  12918. this.dd,
  12919. this.proxy,
  12920. this.mask
  12921. );
  12922. Ext.Window.superclass.beforeDestroy.call(this);
  12923. },
  12924. onDestroy : function(){
  12925. if(this.manager){
  12926. this.manager.unregister(this);
  12927. }
  12928. Ext.Window.superclass.onDestroy.call(this);
  12929. },
  12930. initTools : function(){
  12931. if(this.minimizable){
  12932. this.addTool({
  12933. id: 'minimize',
  12934. handler: this.minimize.createDelegate(this, [])
  12935. });
  12936. }
  12937. if(this.maximizable){
  12938. this.addTool({
  12939. id: 'maximize',
  12940. handler: this.maximize.createDelegate(this, [])
  12941. });
  12942. this.addTool({
  12943. id: 'restore',
  12944. handler: this.restore.createDelegate(this, []),
  12945. hidden:true
  12946. });
  12947. this.header.on('dblclick', this.toggleMaximize, this);
  12948. }
  12949. if(this.closable){
  12950. this.addTool({
  12951. id: 'close',
  12952. handler: this[this.closeAction].createDelegate(this, [])
  12953. });
  12954. }
  12955. },
  12956. resizerAction : function(){
  12957. var box = this.proxy.getBox();
  12958. this.proxy.hide();
  12959. this.window.handleResize(box);
  12960. return box;
  12961. },
  12962. beforeResize : function(){
  12963. this.resizer.minHeight = Math.max(this.minHeight, this.getFrameHeight() + 40); this.resizer.minWidth = Math.max(this.minWidth, this.getFrameWidth() + 40);
  12964. this.resizeBox = this.el.getBox();
  12965. },
  12966. updateHandles : function(){
  12967. if(Ext.isIE && this.resizer){
  12968. this.resizer.syncHandleHeight();
  12969. this.el.repaint();
  12970. }
  12971. },
  12972. handleResize : function(box){
  12973. var rz = this.resizeBox;
  12974. if(rz.x != box.x || rz.y != box.y){
  12975. this.updateBox(box);
  12976. }else{
  12977. this.setSize(box);
  12978. }
  12979. this.focus();
  12980. this.updateHandles();
  12981. this.saveState();
  12982. this.fireEvent("resize", this, box.width, box.height);
  12983. },
  12984. focus : function(){
  12985. var f = this.focusEl, db = this.defaultButton, t = typeof db;
  12986. if(t != 'undefined'){
  12987. if(t == 'number'){
  12988. f = this.buttons[db];
  12989. }else if(t == 'string'){
  12990. f = Ext.getCmp(db);
  12991. }else{
  12992. f = db;
  12993. }
  12994. }
  12995. f.focus.defer(10, f);
  12996. },
  12997. setAnimateTarget : function(el){
  12998. el = Ext.get(el);
  12999. this.animateTarget = el;
  13000. },
  13001. beforeShow : function(){
  13002. delete this.el.lastXY;
  13003. delete this.el.lastLT;
  13004. if(this.x === undefined || this.y === undefined){
  13005. var xy = this.el.getAlignToXY(this.container, 'c-c');
  13006. var pos = this.el.translatePoints(xy[0], xy[1]);
  13007. this.x = this.x === undefined? pos.left : this.x;
  13008. this.y = this.y === undefined? pos.top : this.y;
  13009. }
  13010. this.el.setLeftTop(this.x, this.y);
  13011. if(this.expandOnShow){
  13012. this.expand(false);
  13013. }
  13014. if(this.modal){
  13015. Ext.getBody().addClass("x-body-masked");
  13016. this.mask.setSize(Ext.lib.Dom.getViewWidth(true), Ext.lib.Dom.getViewHeight(true));
  13017. this.mask.show();
  13018. }
  13019. },
  13020. show : function(animateTarget, cb, scope){
  13021. if(!this.rendered){
  13022. this.render(Ext.getBody());
  13023. }
  13024. if(this.hidden === false){
  13025. this.toFront();
  13026. return;
  13027. }
  13028. if(this.fireEvent("beforeshow", this) === false){
  13029. return;
  13030. }
  13031. if(cb){
  13032. this.on('show', cb, scope, {single:true});
  13033. }
  13034. this.hidden = false;
  13035. if(animateTarget !== undefined){
  13036. this.setAnimateTarget(animateTarget);
  13037. }
  13038. this.beforeShow();
  13039. if(this.animateTarget){
  13040. this.animShow();
  13041. }else{
  13042. this.afterShow();
  13043. }
  13044. },
  13045. afterShow : function(){
  13046. this.proxy.hide();
  13047. this.el.setStyle('display', 'block');
  13048. this.el.show();
  13049. if(this.maximized){
  13050. this.fitContainer();
  13051. }
  13052. if(Ext.isMac && Ext.isGecko){ this.cascade(this.setAutoScroll);
  13053. }
  13054. if(this.monitorResize || this.modal || this.constrain || this.constrainHeader){
  13055. Ext.EventManager.onWindowResize(this.onWindowResize, this);
  13056. }
  13057. this.doConstrain();
  13058. if(this.layout){
  13059. this.doLayout();
  13060. }
  13061. if(this.keyMap){
  13062. this.keyMap.enable();
  13063. }
  13064. this.toFront();
  13065. this.updateHandles();
  13066. this.fireEvent("show", this);
  13067. },
  13068. animShow : function(){
  13069. this.proxy.show();
  13070. this.proxy.setBox(this.animateTarget.getBox());
  13071. this.proxy.setOpacity(0);
  13072. var b = this.getBox(false);
  13073. b.callback = this.afterShow;
  13074. b.scope = this;
  13075. b.duration = .25;
  13076. b.easing = 'easeNone';
  13077. b.opacity = .5;
  13078. b.block = true;
  13079. this.el.setStyle('display', 'none');
  13080. this.proxy.shift(b);
  13081. },
  13082. hide : function(animateTarget, cb, scope){
  13083. if(this.hidden || this.fireEvent("beforehide", this) === false){
  13084. return;
  13085. }
  13086. if(cb){
  13087. this.on('hide', cb, scope, {single:true});
  13088. }
  13089. this.hidden = true;
  13090. if(animateTarget !== undefined){
  13091. this.setAnimateTarget(animateTarget);
  13092. }
  13093. if(this.animateTarget){
  13094. this.animHide();
  13095. }else{
  13096. this.el.hide();
  13097. this.afterHide();
  13098. }
  13099. },
  13100. afterHide : function(){
  13101. this.proxy.hide();
  13102. if(this.monitorResize || this.modal || this.constrain || this.constrainHeader){
  13103. Ext.EventManager.removeResizeListener(this.onWindowResize, this);
  13104. }
  13105. if(this.modal){
  13106. this.mask.hide();
  13107. Ext.getBody().removeClass("x-body-masked");
  13108. }
  13109. if(this.keyMap){
  13110. this.keyMap.disable();
  13111. }
  13112. this.fireEvent("hide", this);
  13113. },
  13114. animHide : function(){
  13115. this.proxy.setOpacity(.5);
  13116. this.proxy.show();
  13117. var tb = this.getBox(false);
  13118. this.proxy.setBox(tb);
  13119. this.el.hide();
  13120. var b = this.animateTarget.getBox();
  13121. b.callback = this.afterHide;
  13122. b.scope = this;
  13123. b.duration = .25;
  13124. b.easing = 'easeNone';
  13125. b.block = true;
  13126. b.opacity = 0;
  13127. this.proxy.shift(b);
  13128. },
  13129. onWindowResize : function(){
  13130. if(this.maximized){
  13131. this.fitContainer();
  13132. }
  13133. if(this.modal){
  13134. this.mask.setSize('100%', '100%');
  13135. var force = this.mask.dom.offsetHeight;
  13136. this.mask.setSize(Ext.lib.Dom.getViewWidth(true), Ext.lib.Dom.getViewHeight(true));
  13137. }
  13138. this.doConstrain();
  13139. },
  13140. doConstrain : function(){
  13141. if(this.constrain || this.constrainHeader){
  13142. var offsets;
  13143. if(this.constrain){
  13144. offsets = {
  13145. right:this.el.shadowOffset,
  13146. left:this.el.shadowOffset,
  13147. bottom:this.el.shadowOffset
  13148. };
  13149. }else {
  13150. var s = this.getSize();
  13151. offsets = {
  13152. right:-(s.width - 100),
  13153. bottom:-(s.height - 25)
  13154. };
  13155. }
  13156. var xy = this.el.getConstrainToXY(this.container, true, offsets);
  13157. if(xy){
  13158. this.setPosition(xy[0], xy[1]);
  13159. }
  13160. }
  13161. },
  13162. ghost : function(cls){
  13163. var ghost = this.createGhost(cls);
  13164. var box = this.getBox(true);
  13165. ghost.setLeftTop(box.x, box.y);
  13166. ghost.setWidth(box.width);
  13167. this.el.hide();
  13168. this.activeGhost = ghost;
  13169. return ghost;
  13170. },
  13171. unghost : function(show, matchPosition){
  13172. if(show !== false){
  13173. this.el.show();
  13174. this.focus();
  13175. if(Ext.isMac && Ext.isGecko){ this.cascade(this.setAutoScroll);
  13176. }
  13177. }
  13178. if(matchPosition !== false){
  13179. this.setPosition(this.activeGhost.getLeft(true), this.activeGhost.getTop(true));
  13180. }
  13181. this.activeGhost.hide();
  13182. this.activeGhost.remove();
  13183. delete this.activeGhost;
  13184. },
  13185. minimize : function(){
  13186. this.fireEvent('minimize', this);
  13187. },
  13188. close : function(){
  13189. if(this.fireEvent("beforeclose", this) !== false){
  13190. this.hide(null, function(){
  13191. this.fireEvent('close', this);
  13192. this.destroy();
  13193. }, this);
  13194. }
  13195. },
  13196. maximize : function(){
  13197. if(!this.maximized){
  13198. this.expand(false);
  13199. this.restoreSize = this.getSize();
  13200. this.restorePos = this.getPosition(true);
  13201. this.tools.maximize.hide();
  13202. this.tools.restore.show();
  13203. this.maximized = true;
  13204. this.el.disableShadow();
  13205. if(this.dd){
  13206. this.dd.lock();
  13207. }
  13208. if(this.collapsible){
  13209. this.tools.toggle.hide();
  13210. }
  13211. this.el.addClass('x-window-maximized');
  13212. this.container.addClass('x-window-maximized-ct');
  13213. this.setPosition(0, 0);
  13214. this.fitContainer();
  13215. this.fireEvent('maximize', this);
  13216. }
  13217. },
  13218. restore : function(){
  13219. if(this.maximized){
  13220. this.el.removeClass('x-window-maximized');
  13221. this.tools.restore.hide();
  13222. this.tools.maximize.show();
  13223. this.setPosition(this.restorePos[0], this.restorePos[1]);
  13224. this.setSize(this.restoreSize.width, this.restoreSize.height);
  13225. delete this.restorePos;
  13226. delete this.restoreSize;
  13227. this.maximized = false;
  13228. this.el.enableShadow(true);
  13229. if(this.dd){
  13230. this.dd.unlock();
  13231. }
  13232. if(this.collapsible){
  13233. this.tools.toggle.show();
  13234. }
  13235. this.container.removeClass('x-window-maximized-ct');
  13236. this.doConstrain();
  13237. this.fireEvent('restore', this);
  13238. }
  13239. },
  13240. toggleMaximize : function(){
  13241. this[this.maximized ? 'restore' : 'maximize']();
  13242. },
  13243. fitContainer : function(){
  13244. var vs = this.container.getViewSize();
  13245. this.setSize(vs.width, vs.height);
  13246. },
  13247. setZIndex : function(index){
  13248. if(this.modal){
  13249. this.mask.setStyle("z-index", index);
  13250. }
  13251. this.el.setZIndex(++index);
  13252. index += 5;
  13253. if(this.resizer){
  13254. this.resizer.proxy.setStyle("z-index", ++index);
  13255. }
  13256. this.lastZIndex = index;
  13257. },
  13258. alignTo : function(element, position, offsets){
  13259. var xy = this.el.getAlignToXY(element, position, offsets);
  13260. this.setPagePosition(xy[0], xy[1]);
  13261. return this;
  13262. },
  13263. anchorTo : function(el, alignment, offsets, monitorScroll, _pname){
  13264. var action = function(){
  13265. this.alignTo(el, alignment, offsets);
  13266. };
  13267. Ext.EventManager.onWindowResize(action, this);
  13268. var tm = typeof monitorScroll;
  13269. if(tm != 'undefined'){
  13270. Ext.EventManager.on(window, 'scroll', action, this,
  13271. {buffer: tm == 'number' ? monitorScroll : 50});
  13272. }
  13273. action.call(this);
  13274. this[_pname] = action;
  13275. return this;
  13276. },
  13277. toFront : function(){
  13278. if(this.manager.bringToFront(this)){
  13279. this.focus();
  13280. }
  13281. return this;
  13282. },
  13283. setActive : function(active){
  13284. if(active){
  13285. if(!this.maximized){
  13286. this.el.enableShadow(true);
  13287. }
  13288. this.fireEvent('activate', this);
  13289. }else{
  13290. this.el.disableShadow();
  13291. this.fireEvent('deactivate', this);
  13292. }
  13293. },
  13294. toBack : function(){
  13295. this.manager.sendToBack(this);
  13296. return this;
  13297. },
  13298. center : function(){
  13299. var xy = this.el.getAlignToXY(this.container, 'c-c');
  13300. this.setPagePosition(xy[0], xy[1]);
  13301. return this;
  13302. }
  13303. });
  13304. Ext.reg('window', Ext.Window);
  13305. Ext.Window.DD = function(win){
  13306. this.win = win;
  13307. Ext.Window.DD.superclass.constructor.call(this, win.el.id, 'WindowDD-'+win.id);
  13308. this.setHandleElId(win.header.id);
  13309. this.scroll = false;
  13310. };
  13311. Ext.extend(Ext.Window.DD, Ext.dd.DD, {
  13312. moveOnly:true,
  13313. headerOffsets:[100, 25],
  13314. startDrag : function(){
  13315. var w = this.win;
  13316. this.proxy = w.ghost();
  13317. if(w.constrain !== false){
  13318. var so = w.el.shadowOffset;
  13319. this.constrainTo(w.container, {right: so, left: so, bottom: so});
  13320. }else if(w.constrainHeader !== false){
  13321. var s = this.proxy.getSize();
  13322. this.constrainTo(w.container, {right: -(s.width-this.headerOffsets[0]), bottom: -(s.height-this.headerOffsets[1])});
  13323. }
  13324. },
  13325. b4Drag : Ext.emptyFn,
  13326. onDrag : function(e){
  13327. this.alignElWithMouse(this.proxy, e.getPageX(), e.getPageY());
  13328. },
  13329. endDrag : function(e){
  13330. this.win.unghost();
  13331. this.win.saveState();
  13332. }
  13333. });
  13334. Ext.WindowGroup = function(){
  13335. var list = {};
  13336. var accessList = [];
  13337. var front = null;
  13338. var sortWindows = function(d1, d2){
  13339. return (!d1._lastAccess || d1._lastAccess < d2._lastAccess) ? -1 : 1;
  13340. };
  13341. var orderWindows = function(){
  13342. var a = accessList, len = a.length;
  13343. if(len > 0){
  13344. a.sort(sortWindows);
  13345. var seed = a[0].manager.zseed;
  13346. for(var i = 0; i < len; i++){
  13347. var win = a[i];
  13348. if(win && !win.hidden){
  13349. win.setZIndex(seed + (i*10));
  13350. }
  13351. }
  13352. }
  13353. activateLast();
  13354. };
  13355. var setActiveWin = function(win){
  13356. if(win != front){
  13357. if(front){
  13358. front.setActive(false);
  13359. }
  13360. front = win;
  13361. if(win){
  13362. win.setActive(true);
  13363. }
  13364. }
  13365. };
  13366. var activateLast = function(){
  13367. for(var i = accessList.length-1; i >=0; --i) {
  13368. if(!accessList[i].hidden){
  13369. setActiveWin(accessList[i]);
  13370. return;
  13371. }
  13372. }
  13373. setActiveWin(null);
  13374. };
  13375. return {
  13376. zseed : 9000,
  13377. register : function(win){
  13378. list[win.id] = win;
  13379. accessList.push(win);
  13380. win.on('hide', activateLast);
  13381. },
  13382. unregister : function(win){
  13383. delete list[win.id];
  13384. win.un('hide', activateLast);
  13385. accessList.remove(win);
  13386. },
  13387. get : function(id){
  13388. return typeof id == "object" ? id : list[id];
  13389. },
  13390. bringToFront : function(win){
  13391. win = this.get(win);
  13392. if(win != front){
  13393. win._lastAccess = new Date().getTime();
  13394. orderWindows();
  13395. return true;
  13396. }
  13397. return false;
  13398. },
  13399. sendToBack : function(win){
  13400. win = this.get(win);
  13401. win._lastAccess = -(new Date().getTime());
  13402. orderWindows();
  13403. return win;
  13404. },
  13405. hideAll : function(){
  13406. for(var id in list){
  13407. if(list[id] && typeof list[id] != "function" && list[id].isVisible()){
  13408. list[id].hide();
  13409. }
  13410. }
  13411. },
  13412. getActive : function(){
  13413. return front;
  13414. },
  13415. getBy : function(fn, scope){
  13416. var r = [];
  13417. for(var i = accessList.length-1; i >=0; --i) {
  13418. var win = accessList[i];
  13419. if(fn.call(scope||win, win) !== false){
  13420. r.push(win);
  13421. }
  13422. }
  13423. return r;
  13424. },
  13425. each : function(fn, scope){
  13426. for(var id in list){
  13427. if(list[id] && typeof list[id] != "function"){
  13428. if(fn.call(scope || list[id], list[id]) === false){
  13429. return;
  13430. }
  13431. }
  13432. }
  13433. }
  13434. };
  13435. };
  13436. Ext.WindowMgr = new Ext.WindowGroup();
  13437. Ext.dd.PanelProxy = function(panel, config){
  13438. this.panel = panel;
  13439. this.id = this.panel.id +'-ddproxy';
  13440. Ext.apply(this, config);
  13441. };
  13442. Ext.dd.PanelProxy.prototype = {
  13443. insertProxy : true,
  13444. setStatus : Ext.emptyFn,
  13445. reset : Ext.emptyFn,
  13446. update : Ext.emptyFn,
  13447. stop : Ext.emptyFn,
  13448. sync: Ext.emptyFn,
  13449. getEl : function(){
  13450. return this.ghost;
  13451. },
  13452. getGhost : function(){
  13453. return this.ghost;
  13454. },
  13455. getProxy : function(){
  13456. return this.proxy;
  13457. },
  13458. hide : function(){
  13459. if(this.ghost){
  13460. if(this.proxy){
  13461. this.proxy.remove();
  13462. delete this.proxy;
  13463. }
  13464. this.panel.el.dom.style.display = '';
  13465. this.ghost.remove();
  13466. delete this.ghost;
  13467. }
  13468. },
  13469. show : function(){
  13470. if(!this.ghost){
  13471. this.ghost = this.panel.createGhost(undefined, undefined, Ext.getBody());
  13472. this.ghost.setXY(this.panel.el.getXY())
  13473. if(this.insertProxy){
  13474. this.proxy = this.panel.el.insertSibling({cls:'x-panel-dd-spacer'});
  13475. this.proxy.setSize(this.panel.getSize());
  13476. }
  13477. this.panel.el.dom.style.display = 'none';
  13478. }
  13479. },
  13480. repair : function(xy, callback, scope){
  13481. this.hide();
  13482. if(typeof callback == "function"){
  13483. callback.call(scope || this);
  13484. }
  13485. },
  13486. moveProxy : function(parentNode, before){
  13487. if(this.proxy){
  13488. parentNode.insertBefore(this.proxy.dom, before);
  13489. }
  13490. }
  13491. };
  13492. Ext.Panel.DD = function(panel, cfg){
  13493. this.panel = panel;
  13494. this.dragData = {panel: panel};
  13495. this.proxy = new Ext.dd.PanelProxy(panel, cfg);
  13496. Ext.Panel.DD.superclass.constructor.call(this, panel.el, cfg);
  13497. this.setHandleElId(panel.header.id);
  13498. panel.header.setStyle('cursor', 'move');
  13499. this.scroll = false;
  13500. };
  13501. Ext.extend(Ext.Panel.DD, Ext.dd.DragSource, {
  13502. showFrame: Ext.emptyFn,
  13503. startDrag: Ext.emptyFn,
  13504. b4StartDrag: function(x, y) {
  13505. this.proxy.show();
  13506. },
  13507. b4MouseDown: function(e) {
  13508. var x = e.getPageX();
  13509. var y = e.getPageY();
  13510. this.autoOffset(x, y);
  13511. },
  13512. onInitDrag : function(x, y){
  13513. this.onStartDrag(x, y);
  13514. return true;
  13515. },
  13516. createFrame : Ext.emptyFn,
  13517. getDragEl : function(e){
  13518. return this.proxy.ghost.dom;
  13519. },
  13520. endDrag : function(e){
  13521. this.proxy.hide();
  13522. this.panel.saveState();
  13523. },
  13524. autoOffset : function(x, y) {
  13525. x -= this.startPageX;
  13526. y -= this.startPageY;
  13527. this.setDelta(x, y);
  13528. }
  13529. });
  13530. Ext.state.Provider = function(){
  13531. this.addEvents("statechange");
  13532. this.state = {};
  13533. Ext.state.Provider.superclass.constructor.call(this);
  13534. };
  13535. Ext.extend(Ext.state.Provider, Ext.util.Observable, {
  13536. get : function(name, defaultValue){
  13537. return typeof this.state[name] == "undefined" ?
  13538. defaultValue : this.state[name];
  13539. },
  13540. clear : function(name){
  13541. delete this.state[name];
  13542. this.fireEvent("statechange", this, name, null);
  13543. },
  13544. set : function(name, value){
  13545. this.state[name] = value;
  13546. this.fireEvent("statechange", this, name, value);
  13547. },
  13548. decodeValue : function(cookie){
  13549. var re = /^(a|n|d|b|s|o)\:(.*)$/;
  13550. var matches = re.exec(unescape(cookie));
  13551. if(!matches || !matches[1]) return;
  13552. var type = matches[1];
  13553. var v = matches[2];
  13554. switch(type){
  13555. case "n":
  13556. return parseFloat(v);
  13557. case "d":
  13558. return new Date(Date.parse(v));
  13559. case "b":
  13560. return (v == "1");
  13561. case "a":
  13562. var all = [];
  13563. var values = v.split("^");
  13564. for(var i = 0, len = values.length; i < len; i++){
  13565. all.push(this.decodeValue(values[i]));
  13566. }
  13567. return all;
  13568. case "o":
  13569. var all = {};
  13570. var values = v.split("^");
  13571. for(var i = 0, len = values.length; i < len; i++){
  13572. var kv = values[i].split("=");
  13573. all[kv[0]] = this.decodeValue(kv[1]);
  13574. }
  13575. return all;
  13576. default:
  13577. return v;
  13578. }
  13579. },
  13580. encodeValue : function(v){
  13581. var enc;
  13582. if(typeof v == "number"){
  13583. enc = "n:" + v;
  13584. }else if(typeof v == "boolean"){
  13585. enc = "b:" + (v ? "1" : "0");
  13586. }else if(Ext.isDate(v)){
  13587. enc = "d:" + v.toGMTString();
  13588. }else if(Ext.isArray(v)){
  13589. var flat = "";
  13590. for(var i = 0, len = v.length; i < len; i++){
  13591. flat += this.encodeValue(v[i]);
  13592. if(i != len-1) flat += "^";
  13593. }
  13594. enc = "a:" + flat;
  13595. }else if(typeof v == "object"){
  13596. var flat = "";
  13597. for(var key in v){
  13598. if(typeof v[key] != "function" && v[key] !== undefined){
  13599. flat += key + "=" + this.encodeValue(v[key]) + "^";
  13600. }
  13601. }
  13602. enc = "o:" + flat.substring(0, flat.length-1);
  13603. }else{
  13604. enc = "s:" + v;
  13605. }
  13606. return escape(enc);
  13607. }
  13608. });
  13609. Ext.state.Manager = function(){
  13610. var provider = new Ext.state.Provider();
  13611. return {
  13612. setProvider : function(stateProvider){
  13613. provider = stateProvider;
  13614. },
  13615. get : function(key, defaultValue){
  13616. return provider.get(key, defaultValue);
  13617. },
  13618. set : function(key, value){
  13619. provider.set(key, value);
  13620. },
  13621. clear : function(key){
  13622. provider.clear(key);
  13623. },
  13624. getProvider : function(){
  13625. return provider;
  13626. }
  13627. };
  13628. }();
  13629. Ext.state.CookieProvider = function(config){
  13630. Ext.state.CookieProvider.superclass.constructor.call(this);
  13631. this.path = "/";
  13632. this.expires = new Date(new Date().getTime()+(1000*60*60*24*7));
  13633. this.domain = null;
  13634. this.secure = false;
  13635. Ext.apply(this, config);
  13636. this.state = this.readCookies();
  13637. };
  13638. Ext.extend(Ext.state.CookieProvider, Ext.state.Provider, {
  13639. set : function(name, value){
  13640. if(typeof value == "undefined" || value === null){
  13641. this.clear(name);
  13642. return;
  13643. }
  13644. this.setCookie(name, value);
  13645. Ext.state.CookieProvider.superclass.set.call(this, name, value);
  13646. },
  13647. clear : function(name){
  13648. this.clearCookie(name);
  13649. Ext.state.CookieProvider.superclass.clear.call(this, name);
  13650. },
  13651. readCookies : function(){
  13652. var cookies = {};
  13653. var c = document.cookie + ";";
  13654. var re = /\s?(.*?)=(.*?);/g;
  13655. var matches;
  13656. while((matches = re.exec(c)) != null){
  13657. var name = matches[1];
  13658. var value = matches[2];
  13659. if(name && name.substring(0,3) == "ys-"){
  13660. cookies[name.substr(3)] = this.decodeValue(value);
  13661. }
  13662. }
  13663. return cookies;
  13664. },
  13665. setCookie : function(name, value){
  13666. document.cookie = "ys-"+ name + "=" + this.encodeValue(value) +
  13667. ((this.expires == null) ? "" : ("; expires=" + this.expires.toGMTString())) +
  13668. ((this.path == null) ? "" : ("; path=" + this.path)) +
  13669. ((this.domain == null) ? "" : ("; domain=" + this.domain)) +
  13670. ((this.secure == true) ? "; secure" : "");
  13671. },
  13672. clearCookie : function(name){
  13673. document.cookie = "ys-" + name + "=null; expires=Thu, 01-Jan-70 00:00:01 GMT" +
  13674. ((this.path == null) ? "" : ("; path=" + this.path)) +
  13675. ((this.domain == null) ? "" : ("; domain=" + this.domain)) +
  13676. ((this.secure == true) ? "; secure" : "");
  13677. }
  13678. });
  13679. Ext.DataView = Ext.extend(Ext.BoxComponent, {
  13680. selectedClass : "x-view-selected",
  13681. emptyText : "",
  13682. last: false,
  13683. initComponent : function(){
  13684. Ext.DataView.superclass.initComponent.call(this);
  13685. if(typeof this.tpl == "string"){
  13686. this.tpl = new Ext.XTemplate(this.tpl);
  13687. }
  13688. this.addEvents(
  13689. "beforeclick",
  13690. "click",
  13691. "containerclick",
  13692. "dblclick",
  13693. "contextmenu",
  13694. "selectionchange",
  13695. "beforeselect"
  13696. );
  13697. this.all = new Ext.CompositeElementLite();
  13698. this.selected = new Ext.CompositeElementLite();
  13699. },
  13700. onRender : function(){
  13701. if(!this.el){
  13702. this.el = document.createElement('div');
  13703. }
  13704. Ext.DataView.superclass.onRender.apply(this, arguments);
  13705. },
  13706. afterRender : function(){
  13707. Ext.DataView.superclass.afterRender.call(this);
  13708. this.el.on({
  13709. "click": this.onClick,
  13710. "dblclick": this.onDblClick,
  13711. "contextmenu": this.onContextMenu,
  13712. scope:this
  13713. });
  13714. if(this.overClass){
  13715. this.el.on({
  13716. "mouseover": this.onMouseOver,
  13717. "mouseout": this.onMouseOut,
  13718. scope:this
  13719. });
  13720. }
  13721. if(this.store){
  13722. this.setStore(this.store, true);
  13723. }
  13724. },
  13725. refresh : function(){
  13726. this.clearSelections(false, true);
  13727. this.el.update("");
  13728. var html = [];
  13729. var records = this.store.getRange();
  13730. if(records.length < 1){
  13731. this.el.update(this.emptyText);
  13732. this.all.clear();
  13733. return;
  13734. }
  13735. this.tpl.overwrite(this.el, this.collectData(records, 0));
  13736. this.all.fill(Ext.query(this.itemSelector, this.el.dom));
  13737. this.updateIndexes(0);
  13738. },
  13739. prepareData : function(data){
  13740. return data;
  13741. },
  13742. collectData : function(records, startIndex){
  13743. var r = [];
  13744. for(var i = 0, len = records.length; i < len; i++){
  13745. r[r.length] = this.prepareData(records[i].data, startIndex+i, records[i]);
  13746. }
  13747. return r;
  13748. },
  13749. bufferRender : function(records){
  13750. var div = document.createElement('div');
  13751. this.tpl.overwrite(div, this.collectData(records));
  13752. return Ext.query(this.itemSelector, div);
  13753. },
  13754. onUpdate : function(ds, record){
  13755. var index = this.store.indexOf(record);
  13756. var sel = this.isSelected(index);
  13757. var original = this.all.elements[index];
  13758. var node = this.bufferRender([record], index)[0];
  13759. this.all.replaceElement(index, node, true);
  13760. if(sel){
  13761. this.selected.replaceElement(original, node);
  13762. this.all.item(index).addClass(this.selectedClass);
  13763. }
  13764. this.updateIndexes(index, index);
  13765. },
  13766. onAdd : function(ds, records, index){
  13767. if(this.all.getCount() == 0){
  13768. this.refresh();
  13769. return;
  13770. }
  13771. var nodes = this.bufferRender(records, index), n;
  13772. if(index < this.all.getCount()){
  13773. n = this.all.item(index).insertSibling(nodes, 'before', true);
  13774. this.all.elements.splice(index, 0, n);
  13775. }else{
  13776. n = this.all.last().insertSibling(nodes, 'after', true);
  13777. this.all.elements.push(n);
  13778. }
  13779. this.updateIndexes(index);
  13780. },
  13781. onRemove : function(ds, record, index){
  13782. this.deselect(index);
  13783. this.all.removeElement(index, true);
  13784. this.updateIndexes(index);
  13785. },
  13786. refreshNode : function(index){
  13787. this.onUpdate(this.store, this.store.getAt(index));
  13788. },
  13789. updateIndexes : function(startIndex, endIndex){
  13790. var ns = this.all.elements;
  13791. startIndex = startIndex || 0;
  13792. endIndex = endIndex || ((endIndex === 0) ? 0 : (ns.length - 1));
  13793. for(var i = startIndex; i <= endIndex; i++){
  13794. ns[i].viewIndex = i;
  13795. }
  13796. },
  13797. setStore : function(store, initial){
  13798. if(!initial && this.store){
  13799. this.store.un("beforeload", this.onBeforeLoad, this);
  13800. this.store.un("datachanged", this.refresh, this);
  13801. this.store.un("add", this.onAdd, this);
  13802. this.store.un("remove", this.onRemove, this);
  13803. this.store.un("update", this.onUpdate, this);
  13804. this.store.un("clear", this.refresh, this);
  13805. }
  13806. if(store){
  13807. store = Ext.StoreMgr.lookup(store);
  13808. store.on("beforeload", this.onBeforeLoad, this);
  13809. store.on("datachanged", this.refresh, this);
  13810. store.on("add", this.onAdd, this);
  13811. store.on("remove", this.onRemove, this);
  13812. store.on("update", this.onUpdate, this);
  13813. store.on("clear", this.refresh, this);
  13814. }
  13815. this.store = store;
  13816. if(store){
  13817. this.refresh();
  13818. }
  13819. },
  13820. findItemFromChild : function(node){
  13821. return Ext.fly(node).findParent(this.itemSelector, this.el);
  13822. },
  13823. onClick : function(e){
  13824. var item = e.getTarget(this.itemSelector, this.el);
  13825. if(item){
  13826. var index = this.indexOf(item);
  13827. if(this.onItemClick(item, index, e) !== false){
  13828. this.fireEvent("click", this, index, item, e);
  13829. }
  13830. }else{
  13831. if(this.fireEvent("containerclick", this, e) !== false){
  13832. this.clearSelections();
  13833. }
  13834. }
  13835. },
  13836. onContextMenu : function(e){
  13837. var item = e.getTarget(this.itemSelector, this.el);
  13838. if(item){
  13839. this.fireEvent("contextmenu", this, this.indexOf(item), item, e);
  13840. }
  13841. },
  13842. onDblClick : function(e){
  13843. var item = e.getTarget(this.itemSelector, this.el);
  13844. if(item){
  13845. this.fireEvent("dblclick", this, this.indexOf(item), item, e);
  13846. }
  13847. },
  13848. onMouseOver : function(e){
  13849. var item = e.getTarget(this.itemSelector, this.el);
  13850. if(item && item !== this.lastItem){
  13851. this.lastItem = item;
  13852. Ext.fly(item).addClass(this.overClass);
  13853. }
  13854. },
  13855. onMouseOut : function(e){
  13856. if(this.lastItem){
  13857. if(!e.within(this.lastItem, true)){
  13858. Ext.fly(this.lastItem).removeClass(this.overClass);
  13859. delete this.lastItem;
  13860. }
  13861. }
  13862. },
  13863. onItemClick : function(item, index, e){
  13864. if(this.fireEvent("beforeclick", this, index, item, e) === false){
  13865. return false;
  13866. }
  13867. if(this.multiSelect){
  13868. this.doMultiSelection(item, index, e);
  13869. e.preventDefault();
  13870. }else if(this.singleSelect){
  13871. this.doSingleSelection(item, index, e);
  13872. e.preventDefault();
  13873. }
  13874. return true;
  13875. },
  13876. doSingleSelection : function(item, index, e){
  13877. if(e.ctrlKey && this.isSelected(index)){
  13878. this.deselect(index);
  13879. }else{
  13880. this.select(index, false);
  13881. }
  13882. },
  13883. doMultiSelection : function(item, index, e){
  13884. if(e.shiftKey && this.last !== false){
  13885. var last = this.last;
  13886. this.selectRange(last, index, e.ctrlKey);
  13887. this.last = last;
  13888. }else{
  13889. if((e.ctrlKey||this.simpleSelect) && this.isSelected(index)){
  13890. this.deselect(index);
  13891. }else{
  13892. this.select(index, e.ctrlKey || e.shiftKey || this.simpleSelect);
  13893. }
  13894. }
  13895. },
  13896. getSelectionCount : function(){
  13897. return this.selected.getCount()
  13898. },
  13899. getSelectedNodes : function(){
  13900. return this.selected.elements;
  13901. },
  13902. getSelectedIndexes : function(){
  13903. var indexes = [], s = this.selected.elements;
  13904. for(var i = 0, len = s.length; i < len; i++){
  13905. indexes.push(s[i].viewIndex);
  13906. }
  13907. return indexes;
  13908. },
  13909. getSelectedRecords : function(){
  13910. var r = [], s = this.selected.elements;
  13911. for(var i = 0, len = s.length; i < len; i++){
  13912. r[r.length] = this.store.getAt(s[i].viewIndex);
  13913. }
  13914. return r;
  13915. },
  13916. getRecords : function(nodes){
  13917. var r = [], s = nodes;
  13918. for(var i = 0, len = s.length; i < len; i++){
  13919. r[r.length] = this.store.getAt(s[i].viewIndex);
  13920. }
  13921. return r;
  13922. },
  13923. getRecord : function(node){
  13924. return this.store.getAt(node.viewIndex);
  13925. },
  13926. clearSelections : function(suppressEvent, skipUpdate){
  13927. if(this.multiSelect || this.singleSelect){
  13928. if(!skipUpdate){
  13929. this.selected.removeClass(this.selectedClass);
  13930. }
  13931. this.selected.clear();
  13932. this.last = false;
  13933. if(!suppressEvent){
  13934. this.fireEvent("selectionchange", this, this.selected.elements);
  13935. }
  13936. }
  13937. },
  13938. isSelected : function(node){
  13939. return this.selected.contains(this.getNode(node));
  13940. },
  13941. deselect : function(node){
  13942. if(this.isSelected(node)){
  13943. var node = this.getNode(node);
  13944. this.selected.removeElement(node);
  13945. if(this.last == node.viewIndex){
  13946. this.last = false;
  13947. }
  13948. Ext.fly(node).removeClass(this.selectedClass);
  13949. this.fireEvent("selectionchange", this, this.selected.elements);
  13950. }
  13951. },
  13952. select : function(nodeInfo, keepExisting, suppressEvent){
  13953. if(Ext.isArray(nodeInfo)){
  13954. if(!keepExisting){
  13955. this.clearSelections(true);
  13956. }
  13957. for(var i = 0, len = nodeInfo.length; i < len; i++){
  13958. this.select(nodeInfo[i], true, true);
  13959. }
  13960. } else{
  13961. var node = this.getNode(nodeInfo);
  13962. if(!keepExisting){
  13963. this.clearSelections(true);
  13964. }
  13965. if(node && !this.isSelected(node)){
  13966. if(this.fireEvent("beforeselect", this, node, this.selected.elements) !== false){
  13967. Ext.fly(node).addClass(this.selectedClass);
  13968. this.selected.add(node);
  13969. this.last = node.viewIndex;
  13970. if(!suppressEvent){
  13971. this.fireEvent("selectionchange", this, this.selected.elements);
  13972. }
  13973. }
  13974. }
  13975. }
  13976. },
  13977. selectRange : function(start, end, keepExisting){
  13978. if(!keepExisting){
  13979. this.clearSelections(true);
  13980. }
  13981. this.select(this.getNodes(start, end), true);
  13982. },
  13983. getNode : function(nodeInfo){
  13984. if(typeof nodeInfo == "string"){
  13985. return document.getElementById(nodeInfo);
  13986. }else if(typeof nodeInfo == "number"){
  13987. return this.all.elements[nodeInfo];
  13988. }
  13989. return nodeInfo;
  13990. },
  13991. getNodes : function(start, end){
  13992. var ns = this.all.elements;
  13993. start = start || 0;
  13994. end = typeof end == "undefined" ? ns.length - 1 : end;
  13995. var nodes = [], i;
  13996. if(start <= end){
  13997. for(i = start; i <= end; i++){
  13998. nodes.push(ns[i]);
  13999. }
  14000. } else{
  14001. for(i = start; i >= end; i--){
  14002. nodes.push(ns[i]);
  14003. }
  14004. }
  14005. return nodes;
  14006. },
  14007. indexOf : function(node){
  14008. node = this.getNode(node);
  14009. if(typeof node.viewIndex == "number"){
  14010. return node.viewIndex;
  14011. }
  14012. return this.all.indexOf(node);
  14013. },
  14014. onBeforeLoad : function(){
  14015. if(this.loadingText){
  14016. this.clearSelections(false, true);
  14017. this.el.update('<div class="loading-indicator">'+this.loadingText+'</div>');
  14018. this.all.clear();
  14019. }
  14020. }
  14021. });
  14022. Ext.reg('dataview', Ext.DataView);
  14023. Ext.ColorPalette = function(config){
  14024. Ext.ColorPalette.superclass.constructor.call(this, config);
  14025. this.addEvents(
  14026. 'select'
  14027. );
  14028. if(this.handler){
  14029. this.on("select", this.handler, this.scope, true);
  14030. }
  14031. };
  14032. Ext.extend(Ext.ColorPalette, Ext.Component, {
  14033. itemCls : "x-color-palette",
  14034. value : null,
  14035. clickEvent:'click',
  14036. ctype: "Ext.ColorPalette",
  14037. allowReselect : false,
  14038. colors : [
  14039. "000000", "993300", "333300", "003300", "003366", "000080", "333399", "333333",
  14040. "800000", "FF6600", "808000", "008000", "008080", "0000FF", "666699", "808080",
  14041. "FF0000", "FF9900", "99CC00", "339966", "33CCCC", "3366FF", "800080", "969696",
  14042. "FF00FF", "FFCC00", "FFFF00", "00FF00", "00FFFF", "00CCFF", "993366", "C0C0C0",
  14043. "FF99CC", "FFCC99", "FFFFCC", "CCFFCC", "CCFFFF", "99CCFF", "CC99FF", "FFFFFF"
  14044. ],
  14045. onRender : function(container, position){
  14046. var t = this.tpl || new Ext.XTemplate(
  14047. '<tpl for="."><a href="#" class="color-{.}" hidefocus="on"><em><span style="background:#{.}" unselectable="on">&#160;</span></em></a></tpl>'
  14048. );
  14049. var el = document.createElement("div");
  14050. el.className = this.itemCls;
  14051. t.overwrite(el, this.colors);
  14052. container.dom.insertBefore(el, position);
  14053. this.el = Ext.get(el);
  14054. this.el.on(this.clickEvent, this.handleClick, this, {delegate: "a"});
  14055. if(this.clickEvent != 'click'){
  14056. this.el.on('click', Ext.emptyFn, this, {delegate: "a", preventDefault:true});
  14057. }
  14058. },
  14059. afterRender : function(){
  14060. Ext.ColorPalette.superclass.afterRender.call(this);
  14061. if(this.value){
  14062. var s = this.value;
  14063. this.value = null;
  14064. this.select(s);
  14065. }
  14066. },
  14067. handleClick : function(e, t){
  14068. e.preventDefault();
  14069. if(!this.disabled){
  14070. var c = t.className.match(/(?:^|\s)color-(.{6})(?:\s|$)/)[1];
  14071. this.select(c.toUpperCase());
  14072. }
  14073. },
  14074. select : function(color){
  14075. color = color.replace("#", "");
  14076. if(color != this.value || this.allowReselect){
  14077. var el = this.el;
  14078. if(this.value){
  14079. el.child("a.color-"+this.value).removeClass("x-color-palette-sel");
  14080. }
  14081. el.child("a.color-"+color).addClass("x-color-palette-sel");
  14082. this.value = color;
  14083. this.fireEvent("select", this, color);
  14084. }
  14085. }
  14086. });
  14087. Ext.reg('colorpalette', Ext.ColorPalette);
  14088. Ext.DatePicker = Ext.extend(Ext.Component, {
  14089. todayText : "Today",
  14090. okText : "&#160;OK&#160;",
  14091. cancelText : "Cancel",
  14092. todayTip : "{0} (Spacebar)",
  14093. minDate : null,
  14094. maxDate : null,
  14095. minText : "This date is before the minimum date",
  14096. maxText : "This date is after the maximum date",
  14097. format : "m/d/y",
  14098. disabledDays : null,
  14099. disabledDaysText : "",
  14100. disabledDatesRE : null,
  14101. disabledDatesText : "",
  14102. constrainToViewport : true,
  14103. monthNames : Date.monthNames,
  14104. dayNames : Date.dayNames,
  14105. nextText: 'Next Month (Control+Right)',
  14106. prevText: 'Previous Month (Control+Left)',
  14107. monthYearText: 'Choose a month (Control+Up/Down to move years)',
  14108. startDay : 0,
  14109. initComponent : function(){
  14110. Ext.DatePicker.superclass.initComponent.call(this);
  14111. this.value = this.value ?
  14112. this.value.clearTime() : new Date().clearTime();
  14113. this.addEvents(
  14114. 'select'
  14115. );
  14116. if(this.handler){
  14117. this.on("select", this.handler, this.scope || this);
  14118. }
  14119. this.initDisabledDays();
  14120. },
  14121. initDisabledDays : function(){
  14122. if(!this.disabledDatesRE && this.disabledDates){
  14123. var dd = this.disabledDates;
  14124. var re = "(?:";
  14125. for(var i = 0; i < dd.length; i++){
  14126. re += dd[i];
  14127. if(i != dd.length-1) re += "|";
  14128. }
  14129. this.disabledDatesRE = new RegExp(re + ")");
  14130. }
  14131. },
  14132. setValue : function(value){
  14133. var old = this.value;
  14134. this.value = value.clearTime(true);
  14135. if(this.el){
  14136. this.update(this.value);
  14137. }
  14138. },
  14139. getValue : function(){
  14140. return this.value;
  14141. },
  14142. focus : function(){
  14143. if(this.el){
  14144. this.update(this.activeDate);
  14145. }
  14146. },
  14147. onRender : function(container, position){
  14148. var m = [
  14149. '<table cellspacing="0">',
  14150. '<tr><td class="x-date-left"><a href="#" title="', this.prevText ,'">&#160;</a></td><td class="x-date-middle" align="center"></td><td class="x-date-right"><a href="#" title="', this.nextText ,'">&#160;</a></td></tr>',
  14151. '<tr><td colspan="3"><table class="x-date-inner" cellspacing="0"><thead><tr>'];
  14152. var dn = this.dayNames;
  14153. for(var i = 0; i < 7; i++){
  14154. var d = this.startDay+i;
  14155. if(d > 6){
  14156. d = d-7;
  14157. }
  14158. m.push("<th><span>", dn[d].substr(0,1), "</span></th>");
  14159. }
  14160. m[m.length] = "</tr></thead><tbody><tr>";
  14161. for(var i = 0; i < 42; i++) {
  14162. if(i % 7 == 0 && i != 0){
  14163. m[m.length] = "</tr><tr>";
  14164. }
  14165. m[m.length] = '<td><a href="#" hidefocus="on" class="x-date-date" tabIndex="1"><em><span></span></em></a></td>';
  14166. }
  14167. m[m.length] = '</tr></tbody></table></td></tr><tr><td colspan="3" class="x-date-bottom" align="center"></td></tr></table><div class="x-date-mp"></div>';
  14168. var el = document.createElement("div");
  14169. el.className = "x-date-picker";
  14170. el.innerHTML = m.join("");
  14171. container.dom.insertBefore(el, position);
  14172. this.el = Ext.get(el);
  14173. this.eventEl = Ext.get(el.firstChild);
  14174. new Ext.util.ClickRepeater(this.el.child("td.x-date-left a"), {
  14175. handler: this.showPrevMonth,
  14176. scope: this,
  14177. preventDefault:true,
  14178. stopDefault:true
  14179. });
  14180. new Ext.util.ClickRepeater(this.el.child("td.x-date-right a"), {
  14181. handler: this.showNextMonth,
  14182. scope: this,
  14183. preventDefault:true,
  14184. stopDefault:true
  14185. });
  14186. this.eventEl.on("mousewheel", this.handleMouseWheel, this);
  14187. this.monthPicker = this.el.down('div.x-date-mp');
  14188. this.monthPicker.enableDisplayMode('block');
  14189. var kn = new Ext.KeyNav(this.eventEl, {
  14190. "left" : function(e){
  14191. e.ctrlKey ?
  14192. this.showPrevMonth() :
  14193. this.update(this.activeDate.add("d", -1));
  14194. },
  14195. "right" : function(e){
  14196. e.ctrlKey ?
  14197. this.showNextMonth() :
  14198. this.update(this.activeDate.add("d", 1));
  14199. },
  14200. "up" : function(e){
  14201. e.ctrlKey ?
  14202. this.showNextYear() :
  14203. this.update(this.activeDate.add("d", -7));
  14204. },
  14205. "down" : function(e){
  14206. e.ctrlKey ?
  14207. this.showPrevYear() :
  14208. this.update(this.activeDate.add("d", 7));
  14209. },
  14210. "pageUp" : function(e){
  14211. this.showNextMonth();
  14212. },
  14213. "pageDown" : function(e){
  14214. this.showPrevMonth();
  14215. },
  14216. "enter" : function(e){
  14217. e.stopPropagation();
  14218. return true;
  14219. },
  14220. scope : this
  14221. });
  14222. this.eventEl.on("click", this.handleDateClick, this, {delegate: "a.x-date-date"});
  14223. this.eventEl.addKeyListener(Ext.EventObject.SPACE, this.selectToday, this);
  14224. this.el.unselectable();
  14225. this.cells = this.el.select("table.x-date-inner tbody td");
  14226. this.textNodes = this.el.query("table.x-date-inner tbody span");
  14227. this.mbtn = new Ext.Button({
  14228. text: "&#160;",
  14229. tooltip: this.monthYearText,
  14230. renderTo: this.el.child("td.x-date-middle", true)
  14231. });
  14232. this.mbtn.on('click', this.showMonthPicker, this);
  14233. this.mbtn.el.child(this.mbtn.menuClassTarget).addClass("x-btn-with-menu");
  14234. var today = (new Date()).dateFormat(this.format);
  14235. this.todayBtn = new Ext.Button({
  14236. renderTo: this.el.child("td.x-date-bottom", true),
  14237. text: String.format(this.todayText, today),
  14238. tooltip: String.format(this.todayTip, today),
  14239. handler: this.selectToday,
  14240. scope: this
  14241. });
  14242. if(Ext.isIE){
  14243. this.el.repaint();
  14244. }
  14245. this.update(this.value);
  14246. },
  14247. createMonthPicker : function(){
  14248. if(!this.monthPicker.dom.firstChild){
  14249. var buf = ['<table border="0" cellspacing="0">'];
  14250. for(var i = 0; i < 6; i++){
  14251. buf.push(
  14252. '<tr><td class="x-date-mp-month"><a href="#">', this.monthNames[i].substr(0, 3), '</a></td>',
  14253. '<td class="x-date-mp-month x-date-mp-sep"><a href="#">', this.monthNames[i+6].substr(0, 3), '</a></td>',
  14254. i == 0 ?
  14255. '<td class="x-date-mp-ybtn" align="center"><a class="x-date-mp-prev"></a></td><td class="x-date-mp-ybtn" align="center"><a class="x-date-mp-next"></a></td></tr>' :
  14256. '<td class="x-date-mp-year"><a href="#"></a></td><td class="x-date-mp-year"><a href="#"></a></td></tr>'
  14257. );
  14258. }
  14259. buf.push(
  14260. '<tr class="x-date-mp-btns"><td colspan="4"><button type="button" class="x-date-mp-ok">',
  14261. this.okText,
  14262. '</button><button type="button" class="x-date-mp-cancel">',
  14263. this.cancelText,
  14264. '</button></td></tr>',
  14265. '</table>'
  14266. );
  14267. this.monthPicker.update(buf.join(''));
  14268. this.monthPicker.on('click', this.onMonthClick, this);
  14269. this.monthPicker.on('dblclick', this.onMonthDblClick, this);
  14270. this.mpMonths = this.monthPicker.select('td.x-date-mp-month');
  14271. this.mpYears = this.monthPicker.select('td.x-date-mp-year');
  14272. this.mpMonths.each(function(m, a, i){
  14273. i += 1;
  14274. if((i%2) == 0){
  14275. m.dom.xmonth = 5 + Math.round(i * .5);
  14276. }else{
  14277. m.dom.xmonth = Math.round((i-1) * .5);
  14278. }
  14279. });
  14280. }
  14281. },
  14282. showMonthPicker : function(){
  14283. this.createMonthPicker();
  14284. var size = this.el.getSize();
  14285. this.monthPicker.setSize(size);
  14286. this.monthPicker.child('table').setSize(size);
  14287. this.mpSelMonth = (this.activeDate || this.value).getMonth();
  14288. this.updateMPMonth(this.mpSelMonth);
  14289. this.mpSelYear = (this.activeDate || this.value).getFullYear();
  14290. this.updateMPYear(this.mpSelYear);
  14291. this.monthPicker.slideIn('t', {duration:.2});
  14292. },
  14293. updateMPYear : function(y){
  14294. this.mpyear = y;
  14295. var ys = this.mpYears.elements;
  14296. for(var i = 1; i <= 10; i++){
  14297. var td = ys[i-1], y2;
  14298. if((i%2) == 0){
  14299. y2 = y + Math.round(i * .5);
  14300. td.firstChild.innerHTML = y2;
  14301. td.xyear = y2;
  14302. }else{
  14303. y2 = y - (5-Math.round(i * .5));
  14304. td.firstChild.innerHTML = y2;
  14305. td.xyear = y2;
  14306. }
  14307. this.mpYears.item(i-1)[y2 == this.mpSelYear ? 'addClass' : 'removeClass']('x-date-mp-sel');
  14308. }
  14309. },
  14310. updateMPMonth : function(sm){
  14311. this.mpMonths.each(function(m, a, i){
  14312. m[m.dom.xmonth == sm ? 'addClass' : 'removeClass']('x-date-mp-sel');
  14313. });
  14314. },
  14315. selectMPMonth: function(m){
  14316. },
  14317. onMonthClick : function(e, t){
  14318. e.stopEvent();
  14319. var el = new Ext.Element(t), pn;
  14320. if(el.is('button.x-date-mp-cancel')){
  14321. this.hideMonthPicker();
  14322. }
  14323. else if(el.is('button.x-date-mp-ok')){
  14324. this.update(new Date(this.mpSelYear, this.mpSelMonth, (this.activeDate || this.value).getDate()));
  14325. this.hideMonthPicker();
  14326. }
  14327. else if(pn = el.up('td.x-date-mp-month', 2)){
  14328. this.mpMonths.removeClass('x-date-mp-sel');
  14329. pn.addClass('x-date-mp-sel');
  14330. this.mpSelMonth = pn.dom.xmonth;
  14331. }
  14332. else if(pn = el.up('td.x-date-mp-year', 2)){
  14333. this.mpYears.removeClass('x-date-mp-sel');
  14334. pn.addClass('x-date-mp-sel');
  14335. this.mpSelYear = pn.dom.xyear;
  14336. }
  14337. else if(el.is('a.x-date-mp-prev')){
  14338. this.updateMPYear(this.mpyear-10);
  14339. }
  14340. else if(el.is('a.x-date-mp-next')){
  14341. this.updateMPYear(this.mpyear+10);
  14342. }
  14343. },
  14344. onMonthDblClick : function(e, t){
  14345. e.stopEvent();
  14346. var el = new Ext.Element(t), pn;
  14347. if(pn = el.up('td.x-date-mp-month', 2)){
  14348. this.update(new Date(this.mpSelYear, pn.dom.xmonth, (this.activeDate || this.value).getDate()));
  14349. this.hideMonthPicker();
  14350. }
  14351. else if(pn = el.up('td.x-date-mp-year', 2)){
  14352. this.update(new Date(pn.dom.xyear, this.mpSelMonth, (this.activeDate || this.value).getDate()));
  14353. this.hideMonthPicker();
  14354. }
  14355. },
  14356. hideMonthPicker : function(disableAnim){
  14357. if(this.monthPicker){
  14358. if(disableAnim === true){
  14359. this.monthPicker.hide();
  14360. }else{
  14361. this.monthPicker.slideOut('t', {duration:.2});
  14362. }
  14363. }
  14364. },
  14365. showPrevMonth : function(e){
  14366. this.update(this.activeDate.add("mo", -1));
  14367. },
  14368. showNextMonth : function(e){
  14369. this.update(this.activeDate.add("mo", 1));
  14370. },
  14371. showPrevYear : function(){
  14372. this.update(this.activeDate.add("y", -1));
  14373. },
  14374. showNextYear : function(){
  14375. this.update(this.activeDate.add("y", 1));
  14376. },
  14377. handleMouseWheel : function(e){
  14378. var delta = e.getWheelDelta();
  14379. if(delta > 0){
  14380. this.showPrevMonth();
  14381. e.stopEvent();
  14382. } else if(delta < 0){
  14383. this.showNextMonth();
  14384. e.stopEvent();
  14385. }
  14386. },
  14387. handleDateClick : function(e, t){
  14388. e.stopEvent();
  14389. if(t.dateValue && !Ext.fly(t.parentNode).hasClass("x-date-disabled")){
  14390. this.setValue(new Date(t.dateValue));
  14391. this.fireEvent("select", this, this.value);
  14392. }
  14393. },
  14394. selectToday : function(){
  14395. this.setValue(new Date().clearTime());
  14396. this.fireEvent("select", this, this.value);
  14397. },
  14398. update : function(date){
  14399. var vd = this.activeDate;
  14400. this.activeDate = date;
  14401. if(vd && this.el){
  14402. var t = date.getTime();
  14403. if(vd.getMonth() == date.getMonth() && vd.getFullYear() == date.getFullYear()){
  14404. this.cells.removeClass("x-date-selected");
  14405. this.cells.each(function(c){
  14406. if(c.dom.firstChild.dateValue == t){
  14407. c.addClass("x-date-selected");
  14408. setTimeout(function(){
  14409. try{c.dom.firstChild.focus();}catch(e){}
  14410. }, 50);
  14411. return false;
  14412. }
  14413. });
  14414. return;
  14415. }
  14416. }
  14417. var days = date.getDaysInMonth();
  14418. var firstOfMonth = date.getFirstDateOfMonth();
  14419. var startingPos = firstOfMonth.getDay()-this.startDay;
  14420. if(startingPos <= this.startDay){
  14421. startingPos += 7;
  14422. }
  14423. var pm = date.add("mo", -1);
  14424. var prevStart = pm.getDaysInMonth()-startingPos;
  14425. var cells = this.cells.elements;
  14426. var textEls = this.textNodes;
  14427. days += startingPos;
  14428. var day = 86400000;
  14429. var d = (new Date(pm.getFullYear(), pm.getMonth(), prevStart)).clearTime();
  14430. var today = new Date().clearTime().getTime();
  14431. var sel = date.clearTime().getTime();
  14432. var min = this.minDate ? this.minDate.clearTime() : Number.NEGATIVE_INFINITY;
  14433. var max = this.maxDate ? this.maxDate.clearTime() : Number.POSITIVE_INFINITY;
  14434. var ddMatch = this.disabledDatesRE;
  14435. var ddText = this.disabledDatesText;
  14436. var ddays = this.disabledDays ? this.disabledDays.join("") : false;
  14437. var ddaysText = this.disabledDaysText;
  14438. var format = this.format;
  14439. var setCellClass = function(cal, cell){
  14440. cell.title = "";
  14441. var t = d.getTime();
  14442. cell.firstChild.dateValue = t;
  14443. if(t == today){
  14444. cell.className += " x-date-today";
  14445. cell.title = cal.todayText;
  14446. }
  14447. if(t == sel){
  14448. cell.className += " x-date-selected";
  14449. setTimeout(function(){
  14450. try{cell.firstChild.focus();}catch(e){}
  14451. }, 50);
  14452. }
  14453. if(t < min) {
  14454. cell.className = " x-date-disabled";
  14455. cell.title = cal.minText;
  14456. return;
  14457. }
  14458. if(t > max) {
  14459. cell.className = " x-date-disabled";
  14460. cell.title = cal.maxText;
  14461. return;
  14462. }
  14463. if(ddays){
  14464. if(ddays.indexOf(d.getDay()) != -1){
  14465. cell.title = ddaysText;
  14466. cell.className = " x-date-disabled";
  14467. }
  14468. }
  14469. if(ddMatch && format){
  14470. var fvalue = d.dateFormat(format);
  14471. if(ddMatch.test(fvalue)){
  14472. cell.title = ddText.replace("%0", fvalue);
  14473. cell.className = " x-date-disabled";
  14474. }
  14475. }
  14476. };
  14477. var i = 0;
  14478. for(; i < startingPos; i++) {
  14479. textEls[i].innerHTML = (++prevStart);
  14480. d.setDate(d.getDate()+1);
  14481. cells[i].className = "x-date-prevday";
  14482. setCellClass(this, cells[i]);
  14483. }
  14484. for(; i < days; i++){
  14485. intDay = i - startingPos + 1;
  14486. textEls[i].innerHTML = (intDay);
  14487. d.setDate(d.getDate()+1);
  14488. cells[i].className = "x-date-active";
  14489. setCellClass(this, cells[i]);
  14490. }
  14491. var extraDays = 0;
  14492. for(; i < 42; i++) {
  14493. textEls[i].innerHTML = (++extraDays);
  14494. d.setDate(d.getDate()+1);
  14495. cells[i].className = "x-date-nextday";
  14496. setCellClass(this, cells[i]);
  14497. }
  14498. this.mbtn.setText(this.monthNames[date.getMonth()] + " " + date.getFullYear());
  14499. if(!this.internalRender){
  14500. var main = this.el.dom.firstChild;
  14501. var w = main.offsetWidth;
  14502. this.el.setWidth(w + this.el.getBorderWidth("lr"));
  14503. Ext.fly(main).setWidth(w);
  14504. this.internalRender = true;
  14505. if(Ext.isOpera && !this.secondPass){
  14506. main.rows[0].cells[1].style.width = (w - (main.rows[0].cells[0].offsetWidth+main.rows[0].cells[2].offsetWidth)) + "px";
  14507. this.secondPass = true;
  14508. this.update.defer(10, this, [date]);
  14509. }
  14510. }
  14511. },
  14512. beforeDestroy : function() {
  14513. this.mbtn.destroy();
  14514. this.todayBtn.destroy();
  14515. }
  14516. });
  14517. Ext.reg('datepicker', Ext.DatePicker);
  14518. Ext.TabPanel = Ext.extend(Ext.Panel, {
  14519. monitorResize : true,
  14520. deferredRender : true,
  14521. tabWidth: 120,
  14522. minTabWidth: 30,
  14523. resizeTabs:false,
  14524. enableTabScroll: false,
  14525. scrollIncrement : 0,
  14526. scrollRepeatInterval : 400,
  14527. scrollDuration : .35,
  14528. animScroll : true,
  14529. tabPosition: 'top',
  14530. baseCls: 'x-tab-panel',
  14531. autoTabs : false,
  14532. autoTabSelector:'div.x-tab',
  14533. activeTab : null,
  14534. tabMargin : 2,
  14535. plain: false,
  14536. wheelIncrement : 20,
  14537. idDelimiter : '__',
  14538. itemCls : 'x-tab-item',
  14539. elements: 'body',
  14540. headerAsText: false,
  14541. frame: false,
  14542. hideBorders:true,
  14543. initComponent : function(){
  14544. this.frame = false;
  14545. Ext.TabPanel.superclass.initComponent.call(this);
  14546. this.addEvents(
  14547. 'beforetabchange',
  14548. 'tabchange',
  14549. 'contextmenu'
  14550. );
  14551. this.setLayout(new Ext.layout.CardLayout({
  14552. deferredRender: this.deferredRender
  14553. }));
  14554. if(this.tabPosition == 'top'){
  14555. this.elements += ',header';
  14556. this.stripTarget = 'header';
  14557. }else {
  14558. this.elements += ',footer';
  14559. this.stripTarget = 'footer';
  14560. }
  14561. if(!this.stack){
  14562. this.stack = Ext.TabPanel.AccessStack();
  14563. }
  14564. this.initItems();
  14565. },
  14566. render : function(){
  14567. Ext.TabPanel.superclass.render.apply(this, arguments);
  14568. if(this.activeTab !== undefined){
  14569. var item = this.activeTab;
  14570. delete this.activeTab;
  14571. this.setActiveTab(item);
  14572. }
  14573. },
  14574. onRender : function(ct, position){
  14575. Ext.TabPanel.superclass.onRender.call(this, ct, position);
  14576. if(this.plain){
  14577. var pos = this.tabPosition == 'top' ? 'header' : 'footer';
  14578. this[pos].addClass('x-tab-panel-'+pos+'-plain');
  14579. }
  14580. var st = this[this.stripTarget];
  14581. this.stripWrap = st.createChild({cls:'x-tab-strip-wrap', cn:{
  14582. tag:'ul', cls:'x-tab-strip x-tab-strip-'+this.tabPosition}});
  14583. this.stripSpacer = st.createChild({cls:'x-tab-strip-spacer'});
  14584. this.strip = new Ext.Element(this.stripWrap.dom.firstChild);
  14585. this.edge = this.strip.createChild({tag:'li', cls:'x-tab-edge'});
  14586. this.strip.createChild({cls:'x-clear'});
  14587. this.body.addClass('x-tab-panel-body-'+this.tabPosition);
  14588. if(!this.itemTpl){
  14589. var tt = new Ext.Template(
  14590. '<li class="{cls}" id="{id}"><a class="x-tab-strip-close" onclick="return false;"></a>',
  14591. '<a class="x-tab-right" href="#" onclick="return false;"><em class="x-tab-left">',
  14592. '<span class="x-tab-strip-inner"><span class="x-tab-strip-text {iconCls}">{text}</span></span>',
  14593. '</em></a></li>'
  14594. );
  14595. tt.disableFormats = true;
  14596. tt.compile();
  14597. Ext.TabPanel.prototype.itemTpl = tt;
  14598. }
  14599. this.items.each(this.initTab, this);
  14600. },
  14601. afterRender : function(){
  14602. Ext.TabPanel.superclass.afterRender.call(this);
  14603. if(this.autoTabs){
  14604. this.readTabs(false);
  14605. }
  14606. },
  14607. initEvents : function(){
  14608. Ext.TabPanel.superclass.initEvents.call(this);
  14609. this.on('add', this.onAdd, this);
  14610. this.on('remove', this.onRemove, this);
  14611. this.strip.on('mousedown', this.onStripMouseDown, this);
  14612. this.strip.on('click', this.onStripClick, this);
  14613. this.strip.on('contextmenu', this.onStripContextMenu, this);
  14614. if(this.enableTabScroll){
  14615. this.strip.on('mousewheel', this.onWheel, this);
  14616. }
  14617. },
  14618. findTargets : function(e){
  14619. var item = null;
  14620. var itemEl = e.getTarget('li', this.strip);
  14621. if(itemEl){
  14622. item = this.getComponent(itemEl.id.split(this.idDelimiter)[1]);
  14623. if(item.disabled){
  14624. return {
  14625. close : null,
  14626. item : null,
  14627. el : null
  14628. };
  14629. }
  14630. }
  14631. return {
  14632. close : e.getTarget('.x-tab-strip-close', this.strip),
  14633. item : item,
  14634. el : itemEl
  14635. };
  14636. },
  14637. onStripMouseDown : function(e){
  14638. e.preventDefault();
  14639. if(e.button != 0){
  14640. return;
  14641. }
  14642. var t = this.findTargets(e);
  14643. if(t.close){
  14644. this.remove(t.item);
  14645. return;
  14646. }
  14647. if(t.item && t.item != this.activeTab){
  14648. this.setActiveTab(t.item);
  14649. }
  14650. },
  14651. onStripClick : function(e){
  14652. var t = this.findTargets(e);
  14653. if(!t.close && t.item && t.item != this.activeTab){
  14654. this.setActiveTab(t.item);
  14655. }
  14656. },
  14657. onStripContextMenu : function(e){
  14658. e.preventDefault();
  14659. var t = this.findTargets(e);
  14660. if(t.item){
  14661. this.fireEvent('contextmenu', this, t.item, e);
  14662. }
  14663. },
  14664. readTabs : function(removeExisting){
  14665. if(removeExisting === true){
  14666. this.items.each(function(item){
  14667. this.remove(item);
  14668. }, this);
  14669. }
  14670. var tabs = this.el.query(this.autoTabSelector);
  14671. for(var i = 0, len = tabs.length; i < len; i++){
  14672. var tab = tabs[i];
  14673. var title = tab.getAttribute('title');
  14674. tab.removeAttribute('title');
  14675. this.add({
  14676. title: title,
  14677. el: tab
  14678. });
  14679. }
  14680. },
  14681. initTab : function(item, index){
  14682. var before = this.strip.dom.childNodes[index];
  14683. var cls = item.closable ? 'x-tab-strip-closable' : '';
  14684. if(item.disabled){
  14685. cls += ' x-item-disabled';
  14686. }
  14687. if(item.iconCls){
  14688. cls += ' x-tab-with-icon';
  14689. }
  14690. if(item.tabCls){
  14691. cls += ' ' + item.tabCls;
  14692. }
  14693. var p = {
  14694. id: this.id + this.idDelimiter + item.getItemId(),
  14695. text: item.title,
  14696. cls: cls,
  14697. iconCls: item.iconCls || ''
  14698. };
  14699. var el = before ?
  14700. this.itemTpl.insertBefore(before, p) :
  14701. this.itemTpl.append(this.strip, p);
  14702. Ext.fly(el).addClassOnOver('x-tab-strip-over');
  14703. if(item.tabTip){
  14704. Ext.fly(el).child('span.x-tab-strip-text', true).qtip = item.tabTip;
  14705. }
  14706. item.on('disable', this.onItemDisabled, this);
  14707. item.on('enable', this.onItemEnabled, this);
  14708. item.on('titlechange', this.onItemTitleChanged, this);
  14709. item.on('beforeshow', this.onBeforeShowItem, this);
  14710. },
  14711. onAdd : function(tp, item, index){
  14712. this.initTab(item, index);
  14713. if(this.items.getCount() == 1){
  14714. this.syncSize();
  14715. }
  14716. this.delegateUpdates();
  14717. },
  14718. onBeforeAdd : function(item){
  14719. var existing = item.events ? (this.items.containsKey(item.getItemId()) ? item : null) : this.items.get(item);
  14720. if(existing){
  14721. this.setActiveTab(item);
  14722. return false;
  14723. }
  14724. Ext.TabPanel.superclass.onBeforeAdd.apply(this, arguments);
  14725. var es = item.elements;
  14726. item.elements = es ? es.replace(',header', '') : es;
  14727. item.border = (item.border === true);
  14728. },
  14729. onRemove : function(tp, item){
  14730. Ext.removeNode(this.getTabEl(item));
  14731. this.stack.remove(item);
  14732. if(item == this.activeTab){
  14733. var next = this.stack.next();
  14734. if(next){
  14735. this.setActiveTab(next);
  14736. }else{
  14737. this.setActiveTab(0);
  14738. }
  14739. }
  14740. this.delegateUpdates();
  14741. },
  14742. onBeforeShowItem : function(item){
  14743. if(item != this.activeTab){
  14744. this.setActiveTab(item);
  14745. return false;
  14746. }
  14747. },
  14748. onItemDisabled : function(item){
  14749. var el = this.getTabEl(item);
  14750. if(el){
  14751. Ext.fly(el).addClass('x-item-disabled');
  14752. }
  14753. this.stack.remove(item);
  14754. },
  14755. onItemEnabled : function(item){
  14756. var el = this.getTabEl(item);
  14757. if(el){
  14758. Ext.fly(el).removeClass('x-item-disabled');
  14759. }
  14760. },
  14761. onItemTitleChanged : function(item){
  14762. var el = this.getTabEl(item);
  14763. if(el){
  14764. Ext.fly(el).child('span.x-tab-strip-text', true).innerHTML = item.title;
  14765. }
  14766. },
  14767. getTabEl : function(item){
  14768. var itemId = (typeof item === 'number')?this.items.items[item].getItemId() : item.getItemId();
  14769. return document.getElementById(this.id+this.idDelimiter+itemId);
  14770. },
  14771. onResize : function(){
  14772. Ext.TabPanel.superclass.onResize.apply(this, arguments);
  14773. this.delegateUpdates();
  14774. },
  14775. beginUpdate : function(){
  14776. this.suspendUpdates = true;
  14777. },
  14778. endUpdate : function(){
  14779. this.suspendUpdates = false;
  14780. this.delegateUpdates();
  14781. },
  14782. hideTabStripItem : function(item){
  14783. item = this.getComponent(item);
  14784. var el = this.getTabEl(item);
  14785. if(el){
  14786. el.style.display = 'none';
  14787. this.delegateUpdates();
  14788. }
  14789. },
  14790. unhideTabStripItem : function(item){
  14791. item = this.getComponent(item);
  14792. var el = this.getTabEl(item);
  14793. if(el){
  14794. el.style.display = '';
  14795. this.delegateUpdates();
  14796. }
  14797. },
  14798. delegateUpdates : function(){
  14799. if(this.suspendUpdates){
  14800. return;
  14801. }
  14802. if(this.resizeTabs && this.rendered){
  14803. this.autoSizeTabs();
  14804. }
  14805. if(this.enableTabScroll && this.rendered){
  14806. this.autoScrollTabs();
  14807. }
  14808. },
  14809. autoSizeTabs : function(){
  14810. var count = this.items.length;
  14811. var ce = this.tabPosition != 'bottom' ? 'header' : 'footer';
  14812. var ow = this[ce].dom.offsetWidth;
  14813. var aw = this[ce].dom.clientWidth;
  14814. if(!this.resizeTabs || count < 1 || !aw){ return;
  14815. }
  14816. var each = Math.max(Math.min(Math.floor((aw-4) / count) - this.tabMargin, this.tabWidth), this.minTabWidth); this.lastTabWidth = each;
  14817. var lis = this.stripWrap.dom.getElementsByTagName('li');
  14818. for(var i = 0, len = lis.length-1; i < len; i++) { var li = lis[i];
  14819. var inner = li.childNodes[1].firstChild.firstChild;
  14820. var tw = li.offsetWidth;
  14821. var iw = inner.offsetWidth;
  14822. inner.style.width = (each - (tw-iw)) + 'px';
  14823. }
  14824. },
  14825. adjustBodyWidth : function(w){
  14826. if(this.header){
  14827. this.header.setWidth(w);
  14828. }
  14829. if(this.footer){
  14830. this.footer.setWidth(w);
  14831. }
  14832. return w;
  14833. },
  14834. setActiveTab : function(item){
  14835. item = this.getComponent(item);
  14836. if(!item || this.fireEvent('beforetabchange', this, item, this.activeTab) === false){
  14837. return;
  14838. }
  14839. if(!this.rendered){
  14840. this.activeTab = item;
  14841. return;
  14842. }
  14843. if(this.activeTab != item){
  14844. if(this.activeTab){
  14845. var oldEl = this.getTabEl(this.activeTab);
  14846. if(oldEl){
  14847. Ext.fly(oldEl).removeClass('x-tab-strip-active');
  14848. }
  14849. this.activeTab.fireEvent('deactivate', this.activeTab);
  14850. }
  14851. var el = this.getTabEl(item);
  14852. Ext.fly(el).addClass('x-tab-strip-active');
  14853. this.activeTab = item;
  14854. this.stack.add(item);
  14855. this.layout.setActiveItem(item);
  14856. if(this.layoutOnTabChange && item.doLayout){
  14857. item.doLayout();
  14858. }
  14859. if(this.scrolling){
  14860. this.scrollToTab(item, this.animScroll);
  14861. }
  14862. item.fireEvent('activate', item);
  14863. this.fireEvent('tabchange', this, item);
  14864. }
  14865. },
  14866. getActiveTab : function(){
  14867. return this.activeTab || null;
  14868. },
  14869. getItem : function(item){
  14870. return this.getComponent(item);
  14871. },
  14872. autoScrollTabs : function(){
  14873. var count = this.items.length;
  14874. var ow = this.header.dom.offsetWidth;
  14875. var tw = this.header.dom.clientWidth;
  14876. var wrap = this.stripWrap;
  14877. var wd = wrap.dom;
  14878. var cw = wd.offsetWidth;
  14879. var pos = this.getScrollPos();
  14880. var l = this.edge.getOffsetsTo(this.stripWrap)[0] + pos;
  14881. if(!this.enableTabScroll || count < 1 || cw < 20){ return;
  14882. }
  14883. if(l <= tw){
  14884. wd.scrollLeft = 0;
  14885. wrap.setWidth(tw);
  14886. if(this.scrolling){
  14887. this.scrolling = false;
  14888. this.header.removeClass('x-tab-scrolling');
  14889. this.scrollLeft.hide();
  14890. this.scrollRight.hide();
  14891. if(Ext.isAir){
  14892. wd.style.marginLeft = '';
  14893. wd.style.marginRight = '';
  14894. }
  14895. }
  14896. }else{
  14897. if(!this.scrolling){
  14898. this.header.addClass('x-tab-scrolling');
  14899. if(Ext.isAir){
  14900. wd.style.marginLeft = '18px';
  14901. wd.style.marginRight = '18px';
  14902. }
  14903. }
  14904. tw -= wrap.getMargins('lr');
  14905. wrap.setWidth(tw > 20 ? tw : 20);
  14906. if(!this.scrolling){
  14907. if(!this.scrollLeft){
  14908. this.createScrollers();
  14909. }else{
  14910. this.scrollLeft.show();
  14911. this.scrollRight.show();
  14912. }
  14913. }
  14914. this.scrolling = true;
  14915. if(pos > (l-tw)){ wd.scrollLeft = l-tw;
  14916. }else{ this.scrollToTab(this.activeTab, false);
  14917. }
  14918. this.updateScrollButtons();
  14919. }
  14920. },
  14921. createScrollers : function(){
  14922. var h = this.stripWrap.dom.offsetHeight;
  14923. var sl = this.header.insertFirst({
  14924. cls:'x-tab-scroller-left'
  14925. });
  14926. sl.setHeight(h);
  14927. sl.addClassOnOver('x-tab-scroller-left-over');
  14928. this.leftRepeater = new Ext.util.ClickRepeater(sl, {
  14929. interval : this.scrollRepeatInterval,
  14930. handler: this.onScrollLeft,
  14931. scope: this
  14932. });
  14933. this.scrollLeft = sl;
  14934. var sr = this.header.insertFirst({
  14935. cls:'x-tab-scroller-right'
  14936. });
  14937. sr.setHeight(h);
  14938. sr.addClassOnOver('x-tab-scroller-right-over');
  14939. this.rightRepeater = new Ext.util.ClickRepeater(sr, {
  14940. interval : this.scrollRepeatInterval,
  14941. handler: this.onScrollRight,
  14942. scope: this
  14943. });
  14944. this.scrollRight = sr;
  14945. },
  14946. getScrollWidth : function(){
  14947. return this.edge.getOffsetsTo(this.stripWrap)[0] + this.getScrollPos();
  14948. },
  14949. getScrollPos : function(){
  14950. return parseInt(this.stripWrap.dom.scrollLeft, 10) || 0;
  14951. },
  14952. getScrollArea : function(){
  14953. return parseInt(this.stripWrap.dom.clientWidth, 10) || 0;
  14954. },
  14955. getScrollAnim : function(){
  14956. return {duration:this.scrollDuration, callback: this.updateScrollButtons, scope: this};
  14957. },
  14958. getScrollIncrement : function(){
  14959. return this.scrollIncrement || (this.resizeTabs ? this.lastTabWidth+2 : 100);
  14960. },
  14961. scrollToTab : function(item, animate){
  14962. if(!item){ return; }
  14963. var el = this.getTabEl(item);
  14964. var pos = this.getScrollPos(), area = this.getScrollArea();
  14965. var left = Ext.fly(el).getOffsetsTo(this.stripWrap)[0] + pos;
  14966. var right = left + el.offsetWidth;
  14967. if(left < pos){
  14968. this.scrollTo(left, animate);
  14969. }else if(right > (pos + area)){
  14970. this.scrollTo(right - area, animate);
  14971. }
  14972. },
  14973. scrollTo : function(pos, animate){
  14974. this.stripWrap.scrollTo('left', pos, animate ? this.getScrollAnim() : false);
  14975. if(!animate){
  14976. this.updateScrollButtons();
  14977. }
  14978. },
  14979. onWheel : function(e){
  14980. var d = e.getWheelDelta()*this.wheelIncrement*-1;
  14981. e.stopEvent();
  14982. var pos = this.getScrollPos();
  14983. var newpos = pos + d;
  14984. var sw = this.getScrollWidth()-this.getScrollArea();
  14985. var s = Math.max(0, Math.min(sw, newpos));
  14986. if(s != pos){
  14987. this.scrollTo(s, false);
  14988. }
  14989. },
  14990. onScrollRight : function(){
  14991. var sw = this.getScrollWidth()-this.getScrollArea();
  14992. var pos = this.getScrollPos();
  14993. var s = Math.min(sw, pos + this.getScrollIncrement());
  14994. if(s != pos){
  14995. this.scrollTo(s, this.animScroll);
  14996. }
  14997. },
  14998. onScrollLeft : function(){
  14999. var pos = this.getScrollPos();
  15000. var s = Math.max(0, pos - this.getScrollIncrement());
  15001. if(s != pos){
  15002. this.scrollTo(s, this.animScroll);
  15003. }
  15004. },
  15005. updateScrollButtons : function(){
  15006. var pos = this.getScrollPos();
  15007. this.scrollLeft[pos == 0 ? 'addClass' : 'removeClass']('x-tab-scroller-left-disabled');
  15008. this.scrollRight[pos >= (this.getScrollWidth()-this.getScrollArea()) ? 'addClass' : 'removeClass']('x-tab-scroller-right-disabled');
  15009. }
  15010. });
  15011. Ext.reg('tabpanel', Ext.TabPanel);
  15012. Ext.TabPanel.prototype.activate = Ext.TabPanel.prototype.setActiveTab;
  15013. Ext.TabPanel.AccessStack = function(){
  15014. var items = [];
  15015. return {
  15016. add : function(item){
  15017. items.push(item);
  15018. if(items.length > 10){
  15019. items.shift();
  15020. }
  15021. },
  15022. remove : function(item){
  15023. var s = [];
  15024. for(var i = 0, len = items.length; i < len; i++) {
  15025. if(items[i] != item){
  15026. s.push(items[i]);
  15027. }
  15028. }
  15029. items = s;
  15030. },
  15031. next : function(){
  15032. return items.pop();
  15033. }
  15034. };
  15035. };
  15036. Ext.Button = Ext.extend(Ext.Component, {
  15037. hidden : false,
  15038. disabled : false,
  15039. pressed : false,
  15040. enableToggle: false,
  15041. menuAlign : "tl-bl?",
  15042. type : 'button',
  15043. menuClassTarget: 'tr',
  15044. clickEvent : 'click',
  15045. handleMouseEvents : true,
  15046. tooltipType : 'qtip',
  15047. buttonSelector : "button:first",
  15048. initComponent : function(){
  15049. Ext.Button.superclass.initComponent.call(this);
  15050. this.addEvents(
  15051. "click",
  15052. "toggle",
  15053. 'mouseover',
  15054. 'mouseout',
  15055. 'menushow',
  15056. 'menuhide',
  15057. 'menutriggerover',
  15058. 'menutriggerout'
  15059. );
  15060. if(this.menu){
  15061. this.menu = Ext.menu.MenuMgr.get(this.menu);
  15062. }
  15063. if(typeof this.toggleGroup === 'string'){
  15064. this.enableToggle = true;
  15065. }
  15066. },
  15067. onRender : function(ct, position){
  15068. if(!this.template){
  15069. if(!Ext.Button.buttonTemplate){
  15070. Ext.Button.buttonTemplate = new Ext.Template(
  15071. '<table border="0" cellpadding="0" cellspacing="0" class="x-btn-wrap"><tbody><tr>',
  15072. '<td class="x-btn-left"><i>&#160;</i></td><td class="x-btn-center"><em unselectable="on"><button class="x-btn-text" type="{1}">{0}</button></em></td><td class="x-btn-right"><i>&#160;</i></td>',
  15073. "</tr></tbody></table>");
  15074. }
  15075. this.template = Ext.Button.buttonTemplate;
  15076. }
  15077. var btn, targs = [this.text || '&#160;', this.type];
  15078. if(position){
  15079. btn = this.template.insertBefore(position, targs, true);
  15080. }else{
  15081. btn = this.template.append(ct, targs, true);
  15082. }
  15083. var btnEl = btn.child(this.buttonSelector);
  15084. btnEl.on('focus', this.onFocus, this);
  15085. btnEl.on('blur', this.onBlur, this);
  15086. this.initButtonEl(btn, btnEl);
  15087. if(this.menu){
  15088. this.el.child(this.menuClassTarget).addClass("x-btn-with-menu");
  15089. }
  15090. Ext.ButtonToggleMgr.register(this);
  15091. },
  15092. initButtonEl : function(btn, btnEl){
  15093. this.el = btn;
  15094. btn.addClass("x-btn");
  15095. if(this.icon){
  15096. btnEl.setStyle('background-image', 'url(' +this.icon +')');
  15097. }
  15098. if(this.iconCls){
  15099. btnEl.addClass(this.iconCls);
  15100. if(!this.cls){
  15101. btn.addClass(this.text ? 'x-btn-text-icon' : 'x-btn-icon');
  15102. }
  15103. }
  15104. if(this.tabIndex !== undefined){
  15105. btnEl.dom.tabIndex = this.tabIndex;
  15106. }
  15107. if(this.tooltip){
  15108. if(typeof this.tooltip == 'object'){
  15109. Ext.QuickTips.register(Ext.apply({
  15110. target: btnEl.id
  15111. }, this.tooltip));
  15112. } else {
  15113. btnEl.dom[this.tooltipType] = this.tooltip;
  15114. }
  15115. }
  15116. if(this.pressed){
  15117. this.el.addClass("x-btn-pressed");
  15118. }
  15119. if(this.handleMouseEvents){
  15120. btn.on("mouseover", this.onMouseOver, this);
  15121. btn.on("mousedown", this.onMouseDown, this);
  15122. }
  15123. if(this.menu){
  15124. this.menu.on("show", this.onMenuShow, this);
  15125. this.menu.on("hide", this.onMenuHide, this);
  15126. }
  15127. if(this.id){
  15128. this.el.dom.id = this.el.id = this.id;
  15129. }
  15130. if(this.repeat){
  15131. var repeater = new Ext.util.ClickRepeater(btn,
  15132. typeof this.repeat == "object" ? this.repeat : {}
  15133. );
  15134. repeater.on("click", this.onClick, this);
  15135. }
  15136. btn.on(this.clickEvent, this.onClick, this);
  15137. },
  15138. afterRender : function(){
  15139. Ext.Button.superclass.afterRender.call(this);
  15140. if(Ext.isIE6){
  15141. this.autoWidth.defer(1, this);
  15142. }else{
  15143. this.autoWidth();
  15144. }
  15145. },
  15146. setIconClass : function(cls){
  15147. if(this.el){
  15148. this.el.child(this.buttonSelector).replaceClass(this.iconCls, cls);
  15149. }
  15150. this.iconCls = cls;
  15151. },
  15152. beforeDestroy: function(){
  15153. if(this.rendered){
  15154. var btn = this.el.child(this.buttonSelector);
  15155. if(btn){
  15156. btn.removeAllListeners();
  15157. }
  15158. }
  15159. if(this.menu){
  15160. Ext.destroy(this.menu);
  15161. }
  15162. },
  15163. onDestroy : function(){
  15164. if(this.rendered){
  15165. Ext.ButtonToggleMgr.unregister(this);
  15166. }
  15167. },
  15168. autoWidth : function(){
  15169. if(this.el){
  15170. this.el.setWidth("auto");
  15171. if(Ext.isIE7 && Ext.isStrict){
  15172. var ib = this.el.child(this.buttonSelector);
  15173. if(ib && ib.getWidth() > 20){
  15174. ib.clip();
  15175. ib.setWidth(Ext.util.TextMetrics.measure(ib, this.text).width+ib.getFrameWidth('lr'));
  15176. }
  15177. }
  15178. if(this.minWidth){
  15179. if(this.el.getWidth() < this.minWidth){
  15180. this.el.setWidth(this.minWidth);
  15181. }
  15182. }
  15183. }
  15184. },
  15185. setHandler : function(handler, scope){
  15186. this.handler = handler;
  15187. this.scope = scope;
  15188. },
  15189. setText : function(text){
  15190. this.text = text;
  15191. if(this.el){
  15192. this.el.child("td.x-btn-center " + this.buttonSelector).update(text);
  15193. }
  15194. this.autoWidth();
  15195. },
  15196. getText : function(){
  15197. return this.text;
  15198. },
  15199. toggle : function(state){
  15200. state = state === undefined ? !this.pressed : state;
  15201. if(state != this.pressed){
  15202. if(state){
  15203. this.el.addClass("x-btn-pressed");
  15204. this.pressed = true;
  15205. this.fireEvent("toggle", this, true);
  15206. }else{
  15207. this.el.removeClass("x-btn-pressed");
  15208. this.pressed = false;
  15209. this.fireEvent("toggle", this, false);
  15210. }
  15211. if(this.toggleHandler){
  15212. this.toggleHandler.call(this.scope || this, this, state);
  15213. }
  15214. }
  15215. },
  15216. focus : function(){
  15217. this.el.child(this.buttonSelector).focus();
  15218. },
  15219. onDisable : function(){
  15220. if(this.el){
  15221. if(!Ext.isIE6 || !this.text){
  15222. this.el.addClass(this.disabledClass);
  15223. }
  15224. this.el.dom.disabled = true;
  15225. }
  15226. this.disabled = true;
  15227. },
  15228. onEnable : function(){
  15229. if(this.el){
  15230. if(!Ext.isIE6 || !this.text){
  15231. this.el.removeClass(this.disabledClass);
  15232. }
  15233. this.el.dom.disabled = false;
  15234. }
  15235. this.disabled = false;
  15236. },
  15237. showMenu : function(){
  15238. if(this.menu){
  15239. this.menu.show(this.el, this.menuAlign);
  15240. }
  15241. return this;
  15242. },
  15243. hideMenu : function(){
  15244. if(this.menu){
  15245. this.menu.hide();
  15246. }
  15247. return this;
  15248. },
  15249. hasVisibleMenu : function(){
  15250. return this.menu && this.menu.isVisible();
  15251. },
  15252. onClick : function(e){
  15253. if(e){
  15254. e.preventDefault();
  15255. }
  15256. if(e.button != 0){
  15257. return;
  15258. }
  15259. if(!this.disabled){
  15260. if(this.enableToggle && (this.allowDepress !== false || !this.pressed)){
  15261. this.toggle();
  15262. }
  15263. if(this.menu && !this.menu.isVisible() && !this.ignoreNextClick){
  15264. this.showMenu();
  15265. }
  15266. this.fireEvent("click", this, e);
  15267. if(this.handler){
  15268. this.handler.call(this.scope || this, this, e);
  15269. }
  15270. }
  15271. },
  15272. isMenuTriggerOver : function(e, internal){
  15273. return this.menu && !internal;
  15274. },
  15275. isMenuTriggerOut : function(e, internal){
  15276. return this.menu && !internal;
  15277. },
  15278. onMouseOver : function(e){
  15279. if(!this.disabled){
  15280. var internal = e.within(this.el, true);
  15281. if(!internal){
  15282. this.el.addClass("x-btn-over");
  15283. Ext.getDoc().on('mouseover', this.monitorMouseOver, this);
  15284. this.fireEvent('mouseover', this, e);
  15285. }
  15286. if(this.isMenuTriggerOver(e, internal)){
  15287. this.fireEvent('menutriggerover', this, this.menu, e);
  15288. }
  15289. }
  15290. },
  15291. monitorMouseOver : function(e){
  15292. if(e.target != this.el.dom && !e.within(this.el)){
  15293. Ext.getDoc().un('mouseover', this.monitorMouseOver, this);
  15294. this.onMouseOut(e);
  15295. }
  15296. },
  15297. onMouseOut : function(e){
  15298. var internal = e.within(this.el) && e.target != this.el.dom;
  15299. this.el.removeClass("x-btn-over");
  15300. this.fireEvent('mouseout', this, e);
  15301. if(this.isMenuTriggerOut(e, internal)){
  15302. this.fireEvent('menutriggerout', this, this.menu, e);
  15303. }
  15304. },
  15305. onFocus : function(e){
  15306. if(!this.disabled){
  15307. this.el.addClass("x-btn-focus");
  15308. }
  15309. },
  15310. onBlur : function(e){
  15311. this.el.removeClass("x-btn-focus");
  15312. },
  15313. getClickEl : function(e, isUp){
  15314. return this.el;
  15315. },
  15316. onMouseDown : function(e){
  15317. if(!this.disabled && e.button == 0){
  15318. this.getClickEl(e).addClass("x-btn-click");
  15319. Ext.getDoc().on('mouseup', this.onMouseUp, this);
  15320. }
  15321. },
  15322. onMouseUp : function(e){
  15323. if(e.button == 0){
  15324. this.getClickEl(e, true).removeClass("x-btn-click");
  15325. Ext.getDoc().un('mouseup', this.onMouseUp, this);
  15326. }
  15327. },
  15328. onMenuShow : function(e){
  15329. this.ignoreNextClick = 0;
  15330. this.el.addClass("x-btn-menu-active");
  15331. this.fireEvent('menushow', this, this.menu);
  15332. },
  15333. onMenuHide : function(e){
  15334. this.el.removeClass("x-btn-menu-active");
  15335. this.ignoreNextClick = this.restoreClick.defer(250, this);
  15336. this.fireEvent('menuhide', this, this.menu);
  15337. },
  15338. restoreClick : function(){
  15339. this.ignoreNextClick = 0;
  15340. }
  15341. });
  15342. Ext.reg('button', Ext.Button);
  15343. Ext.ButtonToggleMgr = function(){
  15344. var groups = {};
  15345. function toggleGroup(btn, state){
  15346. if(state){
  15347. var g = groups[btn.toggleGroup];
  15348. for(var i = 0, l = g.length; i < l; i++){
  15349. if(g[i] != btn){
  15350. g[i].toggle(false);
  15351. }
  15352. }
  15353. }
  15354. }
  15355. return {
  15356. register : function(btn){
  15357. if(!btn.toggleGroup){
  15358. return;
  15359. }
  15360. var g = groups[btn.toggleGroup];
  15361. if(!g){
  15362. g = groups[btn.toggleGroup] = [];
  15363. }
  15364. g.push(btn);
  15365. btn.on("toggle", toggleGroup);
  15366. },
  15367. unregister : function(btn){
  15368. if(!btn.toggleGroup){
  15369. return;
  15370. }
  15371. var g = groups[btn.toggleGroup];
  15372. if(g){
  15373. g.remove(btn);
  15374. btn.un("toggle", toggleGroup);
  15375. }
  15376. }
  15377. };
  15378. }();
  15379. Ext.SplitButton = Ext.extend(Ext.Button, {
  15380. arrowSelector : 'button:last',
  15381. initComponent : function(){
  15382. Ext.SplitButton.superclass.initComponent.call(this);
  15383. this.addEvents("arrowclick");
  15384. },
  15385. onRender : function(ct, position){
  15386. var tpl = new Ext.Template(
  15387. '<table cellspacing="0" class="x-btn-menu-wrap x-btn"><tr><td>',
  15388. '<table cellspacing="0" class="x-btn-wrap x-btn-menu-text-wrap"><tbody>',
  15389. '<tr><td class="x-btn-left"><i>&#160;</i></td><td class="x-btn-center"><button class="x-btn-text" type="{1}">{0}</button></td></tr>',
  15390. "</tbody></table></td><td>",
  15391. '<table cellspacing="0" class="x-btn-wrap x-btn-menu-arrow-wrap"><tbody>',
  15392. '<tr><td class="x-btn-center"><button class="x-btn-menu-arrow-el" type="button">&#160;</button></td><td class="x-btn-right"><i>&#160;</i></td></tr>',
  15393. "</tbody></table></td></tr></table>"
  15394. );
  15395. var btn, targs = [this.text || '&#160;', this.type];
  15396. if(position){
  15397. btn = tpl.insertBefore(position, targs, true);
  15398. }else{
  15399. btn = tpl.append(ct, targs, true);
  15400. }
  15401. var btnEl = btn.child(this.buttonSelector);
  15402. this.initButtonEl(btn, btnEl);
  15403. this.arrowBtnTable = btn.child("table:last");
  15404. if(this.arrowTooltip){
  15405. btn.child(this.arrowSelector).dom[this.tooltipType] = this.arrowTooltip;
  15406. }
  15407. },
  15408. autoWidth : function(){
  15409. if(this.el){
  15410. var tbl = this.el.child("table:first");
  15411. var tbl2 = this.el.child("table:last");
  15412. this.el.setWidth("auto");
  15413. tbl.setWidth("auto");
  15414. if(Ext.isIE7 && Ext.isStrict){
  15415. var ib = this.el.child(this.buttonSelector);
  15416. if(ib && ib.getWidth() > 20){
  15417. ib.clip();
  15418. ib.setWidth(Ext.util.TextMetrics.measure(ib, this.text).width+ib.getFrameWidth('lr'));
  15419. }
  15420. }
  15421. if(this.minWidth){
  15422. if((tbl.getWidth()+tbl2.getWidth()) < this.minWidth){
  15423. tbl.setWidth(this.minWidth-tbl2.getWidth());
  15424. }
  15425. }
  15426. this.el.setWidth(tbl.getWidth()+tbl2.getWidth());
  15427. }
  15428. },
  15429. setArrowHandler : function(handler, scope){
  15430. this.arrowHandler = handler;
  15431. this.scope = scope;
  15432. },
  15433. onClick : function(e){
  15434. e.preventDefault();
  15435. if(!this.disabled){
  15436. if(e.getTarget(".x-btn-menu-arrow-wrap")){
  15437. if(this.menu && !this.menu.isVisible() && !this.ignoreNextClick){
  15438. this.showMenu();
  15439. }
  15440. this.fireEvent("arrowclick", this, e);
  15441. if(this.arrowHandler){
  15442. this.arrowHandler.call(this.scope || this, this, e);
  15443. }
  15444. }else{
  15445. if(this.enableToggle){
  15446. this.toggle();
  15447. }
  15448. this.fireEvent("click", this, e);
  15449. if(this.handler){
  15450. this.handler.call(this.scope || this, this, e);
  15451. }
  15452. }
  15453. }
  15454. },
  15455. getClickEl : function(e, isUp){
  15456. if(!isUp){
  15457. return (this.lastClickEl = e.getTarget("table", 10, true));
  15458. }
  15459. return this.lastClickEl;
  15460. },
  15461. onDisable : function(){
  15462. if(this.el){
  15463. if(!Ext.isIE6){
  15464. this.el.addClass("x-item-disabled");
  15465. }
  15466. this.el.child(this.buttonSelector).dom.disabled = true;
  15467. this.el.child(this.arrowSelector).dom.disabled = true;
  15468. }
  15469. this.disabled = true;
  15470. },
  15471. onEnable : function(){
  15472. if(this.el){
  15473. if(!Ext.isIE6){
  15474. this.el.removeClass("x-item-disabled");
  15475. }
  15476. this.el.child(this.buttonSelector).dom.disabled = false;
  15477. this.el.child(this.arrowSelector).dom.disabled = false;
  15478. }
  15479. this.disabled = false;
  15480. },
  15481. isMenuTriggerOver : function(e){
  15482. return this.menu && e.within(this.arrowBtnTable) && !e.within(this.arrowBtnTable, true);
  15483. },
  15484. isMenuTriggerOut : function(e, internal){
  15485. return this.menu && !e.within(this.arrowBtnTable);
  15486. },
  15487. onDestroy : function(){
  15488. Ext.destroy(this.arrowBtnTable);
  15489. Ext.SplitButton.superclass.onDestroy.call(this);
  15490. }
  15491. });
  15492. Ext.MenuButton = Ext.SplitButton;
  15493. Ext.reg('splitbutton', Ext.SplitButton);
  15494. Ext.CycleButton = Ext.extend(Ext.SplitButton, {
  15495. getItemText : function(item){
  15496. if(item && this.showText === true){
  15497. var text = '';
  15498. if(this.prependText){
  15499. text += this.prependText;
  15500. }
  15501. text += item.text;
  15502. return text;
  15503. }
  15504. return undefined;
  15505. },
  15506. setActiveItem : function(item, suppressEvent){
  15507. if(typeof item != 'object'){
  15508. item = this.menu.items.get(item);
  15509. }
  15510. if(item){
  15511. if(!this.rendered){
  15512. this.text = this.getItemText(item);
  15513. this.iconCls = item.iconCls;
  15514. }else{
  15515. var t = this.getItemText(item);
  15516. if(t){
  15517. this.setText(t);
  15518. }
  15519. this.setIconClass(item.iconCls);
  15520. }
  15521. this.activeItem = item;
  15522. if(!item.checked){
  15523. item.setChecked(true, true);
  15524. }
  15525. if(this.forceIcon){
  15526. this.setIconClass(this.forceIcon);
  15527. }
  15528. if(!suppressEvent){
  15529. this.fireEvent('change', this, item);
  15530. }
  15531. }
  15532. },
  15533. getActiveItem : function(){
  15534. return this.activeItem;
  15535. },
  15536. initComponent : function(){
  15537. this.addEvents(
  15538. "change"
  15539. );
  15540. if(this.changeHandler){
  15541. this.on('change', this.changeHandler, this.scope||this);
  15542. delete this.changeHandler;
  15543. }
  15544. this.itemCount = this.items.length;
  15545. this.menu = {cls:'x-cycle-menu', items:[]};
  15546. var checked;
  15547. for(var i = 0, len = this.itemCount; i < len; i++){
  15548. var item = this.items[i];
  15549. item.group = item.group || this.id;
  15550. item.itemIndex = i;
  15551. item.checkHandler = this.checkHandler;
  15552. item.scope = this;
  15553. item.checked = item.checked || false;
  15554. this.menu.items.push(item);
  15555. if(item.checked){
  15556. checked = item;
  15557. }
  15558. }
  15559. this.setActiveItem(checked, true);
  15560. Ext.CycleButton.superclass.initComponent.call(this);
  15561. this.on('click', this.toggleSelected, this);
  15562. },
  15563. checkHandler : function(item, pressed){
  15564. if(pressed){
  15565. this.setActiveItem(item);
  15566. }
  15567. },
  15568. toggleSelected : function(){
  15569. this.menu.render();
  15570. var nextIdx, checkItem;
  15571. for (var i = 1; i < this.itemCount; i++) {
  15572. nextIdx = (this.activeItem.itemIndex + i) % this.itemCount;
  15573. checkItem = this.menu.items.itemAt(nextIdx);
  15574. if (!checkItem.disabled) {
  15575. checkItem.setChecked(true);
  15576. break;
  15577. }
  15578. }
  15579. }
  15580. });
  15581. Ext.reg('cycle', Ext.CycleButton);
  15582. Ext.Toolbar = function(config){
  15583. if(Ext.isArray(config)){
  15584. config = {buttons:config};
  15585. }
  15586. Ext.Toolbar.superclass.constructor.call(this, config);
  15587. };
  15588. (function(){
  15589. var T = Ext.Toolbar;
  15590. Ext.extend(T, Ext.BoxComponent, {
  15591. trackMenus : true,
  15592. initComponent : function(){
  15593. T.superclass.initComponent.call(this);
  15594. if(this.items){
  15595. this.buttons = this.items;
  15596. }
  15597. this.items = new Ext.util.MixedCollection(false, function(o){
  15598. return o.itemId || o.id || Ext.id();
  15599. });
  15600. },
  15601. autoCreate: {
  15602. cls:'x-toolbar x-small-editor',
  15603. html:'<table cellspacing="0"><tr></tr></table>'
  15604. },
  15605. onRender : function(ct, position){
  15606. this.el = ct.createChild(Ext.apply({ id: this.id },this.autoCreate), position);
  15607. this.tr = this.el.child("tr", true);
  15608. },
  15609. afterRender : function(){
  15610. T.superclass.afterRender.call(this);
  15611. if(this.buttons){
  15612. this.add.apply(this, this.buttons);
  15613. delete this.buttons;
  15614. }
  15615. },
  15616. add : function(){
  15617. var a = arguments, l = a.length;
  15618. for(var i = 0; i < l; i++){
  15619. var el = a[i];
  15620. if(el.isFormField){
  15621. this.addField(el);
  15622. }else if(el.render){
  15623. this.addItem(el);
  15624. }else if(typeof el == "string"){
  15625. if(el == "separator" || el == "-"){
  15626. this.addSeparator();
  15627. }else if(el == " "){
  15628. this.addSpacer();
  15629. }else if(el == "->"){
  15630. this.addFill();
  15631. }else{
  15632. this.addText(el);
  15633. }
  15634. }else if(el.tagName){
  15635. this.addElement(el);
  15636. }else if(typeof el == "object"){
  15637. if(el.xtype){
  15638. this.addField(Ext.ComponentMgr.create(el, 'button'));
  15639. }else{
  15640. this.addButton(el);
  15641. }
  15642. }
  15643. }
  15644. },
  15645. addSeparator : function(){
  15646. return this.addItem(new T.Separator());
  15647. },
  15648. addSpacer : function(){
  15649. return this.addItem(new T.Spacer());
  15650. },
  15651. addFill : function(){
  15652. return this.addItem(new T.Fill());
  15653. },
  15654. addElement : function(el){
  15655. return this.addItem(new T.Item(el));
  15656. },
  15657. addItem : function(item){
  15658. var td = this.nextBlock();
  15659. this.initMenuTracking(item);
  15660. item.render(td);
  15661. this.items.add(item);
  15662. return item;
  15663. },
  15664. addButton : function(config){
  15665. if(Ext.isArray(config)){
  15666. var buttons = [];
  15667. for(var i = 0, len = config.length; i < len; i++) {
  15668. buttons.push(this.addButton(config[i]));
  15669. }
  15670. return buttons;
  15671. }
  15672. var b = config;
  15673. if(!(config instanceof T.Button)){
  15674. b = config.split ?
  15675. new T.SplitButton(config) :
  15676. new T.Button(config);
  15677. }
  15678. var td = this.nextBlock();
  15679. this.initMenuTracking(b);
  15680. b.render(td);
  15681. this.items.add(b);
  15682. return b;
  15683. },
  15684. initMenuTracking : function(item){
  15685. if(this.trackMenus && item.menu){
  15686. item.on({
  15687. 'menutriggerover' : this.onButtonTriggerOver,
  15688. 'menushow' : this.onButtonMenuShow,
  15689. 'menuhide' : this.onButtonMenuHide,
  15690. scope: this
  15691. })
  15692. }
  15693. },
  15694. addText : function(text){
  15695. return this.addItem(new T.TextItem(text));
  15696. },
  15697. insertButton : function(index, item){
  15698. if(Ext.isArray(item)){
  15699. var buttons = [];
  15700. for(var i = 0, len = item.length; i < len; i++) {
  15701. buttons.push(this.insertButton(index + i, item[i]));
  15702. }
  15703. return buttons;
  15704. }
  15705. if (!(item instanceof T.Button)){
  15706. item = new T.Button(item);
  15707. }
  15708. var td = document.createElement("td");
  15709. this.tr.insertBefore(td, this.tr.childNodes[index]);
  15710. this.initMenuTracking(item);
  15711. item.render(td);
  15712. this.items.insert(index, item);
  15713. return item;
  15714. },
  15715. addDom : function(config, returnEl){
  15716. var td = this.nextBlock();
  15717. Ext.DomHelper.overwrite(td, config);
  15718. var ti = new T.Item(td.firstChild);
  15719. ti.render(td);
  15720. this.items.add(ti);
  15721. return ti;
  15722. },
  15723. addField : function(field){
  15724. var td = this.nextBlock();
  15725. field.render(td);
  15726. var ti = new T.Item(td.firstChild);
  15727. ti.render(td);
  15728. this.items.add(ti);
  15729. return ti;
  15730. },
  15731. nextBlock : function(){
  15732. var td = document.createElement("td");
  15733. this.tr.appendChild(td);
  15734. return td;
  15735. },
  15736. onDestroy : function(){
  15737. Ext.Toolbar.superclass.onDestroy.call(this);
  15738. if(this.rendered){
  15739. if(this.items){
  15740. Ext.destroy.apply(Ext, this.items.items);
  15741. }
  15742. Ext.Element.uncache(this.tr);
  15743. }
  15744. },
  15745. onDisable : function(){
  15746. this.items.each(function(item){
  15747. if(item.disable){
  15748. item.disable();
  15749. }
  15750. });
  15751. },
  15752. onEnable : function(){
  15753. this.items.each(function(item){
  15754. if(item.enable){
  15755. item.enable();
  15756. }
  15757. });
  15758. },
  15759. onButtonTriggerOver : function(btn){
  15760. if(this.activeMenuBtn && this.activeMenuBtn != btn){
  15761. this.activeMenuBtn.hideMenu();
  15762. btn.showMenu();
  15763. this.activeMenuBtn = btn;
  15764. }
  15765. },
  15766. onButtonMenuShow : function(btn){
  15767. this.activeMenuBtn = btn;
  15768. },
  15769. onButtonMenuHide : function(btn){
  15770. delete this.activeMenuBtn;
  15771. }
  15772. });
  15773. Ext.reg('toolbar', Ext.Toolbar);
  15774. T.Item = function(el){
  15775. this.el = Ext.getDom(el);
  15776. this.id = Ext.id(this.el);
  15777. this.hidden = false;
  15778. };
  15779. T.Item.prototype = {
  15780. getEl : function(){
  15781. return this.el;
  15782. },
  15783. render : function(td){
  15784. this.td = td;
  15785. td.appendChild(this.el);
  15786. },
  15787. destroy : function(){
  15788. if(this.td && this.td.parentNode){
  15789. this.td.parentNode.removeChild(this.td);
  15790. }
  15791. },
  15792. show: function(){
  15793. this.hidden = false;
  15794. this.td.style.display = "";
  15795. },
  15796. hide: function(){
  15797. this.hidden = true;
  15798. this.td.style.display = "none";
  15799. },
  15800. setVisible: function(visible){
  15801. if(visible) {
  15802. this.show();
  15803. }else{
  15804. this.hide();
  15805. }
  15806. },
  15807. focus : function(){
  15808. Ext.fly(this.el).focus();
  15809. },
  15810. disable : function(){
  15811. Ext.fly(this.td).addClass("x-item-disabled");
  15812. this.disabled = true;
  15813. this.el.disabled = true;
  15814. },
  15815. enable : function(){
  15816. Ext.fly(this.td).removeClass("x-item-disabled");
  15817. this.disabled = false;
  15818. this.el.disabled = false;
  15819. }
  15820. };
  15821. Ext.reg('tbitem', T.Item);
  15822. T.Separator = function(){
  15823. var s = document.createElement("span");
  15824. s.className = "ytb-sep";
  15825. T.Separator.superclass.constructor.call(this, s);
  15826. };
  15827. Ext.extend(T.Separator, T.Item, {
  15828. enable:Ext.emptyFn,
  15829. disable:Ext.emptyFn,
  15830. focus:Ext.emptyFn
  15831. });
  15832. Ext.reg('tbseparator', T.Separator);
  15833. T.Spacer = function(){
  15834. var s = document.createElement("div");
  15835. s.className = "ytb-spacer";
  15836. T.Spacer.superclass.constructor.call(this, s);
  15837. };
  15838. Ext.extend(T.Spacer, T.Item, {
  15839. enable:Ext.emptyFn,
  15840. disable:Ext.emptyFn,
  15841. focus:Ext.emptyFn
  15842. });
  15843. Ext.reg('tbspacer', T.Spacer);
  15844. T.Fill = Ext.extend(T.Spacer, {
  15845. render : function(td){
  15846. td.style.width = '100%';
  15847. T.Fill.superclass.render.call(this, td);
  15848. }
  15849. });
  15850. Ext.reg('tbfill', T.Fill);
  15851. T.TextItem = function(t){
  15852. var s = document.createElement("span");
  15853. s.className = "ytb-text";
  15854. s.innerHTML = t.text ? t.text : t;
  15855. T.TextItem.superclass.constructor.call(this, s);
  15856. };
  15857. Ext.extend(T.TextItem, T.Item, {
  15858. enable:Ext.emptyFn,
  15859. disable:Ext.emptyFn,
  15860. focus:Ext.emptyFn
  15861. });
  15862. Ext.reg('tbtext', T.TextItem);
  15863. T.Button = Ext.extend(Ext.Button, {
  15864. hideParent : true,
  15865. onDestroy : function(){
  15866. T.Button.superclass.onDestroy.call(this);
  15867. if(this.container){
  15868. this.container.remove();
  15869. }
  15870. }
  15871. });
  15872. Ext.reg('tbbutton', T.Button);
  15873. T.SplitButton = Ext.extend(Ext.SplitButton, {
  15874. hideParent : true,
  15875. onDestroy : function(){
  15876. T.SplitButton.superclass.onDestroy.call(this);
  15877. if(this.container){
  15878. this.container.remove();
  15879. }
  15880. }
  15881. });
  15882. Ext.reg('tbsplit', T.SplitButton);
  15883. T.MenuButton = T.SplitButton;
  15884. })();
  15885. Ext.PagingToolbar = Ext.extend(Ext.Toolbar, {
  15886. pageSize: 20,
  15887. displayMsg : 'Displaying {0} - {1} of {2}',
  15888. emptyMsg : 'No data to display',
  15889. beforePageText : "Page",
  15890. afterPageText : "of {0}",
  15891. firstText : "First Page",
  15892. prevText : "Previous Page",
  15893. nextText : "Next Page",
  15894. lastText : "Last Page",
  15895. refreshText : "Refresh",
  15896. paramNames : {start: 'start', limit: 'limit'},
  15897. initComponent : function(){
  15898. Ext.PagingToolbar.superclass.initComponent.call(this);
  15899. this.cursor = 0;
  15900. this.bind(this.store);
  15901. },
  15902. onRender : function(ct, position){
  15903. Ext.PagingToolbar.superclass.onRender.call(this, ct, position);
  15904. this.first = this.addButton({
  15905. tooltip: this.firstText,
  15906. iconCls: "x-tbar-page-first",
  15907. disabled: true,
  15908. handler: this.onClick.createDelegate(this, ["first"])
  15909. });
  15910. this.prev = this.addButton({
  15911. tooltip: this.prevText,
  15912. iconCls: "x-tbar-page-prev",
  15913. disabled: true,
  15914. handler: this.onClick.createDelegate(this, ["prev"])
  15915. });
  15916. this.addSeparator();
  15917. this.add(this.beforePageText);
  15918. this.field = Ext.get(this.addDom({
  15919. tag: "input",
  15920. type: "text",
  15921. size: "3",
  15922. value: "1",
  15923. cls: "x-tbar-page-number"
  15924. }).el);
  15925. this.field.on("keydown", this.onPagingKeydown, this);
  15926. this.field.on("focus", function(){this.dom.select();});
  15927. this.afterTextEl = this.addText(String.format(this.afterPageText, 1));
  15928. this.field.setHeight(18);
  15929. this.addSeparator();
  15930. this.next = this.addButton({
  15931. tooltip: this.nextText,
  15932. iconCls: "x-tbar-page-next",
  15933. disabled: true,
  15934. handler: this.onClick.createDelegate(this, ["next"])
  15935. });
  15936. this.last = this.addButton({
  15937. tooltip: this.lastText,
  15938. iconCls: "x-tbar-page-last",
  15939. disabled: true,
  15940. handler: this.onClick.createDelegate(this, ["last"])
  15941. });
  15942. this.addSeparator();
  15943. this.loading = this.addButton({
  15944. tooltip: this.refreshText,
  15945. iconCls: "x-tbar-loading",
  15946. handler: this.onClick.createDelegate(this, ["refresh"])
  15947. });
  15948. if(this.displayInfo){
  15949. this.displayEl = Ext.fly(this.el.dom).createChild({cls:'x-paging-info'});
  15950. }
  15951. if(this.dsLoaded){
  15952. this.onLoad.apply(this, this.dsLoaded);
  15953. }
  15954. },
  15955. updateInfo : function(){
  15956. if(this.displayEl){
  15957. var count = this.store.getCount();
  15958. var msg = count == 0 ?
  15959. this.emptyMsg :
  15960. String.format(
  15961. this.displayMsg,
  15962. this.cursor+1, this.cursor+count, this.store.getTotalCount()
  15963. );
  15964. this.displayEl.update(msg);
  15965. }
  15966. },
  15967. onLoad : function(store, r, o){
  15968. if(!this.rendered){
  15969. this.dsLoaded = [store, r, o];
  15970. return;
  15971. }
  15972. this.cursor = o.params ? o.params[this.paramNames.start] : 0;
  15973. var d = this.getPageData(), ap = d.activePage, ps = d.pages;
  15974. this.afterTextEl.el.innerHTML = String.format(this.afterPageText, d.pages);
  15975. this.field.dom.value = ap;
  15976. this.first.setDisabled(ap == 1);
  15977. this.prev.setDisabled(ap == 1);
  15978. this.next.setDisabled(ap == ps);
  15979. this.last.setDisabled(ap == ps);
  15980. this.loading.enable();
  15981. this.updateInfo();
  15982. },
  15983. getPageData : function(){
  15984. var total = this.store.getTotalCount();
  15985. return {
  15986. total : total,
  15987. activePage : Math.ceil((this.cursor+this.pageSize)/this.pageSize),
  15988. pages : total < this.pageSize ? 1 : Math.ceil(total/this.pageSize)
  15989. };
  15990. },
  15991. onLoadError : function(){
  15992. if(!this.rendered){
  15993. return;
  15994. }
  15995. this.loading.enable();
  15996. },
  15997. readPage : function(d){
  15998. var v = this.field.dom.value, pageNum;
  15999. if (!v || isNaN(pageNum = parseInt(v, 10))) {
  16000. this.field.dom.value = d.activePage;
  16001. return false;
  16002. }
  16003. return pageNum;
  16004. },
  16005. onPagingKeydown : function(e){
  16006. var k = e.getKey(), d = this.getPageData(), pageNum;
  16007. if (k == e.RETURN) {
  16008. e.stopEvent();
  16009. if(pageNum = this.readPage(d)){
  16010. pageNum = Math.min(Math.max(1, pageNum), d.pages) - 1;
  16011. this.doLoad(pageNum * this.pageSize);
  16012. }
  16013. }else if (k == e.HOME || k == e.END){
  16014. e.stopEvent();
  16015. pageNum = k == e.HOME ? 1 : d.pages;
  16016. this.field.dom.value = pageNum;
  16017. }else if (k == e.UP || k == e.PAGEUP || k == e.DOWN || k == e.PAGEDOWN){
  16018. e.stopEvent();
  16019. if(pageNum = this.readPage(d)){
  16020. var increment = e.shiftKey ? 10 : 1;
  16021. if(k == e.DOWN || k == e.PAGEDOWN){
  16022. increment *= -1;
  16023. }
  16024. pageNum += increment;
  16025. if(pageNum >= 1 & pageNum <= d.pages){
  16026. this.field.dom.value = pageNum;
  16027. }
  16028. }
  16029. }
  16030. },
  16031. beforeLoad : function(){
  16032. if(this.rendered && this.loading){
  16033. this.loading.disable();
  16034. }
  16035. },
  16036. doLoad : function(start){
  16037. var o = {}, pn = this.paramNames;
  16038. o[pn.start] = start;
  16039. o[pn.limit] = this.pageSize;
  16040. this.store.load({params:o});
  16041. },
  16042. onClick : function(which){
  16043. var store = this.store;
  16044. switch(which){
  16045. case "first":
  16046. this.doLoad(0);
  16047. break;
  16048. case "prev":
  16049. this.doLoad(Math.max(0, this.cursor-this.pageSize));
  16050. break;
  16051. case "next":
  16052. this.doLoad(this.cursor+this.pageSize);
  16053. break;
  16054. case "last":
  16055. var total = store.getTotalCount();
  16056. var extra = total % this.pageSize;
  16057. var lastStart = extra ? (total - extra) : total-this.pageSize;
  16058. this.doLoad(lastStart);
  16059. break;
  16060. case "refresh":
  16061. this.doLoad(this.cursor);
  16062. break;
  16063. }
  16064. },
  16065. unbind : function(store){
  16066. store = Ext.StoreMgr.lookup(store);
  16067. store.un("beforeload", this.beforeLoad, this);
  16068. store.un("load", this.onLoad, this);
  16069. store.un("loadexception", this.onLoadError, this);
  16070. this.store = undefined;
  16071. },
  16072. bind : function(store){
  16073. store = Ext.StoreMgr.lookup(store);
  16074. store.on("beforeload", this.beforeLoad, this);
  16075. store.on("load", this.onLoad, this);
  16076. store.on("loadexception", this.onLoadError, this);
  16077. this.store = store;
  16078. }
  16079. });
  16080. Ext.reg('paging', Ext.PagingToolbar);
  16081. Ext.Resizable = function(el, config){
  16082. this.el = Ext.get(el);
  16083. if(config && config.wrap){
  16084. config.resizeChild = this.el;
  16085. this.el = this.el.wrap(typeof config.wrap == "object" ? config.wrap : {cls:"xresizable-wrap"});
  16086. this.el.id = this.el.dom.id = config.resizeChild.id + "-rzwrap";
  16087. this.el.setStyle("overflow", "hidden");
  16088. this.el.setPositioning(config.resizeChild.getPositioning());
  16089. config.resizeChild.clearPositioning();
  16090. if(!config.width || !config.height){
  16091. var csize = config.resizeChild.getSize();
  16092. this.el.setSize(csize.width, csize.height);
  16093. }
  16094. if(config.pinned && !config.adjustments){
  16095. config.adjustments = "auto";
  16096. }
  16097. }
  16098. this.proxy = this.el.createProxy({tag: "div", cls: "x-resizable-proxy", id: this.el.id + "-rzproxy"});
  16099. this.proxy.unselectable();
  16100. this.proxy.enableDisplayMode('block');
  16101. Ext.apply(this, config);
  16102. if(this.pinned){
  16103. this.disableTrackOver = true;
  16104. this.el.addClass("x-resizable-pinned");
  16105. }
  16106. var position = this.el.getStyle("position");
  16107. if(position != "absolute" && position != "fixed"){
  16108. this.el.setStyle("position", "relative");
  16109. }
  16110. if(!this.handles){
  16111. this.handles = 's,e,se';
  16112. if(this.multiDirectional){
  16113. this.handles += ',n,w';
  16114. }
  16115. }
  16116. if(this.handles == "all"){
  16117. this.handles = "n s e w ne nw se sw";
  16118. }
  16119. var hs = this.handles.split(/\s*?[,;]\s*?| /);
  16120. var ps = Ext.Resizable.positions;
  16121. for(var i = 0, len = hs.length; i < len; i++){
  16122. if(hs[i] && ps[hs[i]]){
  16123. var pos = ps[hs[i]];
  16124. this[pos] = new Ext.Resizable.Handle(this, pos, this.disableTrackOver, this.transparent);
  16125. }
  16126. }
  16127. this.corner = this.southeast;
  16128. if(this.handles.indexOf("n") != -1 || this.handles.indexOf("w") != -1){
  16129. this.updateBox = true;
  16130. }
  16131. this.activeHandle = null;
  16132. if(this.resizeChild){
  16133. if(typeof this.resizeChild == "boolean"){
  16134. this.resizeChild = Ext.get(this.el.dom.firstChild, true);
  16135. }else{
  16136. this.resizeChild = Ext.get(this.resizeChild, true);
  16137. }
  16138. }
  16139. if(this.adjustments == "auto"){
  16140. var rc = this.resizeChild;
  16141. var hw = this.west, he = this.east, hn = this.north, hs = this.south;
  16142. if(rc && (hw || hn)){
  16143. rc.position("relative");
  16144. rc.setLeft(hw ? hw.el.getWidth() : 0);
  16145. rc.setTop(hn ? hn.el.getHeight() : 0);
  16146. }
  16147. this.adjustments = [
  16148. (he ? -he.el.getWidth() : 0) + (hw ? -hw.el.getWidth() : 0),
  16149. (hn ? -hn.el.getHeight() : 0) + (hs ? -hs.el.getHeight() : 0) -1
  16150. ];
  16151. }
  16152. if(this.draggable){
  16153. this.dd = this.dynamic ?
  16154. this.el.initDD(null) : this.el.initDDProxy(null, {dragElId: this.proxy.id});
  16155. this.dd.setHandleElId(this.resizeChild ? this.resizeChild.id : this.el.id);
  16156. }
  16157. this.addEvents(
  16158. "beforeresize",
  16159. "resize"
  16160. );
  16161. if(this.width !== null && this.height !== null){
  16162. this.resizeTo(this.width, this.height);
  16163. }else{
  16164. this.updateChildSize();
  16165. }
  16166. if(Ext.isIE){
  16167. this.el.dom.style.zoom = 1;
  16168. }
  16169. Ext.Resizable.superclass.constructor.call(this);
  16170. };
  16171. Ext.extend(Ext.Resizable, Ext.util.Observable, {
  16172. resizeChild : false,
  16173. adjustments : [0, 0],
  16174. minWidth : 5,
  16175. minHeight : 5,
  16176. maxWidth : 10000,
  16177. maxHeight : 10000,
  16178. enabled : true,
  16179. animate : false,
  16180. duration : .35,
  16181. dynamic : false,
  16182. handles : false,
  16183. multiDirectional : false,
  16184. disableTrackOver : false,
  16185. easing : 'easeOutStrong',
  16186. widthIncrement : 0,
  16187. heightIncrement : 0,
  16188. pinned : false,
  16189. width : null,
  16190. height : null,
  16191. preserveRatio : false,
  16192. transparent: false,
  16193. minX: 0,
  16194. minY: 0,
  16195. draggable: false,
  16196. resizeTo : function(width, height){
  16197. this.el.setSize(width, height);
  16198. this.updateChildSize();
  16199. this.fireEvent("resize", this, width, height, null);
  16200. },
  16201. startSizing : function(e, handle){
  16202. this.fireEvent("beforeresize", this, e);
  16203. if(this.enabled){
  16204. if(!this.overlay){
  16205. this.overlay = this.el.createProxy({tag: "div", cls: "x-resizable-overlay", html: "&#160;"}, Ext.getBody());
  16206. this.overlay.unselectable();
  16207. this.overlay.enableDisplayMode("block");
  16208. this.overlay.on("mousemove", this.onMouseMove, this);
  16209. this.overlay.on("mouseup", this.onMouseUp, this);
  16210. }
  16211. this.overlay.setStyle("cursor", handle.el.getStyle("cursor"));
  16212. this.resizing = true;
  16213. this.startBox = this.el.getBox();
  16214. this.startPoint = e.getXY();
  16215. this.offsets = [(this.startBox.x + this.startBox.width) - this.startPoint[0],
  16216. (this.startBox.y + this.startBox.height) - this.startPoint[1]];
  16217. this.overlay.setSize(Ext.lib.Dom.getViewWidth(true), Ext.lib.Dom.getViewHeight(true));
  16218. this.overlay.show();
  16219. if(this.constrainTo) {
  16220. var ct = Ext.get(this.constrainTo);
  16221. this.resizeRegion = ct.getRegion().adjust(
  16222. ct.getFrameWidth('t'),
  16223. ct.getFrameWidth('l'),
  16224. -ct.getFrameWidth('b'),
  16225. -ct.getFrameWidth('r')
  16226. );
  16227. }
  16228. this.proxy.setStyle('visibility', 'hidden');
  16229. this.proxy.show();
  16230. this.proxy.setBox(this.startBox);
  16231. if(!this.dynamic){
  16232. this.proxy.setStyle('visibility', 'visible');
  16233. }
  16234. }
  16235. },
  16236. onMouseDown : function(handle, e){
  16237. if(this.enabled){
  16238. e.stopEvent();
  16239. this.activeHandle = handle;
  16240. this.startSizing(e, handle);
  16241. }
  16242. },
  16243. onMouseUp : function(e){
  16244. var size = this.resizeElement();
  16245. this.resizing = false;
  16246. this.handleOut();
  16247. this.overlay.hide();
  16248. this.proxy.hide();
  16249. this.fireEvent("resize", this, size.width, size.height, e);
  16250. },
  16251. updateChildSize : function(){
  16252. if(this.resizeChild){
  16253. var el = this.el;
  16254. var child = this.resizeChild;
  16255. var adj = this.adjustments;
  16256. if(el.dom.offsetWidth){
  16257. var b = el.getSize(true);
  16258. child.setSize(b.width+adj[0], b.height+adj[1]);
  16259. }
  16260. if(Ext.isIE){
  16261. setTimeout(function(){
  16262. if(el.dom.offsetWidth){
  16263. var b = el.getSize(true);
  16264. child.setSize(b.width+adj[0], b.height+adj[1]);
  16265. }
  16266. }, 10);
  16267. }
  16268. }
  16269. },
  16270. snap : function(value, inc, min){
  16271. if(!inc || !value) return value;
  16272. var newValue = value;
  16273. var m = value % inc;
  16274. if(m > 0){
  16275. if(m > (inc/2)){
  16276. newValue = value + (inc-m);
  16277. }else{
  16278. newValue = value - m;
  16279. }
  16280. }
  16281. return Math.max(min, newValue);
  16282. },
  16283. resizeElement : function(){
  16284. var box = this.proxy.getBox();
  16285. if(this.updateBox){
  16286. this.el.setBox(box, false, this.animate, this.duration, null, this.easing);
  16287. }else{
  16288. this.el.setSize(box.width, box.height, this.animate, this.duration, null, this.easing);
  16289. }
  16290. this.updateChildSize();
  16291. if(!this.dynamic){
  16292. this.proxy.hide();
  16293. }
  16294. return box;
  16295. },
  16296. constrain : function(v, diff, m, mx){
  16297. if(v - diff < m){
  16298. diff = v - m;
  16299. }else if(v - diff > mx){
  16300. diff = mx - v;
  16301. }
  16302. return diff;
  16303. },
  16304. onMouseMove : function(e){
  16305. if(this.enabled){
  16306. try{
  16307. if(this.resizeRegion && !this.resizeRegion.contains(e.getPoint())) {
  16308. return;
  16309. }
  16310. var curSize = this.curSize || this.startBox;
  16311. var x = this.startBox.x, y = this.startBox.y;
  16312. var ox = x, oy = y;
  16313. var w = curSize.width, h = curSize.height;
  16314. var ow = w, oh = h;
  16315. var mw = this.minWidth, mh = this.minHeight;
  16316. var mxw = this.maxWidth, mxh = this.maxHeight;
  16317. var wi = this.widthIncrement;
  16318. var hi = this.heightIncrement;
  16319. var eventXY = e.getXY();
  16320. var diffX = -(this.startPoint[0] - Math.max(this.minX, eventXY[0]));
  16321. var diffY = -(this.startPoint[1] - Math.max(this.minY, eventXY[1]));
  16322. var pos = this.activeHandle.position;
  16323. switch(pos){
  16324. case "east":
  16325. w += diffX;
  16326. w = Math.min(Math.max(mw, w), mxw);
  16327. break;
  16328. case "south":
  16329. h += diffY;
  16330. h = Math.min(Math.max(mh, h), mxh);
  16331. break;
  16332. case "southeast":
  16333. w += diffX;
  16334. h += diffY;
  16335. w = Math.min(Math.max(mw, w), mxw);
  16336. h = Math.min(Math.max(mh, h), mxh);
  16337. break;
  16338. case "north":
  16339. diffY = this.constrain(h, diffY, mh, mxh);
  16340. y += diffY;
  16341. h -= diffY;
  16342. break;
  16343. case "west":
  16344. diffX = this.constrain(w, diffX, mw, mxw);
  16345. x += diffX;
  16346. w -= diffX;
  16347. break;
  16348. case "northeast":
  16349. w += diffX;
  16350. w = Math.min(Math.max(mw, w), mxw);
  16351. diffY = this.constrain(h, diffY, mh, mxh);
  16352. y += diffY;
  16353. h -= diffY;
  16354. break;
  16355. case "northwest":
  16356. diffX = this.constrain(w, diffX, mw, mxw);
  16357. diffY = this.constrain(h, diffY, mh, mxh);
  16358. y += diffY;
  16359. h -= diffY;
  16360. x += diffX;
  16361. w -= diffX;
  16362. break;
  16363. case "southwest":
  16364. diffX = this.constrain(w, diffX, mw, mxw);
  16365. h += diffY;
  16366. h = Math.min(Math.max(mh, h), mxh);
  16367. x += diffX;
  16368. w -= diffX;
  16369. break;
  16370. }
  16371. var sw = this.snap(w, wi, mw);
  16372. var sh = this.snap(h, hi, mh);
  16373. if(sw != w || sh != h){
  16374. switch(pos){
  16375. case "northeast":
  16376. y -= sh - h;
  16377. break;
  16378. case "north":
  16379. y -= sh - h;
  16380. break;
  16381. case "southwest":
  16382. x -= sw - w;
  16383. break;
  16384. case "west":
  16385. x -= sw - w;
  16386. break;
  16387. case "northwest":
  16388. x -= sw - w;
  16389. y -= sh - h;
  16390. break;
  16391. }
  16392. w = sw;
  16393. h = sh;
  16394. }
  16395. if(this.preserveRatio){
  16396. switch(pos){
  16397. case "southeast":
  16398. case "east":
  16399. h = oh * (w/ow);
  16400. h = Math.min(Math.max(mh, h), mxh);
  16401. w = ow * (h/oh);
  16402. break;
  16403. case "south":
  16404. w = ow * (h/oh);
  16405. w = Math.min(Math.max(mw, w), mxw);
  16406. h = oh * (w/ow);
  16407. break;
  16408. case "northeast":
  16409. w = ow * (h/oh);
  16410. w = Math.min(Math.max(mw, w), mxw);
  16411. h = oh * (w/ow);
  16412. break;
  16413. case "north":
  16414. var tw = w;
  16415. w = ow * (h/oh);
  16416. w = Math.min(Math.max(mw, w), mxw);
  16417. h = oh * (w/ow);
  16418. x += (tw - w) / 2;
  16419. break;
  16420. case "southwest":
  16421. h = oh * (w/ow);
  16422. h = Math.min(Math.max(mh, h), mxh);
  16423. var tw = w;
  16424. w = ow * (h/oh);
  16425. x += tw - w;
  16426. break;
  16427. case "west":
  16428. var th = h;
  16429. h = oh * (w/ow);
  16430. h = Math.min(Math.max(mh, h), mxh);
  16431. y += (th - h) / 2;
  16432. var tw = w;
  16433. w = ow * (h/oh);
  16434. x += tw - w;
  16435. break;
  16436. case "northwest":
  16437. var tw = w;
  16438. var th = h;
  16439. h = oh * (w/ow);
  16440. h = Math.min(Math.max(mh, h), mxh);
  16441. w = ow * (h/oh);
  16442. y += th - h;
  16443. x += tw - w;
  16444. break;
  16445. }
  16446. }
  16447. this.proxy.setBounds(x, y, w, h);
  16448. if(this.dynamic){
  16449. this.resizeElement();
  16450. }
  16451. }catch(e){}
  16452. }
  16453. },
  16454. handleOver : function(){
  16455. if(this.enabled){
  16456. this.el.addClass("x-resizable-over");
  16457. }
  16458. },
  16459. handleOut : function(){
  16460. if(!this.resizing){
  16461. this.el.removeClass("x-resizable-over");
  16462. }
  16463. },
  16464. getEl : function(){
  16465. return this.el;
  16466. },
  16467. getResizeChild : function(){
  16468. return this.resizeChild;
  16469. },
  16470. destroy : function(removeEl){
  16471. this.proxy.remove();
  16472. if(this.overlay){
  16473. this.overlay.removeAllListeners();
  16474. this.overlay.remove();
  16475. }
  16476. var ps = Ext.Resizable.positions;
  16477. for(var k in ps){
  16478. if(typeof ps[k] != "function" && this[ps[k]]){
  16479. var h = this[ps[k]];
  16480. h.el.removeAllListeners();
  16481. h.el.remove();
  16482. }
  16483. }
  16484. if(removeEl){
  16485. this.el.update("");
  16486. this.el.remove();
  16487. }
  16488. },
  16489. syncHandleHeight : function(){
  16490. var h = this.el.getHeight(true);
  16491. if(this.west){
  16492. this.west.el.setHeight(h);
  16493. }
  16494. if(this.east){
  16495. this.east.el.setHeight(h);
  16496. }
  16497. }
  16498. });
  16499. Ext.Resizable.positions = {
  16500. n: "north", s: "south", e: "east", w: "west", se: "southeast", sw: "southwest", nw: "northwest", ne: "northeast"
  16501. };
  16502. Ext.Resizable.Handle = function(rz, pos, disableTrackOver, transparent){
  16503. if(!this.tpl){
  16504. var tpl = Ext.DomHelper.createTemplate(
  16505. {tag: "div", cls: "x-resizable-handle x-resizable-handle-{0}"}
  16506. );
  16507. tpl.compile();
  16508. Ext.Resizable.Handle.prototype.tpl = tpl;
  16509. }
  16510. this.position = pos;
  16511. this.rz = rz;
  16512. this.el = this.tpl.append(rz.el.dom, [this.position], true);
  16513. this.el.unselectable();
  16514. if(transparent){
  16515. this.el.setOpacity(0);
  16516. }
  16517. this.el.on("mousedown", this.onMouseDown, this);
  16518. if(!disableTrackOver){
  16519. this.el.on("mouseover", this.onMouseOver, this);
  16520. this.el.on("mouseout", this.onMouseOut, this);
  16521. }
  16522. };
  16523. Ext.Resizable.Handle.prototype = {
  16524. afterResize : function(rz){
  16525. },
  16526. onMouseDown : function(e){
  16527. this.rz.onMouseDown(this, e);
  16528. },
  16529. onMouseOver : function(e){
  16530. this.rz.handleOver(this, e);
  16531. },
  16532. onMouseOut : function(e){
  16533. this.rz.handleOut(this, e);
  16534. }
  16535. };
  16536. Ext.Editor = function(field, config){
  16537. this.field = field;
  16538. Ext.Editor.superclass.constructor.call(this, config);
  16539. };
  16540. Ext.extend(Ext.Editor, Ext.Component, {
  16541. value : "",
  16542. alignment: "c-c?",
  16543. shadow : "frame",
  16544. constrain : false,
  16545. swallowKeys : true,
  16546. completeOnEnter : false,
  16547. cancelOnEsc : false,
  16548. updateEl : false,
  16549. initComponent : function(){
  16550. Ext.Editor.superclass.initComponent.call(this);
  16551. this.addEvents(
  16552. "beforestartedit",
  16553. "startedit",
  16554. "beforecomplete",
  16555. "complete",
  16556. "specialkey"
  16557. );
  16558. },
  16559. onRender : function(ct, position){
  16560. this.el = new Ext.Layer({
  16561. shadow: this.shadow,
  16562. cls: "x-editor",
  16563. parentEl : ct,
  16564. shim : this.shim,
  16565. shadowOffset:4,
  16566. id: this.id,
  16567. constrain: this.constrain
  16568. });
  16569. this.el.setStyle("overflow", Ext.isGecko ? "auto" : "hidden");
  16570. if(this.field.msgTarget != 'title'){
  16571. this.field.msgTarget = 'qtip';
  16572. }
  16573. this.field.inEditor = true;
  16574. this.field.render(this.el);
  16575. if(Ext.isGecko){
  16576. this.field.el.dom.setAttribute('autocomplete', 'off');
  16577. }
  16578. this.field.on("specialkey", this.onSpecialKey, this);
  16579. if(this.swallowKeys){
  16580. this.field.el.swallowEvent(['keydown','keypress']);
  16581. }
  16582. this.field.show();
  16583. this.field.on("blur", this.onBlur, this);
  16584. if(this.field.grow){
  16585. this.field.on("autosize", this.el.sync, this.el, {delay:1});
  16586. }
  16587. },
  16588. onSpecialKey : function(field, e){
  16589. if(this.completeOnEnter && e.getKey() == e.ENTER){
  16590. e.stopEvent();
  16591. this.completeEdit();
  16592. }else if(this.cancelOnEsc && e.getKey() == e.ESC){
  16593. this.cancelEdit();
  16594. }else{
  16595. this.fireEvent('specialkey', field, e);
  16596. }
  16597. },
  16598. startEdit : function(el, value){
  16599. if(this.editing){
  16600. this.completeEdit();
  16601. }
  16602. this.boundEl = Ext.get(el);
  16603. var v = value !== undefined ? value : this.boundEl.dom.innerHTML;
  16604. if(!this.rendered){
  16605. this.render(this.parentEl || document.body);
  16606. }
  16607. if(this.fireEvent("beforestartedit", this, this.boundEl, v) === false){
  16608. return;
  16609. }
  16610. this.startValue = v;
  16611. this.field.setValue(v);
  16612. this.doAutoSize();
  16613. this.el.alignTo(this.boundEl, this.alignment);
  16614. this.editing = true;
  16615. this.show();
  16616. },
  16617. doAutoSize : function(){
  16618. if(this.autoSize){
  16619. var sz = this.boundEl.getSize();
  16620. switch(this.autoSize){
  16621. case "width":
  16622. this.setSize(sz.width, "");
  16623. break;
  16624. case "height":
  16625. this.setSize("", sz.height);
  16626. break;
  16627. default:
  16628. this.setSize(sz.width, sz.height);
  16629. }
  16630. }
  16631. },
  16632. setSize : function(w, h){
  16633. delete this.field.lastSize;
  16634. this.field.setSize(w, h);
  16635. if(this.el){
  16636. this.el.sync();
  16637. }
  16638. },
  16639. realign : function(){
  16640. this.el.alignTo(this.boundEl, this.alignment);
  16641. },
  16642. completeEdit : function(remainVisible){
  16643. if(!this.editing){
  16644. return;
  16645. }
  16646. var v = this.getValue();
  16647. if(this.revertInvalid !== false && !this.field.isValid()){
  16648. v = this.startValue;
  16649. this.cancelEdit(true);
  16650. }
  16651. if(String(v) === String(this.startValue) && this.ignoreNoChange){
  16652. this.editing = false;
  16653. this.hide();
  16654. return;
  16655. }
  16656. if(this.fireEvent("beforecomplete", this, v, this.startValue) !== false){
  16657. this.editing = false;
  16658. if(this.updateEl && this.boundEl){
  16659. this.boundEl.update(v);
  16660. }
  16661. if(remainVisible !== true){
  16662. this.hide();
  16663. }
  16664. this.fireEvent("complete", this, v, this.startValue);
  16665. }
  16666. },
  16667. onShow : function(){
  16668. this.el.show();
  16669. if(this.hideEl !== false){
  16670. this.boundEl.hide();
  16671. }
  16672. this.field.show();
  16673. if(Ext.isIE && !this.fixIEFocus){ this.fixIEFocus = true;
  16674. this.deferredFocus.defer(50, this);
  16675. }else{
  16676. this.field.focus();
  16677. }
  16678. this.fireEvent("startedit", this.boundEl, this.startValue);
  16679. },
  16680. deferredFocus : function(){
  16681. if(this.editing){
  16682. this.field.focus();
  16683. }
  16684. },
  16685. cancelEdit : function(remainVisible){
  16686. if(this.editing){
  16687. this.setValue(this.startValue);
  16688. if(remainVisible !== true){
  16689. this.hide();
  16690. }
  16691. }
  16692. },
  16693. onBlur : function(){
  16694. if(this.allowBlur !== true && this.editing){
  16695. this.completeEdit();
  16696. }
  16697. },
  16698. onHide : function(){
  16699. if(this.editing){
  16700. this.completeEdit();
  16701. return;
  16702. }
  16703. this.field.blur();
  16704. if(this.field.collapse){
  16705. this.field.collapse();
  16706. }
  16707. this.el.hide();
  16708. if(this.hideEl !== false){
  16709. this.boundEl.show();
  16710. }
  16711. },
  16712. setValue : function(v){
  16713. this.field.setValue(v);
  16714. },
  16715. getValue : function(){
  16716. return this.field.getValue();
  16717. },
  16718. beforeDestroy : function(){
  16719. this.field.destroy();
  16720. this.field = null;
  16721. }
  16722. });
  16723. Ext.reg('editor', Ext.Editor);
  16724. Ext.MessageBox = function(){
  16725. var dlg, opt, mask, waitTimer;
  16726. var bodyEl, msgEl, textboxEl, textareaEl, progressBar, pp, iconEl, spacerEl;
  16727. var buttons, activeTextEl, bwidth, iconCls = '';
  16728. var handleButton = function(button){
  16729. dlg.hide();
  16730. Ext.callback(opt.fn, opt.scope||window, [button, activeTextEl.dom.value], 1);
  16731. };
  16732. var handleHide = function(){
  16733. if(opt && opt.cls){
  16734. dlg.el.removeClass(opt.cls);
  16735. }
  16736. progressBar.reset();
  16737. };
  16738. var handleEsc = function(d, k, e){
  16739. if(opt && opt.closable !== false){
  16740. dlg.hide();
  16741. }
  16742. if(e){
  16743. e.stopEvent();
  16744. }
  16745. };
  16746. var updateButtons = function(b){
  16747. var width = 0;
  16748. if(!b){
  16749. buttons["ok"].hide();
  16750. buttons["cancel"].hide();
  16751. buttons["yes"].hide();
  16752. buttons["no"].hide();
  16753. return width;
  16754. }
  16755. dlg.footer.dom.style.display = '';
  16756. for(var k in buttons){
  16757. if(typeof buttons[k] != "function"){
  16758. if(b[k]){
  16759. buttons[k].show();
  16760. buttons[k].setText(typeof b[k] == "string" ? b[k] : Ext.MessageBox.buttonText[k]);
  16761. width += buttons[k].el.getWidth()+15;
  16762. }else{
  16763. buttons[k].hide();
  16764. }
  16765. }
  16766. }
  16767. return width;
  16768. };
  16769. return {
  16770. getDialog : function(titleText){
  16771. if(!dlg){
  16772. dlg = new Ext.Window({
  16773. autoCreate : true,
  16774. title:titleText,
  16775. resizable:false,
  16776. constrain:true,
  16777. constrainHeader:true,
  16778. minimizable : false,
  16779. maximizable : false,
  16780. stateful: false,
  16781. modal: true,
  16782. shim:true,
  16783. buttonAlign:"center",
  16784. width:400,
  16785. height:100,
  16786. minHeight: 80,
  16787. plain:true,
  16788. footer:true,
  16789. closable:true,
  16790. close : function(){
  16791. if(opt && opt.buttons && opt.buttons.no && !opt.buttons.cancel){
  16792. handleButton("no");
  16793. }else{
  16794. handleButton("cancel");
  16795. }
  16796. }
  16797. });
  16798. buttons = {};
  16799. var bt = this.buttonText;
  16800. buttons["ok"] = dlg.addButton(bt["ok"], handleButton.createCallback("ok"));
  16801. buttons["yes"] = dlg.addButton(bt["yes"], handleButton.createCallback("yes"));
  16802. buttons["no"] = dlg.addButton(bt["no"], handleButton.createCallback("no"));
  16803. buttons["cancel"] = dlg.addButton(bt["cancel"], handleButton.createCallback("cancel"));
  16804. buttons["ok"].hideMode = buttons["yes"].hideMode = buttons["no"].hideMode = buttons["cancel"].hideMode = 'offsets';
  16805. dlg.render(document.body);
  16806. dlg.getEl().addClass('x-window-dlg');
  16807. mask = dlg.mask;
  16808. bodyEl = dlg.body.createChild({
  16809. html:'<div class="ext-mb-icon"></div><div class="ext-mb-content"><span class="ext-mb-text"></span><br /><input type="text" class="ext-mb-input" /><textarea class="ext-mb-textarea"></textarea></div>'
  16810. });
  16811. iconEl = Ext.get(bodyEl.dom.firstChild);
  16812. var contentEl = bodyEl.dom.childNodes[1];
  16813. msgEl = Ext.get(contentEl.firstChild);
  16814. textboxEl = Ext.get(contentEl.childNodes[2]);
  16815. textboxEl.enableDisplayMode();
  16816. textboxEl.addKeyListener([10,13], function(){
  16817. if(dlg.isVisible() && opt && opt.buttons){
  16818. if(opt.buttons.ok){
  16819. handleButton("ok");
  16820. }else if(opt.buttons.yes){
  16821. handleButton("yes");
  16822. }
  16823. }
  16824. });
  16825. textareaEl = Ext.get(contentEl.childNodes[3]);
  16826. textareaEl.enableDisplayMode();
  16827. progressBar = new Ext.ProgressBar({
  16828. renderTo:bodyEl
  16829. });
  16830. bodyEl.createChild({cls:'x-clear'});
  16831. }
  16832. return dlg;
  16833. },
  16834. updateText : function(text){
  16835. if(!dlg.isVisible() && !opt.width){
  16836. dlg.setSize(this.maxWidth, 100);
  16837. }
  16838. msgEl.update(text || '&#160;');
  16839. var iw = iconCls != '' ? (iconEl.getWidth() + iconEl.getMargins('lr')) : 0;
  16840. var mw = msgEl.getWidth() + msgEl.getMargins('lr');
  16841. var fw = dlg.getFrameWidth('lr');
  16842. var bw = dlg.body.getFrameWidth('lr');
  16843. if (Ext.isIE && iw > 0){
  16844. iw += 3;
  16845. }
  16846. var w = Math.max(Math.min(opt.width || iw+mw+fw+bw, this.maxWidth),
  16847. Math.max(opt.minWidth || this.minWidth, bwidth || 0));
  16848. if(opt.prompt === true){
  16849. activeTextEl.setWidth(w-iw-fw-bw);
  16850. }
  16851. if(opt.progress === true || opt.wait === true){
  16852. progressBar.setSize(w-iw-fw-bw);
  16853. }
  16854. dlg.setSize(w, 'auto').center();
  16855. return this;
  16856. },
  16857. updateProgress : function(value, progressText, msg){
  16858. progressBar.updateProgress(value, progressText);
  16859. if(msg){
  16860. this.updateText(msg);
  16861. }
  16862. return this;
  16863. },
  16864. isVisible : function(){
  16865. return dlg && dlg.isVisible();
  16866. },
  16867. hide : function(){
  16868. if(this.isVisible()){
  16869. dlg.hide();
  16870. handleHide();
  16871. }
  16872. return this;
  16873. },
  16874. show : function(options){
  16875. if(this.isVisible()){
  16876. this.hide();
  16877. }
  16878. opt = options;
  16879. var d = this.getDialog(opt.title || "&#160;");
  16880. d.setTitle(opt.title || "&#160;");
  16881. var allowClose = (opt.closable !== false && opt.progress !== true && opt.wait !== true);
  16882. d.tools.close.setDisplayed(allowClose);
  16883. activeTextEl = textboxEl;
  16884. opt.prompt = opt.prompt || (opt.multiline ? true : false);
  16885. if(opt.prompt){
  16886. if(opt.multiline){
  16887. textboxEl.hide();
  16888. textareaEl.show();
  16889. textareaEl.setHeight(typeof opt.multiline == "number" ?
  16890. opt.multiline : this.defaultTextHeight);
  16891. activeTextEl = textareaEl;
  16892. }else{
  16893. textboxEl.show();
  16894. textareaEl.hide();
  16895. }
  16896. }else{
  16897. textboxEl.hide();
  16898. textareaEl.hide();
  16899. }
  16900. activeTextEl.dom.value = opt.value || "";
  16901. if(opt.prompt){
  16902. d.focusEl = activeTextEl;
  16903. }else{
  16904. var bs = opt.buttons;
  16905. var db = null;
  16906. if(bs && bs.ok){
  16907. db = buttons["ok"];
  16908. }else if(bs && bs.yes){
  16909. db = buttons["yes"];
  16910. }
  16911. if (db){
  16912. d.focusEl = db;
  16913. }
  16914. }
  16915. this.setIcon(opt.icon);
  16916. bwidth = updateButtons(opt.buttons);
  16917. progressBar.setVisible(opt.progress === true || opt.wait === true);
  16918. this.updateProgress(0, opt.progressText);
  16919. this.updateText(opt.msg);
  16920. if(opt.cls){
  16921. d.el.addClass(opt.cls);
  16922. }
  16923. d.proxyDrag = opt.proxyDrag === true;
  16924. d.modal = opt.modal !== false;
  16925. d.mask = opt.modal !== false ? mask : false;
  16926. if(!d.isVisible()){
  16927. document.body.appendChild(dlg.el.dom);
  16928. d.setAnimateTarget(opt.animEl);
  16929. d.show(opt.animEl);
  16930. }
  16931. d.on('show', function(){
  16932. if(allowClose === true){
  16933. d.keyMap.enable();
  16934. }else{
  16935. d.keyMap.disable();
  16936. }
  16937. }, this, {single:true});
  16938. if(opt.wait === true){
  16939. progressBar.wait(opt.waitConfig);
  16940. }
  16941. return this;
  16942. },
  16943. setIcon : function(icon){
  16944. if(icon && icon != ''){
  16945. iconEl.removeClass('x-hidden');
  16946. iconEl.replaceClass(iconCls, icon);
  16947. iconCls = icon;
  16948. }else{
  16949. iconEl.replaceClass(iconCls, 'x-hidden');
  16950. iconCls = '';
  16951. }
  16952. return this;
  16953. },
  16954. progress : function(title, msg, progressText){
  16955. this.show({
  16956. title : title,
  16957. msg : msg,
  16958. buttons: false,
  16959. progress:true,
  16960. closable:false,
  16961. minWidth: this.minProgressWidth,
  16962. progressText: progressText
  16963. });
  16964. return this;
  16965. },
  16966. wait : function(msg, title, config){
  16967. this.show({
  16968. title : title,
  16969. msg : msg,
  16970. buttons: false,
  16971. closable:false,
  16972. wait:true,
  16973. modal:true,
  16974. minWidth: this.minProgressWidth,
  16975. waitConfig: config
  16976. });
  16977. return this;
  16978. },
  16979. alert : function(title, msg, fn, scope){
  16980. this.show({
  16981. title : title,
  16982. msg : msg,
  16983. buttons: this.OK,
  16984. fn: fn,
  16985. scope : scope
  16986. });
  16987. return this;
  16988. },
  16989. confirm : function(title, msg, fn, scope){
  16990. this.show({
  16991. title : title,
  16992. msg : msg,
  16993. buttons: this.YESNO,
  16994. fn: fn,
  16995. scope : scope,
  16996. icon: this.QUESTION
  16997. });
  16998. return this;
  16999. },
  17000. prompt : function(title, msg, fn, scope, multiline){
  17001. this.show({
  17002. title : title,
  17003. msg : msg,
  17004. buttons: this.OKCANCEL,
  17005. fn: fn,
  17006. minWidth:250,
  17007. scope : scope,
  17008. prompt:true,
  17009. multiline: multiline
  17010. });
  17011. return this;
  17012. },
  17013. OK : {ok:true},
  17014. CANCEL : {cancel:true},
  17015. OKCANCEL : {ok:true, cancel:true},
  17016. YESNO : {yes:true, no:true},
  17017. YESNOCANCEL : {yes:true, no:true, cancel:true},
  17018. INFO : 'ext-mb-info',
  17019. WARNING : 'ext-mb-warning',
  17020. QUESTION : 'ext-mb-question',
  17021. ERROR : 'ext-mb-error',
  17022. defaultTextHeight : 75,
  17023. maxWidth : 600,
  17024. minWidth : 100,
  17025. minProgressWidth : 250,
  17026. buttonText : {
  17027. ok : "OK",
  17028. cancel : "Cancel",
  17029. yes : "Yes",
  17030. no : "No"
  17031. }
  17032. };
  17033. }();
  17034. Ext.Msg = Ext.MessageBox;
  17035. Ext.Tip = Ext.extend(Ext.Panel, {
  17036. minWidth : 40,
  17037. maxWidth : 300,
  17038. shadow : "sides",
  17039. defaultAlign : "tl-bl?",
  17040. autoRender: true,
  17041. quickShowInterval : 250,
  17042. frame:true,
  17043. hidden:true,
  17044. baseCls: 'x-tip',
  17045. floating:{shadow:true,shim:true,useDisplay:true,constrain:false},
  17046. autoHeight:true,
  17047. initComponent : function(){
  17048. Ext.Tip.superclass.initComponent.call(this);
  17049. if(this.closable && !this.title){
  17050. this.elements += ',header';
  17051. }
  17052. },
  17053. afterRender : function(){
  17054. Ext.Tip.superclass.afterRender.call(this);
  17055. if(this.closable){
  17056. this.addTool({
  17057. id: 'close',
  17058. handler: this.hide,
  17059. scope: this
  17060. });
  17061. }
  17062. },
  17063. showAt : function(xy){
  17064. Ext.Tip.superclass.show.call(this);
  17065. if(this.measureWidth !== false && (!this.initialConfig || typeof this.initialConfig.width != 'number')){
  17066. var bw = this.body.getTextWidth();
  17067. if(this.title){
  17068. bw = Math.max(bw, this.header.child('span').getTextWidth(this.title));
  17069. }
  17070. bw += this.getFrameWidth() + (this.closable ? 20 : 0) + this.body.getPadding("lr");
  17071. this.setWidth(bw.constrain(this.minWidth, this.maxWidth));
  17072. }
  17073. if(this.constrainPosition){
  17074. xy = this.el.adjustForConstraints(xy);
  17075. }
  17076. this.setPagePosition(xy[0], xy[1]);
  17077. },
  17078. showBy : function(el, pos){
  17079. if(!this.rendered){
  17080. this.render(Ext.getBody());
  17081. }
  17082. this.showAt(this.el.getAlignToXY(el, pos || this.defaultAlign));
  17083. },
  17084. initDraggable : function(){
  17085. this.dd = new Ext.Tip.DD(this, typeof this.draggable == 'boolean' ? null : this.draggable);
  17086. this.header.addClass('x-tip-draggable');
  17087. }
  17088. });
  17089. Ext.Tip.DD = function(tip, config){
  17090. Ext.apply(this, config);
  17091. this.tip = tip;
  17092. Ext.Tip.DD.superclass.constructor.call(this, tip.el.id, 'WindowDD-'+tip.id);
  17093. this.setHandleElId(tip.header.id);
  17094. this.scroll = false;
  17095. };
  17096. Ext.extend(Ext.Tip.DD, Ext.dd.DD, {
  17097. moveOnly:true,
  17098. scroll:false,
  17099. headerOffsets:[100, 25],
  17100. startDrag : function(){
  17101. this.tip.el.disableShadow();
  17102. },
  17103. endDrag : function(e){
  17104. this.tip.el.enableShadow(true);
  17105. }
  17106. });
  17107. Ext.ToolTip = Ext.extend(Ext.Tip, {
  17108. showDelay: 500,
  17109. hideDelay: 200,
  17110. dismissDelay: 5000,
  17111. mouseOffset: [15,18],
  17112. trackMouse : false,
  17113. constrainPosition: true,
  17114. initComponent: function(){
  17115. Ext.ToolTip.superclass.initComponent.call(this);
  17116. this.lastActive = new Date();
  17117. this.initTarget();
  17118. },
  17119. initTarget : function(){
  17120. if(this.target){
  17121. this.target = Ext.get(this.target);
  17122. this.target.on('mouseover', this.onTargetOver, this);
  17123. this.target.on('mouseout', this.onTargetOut, this);
  17124. this.target.on('mousemove', this.onMouseMove, this);
  17125. }
  17126. },
  17127. onMouseMove : function(e){
  17128. this.targetXY = e.getXY();
  17129. if(!this.hidden && this.trackMouse){
  17130. this.setPagePosition(this.getTargetXY());
  17131. }
  17132. },
  17133. getTargetXY : function(){
  17134. return [this.targetXY[0]+this.mouseOffset[0], this.targetXY[1]+this.mouseOffset[1]];
  17135. },
  17136. onTargetOver : function(e){
  17137. if(this.disabled || e.within(this.target.dom, true)){
  17138. return;
  17139. }
  17140. this.clearTimer('hide');
  17141. this.targetXY = e.getXY();
  17142. this.delayShow();
  17143. },
  17144. delayShow : function(){
  17145. if(this.hidden && !this.showTimer){
  17146. if(this.lastActive.getElapsed() < this.quickShowInterval){
  17147. this.show();
  17148. }else{
  17149. this.showTimer = this.show.defer(this.showDelay, this);
  17150. }
  17151. }else if(!this.hidden && this.autoHide !== false){
  17152. this.show();
  17153. }
  17154. },
  17155. onTargetOut : function(e){
  17156. if(this.disabled || e.within(this.target.dom, true)){
  17157. return;
  17158. }
  17159. this.clearTimer('show');
  17160. if(this.autoHide !== false){
  17161. this.delayHide();
  17162. }
  17163. },
  17164. delayHide : function(){
  17165. if(!this.hidden && !this.hideTimer){
  17166. this.hideTimer = this.hide.defer(this.hideDelay, this);
  17167. }
  17168. },
  17169. hide: function(){
  17170. this.clearTimer('dismiss');
  17171. this.lastActive = new Date();
  17172. Ext.ToolTip.superclass.hide.call(this);
  17173. },
  17174. show : function(){
  17175. this.showAt(this.getTargetXY());
  17176. },
  17177. showAt : function(xy){
  17178. this.lastActive = new Date();
  17179. this.clearTimers();
  17180. Ext.ToolTip.superclass.showAt.call(this, xy);
  17181. if(this.dismissDelay && this.autoHide !== false){
  17182. this.dismissTimer = this.hide.defer(this.dismissDelay, this);
  17183. }
  17184. },
  17185. clearTimer : function(name){
  17186. name = name + 'Timer';
  17187. clearTimeout(this[name]);
  17188. delete this[name];
  17189. },
  17190. clearTimers : function(){
  17191. this.clearTimer('show');
  17192. this.clearTimer('dismiss');
  17193. this.clearTimer('hide');
  17194. },
  17195. onShow : function(){
  17196. Ext.ToolTip.superclass.onShow.call(this);
  17197. Ext.getDoc().on('mousedown', this.onDocMouseDown, this);
  17198. },
  17199. onHide : function(){
  17200. Ext.ToolTip.superclass.onHide.call(this);
  17201. Ext.getDoc().un('mousedown', this.onDocMouseDown, this);
  17202. },
  17203. onDocMouseDown : function(e){
  17204. if(this.autoHide !== false && !e.within(this.el.dom)){
  17205. this.disable();
  17206. this.enable.defer(100, this);
  17207. }
  17208. },
  17209. onDisable : function(){
  17210. this.clearTimers();
  17211. this.hide();
  17212. },
  17213. adjustPosition : function(x, y){
  17214. var ay = this.targetXY[1], h = this.getSize().height;
  17215. if(this.constrainPosition && y <= ay && (y+h) >= ay){
  17216. y = ay-h-5;
  17217. }
  17218. return {x : x, y: y};
  17219. },
  17220. onDestroy : function(){
  17221. Ext.ToolTip.superclass.onDestroy.call(this);
  17222. if(this.target){
  17223. this.target.un('mouseover', this.onTargetOver, this);
  17224. this.target.un('mouseout', this.onTargetOut, this);
  17225. this.target.un('mousemove', this.onMouseMove, this);
  17226. }
  17227. }
  17228. });
  17229. Ext.QuickTip = Ext.extend(Ext.ToolTip, {
  17230. interceptTitles : false,
  17231. tagConfig : {
  17232. namespace : "ext",
  17233. attribute : "qtip",
  17234. width : "qwidth",
  17235. target : "target",
  17236. title : "qtitle",
  17237. hide : "hide",
  17238. cls : "qclass",
  17239. align : "qalign"
  17240. },
  17241. initComponent : function(){
  17242. this.target = this.target || Ext.getDoc();
  17243. this.targets = this.targets || {};
  17244. Ext.QuickTip.superclass.initComponent.call(this);
  17245. },
  17246. register : function(config){
  17247. var cs = Ext.isArray(config) ? config : arguments;
  17248. for(var i = 0, len = cs.length; i < len; i++){
  17249. var c = cs[i];
  17250. var target = c.target;
  17251. if(target){
  17252. if(Ext.isArray(target)){
  17253. for(var j = 0, jlen = target.length; j < jlen; j++){
  17254. this.targets[Ext.id(target[j])] = c;
  17255. }
  17256. } else{
  17257. this.targets[Ext.id(target)] = c;
  17258. }
  17259. }
  17260. }
  17261. },
  17262. unregister : function(el){
  17263. delete this.targets[Ext.id(el)];
  17264. },
  17265. onTargetOver : function(e){
  17266. if(this.disabled){
  17267. return;
  17268. }
  17269. this.targetXY = e.getXY();
  17270. var t = e.getTarget();
  17271. if(!t || t.nodeType !== 1 || t == document || t == document.body){
  17272. return;
  17273. }
  17274. if(this.activeTarget && t == this.activeTarget.el){
  17275. this.clearTimer('hide');
  17276. this.show();
  17277. return;
  17278. }
  17279. if(t && this.targets[t.id]){
  17280. this.activeTarget = this.targets[t.id];
  17281. this.activeTarget.el = t;
  17282. this.delayShow();
  17283. return;
  17284. }
  17285. var ttp, et = Ext.fly(t), cfg = this.tagConfig;
  17286. var ns = cfg.namespace;
  17287. if(this.interceptTitles && t.title){
  17288. ttp = t.title;
  17289. t.qtip = ttp;
  17290. t.removeAttribute("title");
  17291. e.preventDefault();
  17292. } else{
  17293. ttp = t.qtip || et.getAttributeNS(ns, cfg.attribute);
  17294. }
  17295. if(ttp){
  17296. var autoHide = et.getAttributeNS(ns, cfg.hide);
  17297. this.activeTarget = {
  17298. el: t,
  17299. text: ttp,
  17300. width: et.getAttributeNS(ns, cfg.width),
  17301. autoHide: autoHide != "user" && autoHide !== 'false',
  17302. title: et.getAttributeNS(ns, cfg.title),
  17303. cls: et.getAttributeNS(ns, cfg.cls),
  17304. align: et.getAttributeNS(ns, cfg.align)
  17305. };
  17306. this.delayShow();
  17307. }
  17308. },
  17309. onTargetOut : function(e){
  17310. this.clearTimer('show');
  17311. if(this.autoHide !== false){
  17312. this.delayHide();
  17313. }
  17314. },
  17315. showAt : function(xy){
  17316. var t = this.activeTarget;
  17317. if(t){
  17318. if(!this.rendered){
  17319. this.render(Ext.getBody());
  17320. this.activeTarget = t;
  17321. }
  17322. if(t.width){
  17323. this.setWidth(t.width);
  17324. this.body.setWidth(this.adjustBodyWidth(t.width - this.getFrameWidth()));
  17325. this.measureWidth = false;
  17326. } else{
  17327. this.measureWidth = true;
  17328. }
  17329. this.setTitle(t.title || '');
  17330. this.body.update(t.text);
  17331. this.autoHide = t.autoHide;
  17332. this.dismissDelay = t.dismissDelay || this.dismissDelay;
  17333. if(this.lastCls){
  17334. this.el.removeClass(this.lastCls);
  17335. delete this.lastCls;
  17336. }
  17337. if(t.cls){
  17338. this.el.addClass(t.cls);
  17339. this.lastCls = t.cls;
  17340. }
  17341. if(t.align){
  17342. xy = this.el.getAlignToXY(t.el, t.align);
  17343. this.constrainPosition = false;
  17344. } else{
  17345. this.constrainPosition = true;
  17346. }
  17347. }
  17348. Ext.QuickTip.superclass.showAt.call(this, xy);
  17349. },
  17350. hide: function(){
  17351. delete this.activeTarget;
  17352. Ext.QuickTip.superclass.hide.call(this);
  17353. }
  17354. });
  17355. Ext.QuickTips = function(){
  17356. var tip, locks = [];
  17357. return {
  17358. init : function(){
  17359. if(!tip){
  17360. tip = new Ext.QuickTip({elements:'header,body'});
  17361. }
  17362. },
  17363. enable : function(){
  17364. if(tip){
  17365. locks.pop();
  17366. if(locks.length < 1){
  17367. tip.enable();
  17368. }
  17369. }
  17370. },
  17371. disable : function(){
  17372. if(tip){
  17373. tip.disable();
  17374. }
  17375. locks.push(1);
  17376. },
  17377. isEnabled : function(){
  17378. return tip && !tip.disabled;
  17379. },
  17380. getQuickTip : function(){
  17381. return tip;
  17382. },
  17383. register : function(){
  17384. tip.register.apply(tip, arguments);
  17385. },
  17386. unregister : function(){
  17387. tip.unregister.apply(tip, arguments);
  17388. },
  17389. tips :function(){
  17390. tip.register.apply(tip, arguments);
  17391. }
  17392. }
  17393. }();
  17394. Ext.tree.TreePanel = Ext.extend(Ext.Panel, {
  17395. rootVisible : true,
  17396. animate: Ext.enableFx,
  17397. lines : true,
  17398. enableDD : false,
  17399. hlDrop : Ext.enableFx,
  17400. pathSeparator: "/",
  17401. initComponent : function(){
  17402. Ext.tree.TreePanel.superclass.initComponent.call(this);
  17403. if(!this.eventModel){
  17404. this.eventModel = new Ext.tree.TreeEventModel(this);
  17405. }
  17406. this.nodeHash = {};
  17407. if(this.root){
  17408. this.setRootNode(this.root);
  17409. }
  17410. this.addEvents(
  17411. "append",
  17412. "remove",
  17413. "movenode",
  17414. "insert",
  17415. "beforeappend",
  17416. "beforeremove",
  17417. "beforemovenode",
  17418. "beforeinsert",
  17419. "beforeload",
  17420. "load",
  17421. "textchange",
  17422. "beforeexpandnode",
  17423. "beforecollapsenode",
  17424. "expandnode",
  17425. "disabledchange",
  17426. "collapsenode",
  17427. "beforeclick",
  17428. "click",
  17429. "checkchange",
  17430. "dblclick",
  17431. "contextmenu",
  17432. "beforechildrenrendered",
  17433. "startdrag",
  17434. "enddrag",
  17435. "dragdrop",
  17436. "beforenodedrop",
  17437. "nodedrop",
  17438. "nodedragover"
  17439. );
  17440. if(this.singleExpand){
  17441. this.on("beforeexpandnode", this.restrictExpand, this);
  17442. }
  17443. },
  17444. proxyNodeEvent : function(ename, a1, a2, a3, a4, a5, a6){
  17445. if(ename == 'collapse' || ename == 'expand' || ename == 'beforecollapse' || ename == 'beforeexpand' || ename == 'move' || ename == 'beforemove'){
  17446. ename = ename+'node';
  17447. }
  17448. return this.fireEvent(ename, a1, a2, a3, a4, a5, a6);
  17449. },
  17450. getRootNode : function(){
  17451. return this.root;
  17452. },
  17453. setRootNode : function(node){
  17454. this.root = node;
  17455. node.ownerTree = this;
  17456. node.isRoot = true;
  17457. this.registerNode(node);
  17458. if(!this.rootVisible){
  17459. var uiP = node.attributes.uiProvider;
  17460. node.ui = uiP ? new uiP(node) : new Ext.tree.RootTreeNodeUI(node);
  17461. }
  17462. return node;
  17463. },
  17464. getNodeById : function(id){
  17465. return this.nodeHash[id];
  17466. },
  17467. registerNode : function(node){
  17468. this.nodeHash[node.id] = node;
  17469. },
  17470. unregisterNode : function(node){
  17471. delete this.nodeHash[node.id];
  17472. },
  17473. toString : function(){
  17474. return "[Tree"+(this.id?" "+this.id:"")+"]";
  17475. },
  17476. restrictExpand : function(node){
  17477. var p = node.parentNode;
  17478. if(p){
  17479. if(p.expandedChild && p.expandedChild.parentNode == p){
  17480. p.expandedChild.collapse();
  17481. }
  17482. p.expandedChild = node;
  17483. }
  17484. },
  17485. getChecked : function(a, startNode){
  17486. startNode = startNode || this.root;
  17487. var r = [];
  17488. var f = function(){
  17489. if(this.attributes.checked){
  17490. r.push(!a ? this : (a == 'id' ? this.id : this.attributes[a]));
  17491. }
  17492. }
  17493. startNode.cascade(f);
  17494. return r;
  17495. },
  17496. getEl : function(){
  17497. return this.el;
  17498. },
  17499. getLoader : function(){
  17500. return this.loader;
  17501. },
  17502. expandAll : function(){
  17503. this.root.expand(true);
  17504. },
  17505. collapseAll : function(){
  17506. this.root.collapse(true);
  17507. },
  17508. getSelectionModel : function(){
  17509. if(!this.selModel){
  17510. this.selModel = new Ext.tree.DefaultSelectionModel();
  17511. }
  17512. return this.selModel;
  17513. },
  17514. expandPath : function(path, attr, callback){
  17515. attr = attr || "id";
  17516. var keys = path.split(this.pathSeparator);
  17517. var curNode = this.root;
  17518. if(curNode.attributes[attr] != keys[1]){
  17519. if(callback){
  17520. callback(false, null);
  17521. }
  17522. return;
  17523. }
  17524. var index = 1;
  17525. var f = function(){
  17526. if(++index == keys.length){
  17527. if(callback){
  17528. callback(true, curNode);
  17529. }
  17530. return;
  17531. }
  17532. var c = curNode.findChild(attr, keys[index]);
  17533. if(!c){
  17534. if(callback){
  17535. callback(false, curNode);
  17536. }
  17537. return;
  17538. }
  17539. curNode = c;
  17540. c.expand(false, false, f);
  17541. };
  17542. curNode.expand(false, false, f);
  17543. },
  17544. selectPath : function(path, attr, callback){
  17545. attr = attr || "id";
  17546. var keys = path.split(this.pathSeparator);
  17547. var v = keys.pop();
  17548. if(keys.length > 0){
  17549. var f = function(success, node){
  17550. if(success && node){
  17551. var n = node.findChild(attr, v);
  17552. if(n){
  17553. n.select();
  17554. if(callback){
  17555. callback(true, n);
  17556. }
  17557. }else if(callback){
  17558. callback(false, n);
  17559. }
  17560. }else{
  17561. if(callback){
  17562. callback(false, n);
  17563. }
  17564. }
  17565. };
  17566. this.expandPath(keys.join(this.pathSeparator), attr, f);
  17567. }else{
  17568. this.root.select();
  17569. if(callback){
  17570. callback(true, this.root);
  17571. }
  17572. }
  17573. },
  17574. getTreeEl : function(){
  17575. return this.body;
  17576. },
  17577. onRender : function(ct, position){
  17578. Ext.tree.TreePanel.superclass.onRender.call(this, ct, position);
  17579. this.el.addClass('x-tree');
  17580. this.innerCt = this.body.createChild({tag:"ul",
  17581. cls:"x-tree-root-ct " +
  17582. (this.useArrows ? 'x-tree-arrows' : this.lines ? "x-tree-lines" : "x-tree-no-lines")});
  17583. },
  17584. initEvents : function(){
  17585. Ext.tree.TreePanel.superclass.initEvents.call(this);
  17586. if(this.containerScroll){
  17587. Ext.dd.ScrollManager.register(this.body);
  17588. }
  17589. if((this.enableDD || this.enableDrop) && !this.dropZone){
  17590. this.dropZone = new Ext.tree.TreeDropZone(this, this.dropConfig || {
  17591. ddGroup: this.ddGroup || "TreeDD", appendOnly: this.ddAppendOnly === true
  17592. });
  17593. }
  17594. if((this.enableDD || this.enableDrag) && !this.dragZone){
  17595. this.dragZone = new Ext.tree.TreeDragZone(this, this.dragConfig || {
  17596. ddGroup: this.ddGroup || "TreeDD",
  17597. scroll: this.ddScroll
  17598. });
  17599. }
  17600. this.getSelectionModel().init(this);
  17601. },
  17602. afterRender : function(){
  17603. Ext.tree.TreePanel.superclass.afterRender.call(this);
  17604. this.root.render();
  17605. if(!this.rootVisible){
  17606. this.root.renderChildren();
  17607. }
  17608. },
  17609. onDestroy : function(){
  17610. if(this.rendered){
  17611. this.body.removeAllListeners();
  17612. Ext.dd.ScrollManager.unregister(this.body);
  17613. if(this.dropZone){
  17614. this.dropZone.unreg();
  17615. }
  17616. if(this.dragZone){
  17617. this.dragZone.unreg();
  17618. }
  17619. }
  17620. this.root.destroy();
  17621. this.nodeHash = null;
  17622. Ext.tree.TreePanel.superclass.onDestroy.call(this);
  17623. }
  17624. });
  17625. Ext.reg('treepanel', Ext.tree.TreePanel);
  17626. Ext.tree.TreeEventModel = function(tree){
  17627. this.tree = tree;
  17628. this.tree.on('render', this.initEvents, this);
  17629. }
  17630. Ext.tree.TreeEventModel.prototype = {
  17631. initEvents : function(){
  17632. var el = this.tree.getTreeEl();
  17633. el.on('click', this.delegateClick, this);
  17634. if(this.tree.trackMouseOver !== false){
  17635. el.on('mouseover', this.delegateOver, this);
  17636. el.on('mouseout', this.delegateOut, this);
  17637. }
  17638. el.on('dblclick', this.delegateDblClick, this);
  17639. el.on('contextmenu', this.delegateContextMenu, this);
  17640. },
  17641. getNode : function(e){
  17642. var t;
  17643. if(t = e.getTarget('.x-tree-node-el', 10)){
  17644. var id = Ext.fly(t, '_treeEvents').getAttributeNS('ext', 'tree-node-id');
  17645. if(id){
  17646. return this.tree.getNodeById(id);
  17647. }
  17648. }
  17649. return null;
  17650. },
  17651. getNodeTarget : function(e){
  17652. var t = e.getTarget('.x-tree-node-icon', 1);
  17653. if(!t){
  17654. t = e.getTarget('.x-tree-node-el', 6);
  17655. }
  17656. return t;
  17657. },
  17658. delegateOut : function(e, t){
  17659. if(!this.beforeEvent(e)){
  17660. return;
  17661. }
  17662. if(e.getTarget('.x-tree-ec-icon', 1)){
  17663. var n = this.getNode(e);
  17664. this.onIconOut(e, n);
  17665. if(n == this.lastEcOver){
  17666. delete this.lastEcOver;
  17667. }
  17668. }
  17669. if((t = this.getNodeTarget(e)) && !e.within(t, true)){
  17670. this.onNodeOut(e, this.getNode(e));
  17671. }
  17672. },
  17673. delegateOver : function(e, t){
  17674. if(!this.beforeEvent(e)){
  17675. return;
  17676. }
  17677. if(this.lastEcOver){
  17678. this.onIconOut(e, this.lastEcOver);
  17679. delete this.lastEcOver;
  17680. }
  17681. if(e.getTarget('.x-tree-ec-icon', 1)){
  17682. this.lastEcOver = this.getNode(e);
  17683. this.onIconOver(e, this.lastEcOver);
  17684. }
  17685. if(t = this.getNodeTarget(e)){
  17686. this.onNodeOver(e, this.getNode(e));
  17687. }
  17688. },
  17689. delegateClick : function(e, t){
  17690. if(!this.beforeEvent(e)){
  17691. return;
  17692. }
  17693. if(e.getTarget('input[type=checkbox]', 1)){
  17694. this.onCheckboxClick(e, this.getNode(e));
  17695. }
  17696. else if(e.getTarget('.x-tree-ec-icon', 1)){
  17697. this.onIconClick(e, this.getNode(e));
  17698. }
  17699. else if(this.getNodeTarget(e)){
  17700. this.onNodeClick(e, this.getNode(e));
  17701. }
  17702. },
  17703. delegateDblClick : function(e, t){
  17704. if(this.beforeEvent(e) && this.getNodeTarget(e)){
  17705. this.onNodeDblClick(e, this.getNode(e));
  17706. }
  17707. },
  17708. delegateContextMenu : function(e, t){
  17709. if(this.beforeEvent(e) && this.getNodeTarget(e)){
  17710. this.onNodeContextMenu(e, this.getNode(e));
  17711. }
  17712. },
  17713. onNodeClick : function(e, node){
  17714. node.ui.onClick(e);
  17715. },
  17716. onNodeOver : function(e, node){
  17717. node.ui.onOver(e);
  17718. },
  17719. onNodeOut : function(e, node){
  17720. node.ui.onOut(e);
  17721. },
  17722. onIconOver : function(e, node){
  17723. node.ui.addClass('x-tree-ec-over');
  17724. },
  17725. onIconOut : function(e, node){
  17726. node.ui.removeClass('x-tree-ec-over');
  17727. },
  17728. onIconClick : function(e, node){
  17729. node.ui.ecClick(e);
  17730. },
  17731. onCheckboxClick : function(e, node){
  17732. node.ui.onCheckChange(e);
  17733. },
  17734. onNodeDblClick : function(e, node){
  17735. node.ui.onDblClick(e);
  17736. },
  17737. onNodeContextMenu : function(e, node){
  17738. node.ui.onContextMenu(e);
  17739. },
  17740. beforeEvent : function(e){
  17741. if(this.disabled){
  17742. e.stopEvent();
  17743. return false;
  17744. }
  17745. return true;
  17746. },
  17747. disable: function(){
  17748. this.disabled = true;
  17749. },
  17750. enable: function(){
  17751. this.disabled = false;
  17752. }
  17753. };
  17754. Ext.tree.DefaultSelectionModel = function(config){
  17755. this.selNode = null;
  17756. this.addEvents(
  17757. "selectionchange",
  17758. "beforeselect"
  17759. );
  17760. Ext.apply(this, config);
  17761. Ext.tree.DefaultSelectionModel.superclass.constructor.call(this);
  17762. };
  17763. Ext.extend(Ext.tree.DefaultSelectionModel, Ext.util.Observable, {
  17764. init : function(tree){
  17765. this.tree = tree;
  17766. tree.getTreeEl().on("keydown", this.onKeyDown, this);
  17767. tree.on("click", this.onNodeClick, this);
  17768. },
  17769. onNodeClick : function(node, e){
  17770. this.select(node);
  17771. },
  17772. select : function(node){
  17773. var last = this.selNode;
  17774. if(last != node && this.fireEvent('beforeselect', this, node, last) !== false){
  17775. if(last){
  17776. last.ui.onSelectedChange(false);
  17777. }
  17778. this.selNode = node;
  17779. node.ui.onSelectedChange(true);
  17780. this.fireEvent("selectionchange", this, node, last);
  17781. }
  17782. return node;
  17783. },
  17784. unselect : function(node){
  17785. if(this.selNode == node){
  17786. this.clearSelections();
  17787. }
  17788. },
  17789. clearSelections : function(){
  17790. var n = this.selNode;
  17791. if(n){
  17792. n.ui.onSelectedChange(false);
  17793. this.selNode = null;
  17794. this.fireEvent("selectionchange", this, null);
  17795. }
  17796. return n;
  17797. },
  17798. getSelectedNode : function(){
  17799. return this.selNode;
  17800. },
  17801. isSelected : function(node){
  17802. return this.selNode == node;
  17803. },
  17804. selectPrevious : function(){
  17805. var s = this.selNode || this.lastSelNode;
  17806. if(!s){
  17807. return null;
  17808. }
  17809. var ps = s.previousSibling;
  17810. if(ps){
  17811. if(!ps.isExpanded() || ps.childNodes.length < 1){
  17812. return this.select(ps);
  17813. } else{
  17814. var lc = ps.lastChild;
  17815. while(lc && lc.isExpanded() && lc.childNodes.length > 0){
  17816. lc = lc.lastChild;
  17817. }
  17818. return this.select(lc);
  17819. }
  17820. } else if(s.parentNode && (this.tree.rootVisible || !s.parentNode.isRoot)){
  17821. return this.select(s.parentNode);
  17822. }
  17823. return null;
  17824. },
  17825. selectNext : function(){
  17826. var s = this.selNode || this.lastSelNode;
  17827. if(!s){
  17828. return null;
  17829. }
  17830. if(s.firstChild && s.isExpanded()){
  17831. return this.select(s.firstChild);
  17832. }else if(s.nextSibling){
  17833. return this.select(s.nextSibling);
  17834. }else if(s.parentNode){
  17835. var newS = null;
  17836. s.parentNode.bubble(function(){
  17837. if(this.nextSibling){
  17838. newS = this.getOwnerTree().selModel.select(this.nextSibling);
  17839. return false;
  17840. }
  17841. });
  17842. return newS;
  17843. }
  17844. return null;
  17845. },
  17846. onKeyDown : function(e){
  17847. var s = this.selNode || this.lastSelNode;
  17848. var sm = this;
  17849. if(!s){
  17850. return;
  17851. }
  17852. var k = e.getKey();
  17853. switch(k){
  17854. case e.DOWN:
  17855. e.stopEvent();
  17856. this.selectNext();
  17857. break;
  17858. case e.UP:
  17859. e.stopEvent();
  17860. this.selectPrevious();
  17861. break;
  17862. case e.RIGHT:
  17863. e.preventDefault();
  17864. if(s.hasChildNodes()){
  17865. if(!s.isExpanded()){
  17866. s.expand();
  17867. }else if(s.firstChild){
  17868. this.select(s.firstChild, e);
  17869. }
  17870. }
  17871. break;
  17872. case e.LEFT:
  17873. e.preventDefault();
  17874. if(s.hasChildNodes() && s.isExpanded()){
  17875. s.collapse();
  17876. }else if(s.parentNode && (this.tree.rootVisible || s.parentNode != this.tree.getRootNode())){
  17877. this.select(s.parentNode, e);
  17878. }
  17879. break;
  17880. };
  17881. }
  17882. });
  17883. Ext.tree.MultiSelectionModel = function(config){
  17884. this.selNodes = [];
  17885. this.selMap = {};
  17886. this.addEvents(
  17887. "selectionchange"
  17888. );
  17889. Ext.apply(this, config);
  17890. Ext.tree.MultiSelectionModel.superclass.constructor.call(this);
  17891. };
  17892. Ext.extend(Ext.tree.MultiSelectionModel, Ext.util.Observable, {
  17893. init : function(tree){
  17894. this.tree = tree;
  17895. tree.getTreeEl().on("keydown", this.onKeyDown, this);
  17896. tree.on("click", this.onNodeClick, this);
  17897. },
  17898. onNodeClick : function(node, e){
  17899. this.select(node, e, e.ctrlKey);
  17900. },
  17901. select : function(node, e, keepExisting){
  17902. if(keepExisting !== true){
  17903. this.clearSelections(true);
  17904. }
  17905. if(this.isSelected(node)){
  17906. this.lastSelNode = node;
  17907. return node;
  17908. }
  17909. this.selNodes.push(node);
  17910. this.selMap[node.id] = node;
  17911. this.lastSelNode = node;
  17912. node.ui.onSelectedChange(true);
  17913. this.fireEvent("selectionchange", this, this.selNodes);
  17914. return node;
  17915. },
  17916. unselect : function(node){
  17917. if(this.selMap[node.id]){
  17918. node.ui.onSelectedChange(false);
  17919. var sn = this.selNodes;
  17920. var index = sn.indexOf(node);
  17921. if(index != -1){
  17922. this.selNodes.splice(index, 1);
  17923. }
  17924. delete this.selMap[node.id];
  17925. this.fireEvent("selectionchange", this, this.selNodes);
  17926. }
  17927. },
  17928. clearSelections : function(suppressEvent){
  17929. var sn = this.selNodes;
  17930. if(sn.length > 0){
  17931. for(var i = 0, len = sn.length; i < len; i++){
  17932. sn[i].ui.onSelectedChange(false);
  17933. }
  17934. this.selNodes = [];
  17935. this.selMap = {};
  17936. if(suppressEvent !== true){
  17937. this.fireEvent("selectionchange", this, this.selNodes);
  17938. }
  17939. }
  17940. },
  17941. isSelected : function(node){
  17942. return this.selMap[node.id] ? true : false;
  17943. },
  17944. getSelectedNodes : function(){
  17945. return this.selNodes;
  17946. },
  17947. onKeyDown : Ext.tree.DefaultSelectionModel.prototype.onKeyDown,
  17948. selectNext : Ext.tree.DefaultSelectionModel.prototype.selectNext,
  17949. selectPrevious : Ext.tree.DefaultSelectionModel.prototype.selectPrevious
  17950. });
  17951. Ext.tree.TreeNode = function(attributes){
  17952. attributes = attributes || {};
  17953. if(typeof attributes == "string"){
  17954. attributes = {text: attributes};
  17955. }
  17956. this.childrenRendered = false;
  17957. this.rendered = false;
  17958. Ext.tree.TreeNode.superclass.constructor.call(this, attributes);
  17959. this.expanded = attributes.expanded === true;
  17960. this.isTarget = attributes.isTarget !== false;
  17961. this.draggable = attributes.draggable !== false && attributes.allowDrag !== false;
  17962. this.allowChildren = attributes.allowChildren !== false && attributes.allowDrop !== false;
  17963. this.text = attributes.text;
  17964. this.disabled = attributes.disabled === true;
  17965. this.addEvents(
  17966. "textchange",
  17967. "beforeexpand",
  17968. "beforecollapse",
  17969. "expand",
  17970. "disabledchange",
  17971. "collapse",
  17972. "beforeclick",
  17973. "click",
  17974. "checkchange",
  17975. "dblclick",
  17976. "contextmenu",
  17977. "beforechildrenrendered"
  17978. );
  17979. var uiClass = this.attributes.uiProvider || this.defaultUI || Ext.tree.TreeNodeUI;
  17980. this.ui = new uiClass(this);
  17981. };
  17982. Ext.extend(Ext.tree.TreeNode, Ext.data.Node, {
  17983. preventHScroll: true,
  17984. isExpanded : function(){
  17985. return this.expanded;
  17986. },
  17987. getUI : function(){
  17988. return this.ui;
  17989. },
  17990. setFirstChild : function(node){
  17991. var of = this.firstChild;
  17992. Ext.tree.TreeNode.superclass.setFirstChild.call(this, node);
  17993. if(this.childrenRendered && of && node != of){
  17994. of.renderIndent(true, true);
  17995. }
  17996. if(this.rendered){
  17997. this.renderIndent(true, true);
  17998. }
  17999. },
  18000. setLastChild : function(node){
  18001. var ol = this.lastChild;
  18002. Ext.tree.TreeNode.superclass.setLastChild.call(this, node);
  18003. if(this.childrenRendered && ol && node != ol){
  18004. ol.renderIndent(true, true);
  18005. }
  18006. if(this.rendered){
  18007. this.renderIndent(true, true);
  18008. }
  18009. },
  18010. appendChild : function(){
  18011. var node = Ext.tree.TreeNode.superclass.appendChild.apply(this, arguments);
  18012. if(node && this.childrenRendered){
  18013. node.render();
  18014. }
  18015. this.ui.updateExpandIcon();
  18016. return node;
  18017. },
  18018. removeChild : function(node){
  18019. this.ownerTree.getSelectionModel().unselect(node);
  18020. Ext.tree.TreeNode.superclass.removeChild.apply(this, arguments);
  18021. if(this.childrenRendered){
  18022. node.ui.remove();
  18023. }
  18024. if(this.childNodes.length < 1){
  18025. this.collapse(false, false);
  18026. }else{
  18027. this.ui.updateExpandIcon();
  18028. }
  18029. if(!this.firstChild && !this.isHiddenRoot()) {
  18030. this.childrenRendered = false;
  18031. }
  18032. return node;
  18033. },
  18034. insertBefore : function(node, refNode){
  18035. var newNode = Ext.tree.TreeNode.superclass.insertBefore.apply(this, arguments);
  18036. if(newNode && refNode && this.childrenRendered){
  18037. node.render();
  18038. }
  18039. this.ui.updateExpandIcon();
  18040. return newNode;
  18041. },
  18042. setText : function(text){
  18043. var oldText = this.text;
  18044. this.text = text;
  18045. this.attributes.text = text;
  18046. if(this.rendered){
  18047. this.ui.onTextChange(this, text, oldText);
  18048. }
  18049. this.fireEvent("textchange", this, text, oldText);
  18050. },
  18051. select : function(){
  18052. this.getOwnerTree().getSelectionModel().select(this);
  18053. },
  18054. unselect : function(){
  18055. this.getOwnerTree().getSelectionModel().unselect(this);
  18056. },
  18057. isSelected : function(){
  18058. return this.getOwnerTree().getSelectionModel().isSelected(this);
  18059. },
  18060. expand : function(deep, anim, callback){
  18061. if(!this.expanded){
  18062. if(this.fireEvent("beforeexpand", this, deep, anim) === false){
  18063. return;
  18064. }
  18065. if(!this.childrenRendered){
  18066. this.renderChildren();
  18067. }
  18068. this.expanded = true;
  18069. if(!this.isHiddenRoot() && (this.getOwnerTree().animate && anim !== false) || anim){
  18070. this.ui.animExpand(function(){
  18071. this.fireEvent("expand", this);
  18072. if(typeof callback == "function"){
  18073. callback(this);
  18074. }
  18075. if(deep === true){
  18076. this.expandChildNodes(true);
  18077. }
  18078. }.createDelegate(this));
  18079. return;
  18080. }else{
  18081. this.ui.expand();
  18082. this.fireEvent("expand", this);
  18083. if(typeof callback == "function"){
  18084. callback(this);
  18085. }
  18086. }
  18087. }else{
  18088. if(typeof callback == "function"){
  18089. callback(this);
  18090. }
  18091. }
  18092. if(deep === true){
  18093. this.expandChildNodes(true);
  18094. }
  18095. },
  18096. isHiddenRoot : function(){
  18097. return this.isRoot && !this.getOwnerTree().rootVisible;
  18098. },
  18099. collapse : function(deep, anim){
  18100. if(this.expanded && !this.isHiddenRoot()){
  18101. if(this.fireEvent("beforecollapse", this, deep, anim) === false){
  18102. return;
  18103. }
  18104. this.expanded = false;
  18105. if((this.getOwnerTree().animate && anim !== false) || anim){
  18106. this.ui.animCollapse(function(){
  18107. this.fireEvent("collapse", this);
  18108. if(deep === true){
  18109. this.collapseChildNodes(true);
  18110. }
  18111. }.createDelegate(this));
  18112. return;
  18113. }else{
  18114. this.ui.collapse();
  18115. this.fireEvent("collapse", this);
  18116. }
  18117. }
  18118. if(deep === true){
  18119. var cs = this.childNodes;
  18120. for(var i = 0, len = cs.length; i < len; i++) {
  18121. cs[i].collapse(true, false);
  18122. }
  18123. }
  18124. },
  18125. delayedExpand : function(delay){
  18126. if(!this.expandProcId){
  18127. this.expandProcId = this.expand.defer(delay, this);
  18128. }
  18129. },
  18130. cancelExpand : function(){
  18131. if(this.expandProcId){
  18132. clearTimeout(this.expandProcId);
  18133. }
  18134. this.expandProcId = false;
  18135. },
  18136. toggle : function(){
  18137. if(this.expanded){
  18138. this.collapse();
  18139. }else{
  18140. this.expand();
  18141. }
  18142. },
  18143. ensureVisible : function(callback){
  18144. var tree = this.getOwnerTree();
  18145. tree.expandPath(this.parentNode.getPath(), false, function(){
  18146. var node = tree.getNodeById(this.id);
  18147. tree.getTreeEl().scrollChildIntoView(node.ui.anchor);
  18148. Ext.callback(callback);
  18149. }.createDelegate(this));
  18150. },
  18151. expandChildNodes : function(deep){
  18152. var cs = this.childNodes;
  18153. for(var i = 0, len = cs.length; i < len; i++) {
  18154. cs[i].expand(deep);
  18155. }
  18156. },
  18157. collapseChildNodes : function(deep){
  18158. var cs = this.childNodes;
  18159. for(var i = 0, len = cs.length; i < len; i++) {
  18160. cs[i].collapse(deep);
  18161. }
  18162. },
  18163. disable : function(){
  18164. this.disabled = true;
  18165. this.unselect();
  18166. if(this.rendered && this.ui.onDisableChange){
  18167. this.ui.onDisableChange(this, true);
  18168. }
  18169. this.fireEvent("disabledchange", this, true);
  18170. },
  18171. enable : function(){
  18172. this.disabled = false;
  18173. if(this.rendered && this.ui.onDisableChange){
  18174. this.ui.onDisableChange(this, false);
  18175. }
  18176. this.fireEvent("disabledchange", this, false);
  18177. },
  18178. renderChildren : function(suppressEvent){
  18179. if(suppressEvent !== false){
  18180. this.fireEvent("beforechildrenrendered", this);
  18181. }
  18182. var cs = this.childNodes;
  18183. for(var i = 0, len = cs.length; i < len; i++){
  18184. cs[i].render(true);
  18185. }
  18186. this.childrenRendered = true;
  18187. },
  18188. sort : function(fn, scope){
  18189. Ext.tree.TreeNode.superclass.sort.apply(this, arguments);
  18190. if(this.childrenRendered){
  18191. var cs = this.childNodes;
  18192. for(var i = 0, len = cs.length; i < len; i++){
  18193. cs[i].render(true);
  18194. }
  18195. }
  18196. },
  18197. render : function(bulkRender){
  18198. this.ui.render(bulkRender);
  18199. if(!this.rendered){
  18200. this.getOwnerTree().registerNode(this);
  18201. this.rendered = true;
  18202. if(this.expanded){
  18203. this.expanded = false;
  18204. this.expand(false, false);
  18205. }
  18206. }
  18207. },
  18208. renderIndent : function(deep, refresh){
  18209. if(refresh){
  18210. this.ui.childIndent = null;
  18211. }
  18212. this.ui.renderIndent();
  18213. if(deep === true && this.childrenRendered){
  18214. var cs = this.childNodes;
  18215. for(var i = 0, len = cs.length; i < len; i++){
  18216. cs[i].renderIndent(true, refresh);
  18217. }
  18218. }
  18219. },
  18220. beginUpdate : function(){
  18221. this.childrenRendered = false;
  18222. },
  18223. endUpdate : function(){
  18224. if(this.expanded){
  18225. this.renderChildren();
  18226. }
  18227. },
  18228. destroy : function(){
  18229. for(var i = 0,l = this.childNodes.length; i < l; i++){
  18230. this.childNodes[i].destroy();
  18231. }
  18232. this.childNodes = null;
  18233. if(this.ui.destroy){
  18234. this.ui.destroy();
  18235. }
  18236. }
  18237. });
  18238. Ext.tree.AsyncTreeNode = function(config){
  18239. this.loaded = false;
  18240. this.loading = false;
  18241. Ext.tree.AsyncTreeNode.superclass.constructor.apply(this, arguments);
  18242. this.addEvents('beforeload', 'load');
  18243. };
  18244. Ext.extend(Ext.tree.AsyncTreeNode, Ext.tree.TreeNode, {
  18245. expand : function(deep, anim, callback){
  18246. if(this.loading){
  18247. var timer;
  18248. var f = function(){
  18249. if(!this.loading){
  18250. clearInterval(timer);
  18251. this.expand(deep, anim, callback);
  18252. }
  18253. }.createDelegate(this);
  18254. timer = setInterval(f, 200);
  18255. return;
  18256. }
  18257. if(!this.loaded){
  18258. if(this.fireEvent("beforeload", this) === false){
  18259. return;
  18260. }
  18261. this.loading = true;
  18262. this.ui.beforeLoad(this);
  18263. var loader = this.loader || this.attributes.loader || this.getOwnerTree().getLoader();
  18264. if(loader){
  18265. loader.load(this, this.loadComplete.createDelegate(this, [deep, anim, callback]));
  18266. return;
  18267. }
  18268. }
  18269. Ext.tree.AsyncTreeNode.superclass.expand.call(this, deep, anim, callback);
  18270. },
  18271. isLoading : function(){
  18272. return this.loading;
  18273. },
  18274. loadComplete : function(deep, anim, callback){
  18275. this.loading = false;
  18276. this.loaded = true;
  18277. this.ui.afterLoad(this);
  18278. this.fireEvent("load", this);
  18279. this.expand(deep, anim, callback);
  18280. },
  18281. isLoaded : function(){
  18282. return this.loaded;
  18283. },
  18284. hasChildNodes : function(){
  18285. if(!this.isLeaf() && !this.loaded){
  18286. return true;
  18287. }else{
  18288. return Ext.tree.AsyncTreeNode.superclass.hasChildNodes.call(this);
  18289. }
  18290. },
  18291. reload : function(callback){
  18292. this.collapse(false, false);
  18293. while(this.firstChild){
  18294. this.removeChild(this.firstChild);
  18295. }
  18296. this.childrenRendered = false;
  18297. this.loaded = false;
  18298. if(this.isHiddenRoot()){
  18299. this.expanded = false;
  18300. }
  18301. this.expand(false, false, callback);
  18302. }
  18303. });
  18304. Ext.tree.TreeNodeUI = function(node){
  18305. this.node = node;
  18306. this.rendered = false;
  18307. this.animating = false;
  18308. this.wasLeaf = true;
  18309. this.ecc = 'x-tree-ec-icon x-tree-elbow';
  18310. this.emptyIcon = Ext.BLANK_IMAGE_URL;
  18311. };
  18312. Ext.tree.TreeNodeUI.prototype = {
  18313. removeChild : function(node){
  18314. if(this.rendered){
  18315. this.ctNode.removeChild(node.ui.getEl());
  18316. }
  18317. },
  18318. beforeLoad : function(){
  18319. this.addClass("x-tree-node-loading");
  18320. },
  18321. afterLoad : function(){
  18322. this.removeClass("x-tree-node-loading");
  18323. },
  18324. onTextChange : function(node, text, oldText){
  18325. if(this.rendered){
  18326. this.textNode.innerHTML = text;
  18327. }
  18328. },
  18329. onDisableChange : function(node, state){
  18330. this.disabled = state;
  18331. if (this.checkbox) {
  18332. this.checkbox.disabled = state;
  18333. }
  18334. if(state){
  18335. this.addClass("x-tree-node-disabled");
  18336. }else{
  18337. this.removeClass("x-tree-node-disabled");
  18338. }
  18339. },
  18340. onSelectedChange : function(state){
  18341. if(state){
  18342. this.focus();
  18343. this.addClass("x-tree-selected");
  18344. }else{
  18345. this.removeClass("x-tree-selected");
  18346. }
  18347. },
  18348. onMove : function(tree, node, oldParent, newParent, index, refNode){
  18349. this.childIndent = null;
  18350. if(this.rendered){
  18351. var targetNode = newParent.ui.getContainer();
  18352. if(!targetNode){
  18353. this.holder = document.createElement("div");
  18354. this.holder.appendChild(this.wrap);
  18355. return;
  18356. }
  18357. var insertBefore = refNode ? refNode.ui.getEl() : null;
  18358. if(insertBefore){
  18359. targetNode.insertBefore(this.wrap, insertBefore);
  18360. }else{
  18361. targetNode.appendChild(this.wrap);
  18362. }
  18363. this.node.renderIndent(true);
  18364. }
  18365. },
  18366. addClass : function(cls){
  18367. if(this.elNode){
  18368. Ext.fly(this.elNode).addClass(cls);
  18369. }
  18370. },
  18371. removeClass : function(cls){
  18372. if(this.elNode){
  18373. Ext.fly(this.elNode).removeClass(cls);
  18374. }
  18375. },
  18376. remove : function(){
  18377. if(this.rendered){
  18378. this.holder = document.createElement("div");
  18379. this.holder.appendChild(this.wrap);
  18380. }
  18381. },
  18382. fireEvent : function(){
  18383. return this.node.fireEvent.apply(this.node, arguments);
  18384. },
  18385. initEvents : function(){
  18386. this.node.on("move", this.onMove, this);
  18387. if(this.node.disabled){
  18388. this.addClass("x-tree-node-disabled");
  18389. if (this.checkbox) {
  18390. this.checkbox.disabled = true;
  18391. }
  18392. }
  18393. if(this.node.hidden){
  18394. this.hide();
  18395. }
  18396. var ot = this.node.getOwnerTree();
  18397. var dd = ot.enableDD || ot.enableDrag || ot.enableDrop;
  18398. if(dd && (!this.node.isRoot || ot.rootVisible)){
  18399. Ext.dd.Registry.register(this.elNode, {
  18400. node: this.node,
  18401. handles: this.getDDHandles(),
  18402. isHandle: false
  18403. });
  18404. }
  18405. },
  18406. getDDHandles : function(){
  18407. return [this.iconNode, this.textNode, this.elNode];
  18408. },
  18409. hide : function(){
  18410. this.node.hidden = true;
  18411. if(this.wrap){
  18412. this.wrap.style.display = "none";
  18413. }
  18414. },
  18415. show : function(){
  18416. this.node.hidden = false;
  18417. if(this.wrap){
  18418. this.wrap.style.display = "";
  18419. }
  18420. },
  18421. onContextMenu : function(e){
  18422. if (this.node.hasListener("contextmenu") || this.node.getOwnerTree().hasListener("contextmenu")) {
  18423. e.preventDefault();
  18424. this.focus();
  18425. this.fireEvent("contextmenu", this.node, e);
  18426. }
  18427. },
  18428. onClick : function(e){
  18429. if(this.dropping){
  18430. e.stopEvent();
  18431. return;
  18432. }
  18433. if(this.fireEvent("beforeclick", this.node, e) !== false){
  18434. var a = e.getTarget('a');
  18435. if(!this.disabled && this.node.attributes.href && a){
  18436. this.fireEvent("click", this.node, e);
  18437. return;
  18438. }else if(a && e.ctrlKey){
  18439. e.stopEvent();
  18440. }
  18441. e.preventDefault();
  18442. if(this.disabled){
  18443. return;
  18444. }
  18445. if(this.node.attributes.singleClickExpand && !this.animating && this.node.hasChildNodes()){
  18446. this.node.toggle();
  18447. }
  18448. this.fireEvent("click", this.node, e);
  18449. }else{
  18450. e.stopEvent();
  18451. }
  18452. },
  18453. onDblClick : function(e){
  18454. e.preventDefault();
  18455. if(this.disabled){
  18456. return;
  18457. }
  18458. if(this.checkbox){
  18459. this.toggleCheck();
  18460. }
  18461. if(!this.animating && this.node.hasChildNodes()){
  18462. this.node.toggle();
  18463. }
  18464. this.fireEvent("dblclick", this.node, e);
  18465. },
  18466. onOver : function(e){
  18467. this.addClass('x-tree-node-over');
  18468. },
  18469. onOut : function(e){
  18470. this.removeClass('x-tree-node-over');
  18471. },
  18472. onCheckChange : function(){
  18473. var checked = this.checkbox.checked;
  18474. this.node.attributes.checked = checked;
  18475. this.fireEvent('checkchange', this.node, checked);
  18476. },
  18477. ecClick : function(e){
  18478. if(!this.animating && (this.node.hasChildNodes() || this.node.attributes.expandable)){
  18479. this.node.toggle();
  18480. }
  18481. },
  18482. startDrop : function(){
  18483. this.dropping = true;
  18484. },
  18485. endDrop : function(){
  18486. setTimeout(function(){
  18487. this.dropping = false;
  18488. }.createDelegate(this), 50);
  18489. },
  18490. expand : function(){
  18491. this.updateExpandIcon();
  18492. this.ctNode.style.display = "";
  18493. },
  18494. focus : function(){
  18495. if(!this.node.preventHScroll){
  18496. try{this.anchor.focus();
  18497. }catch(e){}
  18498. }else if(!Ext.isIE){
  18499. try{
  18500. var noscroll = this.node.getOwnerTree().getTreeEl().dom;
  18501. var l = noscroll.scrollLeft;
  18502. this.anchor.focus();
  18503. noscroll.scrollLeft = l;
  18504. }catch(e){}
  18505. }
  18506. },
  18507. toggleCheck : function(value){
  18508. var cb = this.checkbox;
  18509. if(cb){
  18510. cb.checked = (value === undefined ? !cb.checked : value);
  18511. }
  18512. },
  18513. blur : function(){
  18514. try{
  18515. this.anchor.blur();
  18516. }catch(e){}
  18517. },
  18518. animExpand : function(callback){
  18519. var ct = Ext.get(this.ctNode);
  18520. ct.stopFx();
  18521. if(!this.node.hasChildNodes()){
  18522. this.updateExpandIcon();
  18523. this.ctNode.style.display = "";
  18524. Ext.callback(callback);
  18525. return;
  18526. }
  18527. this.animating = true;
  18528. this.updateExpandIcon();
  18529. ct.slideIn('t', {
  18530. callback : function(){
  18531. this.animating = false;
  18532. Ext.callback(callback);
  18533. },
  18534. scope: this,
  18535. duration: this.node.ownerTree.duration || .25
  18536. });
  18537. },
  18538. highlight : function(){
  18539. var tree = this.node.getOwnerTree();
  18540. Ext.fly(this.wrap).highlight(
  18541. tree.hlColor || "C3DAF9",
  18542. {endColor: tree.hlBaseColor}
  18543. );
  18544. },
  18545. collapse : function(){
  18546. this.updateExpandIcon();
  18547. this.ctNode.style.display = "none";
  18548. },
  18549. animCollapse : function(callback){
  18550. var ct = Ext.get(this.ctNode);
  18551. ct.enableDisplayMode('block');
  18552. ct.stopFx();
  18553. this.animating = true;
  18554. this.updateExpandIcon();
  18555. ct.slideOut('t', {
  18556. callback : function(){
  18557. this.animating = false;
  18558. Ext.callback(callback);
  18559. },
  18560. scope: this,
  18561. duration: this.node.ownerTree.duration || .25
  18562. });
  18563. },
  18564. getContainer : function(){
  18565. return this.ctNode;
  18566. },
  18567. getEl : function(){
  18568. return this.wrap;
  18569. },
  18570. appendDDGhost : function(ghostNode){
  18571. ghostNode.appendChild(this.elNode.cloneNode(true));
  18572. },
  18573. getDDRepairXY : function(){
  18574. return Ext.lib.Dom.getXY(this.iconNode);
  18575. },
  18576. onRender : function(){
  18577. this.render();
  18578. },
  18579. render : function(bulkRender){
  18580. var n = this.node, a = n.attributes;
  18581. var targetNode = n.parentNode ?
  18582. n.parentNode.ui.getContainer() : n.ownerTree.innerCt.dom;
  18583. if(!this.rendered){
  18584. this.rendered = true;
  18585. this.renderElements(n, a, targetNode, bulkRender);
  18586. if(a.qtip){
  18587. if(this.textNode.setAttributeNS){
  18588. this.textNode.setAttributeNS("ext", "qtip", a.qtip);
  18589. if(a.qtipTitle){
  18590. this.textNode.setAttributeNS("ext", "qtitle", a.qtipTitle);
  18591. }
  18592. }else{
  18593. this.textNode.setAttribute("ext:qtip", a.qtip);
  18594. if(a.qtipTitle){
  18595. this.textNode.setAttribute("ext:qtitle", a.qtipTitle);
  18596. }
  18597. }
  18598. }else if(a.qtipCfg){
  18599. a.qtipCfg.target = Ext.id(this.textNode);
  18600. Ext.QuickTips.register(a.qtipCfg);
  18601. }
  18602. this.initEvents();
  18603. if(!this.node.expanded){
  18604. this.updateExpandIcon(true);
  18605. }
  18606. }else{
  18607. if(bulkRender === true) {
  18608. targetNode.appendChild(this.wrap);
  18609. }
  18610. }
  18611. },
  18612. renderElements : function(n, a, targetNode, bulkRender){
  18613. this.indentMarkup = n.parentNode ? n.parentNode.ui.getChildIndent() : '';
  18614. var cb = typeof a.checked == 'boolean';
  18615. var href = a.href ? a.href : Ext.isGecko ? "" : "#";
  18616. var buf = ['<li class="x-tree-node"><div tree-node-id="',n.id,'" class="x-tree-node-el x-tree-node-leaf x-unselectable ', a.cls,'" unselectable="on">',
  18617. '<span class="x-tree-node-indent">',this.indentMarkup,"</span>",
  18618. '<img src="', this.emptyIcon, '" class="x-tree-ec-icon x-tree-elbow" />',
  18619. '<img src="', a.icon || this.emptyIcon, '" class="x-tree-node-icon',(a.icon ? " x-tree-node-inline-icon" : ""),(a.iconCls ? " "+a.iconCls : ""),'" unselectable="on" />',
  18620. cb ? ('<input class="x-tree-node-cb" type="checkbox" ' + (a.checked ? 'checked="checked" />' : '/>')) : '',
  18621. '<a hidefocus="on" class="x-tree-node-anchor" href="',href,'" tabIndex="1" ',
  18622. a.hrefTarget ? ' target="'+a.hrefTarget+'"' : "", '><span unselectable="on">',n.text,"</span></a></div>",
  18623. '<ul class="x-tree-node-ct" style="display:none;"></ul>',
  18624. "</li>"].join('');
  18625. var nel;
  18626. if(bulkRender !== true && n.nextSibling && (nel = n.nextSibling.ui.getEl())){
  18627. this.wrap = Ext.DomHelper.insertHtml("beforeBegin", nel, buf);
  18628. }else{
  18629. this.wrap = Ext.DomHelper.insertHtml("beforeEnd", targetNode, buf);
  18630. }
  18631. this.elNode = this.wrap.childNodes[0];
  18632. this.ctNode = this.wrap.childNodes[1];
  18633. var cs = this.elNode.childNodes;
  18634. this.indentNode = cs[0];
  18635. this.ecNode = cs[1];
  18636. this.iconNode = cs[2];
  18637. var index = 3;
  18638. if(cb){
  18639. this.checkbox = cs[3];
  18640. index++;
  18641. }
  18642. this.anchor = cs[index];
  18643. this.textNode = cs[index].firstChild;
  18644. },
  18645. getAnchor : function(){
  18646. return this.anchor;
  18647. },
  18648. getTextEl : function(){
  18649. return this.textNode;
  18650. },
  18651. getIconEl : function(){
  18652. return this.iconNode;
  18653. },
  18654. isChecked : function(){
  18655. return this.checkbox ? this.checkbox.checked : false;
  18656. },
  18657. updateExpandIcon : function(){
  18658. if(this.rendered){
  18659. var n = this.node, c1, c2;
  18660. var cls = n.isLast() ? "x-tree-elbow-end" : "x-tree-elbow";
  18661. var hasChild = n.hasChildNodes();
  18662. if(hasChild || n.attributes.expandable){
  18663. if(n.expanded){
  18664. cls += "-minus";
  18665. c1 = "x-tree-node-collapsed";
  18666. c2 = "x-tree-node-expanded";
  18667. }else{
  18668. cls += "-plus";
  18669. c1 = "x-tree-node-expanded";
  18670. c2 = "x-tree-node-collapsed";
  18671. }
  18672. if(this.wasLeaf){
  18673. this.removeClass("x-tree-node-leaf");
  18674. this.wasLeaf = false;
  18675. }
  18676. if(this.c1 != c1 || this.c2 != c2){
  18677. Ext.fly(this.elNode).replaceClass(c1, c2);
  18678. this.c1 = c1; this.c2 = c2;
  18679. }
  18680. }else{
  18681. if(!this.wasLeaf){
  18682. Ext.fly(this.elNode).replaceClass("x-tree-node-expanded", "x-tree-node-leaf");
  18683. delete this.c1;
  18684. delete this.c2;
  18685. this.wasLeaf = true;
  18686. }
  18687. }
  18688. var ecc = "x-tree-ec-icon "+cls;
  18689. if(this.ecc != ecc){
  18690. this.ecNode.className = ecc;
  18691. this.ecc = ecc;
  18692. }
  18693. }
  18694. },
  18695. getChildIndent : function(){
  18696. if(!this.childIndent){
  18697. var buf = [];
  18698. var p = this.node;
  18699. while(p){
  18700. if(!p.isRoot || (p.isRoot && p.ownerTree.rootVisible)){
  18701. if(!p.isLast()) {
  18702. buf.unshift('<img src="'+this.emptyIcon+'" class="x-tree-elbow-line" />');
  18703. } else {
  18704. buf.unshift('<img src="'+this.emptyIcon+'" class="x-tree-icon" />');
  18705. }
  18706. }
  18707. p = p.parentNode;
  18708. }
  18709. this.childIndent = buf.join("");
  18710. }
  18711. return this.childIndent;
  18712. },
  18713. renderIndent : function(){
  18714. if(this.rendered){
  18715. var indent = "";
  18716. var p = this.node.parentNode;
  18717. if(p){
  18718. indent = p.ui.getChildIndent();
  18719. }
  18720. if(this.indentMarkup != indent){
  18721. this.indentNode.innerHTML = indent;
  18722. this.indentMarkup = indent;
  18723. }
  18724. this.updateExpandIcon();
  18725. }
  18726. },
  18727. destroy : function(){
  18728. if(this.elNode){
  18729. Ext.dd.Registry.unregister(this.elNode.id);
  18730. }
  18731. delete this.elNode;
  18732. delete this.ctNode;
  18733. delete this.indentNode;
  18734. delete this.ecNode;
  18735. delete this.iconNode;
  18736. delete this.checkbox;
  18737. delete this.anchor;
  18738. delete this.textNode;
  18739. Ext.removeNode(this.ctNode);
  18740. }
  18741. };
  18742. Ext.tree.RootTreeNodeUI = Ext.extend(Ext.tree.TreeNodeUI, {
  18743. render : function(){
  18744. if(!this.rendered){
  18745. var targetNode = this.node.ownerTree.innerCt.dom;
  18746. this.node.expanded = true;
  18747. targetNode.innerHTML = '<div class="x-tree-root-node"></div>';
  18748. this.wrap = this.ctNode = targetNode.firstChild;
  18749. }
  18750. },
  18751. collapse : Ext.emptyFn,
  18752. expand : Ext.emptyFn
  18753. });
  18754. Ext.tree.TreeLoader = function(config){
  18755. this.baseParams = {};
  18756. this.requestMethod = "POST";
  18757. Ext.apply(this, config);
  18758. this.addEvents(
  18759. "beforeload",
  18760. "load",
  18761. "loadexception"
  18762. );
  18763. Ext.tree.TreeLoader.superclass.constructor.call(this);
  18764. };
  18765. Ext.extend(Ext.tree.TreeLoader, Ext.util.Observable, {
  18766. uiProviders : {},
  18767. clearOnLoad : true,
  18768. load : function(node, callback){
  18769. if(this.clearOnLoad){
  18770. while(node.firstChild){
  18771. node.removeChild(node.firstChild);
  18772. }
  18773. }
  18774. if(this.doPreload(node)){
  18775. if(typeof callback == "function"){
  18776. callback();
  18777. }
  18778. }else if(this.dataUrl||this.url){
  18779. this.requestData(node, callback);
  18780. }
  18781. },
  18782. doPreload : function(node){
  18783. if(node.attributes.children){
  18784. if(node.childNodes.length < 1){
  18785. var cs = node.attributes.children;
  18786. node.beginUpdate();
  18787. for(var i = 0, len = cs.length; i < len; i++){
  18788. var cn = node.appendChild(this.createNode(cs[i]));
  18789. if(this.preloadChildren){
  18790. this.doPreload(cn);
  18791. }
  18792. }
  18793. node.endUpdate();
  18794. }
  18795. return true;
  18796. }else {
  18797. return false;
  18798. }
  18799. },
  18800. getParams: function(node){
  18801. var buf = [], bp = this.baseParams;
  18802. for(var key in bp){
  18803. if(typeof bp[key] != "function"){
  18804. buf.push(encodeURIComponent(key), "=", encodeURIComponent(bp[key]), "&");
  18805. }
  18806. }
  18807. buf.push("node=", encodeURIComponent(node.id));
  18808. return buf.join("");
  18809. },
  18810. requestData : function(node, callback){
  18811. if(this.fireEvent("beforeload", this, node, callback) !== false){
  18812. this.transId = Ext.Ajax.request({
  18813. method:this.requestMethod,
  18814. url: this.dataUrl||this.url,
  18815. success: this.handleResponse,
  18816. failure: this.handleFailure,
  18817. scope: this,
  18818. argument: {callback: callback, node: node},
  18819. params: this.getParams(node)
  18820. });
  18821. }else{
  18822. if(typeof callback == "function"){
  18823. callback();
  18824. }
  18825. }
  18826. },
  18827. isLoading : function(){
  18828. return this.transId ? true : false;
  18829. },
  18830. abort : function(){
  18831. if(this.isLoading()){
  18832. Ext.Ajax.abort(this.transId);
  18833. }
  18834. },
  18835. createNode : function(attr){
  18836. if(this.baseAttrs){
  18837. Ext.applyIf(attr, this.baseAttrs);
  18838. }
  18839. if(this.applyLoader !== false){
  18840. attr.loader = this;
  18841. }
  18842. if(typeof attr.uiProvider == 'string'){
  18843. attr.uiProvider = this.uiProviders[attr.uiProvider] || eval(attr.uiProvider);
  18844. }
  18845. return(attr.leaf ?
  18846. new Ext.tree.TreeNode(attr) :
  18847. new Ext.tree.AsyncTreeNode(attr));
  18848. },
  18849. processResponse : function(response, node, callback){
  18850. var json = response.responseText;
  18851. try {
  18852. var o = eval("("+json+")");
  18853. node.beginUpdate();
  18854. for(var i = 0, len = o.length; i < len; i++){
  18855. var n = this.createNode(o[i]);
  18856. if(n){
  18857. node.appendChild(n);
  18858. }
  18859. }
  18860. node.endUpdate();
  18861. if(typeof callback == "function"){
  18862. callback(this, node);
  18863. }
  18864. }catch(e){
  18865. this.handleFailure(response);
  18866. }
  18867. },
  18868. handleResponse : function(response){
  18869. this.transId = false;
  18870. var a = response.argument;
  18871. this.processResponse(response, a.node, a.callback);
  18872. this.fireEvent("load", this, a.node, response);
  18873. },
  18874. handleFailure : function(response){
  18875. this.transId = false;
  18876. var a = response.argument;
  18877. this.fireEvent("loadexception", this, a.node, response);
  18878. if(typeof a.callback == "function"){
  18879. a.callback(this, a.node);
  18880. }
  18881. }
  18882. });
  18883. Ext.tree.TreeFilter = function(tree, config){
  18884. this.tree = tree;
  18885. this.filtered = {};
  18886. Ext.apply(this, config);
  18887. };
  18888. Ext.tree.TreeFilter.prototype = {
  18889. clearBlank:false,
  18890. reverse:false,
  18891. autoClear:false,
  18892. remove:false,
  18893. filter : function(value, attr, startNode){
  18894. attr = attr || "text";
  18895. var f;
  18896. if(typeof value == "string"){
  18897. var vlen = value.length;
  18898. if(vlen == 0 && this.clearBlank){
  18899. this.clear();
  18900. return;
  18901. }
  18902. value = value.toLowerCase();
  18903. f = function(n){
  18904. return n.attributes[attr].substr(0, vlen).toLowerCase() == value;
  18905. };
  18906. }else if(value.exec){
  18907. f = function(n){
  18908. return value.test(n.attributes[attr]);
  18909. };
  18910. }else{
  18911. throw 'Illegal filter type, must be string or regex';
  18912. }
  18913. this.filterBy(f, null, startNode);
  18914. },
  18915. filterBy : function(fn, scope, startNode){
  18916. startNode = startNode || this.tree.root;
  18917. if(this.autoClear){
  18918. this.clear();
  18919. }
  18920. var af = this.filtered, rv = this.reverse;
  18921. var f = function(n){
  18922. if(n == startNode){
  18923. return true;
  18924. }
  18925. if(af[n.id]){
  18926. return false;
  18927. }
  18928. var m = fn.call(scope || n, n);
  18929. if(!m || rv){
  18930. af[n.id] = n;
  18931. n.ui.hide();
  18932. return false;
  18933. }
  18934. return true;
  18935. };
  18936. startNode.cascade(f);
  18937. if(this.remove){
  18938. for(var id in af){
  18939. if(typeof id != "function"){
  18940. var n = af[id];
  18941. if(n && n.parentNode){
  18942. n.parentNode.removeChild(n);
  18943. }
  18944. }
  18945. }
  18946. }
  18947. },
  18948. clear : function(){
  18949. var t = this.tree;
  18950. var af = this.filtered;
  18951. for(var id in af){
  18952. if(typeof id != "function"){
  18953. var n = af[id];
  18954. if(n){
  18955. n.ui.show();
  18956. }
  18957. }
  18958. }
  18959. this.filtered = {};
  18960. }
  18961. };
  18962. Ext.tree.TreeSorter = function(tree, config){
  18963. Ext.apply(this, config);
  18964. tree.on("beforechildrenrendered", this.doSort, this);
  18965. tree.on("append", this.updateSort, this);
  18966. tree.on("insert", this.updateSort, this);
  18967. tree.on("textchange", this.updateSortParent, this);
  18968. var dsc = this.dir && this.dir.toLowerCase() == "desc";
  18969. var p = this.property || "text";
  18970. var sortType = this.sortType;
  18971. var fs = this.folderSort;
  18972. var cs = this.caseSensitive === true;
  18973. var leafAttr = this.leafAttr || 'leaf';
  18974. this.sortFn = function(n1, n2){
  18975. if(fs){
  18976. if(n1.attributes[leafAttr] && !n2.attributes[leafAttr]){
  18977. return 1;
  18978. }
  18979. if(!n1.attributes[leafAttr] && n2.attributes[leafAttr]){
  18980. return -1;
  18981. }
  18982. }
  18983. var v1 = sortType ? sortType(n1) : (cs ? n1.attributes[p] : n1.attributes[p].toUpperCase());
  18984. var v2 = sortType ? sortType(n2) : (cs ? n2.attributes[p] : n2.attributes[p].toUpperCase());
  18985. if(v1 < v2){
  18986. return dsc ? +1 : -1;
  18987. }else if(v1 > v2){
  18988. return dsc ? -1 : +1;
  18989. }else{
  18990. return 0;
  18991. }
  18992. };
  18993. };
  18994. Ext.tree.TreeSorter.prototype = {
  18995. doSort : function(node){
  18996. node.sort(this.sortFn);
  18997. },
  18998. compareNodes : function(n1, n2){
  18999. return (n1.text.toUpperCase() > n2.text.toUpperCase() ? 1 : -1);
  19000. },
  19001. updateSort : function(tree, node){
  19002. if(node.childrenRendered){
  19003. this.doSort.defer(1, this, [node]);
  19004. }
  19005. },
  19006. updateSortParent : function(node){
  19007. var p = node.parentNode;
  19008. if(p && p.childrenRendered){
  19009. this.doSort.defer(1, this, [p]);
  19010. }
  19011. }
  19012. };
  19013. if(Ext.dd.DropZone){
  19014. Ext.tree.TreeDropZone = function(tree, config){
  19015. this.allowParentInsert = false;
  19016. this.allowContainerDrop = false;
  19017. this.appendOnly = false;
  19018. Ext.tree.TreeDropZone.superclass.constructor.call(this, tree.innerCt, config);
  19019. this.tree = tree;
  19020. this.dragOverData = {};
  19021. this.lastInsertClass = "x-tree-no-status";
  19022. };
  19023. Ext.extend(Ext.tree.TreeDropZone, Ext.dd.DropZone, {
  19024. ddGroup : "TreeDD",
  19025. expandDelay : 1000,
  19026. expandNode : function(node){
  19027. if(node.hasChildNodes() && !node.isExpanded()){
  19028. node.expand(false, null, this.triggerCacheRefresh.createDelegate(this));
  19029. }
  19030. },
  19031. queueExpand : function(node){
  19032. this.expandProcId = this.expandNode.defer(this.expandDelay, this, [node]);
  19033. },
  19034. cancelExpand : function(){
  19035. if(this.expandProcId){
  19036. clearTimeout(this.expandProcId);
  19037. this.expandProcId = false;
  19038. }
  19039. },
  19040. isValidDropPoint : function(n, pt, dd, e, data){
  19041. if(!n || !data){ return false; }
  19042. var targetNode = n.node;
  19043. var dropNode = data.node;
  19044. if(!(targetNode && targetNode.isTarget && pt)){
  19045. return false;
  19046. }
  19047. if(pt == "append" && targetNode.allowChildren === false){
  19048. return false;
  19049. }
  19050. if((pt == "above" || pt == "below") && (targetNode.parentNode && targetNode.parentNode.allowChildren === false)){
  19051. return false;
  19052. }
  19053. if(dropNode && (targetNode == dropNode || dropNode.contains(targetNode))){
  19054. return false;
  19055. }
  19056. var overEvent = this.dragOverData;
  19057. overEvent.tree = this.tree;
  19058. overEvent.target = targetNode;
  19059. overEvent.data = data;
  19060. overEvent.point = pt;
  19061. overEvent.source = dd;
  19062. overEvent.rawEvent = e;
  19063. overEvent.dropNode = dropNode;
  19064. overEvent.cancel = false;
  19065. var result = this.tree.fireEvent("nodedragover", overEvent);
  19066. return overEvent.cancel === false && result !== false;
  19067. },
  19068. getDropPoint : function(e, n, dd){
  19069. var tn = n.node;
  19070. if(tn.isRoot){
  19071. return tn.allowChildren !== false ? "append" : false;
  19072. }
  19073. var dragEl = n.ddel;
  19074. var t = Ext.lib.Dom.getY(dragEl), b = t + dragEl.offsetHeight;
  19075. var y = Ext.lib.Event.getPageY(e);
  19076. var noAppend = tn.allowChildren === false || tn.isLeaf();
  19077. if(this.appendOnly || tn.parentNode.allowChildren === false){
  19078. return noAppend ? false : "append";
  19079. }
  19080. var noBelow = false;
  19081. if(!this.allowParentInsert){
  19082. noBelow = tn.hasChildNodes() && tn.isExpanded();
  19083. }
  19084. var q = (b - t) / (noAppend ? 2 : 3);
  19085. if(y >= t && y < (t + q)){
  19086. return "above";
  19087. }else if(!noBelow && (noAppend || y >= b-q && y <= b)){
  19088. return "below";
  19089. }else{
  19090. return "append";
  19091. }
  19092. },
  19093. onNodeEnter : function(n, dd, e, data){
  19094. this.cancelExpand();
  19095. },
  19096. onNodeOver : function(n, dd, e, data){
  19097. var pt = this.getDropPoint(e, n, dd);
  19098. var node = n.node;
  19099. if(!this.expandProcId && pt == "append" && node.hasChildNodes() && !n.node.isExpanded()){
  19100. this.queueExpand(node);
  19101. }else if(pt != "append"){
  19102. this.cancelExpand();
  19103. }
  19104. var returnCls = this.dropNotAllowed;
  19105. if(this.isValidDropPoint(n, pt, dd, e, data)){
  19106. if(pt){
  19107. var el = n.ddel;
  19108. var cls;
  19109. if(pt == "above"){
  19110. returnCls = n.node.isFirst() ? "x-tree-drop-ok-above" : "x-tree-drop-ok-between";
  19111. cls = "x-tree-drag-insert-above";
  19112. }else if(pt == "below"){
  19113. returnCls = n.node.isLast() ? "x-tree-drop-ok-below" : "x-tree-drop-ok-between";
  19114. cls = "x-tree-drag-insert-below";
  19115. }else{
  19116. returnCls = "x-tree-drop-ok-append";
  19117. cls = "x-tree-drag-append";
  19118. }
  19119. if(this.lastInsertClass != cls){
  19120. Ext.fly(el).replaceClass(this.lastInsertClass, cls);
  19121. this.lastInsertClass = cls;
  19122. }
  19123. }
  19124. }
  19125. return returnCls;
  19126. },
  19127. onNodeOut : function(n, dd, e, data){
  19128. this.cancelExpand();
  19129. this.removeDropIndicators(n);
  19130. },
  19131. onNodeDrop : function(n, dd, e, data){
  19132. var point = this.getDropPoint(e, n, dd);
  19133. var targetNode = n.node;
  19134. targetNode.ui.startDrop();
  19135. if(!this.isValidDropPoint(n, point, dd, e, data)){
  19136. targetNode.ui.endDrop();
  19137. return false;
  19138. }
  19139. var dropNode = data.node || (dd.getTreeNode ? dd.getTreeNode(data, targetNode, point, e) : null);
  19140. var dropEvent = {
  19141. tree : this.tree,
  19142. target: targetNode,
  19143. data: data,
  19144. point: point,
  19145. source: dd,
  19146. rawEvent: e,
  19147. dropNode: dropNode,
  19148. cancel: !dropNode,
  19149. dropStatus: false
  19150. };
  19151. var retval = this.tree.fireEvent("beforenodedrop", dropEvent);
  19152. if(retval === false || dropEvent.cancel === true || !dropEvent.dropNode){
  19153. targetNode.ui.endDrop();
  19154. return dropEvent.dropStatus;
  19155. }
  19156. targetNode = dropEvent.target;
  19157. if(point == "append" && !targetNode.isExpanded()){
  19158. targetNode.expand(false, null, function(){
  19159. this.completeDrop(dropEvent);
  19160. }.createDelegate(this));
  19161. }else{
  19162. this.completeDrop(dropEvent);
  19163. }
  19164. return true;
  19165. },
  19166. completeDrop : function(de){
  19167. var ns = de.dropNode, p = de.point, t = de.target;
  19168. if(!Ext.isArray(ns)){
  19169. ns = [ns];
  19170. }
  19171. var n;
  19172. for(var i = 0, len = ns.length; i < len; i++){
  19173. n = ns[i];
  19174. if(p == "above"){
  19175. t.parentNode.insertBefore(n, t);
  19176. }else if(p == "below"){
  19177. t.parentNode.insertBefore(n, t.nextSibling);
  19178. }else{
  19179. t.appendChild(n);
  19180. }
  19181. }
  19182. n.ui.focus();
  19183. if(this.tree.hlDrop){
  19184. n.ui.highlight();
  19185. }
  19186. t.ui.endDrop();
  19187. this.tree.fireEvent("nodedrop", de);
  19188. },
  19189. afterNodeMoved : function(dd, data, e, targetNode, dropNode){
  19190. if(this.tree.hlDrop){
  19191. dropNode.ui.focus();
  19192. dropNode.ui.highlight();
  19193. }
  19194. this.tree.fireEvent("nodedrop", this.tree, targetNode, data, dd, e);
  19195. },
  19196. getTree : function(){
  19197. return this.tree;
  19198. },
  19199. removeDropIndicators : function(n){
  19200. if(n && n.ddel){
  19201. var el = n.ddel;
  19202. Ext.fly(el).removeClass([
  19203. "x-tree-drag-insert-above",
  19204. "x-tree-drag-insert-below",
  19205. "x-tree-drag-append"]);
  19206. this.lastInsertClass = "_noclass";
  19207. }
  19208. },
  19209. beforeDragDrop : function(target, e, id){
  19210. this.cancelExpand();
  19211. return true;
  19212. },
  19213. afterRepair : function(data){
  19214. if(data && Ext.enableFx){
  19215. data.node.ui.highlight();
  19216. }
  19217. this.hideProxy();
  19218. }
  19219. });
  19220. }
  19221. if(Ext.dd.DragZone){
  19222. Ext.tree.TreeDragZone = function(tree, config){
  19223. Ext.tree.TreeDragZone.superclass.constructor.call(this, tree.getTreeEl(), config);
  19224. this.tree = tree;
  19225. };
  19226. Ext.extend(Ext.tree.TreeDragZone, Ext.dd.DragZone, {
  19227. ddGroup : "TreeDD",
  19228. onBeforeDrag : function(data, e){
  19229. var n = data.node;
  19230. return n && n.draggable && !n.disabled;
  19231. },
  19232. onInitDrag : function(e){
  19233. var data = this.dragData;
  19234. this.tree.getSelectionModel().select(data.node);
  19235. this.tree.eventModel.disable();
  19236. this.proxy.update("");
  19237. data.node.ui.appendDDGhost(this.proxy.ghost.dom);
  19238. this.tree.fireEvent("startdrag", this.tree, data.node, e);
  19239. },
  19240. getRepairXY : function(e, data){
  19241. return data.node.ui.getDDRepairXY();
  19242. },
  19243. onEndDrag : function(data, e){
  19244. this.tree.eventModel.enable.defer(100, this.tree.eventModel);
  19245. this.tree.fireEvent("enddrag", this.tree, data.node, e);
  19246. },
  19247. onValidDrop : function(dd, e, id){
  19248. this.tree.fireEvent("dragdrop", this.tree, this.dragData.node, dd, e);
  19249. this.hideProxy();
  19250. },
  19251. beforeInvalidDrop : function(e, id){
  19252. var sm = this.tree.getSelectionModel();
  19253. sm.clearSelections();
  19254. sm.select(this.dragData.node);
  19255. }
  19256. });
  19257. }
  19258. Ext.tree.TreeEditor = function(tree, config){
  19259. config = config || {};
  19260. var field = config.events ? config : new Ext.form.TextField(config);
  19261. Ext.tree.TreeEditor.superclass.constructor.call(this, field);
  19262. this.tree = tree;
  19263. if(!tree.rendered){
  19264. tree.on('render', this.initEditor, this);
  19265. }else{
  19266. this.initEditor(tree);
  19267. }
  19268. };
  19269. Ext.extend(Ext.tree.TreeEditor, Ext.Editor, {
  19270. alignment: "l-l",
  19271. autoSize: false,
  19272. hideEl : false,
  19273. cls: "x-small-editor x-tree-editor",
  19274. shim:false,
  19275. shadow:"frame",
  19276. maxWidth: 250,
  19277. editDelay : 350,
  19278. initEditor : function(tree){
  19279. tree.on('beforeclick', this.beforeNodeClick, this);
  19280. tree.on('dblclick', this.onNodeDblClick, this);
  19281. this.on('complete', this.updateNode, this);
  19282. this.on('beforestartedit', this.fitToTree, this);
  19283. this.on('startedit', this.bindScroll, this, {delay:10});
  19284. this.on('specialkey', this.onSpecialKey, this);
  19285. },
  19286. fitToTree : function(ed, el){
  19287. var td = this.tree.getTreeEl().dom, nd = el.dom;
  19288. if(td.scrollLeft > nd.offsetLeft){ td.scrollLeft = nd.offsetLeft;
  19289. }
  19290. var w = Math.min(
  19291. this.maxWidth,
  19292. (td.clientWidth > 20 ? td.clientWidth : td.offsetWidth) - Math.max(0, nd.offsetLeft-td.scrollLeft) - 5);
  19293. this.setSize(w, '');
  19294. },
  19295. triggerEdit : function(node, defer){
  19296. this.completeEdit();
  19297. if(node.attributes.editable !== false){
  19298. this.editNode = node;
  19299. this.autoEditTimer = this.startEdit.defer(this.editDelay, this, [node.ui.textNode, node.text]);
  19300. return false;
  19301. }
  19302. },
  19303. bindScroll : function(){
  19304. this.tree.getTreeEl().on('scroll', this.cancelEdit, this);
  19305. },
  19306. beforeNodeClick : function(node, e){
  19307. clearTimeout(this.autoEditTimer);
  19308. if(this.tree.getSelectionModel().isSelected(node)){
  19309. e.stopEvent();
  19310. return this.triggerEdit(node);
  19311. }
  19312. },
  19313. onNodeDblClick : function(node, e){
  19314. clearTimeout(this.autoEditTimer);
  19315. },
  19316. updateNode : function(ed, value){
  19317. this.tree.getTreeEl().un('scroll', this.cancelEdit, this);
  19318. this.editNode.setText(value);
  19319. },
  19320. onHide : function(){
  19321. Ext.tree.TreeEditor.superclass.onHide.call(this);
  19322. if(this.editNode){
  19323. this.editNode.ui.focus.defer(50, this.editNode.ui);
  19324. }
  19325. },
  19326. onSpecialKey : function(field, e){
  19327. var k = e.getKey();
  19328. if(k == e.ESC){
  19329. e.stopEvent();
  19330. this.cancelEdit();
  19331. }else if(k == e.ENTER && !e.hasModifier()){
  19332. e.stopEvent();
  19333. this.completeEdit();
  19334. }
  19335. }
  19336. });
  19337. Ext.menu.Menu = function(config){
  19338. if(Ext.isArray(config)){
  19339. config = {items:config};
  19340. }
  19341. Ext.apply(this, config);
  19342. this.id = this.id || Ext.id();
  19343. this.addEvents(
  19344. 'beforeshow',
  19345. 'beforehide',
  19346. 'show',
  19347. 'hide',
  19348. 'click',
  19349. 'mouseover',
  19350. 'mouseout',
  19351. 'itemclick'
  19352. );
  19353. Ext.menu.MenuMgr.register(this);
  19354. Ext.menu.Menu.superclass.constructor.call(this);
  19355. var mis = this.items;
  19356. this.items = new Ext.util.MixedCollection();
  19357. if(mis){
  19358. this.add.apply(this, mis);
  19359. }
  19360. };
  19361. Ext.extend(Ext.menu.Menu, Ext.util.Observable, {
  19362. minWidth : 120,
  19363. shadow : "sides",
  19364. subMenuAlign : "tl-tr?",
  19365. defaultAlign : "tl-bl?",
  19366. allowOtherMenus : false,
  19367. hidden:true,
  19368. createEl : function(){
  19369. return new Ext.Layer({
  19370. cls: "x-menu",
  19371. shadow:this.shadow,
  19372. constrain: false,
  19373. parentEl: this.parentEl || document.body,
  19374. zindex:15000
  19375. });
  19376. },
  19377. render : function(){
  19378. if(this.el){
  19379. return;
  19380. }
  19381. var el = this.el = this.createEl();
  19382. if(!this.keyNav){
  19383. this.keyNav = new Ext.menu.MenuNav(this);
  19384. }
  19385. if(this.plain){
  19386. el.addClass("x-menu-plain");
  19387. }
  19388. if(this.cls){
  19389. el.addClass(this.cls);
  19390. }
  19391. this.focusEl = el.createChild({
  19392. tag: "a", cls: "x-menu-focus", href: "#", onclick: "return false;", tabIndex:"-1"
  19393. });
  19394. var ul = el.createChild({tag: "ul", cls: "x-menu-list"});
  19395. ul.on("click", this.onClick, this);
  19396. ul.on("mouseover", this.onMouseOver, this);
  19397. ul.on("mouseout", this.onMouseOut, this);
  19398. this.items.each(function(item){
  19399. var li = document.createElement("li");
  19400. li.className = "x-menu-list-item";
  19401. ul.dom.appendChild(li);
  19402. item.render(li, this);
  19403. }, this);
  19404. this.ul = ul;
  19405. this.autoWidth();
  19406. },
  19407. autoWidth : function(){
  19408. var el = this.el, ul = this.ul;
  19409. if(!el){
  19410. return;
  19411. }
  19412. var w = this.width;
  19413. if(w){
  19414. el.setWidth(w);
  19415. }else if(Ext.isIE){
  19416. el.setWidth(this.minWidth);
  19417. var t = el.dom.offsetWidth; el.setWidth(ul.getWidth()+el.getFrameWidth("lr"));
  19418. }
  19419. },
  19420. delayAutoWidth : function(){
  19421. if(this.el){
  19422. if(!this.awTask){
  19423. this.awTask = new Ext.util.DelayedTask(this.autoWidth, this);
  19424. }
  19425. this.awTask.delay(20);
  19426. }
  19427. },
  19428. findTargetItem : function(e){
  19429. var t = e.getTarget(".x-menu-list-item", this.ul, true);
  19430. if(t && t.menuItemId){
  19431. return this.items.get(t.menuItemId);
  19432. }
  19433. },
  19434. onClick : function(e){
  19435. var t;
  19436. if(t = this.findTargetItem(e)){
  19437. t.onClick(e);
  19438. this.fireEvent("click", this, t, e);
  19439. }
  19440. },
  19441. setActiveItem : function(item, autoExpand){
  19442. if(item != this.activeItem){
  19443. if(this.activeItem){
  19444. this.activeItem.deactivate();
  19445. }
  19446. this.activeItem = item;
  19447. item.activate(autoExpand);
  19448. }else if(autoExpand){
  19449. item.expandMenu();
  19450. }
  19451. },
  19452. tryActivate : function(start, step){
  19453. var items = this.items;
  19454. for(var i = start, len = items.length; i >= 0 && i < len; i+= step){
  19455. var item = items.get(i);
  19456. if(!item.disabled && item.canActivate){
  19457. this.setActiveItem(item, false);
  19458. return item;
  19459. }
  19460. }
  19461. return false;
  19462. },
  19463. onMouseOver : function(e){
  19464. var t;
  19465. if(t = this.findTargetItem(e)){
  19466. if(t.canActivate && !t.disabled){
  19467. this.setActiveItem(t, true);
  19468. }
  19469. }
  19470. this.fireEvent("mouseover", this, e, t);
  19471. },
  19472. onMouseOut : function(e){
  19473. var t;
  19474. if(t = this.findTargetItem(e)){
  19475. if(t == this.activeItem && t.shouldDeactivate(e)){
  19476. this.activeItem.deactivate();
  19477. delete this.activeItem;
  19478. }
  19479. }
  19480. this.fireEvent("mouseout", this, e, t);
  19481. },
  19482. isVisible : function(){
  19483. return this.el && !this.hidden;
  19484. },
  19485. show : function(el, pos, parentMenu){
  19486. this.parentMenu = parentMenu;
  19487. if(!this.el){
  19488. this.render();
  19489. }
  19490. this.fireEvent("beforeshow", this);
  19491. this.showAt(this.el.getAlignToXY(el, pos || this.defaultAlign), parentMenu, false);
  19492. },
  19493. showAt : function(xy, parentMenu, _e){
  19494. this.parentMenu = parentMenu;
  19495. if(!this.el){
  19496. this.render();
  19497. }
  19498. if(_e !== false){
  19499. this.fireEvent("beforeshow", this);
  19500. xy = this.el.adjustForConstraints(xy);
  19501. }
  19502. this.el.setXY(xy);
  19503. this.el.show();
  19504. this.hidden = false;
  19505. this.focus();
  19506. this.fireEvent("show", this);
  19507. },
  19508. focus : function(){
  19509. if(!this.hidden){
  19510. this.doFocus.defer(50, this);
  19511. }
  19512. },
  19513. doFocus : function(){
  19514. if(!this.hidden){
  19515. this.focusEl.focus();
  19516. }
  19517. },
  19518. hide : function(deep){
  19519. if(this.el && this.isVisible()){
  19520. this.fireEvent("beforehide", this);
  19521. if(this.activeItem){
  19522. this.activeItem.deactivate();
  19523. this.activeItem = null;
  19524. }
  19525. this.el.hide();
  19526. this.hidden = true;
  19527. this.fireEvent("hide", this);
  19528. }
  19529. if(deep === true && this.parentMenu){
  19530. this.parentMenu.hide(true);
  19531. }
  19532. },
  19533. add : function(){
  19534. var a = arguments, l = a.length, item;
  19535. for(var i = 0; i < l; i++){
  19536. var el = a[i];
  19537. if(el.render){ item = this.addItem(el);
  19538. }else if(typeof el == "string"){ if(el == "separator" || el == "-"){
  19539. item = this.addSeparator();
  19540. }else{
  19541. item = this.addText(el);
  19542. }
  19543. }else if(el.tagName || el.el){ item = this.addElement(el);
  19544. }else if(typeof el == "object"){ Ext.applyIf(el, this.defaults);
  19545. item = this.addMenuItem(el);
  19546. }
  19547. }
  19548. return item;
  19549. },
  19550. getEl : function(){
  19551. if(!this.el){
  19552. this.render();
  19553. }
  19554. return this.el;
  19555. },
  19556. addSeparator : function(){
  19557. return this.addItem(new Ext.menu.Separator());
  19558. },
  19559. addElement : function(el){
  19560. return this.addItem(new Ext.menu.BaseItem(el));
  19561. },
  19562. addItem : function(item){
  19563. this.items.add(item);
  19564. if(this.ul){
  19565. var li = document.createElement("li");
  19566. li.className = "x-menu-list-item";
  19567. this.ul.dom.appendChild(li);
  19568. item.render(li, this);
  19569. this.delayAutoWidth();
  19570. }
  19571. return item;
  19572. },
  19573. addMenuItem : function(config){
  19574. if(!(config instanceof Ext.menu.Item)){
  19575. if(typeof config.checked == "boolean"){ config = new Ext.menu.CheckItem(config);
  19576. }else{
  19577. config = new Ext.menu.Item(config);
  19578. }
  19579. }
  19580. return this.addItem(config);
  19581. },
  19582. addText : function(text){
  19583. return this.addItem(new Ext.menu.TextItem(text));
  19584. },
  19585. insert : function(index, item){
  19586. this.items.insert(index, item);
  19587. if(this.ul){
  19588. var li = document.createElement("li");
  19589. li.className = "x-menu-list-item";
  19590. this.ul.dom.insertBefore(li, this.ul.dom.childNodes[index]);
  19591. item.render(li, this);
  19592. this.delayAutoWidth();
  19593. }
  19594. return item;
  19595. },
  19596. remove : function(item){
  19597. this.items.removeKey(item.id);
  19598. item.destroy();
  19599. },
  19600. removeAll : function(){
  19601. var f;
  19602. while(f = this.items.first()){
  19603. this.remove(f);
  19604. }
  19605. },
  19606. destroy : function(){
  19607. this.beforeDestroy();
  19608. Ext.menu.MenuMgr.unregister(this);
  19609. if (this.keyNav) {
  19610. this.keyNav.disable();
  19611. }
  19612. this.removeAll();
  19613. if (this.ul) {
  19614. this.ul.removeAllListeners();
  19615. }
  19616. if (this.el) {
  19617. this.el.destroy();
  19618. }
  19619. },
  19620. beforeDestroy : Ext.emptyFn
  19621. });
  19622. Ext.menu.MenuNav = function(menu){
  19623. Ext.menu.MenuNav.superclass.constructor.call(this, menu.el);
  19624. this.scope = this.menu = menu;
  19625. };
  19626. Ext.extend(Ext.menu.MenuNav, Ext.KeyNav, {
  19627. doRelay : function(e, h){
  19628. var k = e.getKey();
  19629. if(!this.menu.activeItem && e.isNavKeyPress() && k != e.SPACE && k != e.RETURN){
  19630. this.menu.tryActivate(0, 1);
  19631. return false;
  19632. }
  19633. return h.call(this.scope || this, e, this.menu);
  19634. },
  19635. up : function(e, m){
  19636. if(!m.tryActivate(m.items.indexOf(m.activeItem)-1, -1)){
  19637. m.tryActivate(m.items.length-1, -1);
  19638. }
  19639. },
  19640. down : function(e, m){
  19641. if(!m.tryActivate(m.items.indexOf(m.activeItem)+1, 1)){
  19642. m.tryActivate(0, 1);
  19643. }
  19644. },
  19645. right : function(e, m){
  19646. if(m.activeItem){
  19647. m.activeItem.expandMenu(true);
  19648. }
  19649. },
  19650. left : function(e, m){
  19651. m.hide();
  19652. if(m.parentMenu && m.parentMenu.activeItem){
  19653. m.parentMenu.activeItem.activate();
  19654. }
  19655. },
  19656. enter : function(e, m){
  19657. if(m.activeItem){
  19658. e.stopPropagation();
  19659. m.activeItem.onClick(e);
  19660. m.fireEvent("click", this, m.activeItem);
  19661. return true;
  19662. }
  19663. }
  19664. });
  19665. Ext.menu.MenuMgr = function(){
  19666. var menus, active, groups = {}, attached = false, lastShow = new Date();
  19667. function init(){
  19668. menus = {};
  19669. active = new Ext.util.MixedCollection();
  19670. Ext.getDoc().addKeyListener(27, function(){
  19671. if(active.length > 0){
  19672. hideAll();
  19673. }
  19674. });
  19675. }
  19676. function hideAll(){
  19677. if(active && active.length > 0){
  19678. var c = active.clone();
  19679. c.each(function(m){
  19680. m.hide();
  19681. });
  19682. }
  19683. }
  19684. function onHide(m){
  19685. active.remove(m);
  19686. if(active.length < 1){
  19687. Ext.getDoc().un("mousedown", onMouseDown);
  19688. attached = false;
  19689. }
  19690. }
  19691. function onShow(m){
  19692. var last = active.last();
  19693. lastShow = new Date();
  19694. active.add(m);
  19695. if(!attached){
  19696. Ext.getDoc().on("mousedown", onMouseDown);
  19697. attached = true;
  19698. }
  19699. if(m.parentMenu){
  19700. m.getEl().setZIndex(parseInt(m.parentMenu.getEl().getStyle("z-index"), 10) + 3);
  19701. m.parentMenu.activeChild = m;
  19702. }else if(last && last.isVisible()){
  19703. m.getEl().setZIndex(parseInt(last.getEl().getStyle("z-index"), 10) + 3);
  19704. }
  19705. }
  19706. function onBeforeHide(m){
  19707. if(m.activeChild){
  19708. m.activeChild.hide();
  19709. }
  19710. if(m.autoHideTimer){
  19711. clearTimeout(m.autoHideTimer);
  19712. delete m.autoHideTimer;
  19713. }
  19714. }
  19715. function onBeforeShow(m){
  19716. var pm = m.parentMenu;
  19717. if(!pm && !m.allowOtherMenus){
  19718. hideAll();
  19719. }else if(pm && pm.activeChild){
  19720. pm.activeChild.hide();
  19721. }
  19722. }
  19723. function onMouseDown(e){
  19724. if(lastShow.getElapsed() > 50 && active.length > 0 && !e.getTarget(".x-menu")){
  19725. hideAll();
  19726. }
  19727. }
  19728. function onBeforeCheck(mi, state){
  19729. if(state){
  19730. var g = groups[mi.group];
  19731. for(var i = 0, l = g.length; i < l; i++){
  19732. if(g[i] != mi){
  19733. g[i].setChecked(false);
  19734. }
  19735. }
  19736. }
  19737. }
  19738. return {
  19739. hideAll : function(){
  19740. hideAll();
  19741. },
  19742. register : function(menu){
  19743. if(!menus){
  19744. init();
  19745. }
  19746. menus[menu.id] = menu;
  19747. menu.on("beforehide", onBeforeHide);
  19748. menu.on("hide", onHide);
  19749. menu.on("beforeshow", onBeforeShow);
  19750. menu.on("show", onShow);
  19751. var g = menu.group;
  19752. if(g && menu.events["checkchange"]){
  19753. if(!groups[g]){
  19754. groups[g] = [];
  19755. }
  19756. groups[g].push(menu);
  19757. menu.on("checkchange", onCheck);
  19758. }
  19759. },
  19760. get : function(menu){
  19761. if(typeof menu == "string"){ if(!menus){ return null;
  19762. }
  19763. return menus[menu];
  19764. }else if(menu.events){ return menu;
  19765. }else if(typeof menu.length == 'number'){ return new Ext.menu.Menu({items:menu});
  19766. }else{ return new Ext.menu.Menu(menu);
  19767. }
  19768. },
  19769. unregister : function(menu){
  19770. delete menus[menu.id];
  19771. menu.un("beforehide", onBeforeHide);
  19772. menu.un("hide", onHide);
  19773. menu.un("beforeshow", onBeforeShow);
  19774. menu.un("show", onShow);
  19775. var g = menu.group;
  19776. if(g && menu.events["checkchange"]){
  19777. groups[g].remove(menu);
  19778. menu.un("checkchange", onCheck);
  19779. }
  19780. },
  19781. registerCheckable : function(menuItem){
  19782. var g = menuItem.group;
  19783. if(g){
  19784. if(!groups[g]){
  19785. groups[g] = [];
  19786. }
  19787. groups[g].push(menuItem);
  19788. menuItem.on("beforecheckchange", onBeforeCheck);
  19789. }
  19790. },
  19791. unregisterCheckable : function(menuItem){
  19792. var g = menuItem.group;
  19793. if(g){
  19794. groups[g].remove(menuItem);
  19795. menuItem.un("beforecheckchange", onBeforeCheck);
  19796. }
  19797. },
  19798. getCheckedItem : function(groupId){
  19799. var g = groups[groupId];
  19800. if(g){
  19801. for(var i = 0, l = g.length; i < l; i++){
  19802. if(g[i].checked){
  19803. return g[i];
  19804. }
  19805. }
  19806. }
  19807. return null;
  19808. },
  19809. setCheckedItem : function(groupId, itemId){
  19810. var g = groups[groupId];
  19811. if(g){
  19812. for(var i = 0, l = g.length; i < l; i++){
  19813. if(g[i].id == itemId){
  19814. g[i].setChecked(true);
  19815. }
  19816. }
  19817. }
  19818. return null;
  19819. }
  19820. };
  19821. }();
  19822. Ext.menu.BaseItem = function(config){
  19823. Ext.menu.BaseItem.superclass.constructor.call(this, config);
  19824. this.addEvents(
  19825. 'click',
  19826. 'activate',
  19827. 'deactivate'
  19828. );
  19829. if(this.handler){
  19830. this.on("click", this.handler, this.scope);
  19831. }
  19832. };
  19833. Ext.extend(Ext.menu.BaseItem, Ext.Component, {
  19834. canActivate : false,
  19835. activeClass : "x-menu-item-active",
  19836. hideOnClick : true,
  19837. hideDelay : 100,
  19838. ctype: "Ext.menu.BaseItem",
  19839. actionMode : "container",
  19840. render : function(container, parentMenu){
  19841. this.parentMenu = parentMenu;
  19842. Ext.menu.BaseItem.superclass.render.call(this, container);
  19843. this.container.menuItemId = this.id;
  19844. },
  19845. onRender : function(container, position){
  19846. this.el = Ext.get(this.el);
  19847. container.dom.appendChild(this.el.dom);
  19848. },
  19849. setHandler : function(handler, scope){
  19850. if(this.handler){
  19851. this.un("click", this.handler, this.scope);
  19852. }
  19853. this.on("click", this.handler = handler, this.scope = scope);
  19854. },
  19855. onClick : function(e){
  19856. if(!this.disabled && this.fireEvent("click", this, e) !== false
  19857. && this.parentMenu.fireEvent("itemclick", this, e) !== false){
  19858. this.handleClick(e);
  19859. }else{
  19860. e.stopEvent();
  19861. }
  19862. },
  19863. activate : function(){
  19864. if(this.disabled){
  19865. return false;
  19866. }
  19867. var li = this.container;
  19868. li.addClass(this.activeClass);
  19869. this.region = li.getRegion().adjust(2, 2, -2, -2);
  19870. this.fireEvent("activate", this);
  19871. return true;
  19872. },
  19873. deactivate : function(){
  19874. this.container.removeClass(this.activeClass);
  19875. this.fireEvent("deactivate", this);
  19876. },
  19877. shouldDeactivate : function(e){
  19878. return !this.region || !this.region.contains(e.getPoint());
  19879. },
  19880. handleClick : function(e){
  19881. if(this.hideOnClick){
  19882. this.parentMenu.hide.defer(this.hideDelay, this.parentMenu, [true]);
  19883. }
  19884. },
  19885. expandMenu : function(autoActivate){
  19886. },
  19887. hideMenu : function(){
  19888. }
  19889. });
  19890. Ext.menu.TextItem = function(text){
  19891. this.text = text;
  19892. Ext.menu.TextItem.superclass.constructor.call(this);
  19893. };
  19894. Ext.extend(Ext.menu.TextItem, Ext.menu.BaseItem, {
  19895. hideOnClick : false,
  19896. itemCls : "x-menu-text",
  19897. onRender : function(){
  19898. var s = document.createElement("span");
  19899. s.className = this.itemCls;
  19900. s.innerHTML = this.text;
  19901. this.el = s;
  19902. Ext.menu.TextItem.superclass.onRender.apply(this, arguments);
  19903. }
  19904. });
  19905. Ext.menu.Separator = function(config){
  19906. Ext.menu.Separator.superclass.constructor.call(this, config);
  19907. };
  19908. Ext.extend(Ext.menu.Separator, Ext.menu.BaseItem, {
  19909. itemCls : "x-menu-sep",
  19910. hideOnClick : false,
  19911. onRender : function(li){
  19912. var s = document.createElement("span");
  19913. s.className = this.itemCls;
  19914. s.innerHTML = "&#160;";
  19915. this.el = s;
  19916. li.addClass("x-menu-sep-li");
  19917. Ext.menu.Separator.superclass.onRender.apply(this, arguments);
  19918. }
  19919. });
  19920. Ext.menu.Item = function(config){
  19921. Ext.menu.Item.superclass.constructor.call(this, config);
  19922. if(this.menu){
  19923. this.menu = Ext.menu.MenuMgr.get(this.menu);
  19924. }
  19925. };
  19926. Ext.extend(Ext.menu.Item, Ext.menu.BaseItem, {
  19927. itemCls : "x-menu-item",
  19928. canActivate : true,
  19929. showDelay: 200,
  19930. hideDelay: 200,
  19931. ctype: "Ext.menu.Item",
  19932. onRender : function(container, position){
  19933. var el = document.createElement("a");
  19934. el.hideFocus = true;
  19935. el.unselectable = "on";
  19936. el.href = this.href || "#";
  19937. if(this.hrefTarget){
  19938. el.target = this.hrefTarget;
  19939. }
  19940. el.className = this.itemCls + (this.menu ? " x-menu-item-arrow" : "") + (this.cls ? " " + this.cls : "");
  19941. el.innerHTML = String.format(
  19942. '<img src="{0}" class="x-menu-item-icon {2}" />{1}',
  19943. this.icon || Ext.BLANK_IMAGE_URL, this.itemText||this.text, this.iconCls || '');
  19944. this.el = el;
  19945. Ext.menu.Item.superclass.onRender.call(this, container, position);
  19946. },
  19947. setText : function(text){
  19948. this.text = text;
  19949. if(this.rendered){
  19950. this.el.update(String.format(
  19951. '<img src="{0}" class="x-menu-item-icon {2}">{1}',
  19952. this.icon || Ext.BLANK_IMAGE_URL, this.text, this.iconCls || ''));
  19953. this.parentMenu.autoWidth();
  19954. }
  19955. },
  19956. setIconClass : function(cls){
  19957. var oldCls = this.iconCls;
  19958. this.iconCls = cls;
  19959. if(this.rendered){
  19960. this.el.child('img.x-menu-item-icon').replaceClass(oldCls, this.iconCls);
  19961. }
  19962. },
  19963. handleClick : function(e){
  19964. if(!this.href){ e.stopEvent();
  19965. }
  19966. Ext.menu.Item.superclass.handleClick.apply(this, arguments);
  19967. },
  19968. activate : function(autoExpand){
  19969. if(Ext.menu.Item.superclass.activate.apply(this, arguments)){
  19970. this.focus();
  19971. if(autoExpand){
  19972. this.expandMenu();
  19973. }
  19974. }
  19975. return true;
  19976. },
  19977. shouldDeactivate : function(e){
  19978. if(Ext.menu.Item.superclass.shouldDeactivate.call(this, e)){
  19979. if(this.menu && this.menu.isVisible()){
  19980. return !this.menu.getEl().getRegion().contains(e.getPoint());
  19981. }
  19982. return true;
  19983. }
  19984. return false;
  19985. },
  19986. deactivate : function(){
  19987. Ext.menu.Item.superclass.deactivate.apply(this, arguments);
  19988. this.hideMenu();
  19989. },
  19990. expandMenu : function(autoActivate){
  19991. if(!this.disabled && this.menu){
  19992. clearTimeout(this.hideTimer);
  19993. delete this.hideTimer;
  19994. if(!this.menu.isVisible() && !this.showTimer){
  19995. this.showTimer = this.deferExpand.defer(this.showDelay, this, [autoActivate]);
  19996. }else if (this.menu.isVisible() && autoActivate){
  19997. this.menu.tryActivate(0, 1);
  19998. }
  19999. }
  20000. },
  20001. deferExpand : function(autoActivate){
  20002. delete this.showTimer;
  20003. this.menu.show(this.container, this.parentMenu.subMenuAlign || "tl-tr?", this.parentMenu);
  20004. if(autoActivate){
  20005. this.menu.tryActivate(0, 1);
  20006. }
  20007. },
  20008. hideMenu : function(){
  20009. clearTimeout(this.showTimer);
  20010. delete this.showTimer;
  20011. if(!this.hideTimer && this.menu && this.menu.isVisible()){
  20012. this.hideTimer = this.deferHide.defer(this.hideDelay, this);
  20013. }
  20014. },
  20015. deferHide : function(){
  20016. delete this.hideTimer;
  20017. this.menu.hide();
  20018. }
  20019. });
  20020. Ext.menu.CheckItem = function(config){
  20021. Ext.menu.CheckItem.superclass.constructor.call(this, config);
  20022. this.addEvents(
  20023. "beforecheckchange" ,
  20024. "checkchange"
  20025. );
  20026. if(this.checkHandler){
  20027. this.on('checkchange', this.checkHandler, this.scope);
  20028. }
  20029. Ext.menu.MenuMgr.registerCheckable(this);
  20030. };
  20031. Ext.extend(Ext.menu.CheckItem, Ext.menu.Item, {
  20032. itemCls : "x-menu-item x-menu-check-item",
  20033. groupClass : "x-menu-group-item",
  20034. checked: false,
  20035. ctype: "Ext.menu.CheckItem",
  20036. onRender : function(c){
  20037. Ext.menu.CheckItem.superclass.onRender.apply(this, arguments);
  20038. if(this.group){
  20039. this.el.addClass(this.groupClass);
  20040. }
  20041. if(this.checked){
  20042. this.checked = false;
  20043. this.setChecked(true, true);
  20044. }
  20045. },
  20046. destroy : function(){
  20047. Ext.menu.MenuMgr.unregisterCheckable(this);
  20048. Ext.menu.CheckItem.superclass.destroy.apply(this, arguments);
  20049. },
  20050. setChecked : function(state, suppressEvent){
  20051. if(this.checked != state && this.fireEvent("beforecheckchange", this, state) !== false){
  20052. if(this.container){
  20053. this.container[state ? "addClass" : "removeClass"]("x-menu-item-checked");
  20054. }
  20055. this.checked = state;
  20056. if(suppressEvent !== true){
  20057. this.fireEvent("checkchange", this, state);
  20058. }
  20059. }
  20060. },
  20061. handleClick : function(e){
  20062. if(!this.disabled && !(this.checked && this.group)){ this.setChecked(!this.checked);
  20063. }
  20064. Ext.menu.CheckItem.superclass.handleClick.apply(this, arguments);
  20065. }
  20066. });
  20067. Ext.menu.Adapter = function(component, config){
  20068. Ext.menu.Adapter.superclass.constructor.call(this, config);
  20069. this.component = component;
  20070. };
  20071. Ext.extend(Ext.menu.Adapter, Ext.menu.BaseItem, {
  20072. canActivate : true,
  20073. onRender : function(container, position){
  20074. this.component.render(container);
  20075. this.el = this.component.getEl();
  20076. },
  20077. activate : function(){
  20078. if(this.disabled){
  20079. return false;
  20080. }
  20081. this.component.focus();
  20082. this.fireEvent("activate", this);
  20083. return true;
  20084. },
  20085. deactivate : function(){
  20086. this.fireEvent("deactivate", this);
  20087. },
  20088. disable : function(){
  20089. this.component.disable();
  20090. Ext.menu.Adapter.superclass.disable.call(this);
  20091. },
  20092. enable : function(){
  20093. this.component.enable();
  20094. Ext.menu.Adapter.superclass.enable.call(this);
  20095. }
  20096. });
  20097. Ext.menu.DateItem = function(config){
  20098. Ext.menu.DateItem.superclass.constructor.call(this, new Ext.DatePicker(config), config);
  20099. this.picker = this.component;
  20100. this.addEvents('select');
  20101. this.picker.on("render", function(picker){
  20102. picker.getEl().swallowEvent("click");
  20103. picker.container.addClass("x-menu-date-item");
  20104. });
  20105. this.picker.on("select", this.onSelect, this);
  20106. };
  20107. Ext.extend(Ext.menu.DateItem, Ext.menu.Adapter, {
  20108. onSelect : function(picker, date){
  20109. this.fireEvent("select", this, date, picker);
  20110. Ext.menu.DateItem.superclass.handleClick.call(this);
  20111. }
  20112. });
  20113. Ext.menu.ColorItem = function(config){
  20114. Ext.menu.ColorItem.superclass.constructor.call(this, new Ext.ColorPalette(config), config);
  20115. this.palette = this.component;
  20116. this.relayEvents(this.palette, ["select"]);
  20117. if(this.selectHandler){
  20118. this.on('select', this.selectHandler, this.scope);
  20119. }
  20120. };
  20121. Ext.extend(Ext.menu.ColorItem, Ext.menu.Adapter);
  20122. Ext.menu.DateMenu = function(config){
  20123. Ext.menu.DateMenu.superclass.constructor.call(this, config);
  20124. this.plain = true;
  20125. var di = new Ext.menu.DateItem(config);
  20126. this.add(di);
  20127. this.picker = di.picker;
  20128. this.relayEvents(di, ["select"]);
  20129. this.on('beforeshow', function(){
  20130. if(this.picker){
  20131. this.picker.hideMonthPicker(true);
  20132. }
  20133. }, this);
  20134. };
  20135. Ext.extend(Ext.menu.DateMenu, Ext.menu.Menu, {
  20136. cls:'x-date-menu',
  20137. beforeDestroy : function() {
  20138. this.picker.destroy();
  20139. }
  20140. });
  20141. Ext.menu.ColorMenu = function(config){
  20142. Ext.menu.ColorMenu.superclass.constructor.call(this, config);
  20143. this.plain = true;
  20144. var ci = new Ext.menu.ColorItem(config);
  20145. this.add(ci);
  20146. this.palette = ci.palette;
  20147. this.relayEvents(ci, ["select"]);
  20148. };
  20149. Ext.extend(Ext.menu.ColorMenu, Ext.menu.Menu);
  20150. Ext.form.Field = Ext.extend(Ext.BoxComponent, {
  20151. invalidClass : "x-form-invalid",
  20152. invalidText : "The value in this field is invalid",
  20153. focusClass : "x-form-focus",
  20154. validationEvent : "keyup",
  20155. validateOnBlur : true,
  20156. validationDelay : 250,
  20157. defaultAutoCreate : {tag: "input", type: "text", size: "20", autocomplete: "off"},
  20158. fieldClass : "x-form-field",
  20159. msgTarget : 'qtip',
  20160. msgFx : 'normal',
  20161. readOnly : false,
  20162. disabled : false,
  20163. isFormField : true,
  20164. hasFocus : false,
  20165. initComponent : function(){
  20166. Ext.form.Field.superclass.initComponent.call(this);
  20167. this.addEvents(
  20168. 'focus',
  20169. 'blur',
  20170. 'specialkey',
  20171. 'change',
  20172. 'invalid',
  20173. 'valid'
  20174. );
  20175. },
  20176. getName: function(){
  20177. return this.rendered && this.el.dom.name ? this.el.dom.name : (this.hiddenName || '');
  20178. },
  20179. onRender : function(ct, position){
  20180. Ext.form.Field.superclass.onRender.call(this, ct, position);
  20181. if(!this.el){
  20182. var cfg = this.getAutoCreate();
  20183. if(!cfg.name){
  20184. cfg.name = this.name || this.id;
  20185. }
  20186. if(this.inputType){
  20187. cfg.type = this.inputType;
  20188. }
  20189. this.el = ct.createChild(cfg, position);
  20190. }
  20191. var type = this.el.dom.type;
  20192. if(type){
  20193. if(type == 'password'){
  20194. type = 'text';
  20195. }
  20196. this.el.addClass('x-form-'+type);
  20197. }
  20198. if(this.readOnly){
  20199. this.el.dom.readOnly = true;
  20200. }
  20201. if(this.tabIndex !== undefined){
  20202. this.el.dom.setAttribute('tabIndex', this.tabIndex);
  20203. }
  20204. this.el.addClass([this.fieldClass, this.cls]);
  20205. this.initValue();
  20206. },
  20207. initValue : function(){
  20208. if(this.value !== undefined){
  20209. this.setValue(this.value);
  20210. }else if(this.el.dom.value.length > 0){
  20211. this.setValue(this.el.dom.value);
  20212. }
  20213. },
  20214. isDirty : function() {
  20215. if(this.disabled) {
  20216. return false;
  20217. }
  20218. return String(this.getValue()) !== String(this.originalValue);
  20219. },
  20220. afterRender : function(){
  20221. Ext.form.Field.superclass.afterRender.call(this);
  20222. this.initEvents();
  20223. },
  20224. fireKey : function(e){
  20225. if(e.isSpecialKey()){
  20226. this.fireEvent("specialkey", this, e);
  20227. }
  20228. },
  20229. reset : function(){
  20230. this.setValue(this.originalValue);
  20231. this.clearInvalid();
  20232. },
  20233. initEvents : function(){
  20234. this.el.on(Ext.isIE ? "keydown" : "keypress", this.fireKey, this);
  20235. this.el.on("focus", this.onFocus, this);
  20236. this.el.on("blur", this.onBlur, this);
  20237. this.originalValue = this.getValue();
  20238. },
  20239. onFocus : function(){
  20240. if(!Ext.isOpera && this.focusClass){ this.el.addClass(this.focusClass);
  20241. }
  20242. if(!this.hasFocus){
  20243. this.hasFocus = true;
  20244. this.startValue = this.getValue();
  20245. this.fireEvent("focus", this);
  20246. }
  20247. },
  20248. beforeBlur : Ext.emptyFn,
  20249. onBlur : function(){
  20250. this.beforeBlur();
  20251. if(!Ext.isOpera && this.focusClass){ this.el.removeClass(this.focusClass);
  20252. }
  20253. this.hasFocus = false;
  20254. if(this.validationEvent !== false && this.validateOnBlur && this.validationEvent != "blur"){
  20255. this.validate();
  20256. }
  20257. var v = this.getValue();
  20258. if(String(v) !== String(this.startValue)){
  20259. this.fireEvent('change', this, v, this.startValue);
  20260. }
  20261. this.fireEvent("blur", this);
  20262. },
  20263. isValid : function(preventMark){
  20264. if(this.disabled){
  20265. return true;
  20266. }
  20267. var restore = this.preventMark;
  20268. this.preventMark = preventMark === true;
  20269. var v = this.validateValue(this.processValue(this.getRawValue()));
  20270. this.preventMark = restore;
  20271. return v;
  20272. },
  20273. validate : function(){
  20274. if(this.disabled || this.validateValue(this.processValue(this.getRawValue()))){
  20275. this.clearInvalid();
  20276. return true;
  20277. }
  20278. return false;
  20279. },
  20280. processValue : function(value){
  20281. return value;
  20282. },
  20283. validateValue : function(value){
  20284. return true;
  20285. },
  20286. markInvalid : function(msg){
  20287. if(!this.rendered || this.preventMark){ return;
  20288. }
  20289. this.el.addClass(this.invalidClass);
  20290. msg = msg || this.invalidText;
  20291. switch(this.msgTarget){
  20292. case 'qtip':
  20293. this.el.dom.qtip = msg;
  20294. this.el.dom.qclass = 'x-form-invalid-tip';
  20295. if(Ext.QuickTips){ Ext.QuickTips.enable();
  20296. }
  20297. break;
  20298. case 'title':
  20299. this.el.dom.title = msg;
  20300. break;
  20301. case 'under':
  20302. if(!this.errorEl){
  20303. var elp = this.el.findParent('.x-form-element', 5, true);
  20304. this.errorEl = elp.createChild({cls:'x-form-invalid-msg'});
  20305. this.errorEl.setWidth(elp.getWidth(true)-20);
  20306. }
  20307. this.errorEl.update(msg);
  20308. Ext.form.Field.msgFx[this.msgFx].show(this.errorEl, this);
  20309. break;
  20310. case 'side':
  20311. if(!this.errorIcon){
  20312. var elp = this.el.findParent('.x-form-element', 5, true);
  20313. this.errorIcon = elp.createChild({cls:'x-form-invalid-icon'});
  20314. }
  20315. this.alignErrorIcon();
  20316. this.errorIcon.dom.qtip = msg;
  20317. this.errorIcon.dom.qclass = 'x-form-invalid-tip';
  20318. this.errorIcon.show();
  20319. this.on('resize', this.alignErrorIcon, this);
  20320. break;
  20321. default:
  20322. var t = Ext.getDom(this.msgTarget);
  20323. t.innerHTML = msg;
  20324. t.style.display = this.msgDisplay;
  20325. break;
  20326. }
  20327. this.fireEvent('invalid', this, msg);
  20328. },
  20329. alignErrorIcon : function(){
  20330. this.errorIcon.alignTo(this.el, 'tl-tr', [2, 0]);
  20331. },
  20332. clearInvalid : function(){
  20333. if(!this.rendered || this.preventMark){ return;
  20334. }
  20335. this.el.removeClass(this.invalidClass);
  20336. switch(this.msgTarget){
  20337. case 'qtip':
  20338. this.el.dom.qtip = '';
  20339. break;
  20340. case 'title':
  20341. this.el.dom.title = '';
  20342. break;
  20343. case 'under':
  20344. if(this.errorEl){
  20345. Ext.form.Field.msgFx[this.msgFx].hide(this.errorEl, this);
  20346. }
  20347. break;
  20348. case 'side':
  20349. if(this.errorIcon){
  20350. this.errorIcon.dom.qtip = '';
  20351. this.errorIcon.hide();
  20352. this.un('resize', this.alignErrorIcon, this);
  20353. }
  20354. break;
  20355. default:
  20356. var t = Ext.getDom(this.msgTarget);
  20357. t.innerHTML = '';
  20358. t.style.display = 'none';
  20359. break;
  20360. }
  20361. this.fireEvent('valid', this);
  20362. },
  20363. getRawValue : function(){
  20364. var v = this.rendered ? this.el.getValue() : Ext.value(this.value, '');
  20365. if(v === this.emptyText){
  20366. v = '';
  20367. }
  20368. return v;
  20369. },
  20370. getValue : function(){
  20371. if(!this.rendered) {
  20372. return this.value;
  20373. }
  20374. var v = this.el.getValue();
  20375. if(v === this.emptyText || v === undefined){
  20376. v = '';
  20377. }
  20378. return v;
  20379. },
  20380. setRawValue : function(v){
  20381. return this.el.dom.value = (v === null || v === undefined ? '' : v);
  20382. },
  20383. setValue : function(v){
  20384. this.value = v;
  20385. if(this.rendered){
  20386. this.el.dom.value = (v === null || v === undefined ? '' : v);
  20387. this.validate();
  20388. }
  20389. },
  20390. adjustSize : function(w, h){
  20391. var s = Ext.form.Field.superclass.adjustSize.call(this, w, h);
  20392. s.width = this.adjustWidth(this.el.dom.tagName, s.width);
  20393. return s;
  20394. },
  20395. adjustWidth : function(tag, w){
  20396. tag = tag.toLowerCase();
  20397. if(typeof w == 'number' && !Ext.isSafari){
  20398. if(Ext.isIE && (tag == 'input' || tag == 'textarea')){
  20399. if(tag == 'input' && !Ext.isStrict){
  20400. return this.inEditor ? w : w - 3;
  20401. }
  20402. if(tag == 'input' && Ext.isStrict){
  20403. return w - (Ext.isIE6 ? 4 : 1);
  20404. }
  20405. if(tag = 'textarea' && Ext.isStrict){
  20406. return w-2;
  20407. }
  20408. }else if(Ext.isOpera && Ext.isStrict){
  20409. if(tag == 'input'){
  20410. return w + 2;
  20411. }
  20412. if(tag = 'textarea'){
  20413. return w-2;
  20414. }
  20415. }
  20416. }
  20417. return w;
  20418. }
  20419. });
  20420. Ext.form.Field.msgFx = {
  20421. normal : {
  20422. show: function(msgEl, f){
  20423. msgEl.setDisplayed('block');
  20424. },
  20425. hide : function(msgEl, f){
  20426. msgEl.setDisplayed(false).update('');
  20427. }
  20428. },
  20429. slide : {
  20430. show: function(msgEl, f){
  20431. msgEl.slideIn('t', {stopFx:true});
  20432. },
  20433. hide : function(msgEl, f){
  20434. msgEl.slideOut('t', {stopFx:true,useDisplay:true});
  20435. }
  20436. },
  20437. slideRight : {
  20438. show: function(msgEl, f){
  20439. msgEl.fixDisplay();
  20440. msgEl.alignTo(f.el, 'tl-tr');
  20441. msgEl.slideIn('l', {stopFx:true});
  20442. },
  20443. hide : function(msgEl, f){
  20444. msgEl.slideOut('l', {stopFx:true,useDisplay:true});
  20445. }
  20446. }
  20447. };
  20448. Ext.reg('field', Ext.form.Field);
  20449. Ext.form.TextField = Ext.extend(Ext.form.Field, {
  20450. grow : false,
  20451. growMin : 30,
  20452. growMax : 800,
  20453. vtype : null,
  20454. maskRe : null,
  20455. disableKeyFilter : false,
  20456. allowBlank : true,
  20457. minLength : 0,
  20458. maxLength : Number.MAX_VALUE,
  20459. minLengthText : "The minimum length for this field is {0}",
  20460. maxLengthText : "The maximum length for this field is {0}",
  20461. selectOnFocus : false,
  20462. blankText : "This field is required",
  20463. validator : null,
  20464. regex : null,
  20465. regexText : "",
  20466. emptyText : null,
  20467. emptyClass : 'x-form-empty-field',
  20468. initComponent : function(){
  20469. Ext.form.TextField.superclass.initComponent.call(this);
  20470. this.addEvents(
  20471. 'autosize'
  20472. );
  20473. },
  20474. initEvents : function(){
  20475. Ext.form.TextField.superclass.initEvents.call(this);
  20476. if(this.validationEvent == 'keyup'){
  20477. this.validationTask = new Ext.util.DelayedTask(this.validate, this);
  20478. this.el.on('keyup', this.filterValidation, this);
  20479. }
  20480. else if(this.validationEvent !== false){
  20481. this.el.on(this.validationEvent, this.validate, this, {buffer: this.validationDelay});
  20482. }
  20483. if(this.selectOnFocus || this.emptyText){
  20484. this.on("focus", this.preFocus, this);
  20485. if(this.emptyText){
  20486. this.on('blur', this.postBlur, this);
  20487. this.applyEmptyText();
  20488. }
  20489. }
  20490. if(this.maskRe || (this.vtype && this.disableKeyFilter !== true && (this.maskRe = Ext.form.VTypes[this.vtype+'Mask']))){
  20491. this.el.on("keypress", this.filterKeys, this);
  20492. }
  20493. if(this.grow){
  20494. this.el.on("keyup", this.onKeyUp, this, {buffer:50});
  20495. this.el.on("click", this.autoSize, this);
  20496. }
  20497. },
  20498. processValue : function(value){
  20499. if(this.stripCharsRe){
  20500. var newValue = value.replace(this.stripCharsRe, '');
  20501. if(newValue !== value){
  20502. this.setRawValue(newValue);
  20503. return newValue;
  20504. }
  20505. }
  20506. return value;
  20507. },
  20508. filterValidation : function(e){
  20509. if(!e.isNavKeyPress()){
  20510. this.validationTask.delay(this.validationDelay);
  20511. }
  20512. },
  20513. onKeyUp : function(e){
  20514. if(!e.isNavKeyPress()){
  20515. this.autoSize();
  20516. }
  20517. },
  20518. reset : function(){
  20519. Ext.form.TextField.superclass.reset.call(this);
  20520. this.applyEmptyText();
  20521. },
  20522. applyEmptyText : function(){
  20523. if(this.rendered && this.emptyText && this.getRawValue().length < 1){
  20524. this.setRawValue(this.emptyText);
  20525. this.el.addClass(this.emptyClass);
  20526. }
  20527. },
  20528. preFocus : function(){
  20529. if(this.emptyText){
  20530. if(this.el.dom.value == this.emptyText){
  20531. this.setRawValue('');
  20532. }
  20533. this.el.removeClass(this.emptyClass);
  20534. }
  20535. if(this.selectOnFocus){
  20536. this.el.dom.select();
  20537. }
  20538. },
  20539. postBlur : function(){
  20540. this.applyEmptyText();
  20541. },
  20542. filterKeys : function(e){
  20543. var k = e.getKey();
  20544. if(!Ext.isIE && (e.isNavKeyPress() || k == e.BACKSPACE || (k == e.DELETE && e.button == -1))){
  20545. return;
  20546. }
  20547. var c = e.getCharCode(), cc = String.fromCharCode(c);
  20548. if(Ext.isIE && (e.isSpecialKey() || !cc)){
  20549. return;
  20550. }
  20551. if(!this.maskRe.test(cc)){
  20552. e.stopEvent();
  20553. }
  20554. },
  20555. setValue : function(v){
  20556. if(this.emptyText && this.el && v !== undefined && v !== null && v !== ''){
  20557. this.el.removeClass(this.emptyClass);
  20558. }
  20559. Ext.form.TextField.superclass.setValue.apply(this, arguments);
  20560. this.applyEmptyText();
  20561. this.autoSize();
  20562. },
  20563. validateValue : function(value){
  20564. if(value.length < 1 || value === this.emptyText){ if(this.allowBlank){
  20565. this.clearInvalid();
  20566. return true;
  20567. }else{
  20568. this.markInvalid(this.blankText);
  20569. return false;
  20570. }
  20571. }
  20572. if(value.length < this.minLength){
  20573. this.markInvalid(String.format(this.minLengthText, this.minLength));
  20574. return false;
  20575. }
  20576. if(value.length > this.maxLength){
  20577. this.markInvalid(String.format(this.maxLengthText, this.maxLength));
  20578. return false;
  20579. }
  20580. if(this.vtype){
  20581. var vt = Ext.form.VTypes;
  20582. if(!vt[this.vtype](value, this)){
  20583. this.markInvalid(this.vtypeText || vt[this.vtype +'Text']);
  20584. return false;
  20585. }
  20586. }
  20587. if(typeof this.validator == "function"){
  20588. var msg = this.validator(value);
  20589. if(msg !== true){
  20590. this.markInvalid(msg);
  20591. return false;
  20592. }
  20593. }
  20594. if(this.regex && !this.regex.test(value)){
  20595. this.markInvalid(this.regexText);
  20596. return false;
  20597. }
  20598. return true;
  20599. },
  20600. selectText : function(start, end){
  20601. var v = this.getRawValue();
  20602. if(v.length > 0){
  20603. start = start === undefined ? 0 : start;
  20604. end = end === undefined ? v.length : end;
  20605. var d = this.el.dom;
  20606. if(d.setSelectionRange){
  20607. d.setSelectionRange(start, end);
  20608. }else if(d.createTextRange){
  20609. var range = d.createTextRange();
  20610. range.moveStart("character", start);
  20611. range.moveEnd("character", end-v.length);
  20612. range.select();
  20613. }
  20614. }
  20615. },
  20616. autoSize : function(){
  20617. if(!this.grow || !this.rendered){
  20618. return;
  20619. }
  20620. if(!this.metrics){
  20621. this.metrics = Ext.util.TextMetrics.createInstance(this.el);
  20622. }
  20623. var el = this.el;
  20624. var v = el.dom.value;
  20625. var d = document.createElement('div');
  20626. d.appendChild(document.createTextNode(v));
  20627. v = d.innerHTML;
  20628. d = null;
  20629. v += "&#160;";
  20630. var w = Math.min(this.growMax, Math.max(this.metrics.getWidth(v) + 10, this.growMin));
  20631. this.el.setWidth(w);
  20632. this.fireEvent("autosize", this, w);
  20633. }
  20634. });
  20635. Ext.reg('textfield', Ext.form.TextField);
  20636. Ext.form.TriggerField = Ext.extend(Ext.form.TextField, {
  20637. defaultAutoCreate : {tag: "input", type: "text", size: "16", autocomplete: "off"},
  20638. hideTrigger:false,
  20639. autoSize: Ext.emptyFn,
  20640. monitorTab : true,
  20641. deferHeight : true,
  20642. mimicing : false,
  20643. onResize : function(w, h){
  20644. Ext.form.TriggerField.superclass.onResize.call(this, w, h);
  20645. if(typeof w == 'number'){
  20646. this.el.setWidth(this.adjustWidth('input', w - this.trigger.getWidth()));
  20647. }
  20648. this.wrap.setWidth(this.el.getWidth()+this.trigger.getWidth());
  20649. },
  20650. adjustSize : Ext.BoxComponent.prototype.adjustSize,
  20651. getResizeEl : function(){
  20652. return this.wrap;
  20653. },
  20654. getPositionEl : function(){
  20655. return this.wrap;
  20656. },
  20657. alignErrorIcon : function(){
  20658. this.errorIcon.alignTo(this.wrap, 'tl-tr', [2, 0]);
  20659. },
  20660. onRender : function(ct, position){
  20661. Ext.form.TriggerField.superclass.onRender.call(this, ct, position);
  20662. this.wrap = this.el.wrap({cls: "x-form-field-wrap"});
  20663. this.trigger = this.wrap.createChild(this.triggerConfig ||
  20664. {tag: "img", src: Ext.BLANK_IMAGE_URL, cls: "x-form-trigger " + this.triggerClass});
  20665. if(this.hideTrigger){
  20666. this.trigger.setDisplayed(false);
  20667. }
  20668. this.initTrigger();
  20669. if(!this.width){
  20670. this.wrap.setWidth(this.el.getWidth()+this.trigger.getWidth());
  20671. }
  20672. },
  20673. initTrigger : function(){
  20674. this.trigger.on("click", this.onTriggerClick, this, {preventDefault:true});
  20675. this.trigger.addClassOnOver('x-form-trigger-over');
  20676. this.trigger.addClassOnClick('x-form-trigger-click');
  20677. },
  20678. onDestroy : function(){
  20679. if(this.trigger){
  20680. this.trigger.removeAllListeners();
  20681. this.trigger.remove();
  20682. }
  20683. if(this.wrap){
  20684. this.wrap.remove();
  20685. }
  20686. Ext.form.TriggerField.superclass.onDestroy.call(this);
  20687. },
  20688. onFocus : function(){
  20689. Ext.form.TriggerField.superclass.onFocus.call(this);
  20690. if(!this.mimicing){
  20691. this.wrap.addClass('x-trigger-wrap-focus');
  20692. this.mimicing = true;
  20693. Ext.get(Ext.isIE ? document.body : document).on("mousedown", this.mimicBlur, this, {delay: 10});
  20694. if(this.monitorTab){
  20695. this.el.on("keydown", this.checkTab, this);
  20696. }
  20697. }
  20698. },
  20699. checkTab : function(e){
  20700. if(e.getKey() == e.TAB){
  20701. this.triggerBlur();
  20702. }
  20703. },
  20704. onBlur : function(){
  20705. },
  20706. mimicBlur : function(e){
  20707. if(!this.wrap.contains(e.target) && this.validateBlur(e)){
  20708. this.triggerBlur();
  20709. }
  20710. },
  20711. triggerBlur : function(){
  20712. this.mimicing = false;
  20713. Ext.get(Ext.isIE ? document.body : document).un("mousedown", this.mimicBlur);
  20714. if(this.monitorTab){
  20715. this.el.un("keydown", this.checkTab, this);
  20716. }
  20717. this.beforeBlur();
  20718. this.wrap.removeClass('x-trigger-wrap-focus');
  20719. Ext.form.TriggerField.superclass.onBlur.call(this);
  20720. },
  20721. beforeBlur : Ext.emptyFn,
  20722. validateBlur : function(e){
  20723. return true;
  20724. },
  20725. onDisable : function(){
  20726. Ext.form.TriggerField.superclass.onDisable.call(this);
  20727. if(this.wrap){
  20728. this.wrap.addClass('x-item-disabled');
  20729. }
  20730. },
  20731. onEnable : function(){
  20732. Ext.form.TriggerField.superclass.onEnable.call(this);
  20733. if(this.wrap){
  20734. this.wrap.removeClass('x-item-disabled');
  20735. }
  20736. },
  20737. onShow : function(){
  20738. if(this.wrap){
  20739. this.wrap.dom.style.display = '';
  20740. this.wrap.dom.style.visibility = 'visible';
  20741. }
  20742. },
  20743. onHide : function(){
  20744. this.wrap.dom.style.display = 'none';
  20745. },
  20746. onTriggerClick : Ext.emptyFn
  20747. });
  20748. Ext.form.TwinTriggerField = Ext.extend(Ext.form.TriggerField, {
  20749. initComponent : function(){
  20750. Ext.form.TwinTriggerField.superclass.initComponent.call(this);
  20751. this.triggerConfig = {
  20752. tag:'span', cls:'x-form-twin-triggers', cn:[
  20753. {tag: "img", src: Ext.BLANK_IMAGE_URL, cls: "x-form-trigger " + this.trigger1Class},
  20754. {tag: "img", src: Ext.BLANK_IMAGE_URL, cls: "x-form-trigger " + this.trigger2Class}
  20755. ]};
  20756. },
  20757. getTrigger : function(index){
  20758. return this.triggers[index];
  20759. },
  20760. initTrigger : function(){
  20761. var ts = this.trigger.select('.x-form-trigger', true);
  20762. this.wrap.setStyle('overflow', 'hidden');
  20763. var triggerField = this;
  20764. ts.each(function(t, all, index){
  20765. t.hide = function(){
  20766. var w = triggerField.wrap.getWidth();
  20767. this.dom.style.display = 'none';
  20768. triggerField.el.setWidth(w-triggerField.trigger.getWidth());
  20769. };
  20770. t.show = function(){
  20771. var w = triggerField.wrap.getWidth();
  20772. this.dom.style.display = '';
  20773. triggerField.el.setWidth(w-triggerField.trigger.getWidth());
  20774. };
  20775. var triggerIndex = 'Trigger'+(index+1);
  20776. if(this['hide'+triggerIndex]){
  20777. t.dom.style.display = 'none';
  20778. }
  20779. t.on("click", this['on'+triggerIndex+'Click'], this, {preventDefault:true});
  20780. t.addClassOnOver('x-form-trigger-over');
  20781. t.addClassOnClick('x-form-trigger-click');
  20782. }, this);
  20783. this.triggers = ts.elements;
  20784. },
  20785. onTrigger1Click : Ext.emptyFn,
  20786. onTrigger2Click : Ext.emptyFn
  20787. });
  20788. Ext.reg('trigger', Ext.form.TriggerField);
  20789. Ext.form.TextArea = Ext.extend(Ext.form.TextField, {
  20790. growMin : 60,
  20791. growMax: 1000,
  20792. growAppend : '&#160;\n&#160;',
  20793. growPad : 0,
  20794. enterIsSpecial : false,
  20795. preventScrollbars: false,
  20796. onRender : function(ct, position){
  20797. if(!this.el){
  20798. this.defaultAutoCreate = {
  20799. tag: "textarea",
  20800. style:"width:100px;height:60px;",
  20801. autocomplete: "off"
  20802. };
  20803. }
  20804. Ext.form.TextArea.superclass.onRender.call(this, ct, position);
  20805. if(this.grow){
  20806. this.textSizeEl = Ext.DomHelper.append(document.body, {
  20807. tag: "pre", cls: "x-form-grow-sizer"
  20808. });
  20809. if(this.preventScrollbars){
  20810. this.el.setStyle("overflow", "hidden");
  20811. }
  20812. this.el.setHeight(this.growMin);
  20813. }
  20814. },
  20815. onDestroy : function(){
  20816. if(this.textSizeEl){
  20817. Ext.removeNode(this.textSizeEl);
  20818. }
  20819. Ext.form.TextArea.superclass.onDestroy.call(this);
  20820. },
  20821. fireKey : function(e){
  20822. if(e.isSpecialKey() && (this.enterIsSpecial || (e.getKey() != e.ENTER || e.hasModifier()))){
  20823. this.fireEvent("specialkey", this, e);
  20824. }
  20825. },
  20826. onKeyUp : function(e){
  20827. if(!e.isNavKeyPress() || e.getKey() == e.ENTER){
  20828. this.autoSize();
  20829. }
  20830. },
  20831. autoSize : function(){
  20832. if(!this.grow || !this.textSizeEl){
  20833. return;
  20834. }
  20835. var el = this.el;
  20836. var v = el.dom.value;
  20837. var ts = this.textSizeEl;
  20838. ts.innerHTML = '';
  20839. ts.appendChild(document.createTextNode(v));
  20840. v = ts.innerHTML;
  20841. Ext.fly(ts).setWidth(this.el.getWidth());
  20842. if(v.length < 1){
  20843. v = "&#160;&#160;";
  20844. }else{
  20845. if(Ext.isIE){
  20846. v = v.replace(/\n/g, '<p>&#160;</p>');
  20847. }
  20848. v += this.growAppend;
  20849. }
  20850. ts.innerHTML = v;
  20851. var h = Math.min(this.growMax, Math.max(ts.offsetHeight, this.growMin)+this.growPad);
  20852. if(h != this.lastHeight){
  20853. this.lastHeight = h;
  20854. this.el.setHeight(h);
  20855. this.fireEvent("autosize", this, h);
  20856. }
  20857. }
  20858. });
  20859. Ext.reg('textarea', Ext.form.TextArea);
  20860. Ext.form.NumberField = Ext.extend(Ext.form.TextField, {
  20861. fieldClass: "x-form-field x-form-num-field",
  20862. allowDecimals : true,
  20863. decimalSeparator : ".",
  20864. decimalPrecision : 2,
  20865. allowNegative : true,
  20866. minValue : Number.NEGATIVE_INFINITY,
  20867. maxValue : Number.MAX_VALUE,
  20868. minText : "The minimum value for this field is {0}",
  20869. maxText : "The maximum value for this field is {0}",
  20870. nanText : "{0} is not a valid number",
  20871. baseChars : "0123456789",
  20872. initEvents : function(){
  20873. Ext.form.NumberField.superclass.initEvents.call(this);
  20874. var allowed = this.baseChars+'';
  20875. if(this.allowDecimals){
  20876. allowed += this.decimalSeparator;
  20877. }
  20878. if(this.allowNegative){
  20879. allowed += "-";
  20880. }
  20881. this.stripCharsRe = new RegExp('[^'+allowed+']', 'gi');
  20882. var keyPress = function(e){
  20883. var k = e.getKey();
  20884. if(!Ext.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)){
  20885. return;
  20886. }
  20887. var c = e.getCharCode();
  20888. if(allowed.indexOf(String.fromCharCode(c)) === -1){
  20889. e.stopEvent();
  20890. }
  20891. };
  20892. this.el.on("keypress", keyPress, this);
  20893. },
  20894. validateValue : function(value){
  20895. if(!Ext.form.NumberField.superclass.validateValue.call(this, value)){
  20896. return false;
  20897. }
  20898. if(value.length < 1){ return true;
  20899. }
  20900. value = String(value).replace(this.decimalSeparator, ".");
  20901. if(isNaN(value)){
  20902. this.markInvalid(String.format(this.nanText, value));
  20903. return false;
  20904. }
  20905. var num = this.parseValue(value);
  20906. if(num < this.minValue){
  20907. this.markInvalid(String.format(this.minText, this.minValue));
  20908. return false;
  20909. }
  20910. if(num > this.maxValue){
  20911. this.markInvalid(String.format(this.maxText, this.maxValue));
  20912. return false;
  20913. }
  20914. return true;
  20915. },
  20916. getValue : function(){
  20917. return this.fixPrecision(this.parseValue(Ext.form.NumberField.superclass.getValue.call(this)));
  20918. },
  20919. setValue : function(v){
  20920. v = parseFloat(v);
  20921. v = isNaN(v) ? '' : String(v).replace(".", this.decimalSeparator);
  20922. Ext.form.NumberField.superclass.setValue.call(this, v);
  20923. },
  20924. parseValue : function(value){
  20925. value = parseFloat(String(value).replace(this.decimalSeparator, "."));
  20926. return isNaN(value) ? '' : value;
  20927. },
  20928. fixPrecision : function(value){
  20929. var nan = isNaN(value);
  20930. if(!this.allowDecimals || this.decimalPrecision == -1 || nan || !value){
  20931. return nan ? '' : value;
  20932. }
  20933. return parseFloat(parseFloat(value).toFixed(this.decimalPrecision));
  20934. },
  20935. beforeBlur : function(){
  20936. var v = this.parseValue(this.getRawValue());
  20937. if(v){
  20938. this.setValue(this.fixPrecision(v));
  20939. }
  20940. }
  20941. });
  20942. Ext.reg('numberfield', Ext.form.NumberField);
  20943. Ext.form.DateField = Ext.extend(Ext.form.TriggerField, {
  20944. format : "m/d/y",
  20945. altFormats : "m/d/Y|n/j/Y|n/j/y|m/j/y|n/d/y|m/j/Y|n/d/Y|m-d-y|m-d-Y|m/d|m-d|md|mdy|mdY|d|Y-m-d",
  20946. disabledDays : null,
  20947. disabledDaysText : "Disabled",
  20948. disabledDates : null,
  20949. disabledDatesText : "Disabled",
  20950. minValue : null,
  20951. maxValue : null,
  20952. minText : "The date in this field must be equal to or after {0}",
  20953. maxText : "The date in this field must be equal to or before {0}",
  20954. invalidText : "{0} is not a valid date - it must be in the format {1}",
  20955. triggerClass : 'x-form-date-trigger',
  20956. defaultAutoCreate : {tag: "input", type: "text", size: "10", autocomplete: "off"},
  20957. initComponent : function(){
  20958. Ext.form.DateField.superclass.initComponent.call(this);
  20959. if(typeof this.minValue == "string"){
  20960. this.minValue = this.parseDate(this.minValue);
  20961. }
  20962. if(typeof this.maxValue == "string"){
  20963. this.maxValue = this.parseDate(this.maxValue);
  20964. }
  20965. this.ddMatch = null;
  20966. if(this.disabledDates){
  20967. var dd = this.disabledDates;
  20968. var re = "(?:";
  20969. for(var i = 0; i < dd.length; i++){
  20970. re += dd[i];
  20971. if(i != dd.length-1) re += "|";
  20972. }
  20973. this.ddMatch = new RegExp(re + ")");
  20974. }
  20975. },
  20976. validateValue : function(value){
  20977. value = this.formatDate(value);
  20978. if(!Ext.form.DateField.superclass.validateValue.call(this, value)){
  20979. return false;
  20980. }
  20981. if(value.length < 1){ return true;
  20982. }
  20983. var svalue = value;
  20984. value = this.parseDate(value);
  20985. if(!value){
  20986. this.markInvalid(String.format(this.invalidText, svalue, this.format));
  20987. return false;
  20988. }
  20989. var time = value.getTime();
  20990. if(this.minValue && time < this.minValue.getTime()){
  20991. this.markInvalid(String.format(this.minText, this.formatDate(this.minValue)));
  20992. return false;
  20993. }
  20994. if(this.maxValue && time > this.maxValue.getTime()){
  20995. this.markInvalid(String.format(this.maxText, this.formatDate(this.maxValue)));
  20996. return false;
  20997. }
  20998. if(this.disabledDays){
  20999. var day = value.getDay();
  21000. for(var i = 0; i < this.disabledDays.length; i++) {
  21001. if(day === this.disabledDays[i]){
  21002. this.markInvalid(this.disabledDaysText);
  21003. return false;
  21004. }
  21005. }
  21006. }
  21007. var fvalue = this.formatDate(value);
  21008. if(this.ddMatch && this.ddMatch.test(fvalue)){
  21009. this.markInvalid(String.format(this.disabledDatesText, fvalue));
  21010. return false;
  21011. }
  21012. return true;
  21013. },
  21014. validateBlur : function(){
  21015. return !this.menu || !this.menu.isVisible();
  21016. },
  21017. getValue : function(){
  21018. return this.parseDate(Ext.form.DateField.superclass.getValue.call(this)) || "";
  21019. },
  21020. setValue : function(date){
  21021. Ext.form.DateField.superclass.setValue.call(this, this.formatDate(this.parseDate(date)));
  21022. },
  21023. parseDate : function(value){
  21024. if(!value || Ext.isDate(value)){
  21025. return value;
  21026. }
  21027. var v = Date.parseDate(value, this.format);
  21028. if(!v && this.altFormats){
  21029. if(!this.altFormatsArray){
  21030. this.altFormatsArray = this.altFormats.split("|");
  21031. }
  21032. for(var i = 0, len = this.altFormatsArray.length; i < len && !v; i++){
  21033. v = Date.parseDate(value, this.altFormatsArray[i]);
  21034. }
  21035. }
  21036. return v;
  21037. },
  21038. onDestroy : function(){
  21039. if(this.menu) {
  21040. this.menu.destroy();
  21041. }
  21042. if(this.wrap){
  21043. this.wrap.remove();
  21044. }
  21045. Ext.form.DateField.superclass.onDestroy.call(this);
  21046. },
  21047. formatDate : function(date){
  21048. return Ext.isDate(date) ? date.dateFormat(this.format) : date;
  21049. },
  21050. menuListeners : {
  21051. select: function(m, d){
  21052. this.setValue(d);
  21053. },
  21054. show : function(){ this.onFocus();
  21055. },
  21056. hide : function(){
  21057. this.focus.defer(10, this);
  21058. var ml = this.menuListeners;
  21059. this.menu.un("select", ml.select, this);
  21060. this.menu.un("show", ml.show, this);
  21061. this.menu.un("hide", ml.hide, this);
  21062. }
  21063. },
  21064. onTriggerClick : function(){
  21065. if(this.disabled){
  21066. return;
  21067. }
  21068. if(this.menu == null){
  21069. this.menu = new Ext.menu.DateMenu();
  21070. }
  21071. Ext.apply(this.menu.picker, {
  21072. minDate : this.minValue,
  21073. maxDate : this.maxValue,
  21074. disabledDatesRE : this.ddMatch,
  21075. disabledDatesText : this.disabledDatesText,
  21076. disabledDays : this.disabledDays,
  21077. disabledDaysText : this.disabledDaysText,
  21078. format : this.format,
  21079. minText : String.format(this.minText, this.formatDate(this.minValue)),
  21080. maxText : String.format(this.maxText, this.formatDate(this.maxValue))
  21081. });
  21082. this.menu.on(Ext.apply({}, this.menuListeners, {
  21083. scope:this
  21084. }));
  21085. this.menu.picker.setValue(this.getValue() || new Date());
  21086. this.menu.show(this.el, "tl-bl?");
  21087. },
  21088. beforeBlur : function(){
  21089. var v = this.parseDate(this.getRawValue());
  21090. if(v){
  21091. this.setValue(v);
  21092. }
  21093. }
  21094. });
  21095. Ext.reg('datefield', Ext.form.DateField);
  21096. Ext.form.ComboBox = Ext.extend(Ext.form.TriggerField, {
  21097. defaultAutoCreate : {tag: "input", type: "text", size: "24", autocomplete: "off"},
  21098. listClass: '',
  21099. selectedClass: 'x-combo-selected',
  21100. triggerClass : 'x-form-arrow-trigger',
  21101. shadow:'sides',
  21102. listAlign: 'tl-bl?',
  21103. maxHeight: 300,
  21104. minHeight: 90,
  21105. triggerAction: 'query',
  21106. minChars : 4,
  21107. typeAhead: false,
  21108. queryDelay: 500,
  21109. pageSize: 0,
  21110. selectOnFocus:false,
  21111. queryParam: 'query',
  21112. loadingText: 'Loading...',
  21113. resizable: false,
  21114. handleHeight : 8,
  21115. editable: true,
  21116. allQuery: '',
  21117. mode: 'remote',
  21118. minListWidth : 70,
  21119. forceSelection:false,
  21120. typeAheadDelay : 250,
  21121. lazyInit : true,
  21122. initComponent : function(){
  21123. Ext.form.ComboBox.superclass.initComponent.call(this);
  21124. this.addEvents(
  21125. 'expand',
  21126. 'collapse',
  21127. 'beforeselect',
  21128. 'select',
  21129. 'beforequery'
  21130. );
  21131. if(this.transform){
  21132. this.allowDomMove = false;
  21133. var s = Ext.getDom(this.transform);
  21134. if(!this.hiddenName){
  21135. this.hiddenName = s.name;
  21136. }
  21137. if(!this.store){
  21138. this.mode = 'local';
  21139. var d = [], opts = s.options;
  21140. for(var i = 0, len = opts.length;i < len; i++){
  21141. var o = opts[i];
  21142. var value = (Ext.isIE ? o.getAttributeNode('value').specified : o.hasAttribute('value')) ? o.value : o.text;
  21143. if(o.selected) {
  21144. this.value = value;
  21145. }
  21146. d.push([value, o.text]);
  21147. }
  21148. this.store = new Ext.data.SimpleStore({
  21149. 'id': 0,
  21150. fields: ['value', 'text'],
  21151. data : d
  21152. });
  21153. this.valueField = 'value';
  21154. this.displayField = 'text';
  21155. }
  21156. s.name = Ext.id(); if(!this.lazyRender){
  21157. this.target = true;
  21158. this.el = Ext.DomHelper.insertBefore(s, this.autoCreate || this.defaultAutoCreate);
  21159. Ext.removeNode(s); this.render(this.el.parentNode);
  21160. }else{
  21161. Ext.removeNode(s); }
  21162. }
  21163. this.selectedIndex = -1;
  21164. if(this.mode == 'local'){
  21165. if(this.initialConfig.queryDelay === undefined){
  21166. this.queryDelay = 10;
  21167. }
  21168. if(this.initialConfig.minChars === undefined){
  21169. this.minChars = 0;
  21170. }
  21171. }
  21172. },
  21173. onRender : function(ct, position){
  21174. Ext.form.ComboBox.superclass.onRender.call(this, ct, position);
  21175. if(this.hiddenName){
  21176. this.hiddenField = this.el.insertSibling({tag:'input', type:'hidden', name: this.hiddenName, id: (this.hiddenId||this.hiddenName)},
  21177. 'before', true);
  21178. this.hiddenField.value =
  21179. this.hiddenValue !== undefined ? this.hiddenValue :
  21180. this.value !== undefined ? this.value : '';
  21181. this.el.dom.removeAttribute('name');
  21182. }
  21183. if(Ext.isGecko){
  21184. this.el.dom.setAttribute('autocomplete', 'off');
  21185. }
  21186. if(!this.lazyInit){
  21187. this.initList();
  21188. }else{
  21189. this.on('focus', this.initList, this, {single: true});
  21190. }
  21191. if(!this.editable){
  21192. this.editable = true;
  21193. this.setEditable(false);
  21194. }
  21195. },
  21196. initList : function(){
  21197. if(!this.list){
  21198. var cls = 'x-combo-list';
  21199. this.list = new Ext.Layer({
  21200. shadow: this.shadow, cls: [cls, this.listClass].join(' '), constrain:false
  21201. });
  21202. var lw = this.listWidth || Math.max(this.wrap.getWidth(), this.minListWidth);
  21203. this.list.setWidth(lw);
  21204. this.list.swallowEvent('mousewheel');
  21205. this.assetHeight = 0;
  21206. if(this.title){
  21207. this.header = this.list.createChild({cls:cls+'-hd', html: this.title});
  21208. this.assetHeight += this.header.getHeight();
  21209. }
  21210. this.innerList = this.list.createChild({cls:cls+'-inner'});
  21211. this.innerList.on('mouseover', this.onViewOver, this);
  21212. this.innerList.on('mousemove', this.onViewMove, this);
  21213. this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
  21214. if(this.pageSize){
  21215. this.footer = this.list.createChild({cls:cls+'-ft'});
  21216. this.pageTb = new Ext.PagingToolbar({
  21217. store:this.store,
  21218. pageSize: this.pageSize,
  21219. renderTo:this.footer
  21220. });
  21221. this.assetHeight += this.footer.getHeight();
  21222. }
  21223. if(!this.tpl){
  21224. this.tpl = '<tpl for="."><div class="'+cls+'-item">{' + this.displayField + '}</div></tpl>';
  21225. }
  21226. this.view = new Ext.DataView({
  21227. applyTo: this.innerList,
  21228. tpl: this.tpl,
  21229. singleSelect: true,
  21230. selectedClass: this.selectedClass,
  21231. itemSelector: this.itemSelector || '.' + cls + '-item'
  21232. });
  21233. this.view.on('click', this.onViewClick, this);
  21234. this.bindStore(this.store, true);
  21235. if(this.resizable){
  21236. this.resizer = new Ext.Resizable(this.list, {
  21237. pinned:true, handles:'se'
  21238. });
  21239. this.resizer.on('resize', function(r, w, h){
  21240. this.maxHeight = h-this.handleHeight-this.list.getFrameWidth('tb')-this.assetHeight;
  21241. this.listWidth = w;
  21242. this.innerList.setWidth(w - this.list.getFrameWidth('lr'));
  21243. this.restrictHeight();
  21244. }, this);
  21245. this[this.pageSize?'footer':'innerList'].setStyle('margin-bottom', this.handleHeight+'px');
  21246. }
  21247. }
  21248. },
  21249. bindStore : function(store, initial){
  21250. if(this.store && !initial){
  21251. this.store.un('beforeload', this.onBeforeLoad, this);
  21252. this.store.un('load', this.onLoad, this);
  21253. this.store.un('loadexception', this.collapse, this);
  21254. if(!store){
  21255. this.store = null;
  21256. if(this.view){
  21257. this.view.setStore(null);
  21258. }
  21259. }
  21260. }
  21261. if(store){
  21262. this.store = Ext.StoreMgr.lookup(store);
  21263. this.store.on('beforeload', this.onBeforeLoad, this);
  21264. this.store.on('load', this.onLoad, this);
  21265. this.store.on('loadexception', this.collapse, this);
  21266. if(this.view){
  21267. this.view.setStore(store);
  21268. }
  21269. }
  21270. },
  21271. initEvents : function(){
  21272. Ext.form.ComboBox.superclass.initEvents.call(this);
  21273. this.keyNav = new Ext.KeyNav(this.el, {
  21274. "up" : function(e){
  21275. this.inKeyMode = true;
  21276. this.selectPrev();
  21277. },
  21278. "down" : function(e){
  21279. if(!this.isExpanded()){
  21280. this.onTriggerClick();
  21281. }else{
  21282. this.inKeyMode = true;
  21283. this.selectNext();
  21284. }
  21285. },
  21286. "enter" : function(e){
  21287. this.onViewClick();
  21288. this.delayedCheck = true;
  21289. this.unsetDelayCheck.defer(10, this);
  21290. },
  21291. "esc" : function(e){
  21292. this.collapse();
  21293. },
  21294. "tab" : function(e){
  21295. this.onViewClick(false);
  21296. return true;
  21297. },
  21298. scope : this,
  21299. doRelay : function(foo, bar, hname){
  21300. if(hname == 'down' || this.scope.isExpanded()){
  21301. return Ext.KeyNav.prototype.doRelay.apply(this, arguments);
  21302. }
  21303. return true;
  21304. },
  21305. forceKeyDown : true
  21306. });
  21307. this.queryDelay = Math.max(this.queryDelay || 10,
  21308. this.mode == 'local' ? 10 : 250);
  21309. this.dqTask = new Ext.util.DelayedTask(this.initQuery, this);
  21310. if(this.typeAhead){
  21311. this.taTask = new Ext.util.DelayedTask(this.onTypeAhead, this);
  21312. }
  21313. if(this.editable !== false){
  21314. this.el.on("keyup", this.onKeyUp, this);
  21315. }
  21316. if(this.forceSelection){
  21317. this.on('blur', this.doForce, this);
  21318. }
  21319. },
  21320. onDestroy : function(){
  21321. if(this.view){
  21322. this.view.el.removeAllListeners();
  21323. this.view.el.remove();
  21324. this.view.purgeListeners();
  21325. }
  21326. if(this.list){
  21327. this.list.destroy();
  21328. }
  21329. this.bindStore(null);
  21330. Ext.form.ComboBox.superclass.onDestroy.call(this);
  21331. },
  21332. unsetDelayCheck : function(){
  21333. delete this.delayedCheck;
  21334. },
  21335. fireKey : function(e){
  21336. if(e.isNavKeyPress() && !this.isExpanded() && !this.delayedCheck){
  21337. this.fireEvent("specialkey", this, e);
  21338. }
  21339. },
  21340. onResize: function(w, h){
  21341. Ext.form.ComboBox.superclass.onResize.apply(this, arguments);
  21342. if(this.list && this.listWidth === undefined){
  21343. var lw = Math.max(w, this.minListWidth);
  21344. this.list.setWidth(lw);
  21345. this.innerList.setWidth(lw - this.list.getFrameWidth('lr'));
  21346. }
  21347. },
  21348. onEnable: function(){
  21349. Ext.form.ComboBox.superclass.onEnable.apply(this, arguments);
  21350. if(this.hiddenField){
  21351. this.hiddenField.disabled = false;
  21352. }
  21353. },
  21354. onDisable: function(){
  21355. Ext.form.ComboBox.superclass.onDisable.apply(this, arguments);
  21356. if(this.hiddenField){
  21357. this.hiddenField.disabled = true;
  21358. }
  21359. },
  21360. setEditable : function(value){
  21361. if(value == this.editable){
  21362. return;
  21363. }
  21364. this.editable = value;
  21365. if(!value){
  21366. this.el.dom.setAttribute('readOnly', true);
  21367. this.el.on('mousedown', this.onTriggerClick, this);
  21368. this.el.addClass('x-combo-noedit');
  21369. }else{
  21370. this.el.dom.setAttribute('readOnly', false);
  21371. this.el.un('mousedown', this.onTriggerClick, this);
  21372. this.el.removeClass('x-combo-noedit');
  21373. }
  21374. },
  21375. onBeforeLoad : function(){
  21376. if(!this.hasFocus){
  21377. return;
  21378. }
  21379. this.innerList.update(this.loadingText ?
  21380. '<div class="loading-indicator">'+this.loadingText+'</div>' : '');
  21381. this.restrictHeight();
  21382. this.selectedIndex = -1;
  21383. },
  21384. onLoad : function(){
  21385. if(!this.hasFocus){
  21386. return;
  21387. }
  21388. if(this.store.getCount() > 0){
  21389. this.expand();
  21390. this.restrictHeight();
  21391. if(this.lastQuery == this.allQuery){
  21392. if(this.editable){
  21393. this.el.dom.select();
  21394. }
  21395. if(!this.selectByValue(this.value, true)){
  21396. this.select(0, true);
  21397. }
  21398. }else{
  21399. this.selectNext();
  21400. if(this.typeAhead && this.lastKey != Ext.EventObject.BACKSPACE && this.lastKey != Ext.EventObject.DELETE){
  21401. this.taTask.delay(this.typeAheadDelay);
  21402. }
  21403. }
  21404. }else{
  21405. this.onEmptyResults();
  21406. }
  21407. },
  21408. onTypeAhead : function(){
  21409. if(this.store.getCount() > 0){
  21410. var r = this.store.getAt(0);
  21411. var newValue = r.data[this.displayField];
  21412. var len = newValue.length;
  21413. var selStart = this.getRawValue().length;
  21414. if(selStart != len){
  21415. this.setRawValue(newValue);
  21416. this.selectText(selStart, newValue.length);
  21417. }
  21418. }
  21419. },
  21420. onSelect : function(record, index){
  21421. if(this.fireEvent('beforeselect', this, record, index) !== false){
  21422. this.setValue(record.data[this.valueField || this.displayField]);
  21423. this.collapse();
  21424. this.fireEvent('select', this, record, index);
  21425. }
  21426. },
  21427. getValue : function(){
  21428. if(this.valueField){
  21429. return typeof this.value != 'undefined' ? this.value : '';
  21430. }else{
  21431. return Ext.form.ComboBox.superclass.getValue.call(this);
  21432. }
  21433. },
  21434. clearValue : function(){
  21435. if(this.hiddenField){
  21436. this.hiddenField.value = '';
  21437. }
  21438. this.setRawValue('');
  21439. this.lastSelectionText = '';
  21440. this.applyEmptyText();
  21441. this.value = '';
  21442. },
  21443. setValue : function(v){
  21444. var text = v;
  21445. if(this.valueField){
  21446. var r = this.findRecord(this.valueField, v);
  21447. if(r){
  21448. text = r.data[this.displayField];
  21449. }else if(this.valueNotFoundText !== undefined){
  21450. text = this.valueNotFoundText;
  21451. }
  21452. }
  21453. this.lastSelectionText = text;
  21454. if(this.hiddenField){
  21455. this.hiddenField.value = v;
  21456. }
  21457. Ext.form.ComboBox.superclass.setValue.call(this, text);
  21458. this.value = v;
  21459. },
  21460. findRecord : function(prop, value){
  21461. var record;
  21462. if(this.store.getCount() > 0){
  21463. this.store.each(function(r){
  21464. if(r.data[prop] == value){
  21465. record = r;
  21466. return false;
  21467. }
  21468. });
  21469. }
  21470. return record;
  21471. },
  21472. onViewMove : function(e, t){
  21473. this.inKeyMode = false;
  21474. },
  21475. onViewOver : function(e, t){
  21476. if(this.inKeyMode){ return;
  21477. }
  21478. var item = this.view.findItemFromChild(t);
  21479. if(item){
  21480. var index = this.view.indexOf(item);
  21481. this.select(index, false);
  21482. }
  21483. },
  21484. onViewClick : function(doFocus){
  21485. var index = this.view.getSelectedIndexes()[0];
  21486. var r = this.store.getAt(index);
  21487. if(r){
  21488. this.onSelect(r, index);
  21489. }
  21490. if(doFocus !== false){
  21491. this.el.focus();
  21492. }
  21493. },
  21494. restrictHeight : function(){
  21495. this.innerList.dom.style.height = '';
  21496. var inner = this.innerList.dom;
  21497. var pad = this.list.getFrameWidth('tb')+(this.resizable?this.handleHeight:0)+this.assetHeight;
  21498. var h = Math.max(inner.clientHeight, inner.offsetHeight, inner.scrollHeight);
  21499. var ha = this.getPosition()[1]-Ext.getBody().getScroll().top;
  21500. var hb = Ext.lib.Dom.getViewHeight()-ha-this.getSize().height;
  21501. var space = Math.max(ha, hb, this.minHeight || 0)-this.list.shadow.offset-pad-2;
  21502. h = Math.min(h, space, this.maxHeight);
  21503. this.innerList.setHeight(h);
  21504. this.list.beginUpdate();
  21505. this.list.setHeight(h+pad);
  21506. this.list.alignTo(this.el, this.listAlign);
  21507. this.list.endUpdate();
  21508. },
  21509. onEmptyResults : function(){
  21510. this.collapse();
  21511. },
  21512. isExpanded : function(){
  21513. return this.list && this.list.isVisible();
  21514. },
  21515. selectByValue : function(v, scrollIntoView){
  21516. if(v !== undefined && v !== null){
  21517. var r = this.findRecord(this.valueField || this.displayField, v);
  21518. if(r){
  21519. this.select(this.store.indexOf(r), scrollIntoView);
  21520. return true;
  21521. }
  21522. }
  21523. return false;
  21524. },
  21525. select : function(index, scrollIntoView){
  21526. this.selectedIndex = index;
  21527. this.view.select(index);
  21528. if(scrollIntoView !== false){
  21529. var el = this.view.getNode(index);
  21530. if(el){
  21531. this.innerList.scrollChildIntoView(el, false);
  21532. }
  21533. }
  21534. },
  21535. selectNext : function(){
  21536. var ct = this.store.getCount();
  21537. if(ct > 0){
  21538. if(this.selectedIndex == -1){
  21539. this.select(0);
  21540. }else if(this.selectedIndex < ct-1){
  21541. this.select(this.selectedIndex+1);
  21542. }
  21543. }
  21544. },
  21545. selectPrev : function(){
  21546. var ct = this.store.getCount();
  21547. if(ct > 0){
  21548. if(this.selectedIndex == -1){
  21549. this.select(0);
  21550. }else if(this.selectedIndex != 0){
  21551. this.select(this.selectedIndex-1);
  21552. }
  21553. }
  21554. },
  21555. onKeyUp : function(e){
  21556. if(this.editable !== false && !e.isSpecialKey()){
  21557. this.lastKey = e.getKey();
  21558. this.dqTask.delay(this.queryDelay);
  21559. }
  21560. },
  21561. validateBlur : function(){
  21562. return !this.list || !this.list.isVisible();
  21563. },
  21564. initQuery : function(){
  21565. this.doQuery(this.getRawValue());
  21566. },
  21567. doForce : function(){
  21568. if(this.el.dom.value.length > 0){
  21569. this.el.dom.value =
  21570. this.lastSelectionText === undefined ? '' : this.lastSelectionText;
  21571. this.applyEmptyText();
  21572. }
  21573. },
  21574. doQuery : function(q, forceAll){
  21575. if(q === undefined || q === null){
  21576. q = '';
  21577. }
  21578. var qe = {
  21579. query: q,
  21580. forceAll: forceAll,
  21581. combo: this,
  21582. cancel:false
  21583. };
  21584. if(this.fireEvent('beforequery', qe)===false || qe.cancel){
  21585. return false;
  21586. }
  21587. q = qe.query;
  21588. forceAll = qe.forceAll;
  21589. if(forceAll === true || (q.length >= this.minChars)){
  21590. if(this.lastQuery !== q){
  21591. this.lastQuery = q;
  21592. if(this.mode == 'local'){
  21593. this.selectedIndex = -1;
  21594. if(forceAll){
  21595. this.store.clearFilter();
  21596. }else{
  21597. this.store.filter(this.displayField, q);
  21598. }
  21599. this.onLoad();
  21600. }else{
  21601. this.store.baseParams[this.queryParam] = q;
  21602. this.store.load({
  21603. params: this.getParams(q)
  21604. });
  21605. this.expand();
  21606. }
  21607. }else{
  21608. this.selectedIndex = -1;
  21609. this.onLoad();
  21610. }
  21611. }
  21612. },
  21613. getParams : function(q){
  21614. var p = {};
  21615. if(this.pageSize){
  21616. p.start = 0;
  21617. p.limit = this.pageSize;
  21618. }
  21619. return p;
  21620. },
  21621. collapse : function(){
  21622. if(!this.isExpanded()){
  21623. return;
  21624. }
  21625. this.list.hide();
  21626. Ext.getDoc().un('mousewheel', this.collapseIf, this);
  21627. Ext.getDoc().un('mousedown', this.collapseIf, this);
  21628. this.fireEvent('collapse', this);
  21629. },
  21630. collapseIf : function(e){
  21631. if(!e.within(this.wrap) && !e.within(this.list)){
  21632. this.collapse();
  21633. }
  21634. },
  21635. expand : function(){
  21636. if(this.isExpanded() || !this.hasFocus){
  21637. return;
  21638. }
  21639. this.list.alignTo(this.wrap, this.listAlign);
  21640. this.list.show();
  21641. this.innerList.setOverflow('auto'); Ext.getDoc().on('mousewheel', this.collapseIf, this);
  21642. Ext.getDoc().on('mousedown', this.collapseIf, this);
  21643. this.fireEvent('expand', this);
  21644. },
  21645. onTriggerClick : function(){
  21646. if(this.disabled){
  21647. return;
  21648. }
  21649. if(this.isExpanded()){
  21650. this.collapse();
  21651. this.el.focus();
  21652. }else {
  21653. this.onFocus({});
  21654. if(this.triggerAction == 'all') {
  21655. this.doQuery(this.allQuery, true);
  21656. } else {
  21657. this.doQuery(this.getRawValue());
  21658. }
  21659. this.el.focus();
  21660. }
  21661. }
  21662. });
  21663. Ext.reg('combo', Ext.form.ComboBox);
  21664. Ext.form.Checkbox = Ext.extend(Ext.form.Field, {
  21665. focusClass : undefined,
  21666. fieldClass: "x-form-field",
  21667. checked: false,
  21668. defaultAutoCreate : { tag: "input", type: 'checkbox', autocomplete: "off"},
  21669. initComponent : function(){
  21670. Ext.form.Checkbox.superclass.initComponent.call(this);
  21671. this.addEvents(
  21672. 'check'
  21673. );
  21674. },
  21675. onResize : function(){
  21676. Ext.form.Checkbox.superclass.onResize.apply(this, arguments);
  21677. if(!this.boxLabel){
  21678. this.el.alignTo(this.wrap, 'c-c');
  21679. }
  21680. },
  21681. initEvents : function(){
  21682. Ext.form.Checkbox.superclass.initEvents.call(this);
  21683. this.el.on("click", this.onClick, this);
  21684. this.el.on("change", this.onClick, this);
  21685. },
  21686. getResizeEl : function(){
  21687. return this.wrap;
  21688. },
  21689. getPositionEl : function(){
  21690. return this.wrap;
  21691. },
  21692. markInvalid : Ext.emptyFn,
  21693. clearInvalid : Ext.emptyFn,
  21694. onRender : function(ct, position){
  21695. Ext.form.Checkbox.superclass.onRender.call(this, ct, position);
  21696. if(this.inputValue !== undefined){
  21697. this.el.dom.value = this.inputValue;
  21698. }
  21699. this.wrap = this.el.wrap({cls: "x-form-check-wrap"});
  21700. if(this.boxLabel){
  21701. this.wrap.createChild({tag: 'label', htmlFor: this.el.id, cls: 'x-form-cb-label', html: this.boxLabel});
  21702. }
  21703. if(this.checked){
  21704. this.setValue(true);
  21705. }else{
  21706. this.checked = this.el.dom.checked;
  21707. }
  21708. },
  21709. onDestroy : function(){
  21710. if(this.wrap){
  21711. this.wrap.remove();
  21712. }
  21713. Ext.form.Checkbox.superclass.onDestroy.call(this);
  21714. },
  21715. initValue : Ext.emptyFn,
  21716. getValue : function(){
  21717. if(this.rendered){
  21718. return this.el.dom.checked;
  21719. }
  21720. return false;
  21721. },
  21722. onClick : function(){
  21723. if(this.el.dom.checked != this.checked){
  21724. this.setValue(this.el.dom.checked);
  21725. }
  21726. },
  21727. setValue : function(v){
  21728. this.checked = (v === true || v === 'true' || v == '1' || String(v).toLowerCase() == 'on');
  21729. if(this.el && this.el.dom){
  21730. this.el.dom.checked = this.checked;
  21731. this.el.dom.defaultChecked = this.checked;
  21732. }
  21733. this.fireEvent("check", this, this.checked);
  21734. }
  21735. });
  21736. Ext.reg('checkbox', Ext.form.Checkbox);
  21737. Ext.form.Radio = Ext.extend(Ext.form.Checkbox, {
  21738. inputType: 'radio',
  21739. markInvalid : Ext.emptyFn,
  21740. clearInvalid : Ext.emptyFn,
  21741. getGroupValue : function(){
  21742. var p = this.el.up('form') || Ext.getBody();
  21743. var c = p.child('input[name='+this.el.dom.name+']:checked', true);
  21744. return c ? c.value : null;
  21745. },
  21746. onClick : function(){
  21747. if(this.el.dom.checked != this.checked){
  21748. var p = this.el.up('form') || Ext.getBody();
  21749. var els = p.select('input[name='+this.el.dom.name+']');
  21750. els.each(function(el){
  21751. if(el.dom.id == this.id){
  21752. this.setValue(true);
  21753. }else{
  21754. Ext.getCmp(el.dom.id).setValue(false);
  21755. }
  21756. }, this);
  21757. }
  21758. },
  21759. setValue : function(v){
  21760. if (typeof v == 'boolean') {
  21761. Ext.form.Radio.superclass.setValue.call(this, v);
  21762. } else {
  21763. var r = this.el.up('form').child('input[name='+this.el.dom.name+'][value='+v+']', true);
  21764. if (r){
  21765. r.checked = true;
  21766. };
  21767. }
  21768. }
  21769. });
  21770. Ext.reg('radio', Ext.form.Radio);
  21771. Ext.form.Hidden = Ext.extend(Ext.form.Field, {
  21772. inputType : 'hidden',
  21773. onRender : function(){
  21774. Ext.form.Hidden.superclass.onRender.apply(this, arguments);
  21775. },
  21776. initEvents : function(){
  21777. this.originalValue = this.getValue();
  21778. },
  21779. setSize : Ext.emptyFn,
  21780. setWidth : Ext.emptyFn,
  21781. setHeight : Ext.emptyFn,
  21782. setPosition : Ext.emptyFn,
  21783. setPagePosition : Ext.emptyFn,
  21784. markInvalid : Ext.emptyFn,
  21785. clearInvalid : Ext.emptyFn
  21786. });
  21787. Ext.reg('hidden', Ext.form.Hidden);
  21788. Ext.form.BasicForm = function(el, config){
  21789. Ext.apply(this, config);
  21790. this.items = new Ext.util.MixedCollection(false, function(o){
  21791. return o.id || (o.id = Ext.id());
  21792. });
  21793. this.addEvents(
  21794. 'beforeaction',
  21795. 'actionfailed',
  21796. 'actioncomplete'
  21797. );
  21798. if(el){
  21799. this.initEl(el);
  21800. }
  21801. Ext.form.BasicForm.superclass.constructor.call(this);
  21802. };
  21803. Ext.extend(Ext.form.BasicForm, Ext.util.Observable, {
  21804. timeout: 30,
  21805. activeAction : null,
  21806. trackResetOnLoad : false,
  21807. initEl : function(el){
  21808. this.el = Ext.get(el);
  21809. this.id = this.el.id || Ext.id();
  21810. if(!this.standardSubmit){
  21811. this.el.on('submit', this.onSubmit, this);
  21812. }
  21813. this.el.addClass('x-form');
  21814. },
  21815. getEl: function(){
  21816. return this.el;
  21817. },
  21818. onSubmit : function(e){
  21819. e.stopEvent();
  21820. },
  21821. destroy: function() {
  21822. this.items.each(function(f){
  21823. Ext.destroy(f);
  21824. });
  21825. if(this.el){
  21826. this.el.removeAllListeners();
  21827. this.el.remove();
  21828. }
  21829. this.purgeListeners();
  21830. },
  21831. isValid : function(){
  21832. var valid = true;
  21833. this.items.each(function(f){
  21834. if(!f.validate()){
  21835. valid = false;
  21836. }
  21837. });
  21838. return valid;
  21839. },
  21840. isDirty : function(){
  21841. var dirty = false;
  21842. this.items.each(function(f){
  21843. if(f.isDirty()){
  21844. dirty = true;
  21845. return false;
  21846. }
  21847. });
  21848. return dirty;
  21849. },
  21850. doAction : function(action, options){
  21851. if(typeof action == 'string'){
  21852. action = new Ext.form.Action.ACTION_TYPES[action](this, options);
  21853. }
  21854. if(this.fireEvent('beforeaction', this, action) !== false){
  21855. this.beforeAction(action);
  21856. action.run.defer(100, action);
  21857. }
  21858. return this;
  21859. },
  21860. submit : function(options){
  21861. if(this.standardSubmit){
  21862. var v = this.isValid();
  21863. if(v){
  21864. this.el.dom.submit();
  21865. }
  21866. return v;
  21867. }
  21868. this.doAction('submit', options);
  21869. return this;
  21870. },
  21871. load : function(options){
  21872. this.doAction('load', options);
  21873. return this;
  21874. },
  21875. updateRecord : function(record){
  21876. record.beginEdit();
  21877. var fs = record.fields;
  21878. fs.each(function(f){
  21879. var field = this.findField(f.name);
  21880. if(field){
  21881. record.set(f.name, field.getValue());
  21882. }
  21883. }, this);
  21884. record.endEdit();
  21885. return this;
  21886. },
  21887. loadRecord : function(record){
  21888. this.setValues(record.data);
  21889. return this;
  21890. },
  21891. beforeAction : function(action){
  21892. var o = action.options;
  21893. if(o.waitMsg){
  21894. if(this.waitMsgTarget === true){
  21895. this.el.mask(o.waitMsg, 'x-mask-loading');
  21896. }else if(this.waitMsgTarget){
  21897. this.waitMsgTarget = Ext.get(this.waitMsgTarget);
  21898. this.waitMsgTarget.mask(o.waitMsg, 'x-mask-loading');
  21899. }else{
  21900. Ext.MessageBox.wait(o.waitMsg, o.waitTitle || this.waitTitle || 'Please Wait...');
  21901. }
  21902. }
  21903. },
  21904. afterAction : function(action, success){
  21905. this.activeAction = null;
  21906. var o = action.options;
  21907. if(o.waitMsg){
  21908. if(this.waitMsgTarget === true){
  21909. this.el.unmask();
  21910. }else if(this.waitMsgTarget){
  21911. this.waitMsgTarget.unmask();
  21912. }else{
  21913. Ext.MessageBox.updateProgress(1);
  21914. Ext.MessageBox.hide();
  21915. }
  21916. }
  21917. if(success){
  21918. if(o.reset){
  21919. this.reset();
  21920. }
  21921. Ext.callback(o.success, o.scope, [this, action]);
  21922. this.fireEvent('actioncomplete', this, action);
  21923. }else{
  21924. Ext.callback(o.failure, o.scope, [this, action]);
  21925. this.fireEvent('actionfailed', this, action);
  21926. }
  21927. },
  21928. findField : function(id){
  21929. var field = this.items.get(id);
  21930. if(!field){
  21931. this.items.each(function(f){
  21932. if(f.isFormField && (f.dataIndex == id || f.id == id || f.getName() == id)){
  21933. field = f;
  21934. return false;
  21935. }
  21936. });
  21937. }
  21938. return field || null;
  21939. },
  21940. markInvalid : function(errors){
  21941. if(Ext.isArray(errors)){
  21942. for(var i = 0, len = errors.length; i < len; i++){
  21943. var fieldError = errors[i];
  21944. var f = this.findField(fieldError.id);
  21945. if(f){
  21946. f.markInvalid(fieldError.msg);
  21947. }
  21948. }
  21949. }else{
  21950. var field, id;
  21951. for(id in errors){
  21952. if(typeof errors[id] != 'function' && (field = this.findField(id))){
  21953. field.markInvalid(errors[id]);
  21954. }
  21955. }
  21956. }
  21957. return this;
  21958. },
  21959. setValues : function(values){
  21960. if(Ext.isArray(values)){ for(var i = 0, len = values.length; i < len; i++){
  21961. var v = values[i];
  21962. var f = this.findField(v.id);
  21963. if(f){
  21964. f.setValue(v.value);
  21965. if(this.trackResetOnLoad){
  21966. f.originalValue = f.getValue();
  21967. }
  21968. }
  21969. }
  21970. }else{ var field, id;
  21971. for(id in values){
  21972. if(typeof values[id] != 'function' && (field = this.findField(id))){
  21973. field.setValue(values[id]);
  21974. if(this.trackResetOnLoad){
  21975. field.originalValue = field.getValue();
  21976. }
  21977. }
  21978. }
  21979. }
  21980. return this;
  21981. },
  21982. getValues : function(asString){
  21983. var fs = Ext.lib.Ajax.serializeForm(this.el.dom);
  21984. if(asString === true){
  21985. return fs;
  21986. }
  21987. return Ext.urlDecode(fs);
  21988. },
  21989. clearInvalid : function(){
  21990. this.items.each(function(f){
  21991. f.clearInvalid();
  21992. });
  21993. return this;
  21994. },
  21995. reset : function(){
  21996. this.items.each(function(f){
  21997. f.reset();
  21998. });
  21999. return this;
  22000. },
  22001. add : function(){
  22002. this.items.addAll(Array.prototype.slice.call(arguments, 0));
  22003. return this;
  22004. },
  22005. remove : function(field){
  22006. this.items.remove(field);
  22007. return this;
  22008. },
  22009. render : function(){
  22010. this.items.each(function(f){
  22011. if(f.isFormField && !f.rendered && document.getElementById(f.id)){ f.applyToMarkup(f.id);
  22012. }
  22013. });
  22014. return this;
  22015. },
  22016. applyToFields : function(o){
  22017. this.items.each(function(f){
  22018. Ext.apply(f, o);
  22019. });
  22020. return this;
  22021. },
  22022. applyIfToFields : function(o){
  22023. this.items.each(function(f){
  22024. Ext.applyIf(f, o);
  22025. });
  22026. return this;
  22027. }
  22028. });
  22029. Ext.BasicForm = Ext.form.BasicForm;
  22030. Ext.FormPanel = Ext.extend(Ext.Panel, {
  22031. buttonAlign:'center',
  22032. minButtonWidth:75,
  22033. labelAlign:'left',
  22034. monitorValid : false,
  22035. monitorPoll : 200,
  22036. layout: 'form',
  22037. initComponent :function(){
  22038. this.form = this.createForm();
  22039. Ext.FormPanel.superclass.initComponent.call(this);
  22040. this.addEvents(
  22041. 'clientvalidation'
  22042. );
  22043. this.relayEvents(this.form, ['beforeaction', 'actionfailed', 'actioncomplete']);
  22044. },
  22045. createForm: function(){
  22046. delete this.initialConfig.listeners;
  22047. return new Ext.form.BasicForm(null, this.initialConfig);
  22048. },
  22049. initFields : function(){
  22050. var f = this.form;
  22051. var formPanel = this;
  22052. var fn = function(c){
  22053. if(c.doLayout && c != formPanel){
  22054. Ext.applyIf(c, {
  22055. labelAlign: c.ownerCt.labelAlign,
  22056. labelWidth: c.ownerCt.labelWidth,
  22057. itemCls: c.ownerCt.itemCls
  22058. });
  22059. if(c.items){
  22060. c.items.each(fn);
  22061. }
  22062. }else if(c.isFormField){
  22063. f.add(c);
  22064. }
  22065. }
  22066. this.items.each(fn);
  22067. },
  22068. getLayoutTarget : function(){
  22069. return this.form.el;
  22070. },
  22071. getForm : function(){
  22072. return this.form;
  22073. },
  22074. onRender : function(ct, position){
  22075. this.initFields();
  22076. Ext.FormPanel.superclass.onRender.call(this, ct, position);
  22077. var o = {
  22078. tag: 'form',
  22079. method : this.method || 'POST',
  22080. id : this.formId || Ext.id()
  22081. };
  22082. if(this.fileUpload) {
  22083. o.enctype = 'multipart/form-data';
  22084. }
  22085. this.form.initEl(this.body.createChild(o));
  22086. },
  22087. beforeDestroy: function(){
  22088. Ext.FormPanel.superclass.beforeDestroy.call(this);
  22089. Ext.destroy(this.form);
  22090. },
  22091. initEvents : function(){
  22092. Ext.FormPanel.superclass.initEvents.call(this);
  22093. this.items.on('remove', this.onRemove, this);
  22094. this.items.on('add', this.onAdd, this);
  22095. if(this.monitorValid){ this.startMonitoring();
  22096. }
  22097. },
  22098. onAdd : function(ct, c) {
  22099. if (c.isFormField) {
  22100. this.form.add(c);
  22101. }
  22102. },
  22103. onRemove : function(c) {
  22104. if (c.isFormField) {
  22105. Ext.destroy(c.container.up('.x-form-item'));
  22106. this.form.remove(c);
  22107. }
  22108. },
  22109. startMonitoring : function(){
  22110. if(!this.bound){
  22111. this.bound = true;
  22112. Ext.TaskMgr.start({
  22113. run : this.bindHandler,
  22114. interval : this.monitorPoll || 200,
  22115. scope: this
  22116. });
  22117. }
  22118. },
  22119. stopMonitoring : function(){
  22120. this.bound = false;
  22121. },
  22122. load : function(){
  22123. this.form.load.apply(this.form, arguments);
  22124. },
  22125. onDisable : function(){
  22126. Ext.FormPanel.superclass.onDisable.call(this);
  22127. if(this.form){
  22128. this.form.items.each(function(){
  22129. this.disable();
  22130. });
  22131. }
  22132. },
  22133. onEnable : function(){
  22134. Ext.FormPanel.superclass.onEnable.call(this);
  22135. if(this.form){
  22136. this.form.items.each(function(){
  22137. this.enable();
  22138. });
  22139. }
  22140. },
  22141. bindHandler : function(){
  22142. if(!this.bound){
  22143. return false; }
  22144. var valid = true;
  22145. this.form.items.each(function(f){
  22146. if(!f.isValid(true)){
  22147. valid = false;
  22148. return false;
  22149. }
  22150. });
  22151. if(this.buttons){
  22152. for(var i = 0, len = this.buttons.length; i < len; i++){
  22153. var btn = this.buttons[i];
  22154. if(btn.formBind === true && btn.disabled === valid){
  22155. btn.setDisabled(!valid);
  22156. }
  22157. }
  22158. }
  22159. this.fireEvent('clientvalidation', this, valid);
  22160. }
  22161. });
  22162. Ext.reg('form', Ext.FormPanel);
  22163. Ext.form.FormPanel = Ext.FormPanel;
  22164. Ext.form.FieldSet = Ext.extend(Ext.Panel, {
  22165. baseCls:'x-fieldset',
  22166. layout: 'form',
  22167. onRender : function(ct, position){
  22168. if(!this.el){
  22169. this.el = document.createElement('fieldset');
  22170. this.el.id = this.id;
  22171. if (this.title || this.header || this.checkboxToggle) {
  22172. this.el.appendChild(document.createElement('legend')).className = 'x-fieldset-header';
  22173. }
  22174. }
  22175. Ext.form.FieldSet.superclass.onRender.call(this, ct, position);
  22176. if(this.checkboxToggle){
  22177. var o = typeof this.checkboxToggle == 'object' ?
  22178. this.checkboxToggle :
  22179. {tag: 'input', type: 'checkbox', name: this.checkboxName || this.id+'-checkbox'};
  22180. this.checkbox = this.header.insertFirst(o);
  22181. this.checkbox.dom.checked = !this.collapsed;
  22182. this.checkbox.on('click', this.onCheckClick, this);
  22183. }
  22184. },
  22185. onCollapse : function(doAnim, animArg){
  22186. if(this.checkbox){
  22187. this.checkbox.dom.checked = false;
  22188. }
  22189. this.afterCollapse();
  22190. },
  22191. onExpand : function(doAnim, animArg){
  22192. if(this.checkbox){
  22193. this.checkbox.dom.checked = true;
  22194. }
  22195. this.afterExpand();
  22196. },
  22197. onCheckClick : function(){
  22198. this[this.checkbox.dom.checked ? 'expand' : 'collapse']();
  22199. }
  22200. });
  22201. Ext.reg('fieldset', Ext.form.FieldSet);
  22202. Ext.form.HtmlEditor = Ext.extend(Ext.form.Field, {
  22203. enableFormat : true,
  22204. enableFontSize : true,
  22205. enableColors : true,
  22206. enableAlignments : true,
  22207. enableLists : true,
  22208. enableSourceEdit : true,
  22209. enableLinks : true,
  22210. enableFont : true,
  22211. createLinkText : 'Please enter the URL for the link:',
  22212. defaultLinkValue : 'http:/'+'/',
  22213. fontFamilies : [
  22214. 'Arial',
  22215. 'Courier New',
  22216. 'Tahoma',
  22217. 'Times New Roman',
  22218. 'Verdana'
  22219. ],
  22220. defaultFont: 'tahoma',
  22221. validationEvent : false,
  22222. deferHeight: true,
  22223. initialized : false,
  22224. activated : false,
  22225. sourceEditMode : false,
  22226. onFocus : Ext.emptyFn,
  22227. iframePad:3,
  22228. hideMode:'offsets',
  22229. defaultAutoCreate : {
  22230. tag: "textarea",
  22231. style:"width:500px;height:300px;",
  22232. autocomplete: "off"
  22233. },
  22234. initComponent : function(){
  22235. this.addEvents(
  22236. 'initialize',
  22237. 'activate',
  22238. 'beforesync',
  22239. 'beforepush',
  22240. 'sync',
  22241. 'push',
  22242. 'editmodechange'
  22243. )
  22244. },
  22245. createFontOptions : function(){
  22246. var buf = [], fs = this.fontFamilies, ff, lc;
  22247. for(var i = 0, len = fs.length; i< len; i++){
  22248. ff = fs[i];
  22249. lc = ff.toLowerCase();
  22250. buf.push(
  22251. '<option value="',lc,'" style="font-family:',ff,';"',
  22252. (this.defaultFont == lc ? ' selected="true">' : '>'),
  22253. ff,
  22254. '</option>'
  22255. );
  22256. }
  22257. return buf.join('');
  22258. },
  22259. createToolbar : function(editor){
  22260. function btn(id, toggle, handler){
  22261. return {
  22262. itemId : id,
  22263. cls : 'x-btn-icon x-edit-'+id,
  22264. enableToggle:toggle !== false,
  22265. scope: editor,
  22266. handler:handler||editor.relayBtnCmd,
  22267. clickEvent:'mousedown',
  22268. tooltip: editor.buttonTips[id] || undefined,
  22269. tabIndex:-1
  22270. };
  22271. }
  22272. var tb = new Ext.Toolbar({
  22273. renderTo:this.wrap.dom.firstChild
  22274. });
  22275. tb.el.on('click', function(e){
  22276. e.preventDefault();
  22277. });
  22278. if(this.enableFont && !Ext.isSafari){
  22279. this.fontSelect = tb.el.createChild({
  22280. tag:'select',
  22281. cls:'x-font-select',
  22282. html: this.createFontOptions()
  22283. });
  22284. this.fontSelect.on('change', function(){
  22285. var font = this.fontSelect.dom.value;
  22286. this.relayCmd('fontname', font);
  22287. this.deferFocus();
  22288. }, this);
  22289. tb.add(
  22290. this.fontSelect.dom,
  22291. '-'
  22292. );
  22293. };
  22294. if(this.enableFormat){
  22295. tb.add(
  22296. btn('bold'),
  22297. btn('italic'),
  22298. btn('underline')
  22299. );
  22300. };
  22301. if(this.enableFontSize){
  22302. tb.add(
  22303. '-',
  22304. btn('increasefontsize', false, this.adjustFont),
  22305. btn('decreasefontsize', false, this.adjustFont)
  22306. );
  22307. };
  22308. if(this.enableColors){
  22309. tb.add(
  22310. '-', {
  22311. itemId:'forecolor',
  22312. cls:'x-btn-icon x-edit-forecolor',
  22313. clickEvent:'mousedown',
  22314. tooltip: editor.buttonTips['forecolor'] || undefined,
  22315. tabIndex:-1,
  22316. menu : new Ext.menu.ColorMenu({
  22317. allowReselect: true,
  22318. focus: Ext.emptyFn,
  22319. value:'000000',
  22320. plain:true,
  22321. selectHandler: function(cp, color){
  22322. this.execCmd('forecolor', Ext.isSafari || Ext.isIE ? '#'+color : color);
  22323. this.deferFocus();
  22324. },
  22325. scope: this,
  22326. clickEvent:'mousedown'
  22327. })
  22328. }, {
  22329. itemId:'backcolor',
  22330. cls:'x-btn-icon x-edit-backcolor',
  22331. clickEvent:'mousedown',
  22332. tooltip: editor.buttonTips['backcolor'] || undefined,
  22333. tabIndex:-1,
  22334. menu : new Ext.menu.ColorMenu({
  22335. focus: Ext.emptyFn,
  22336. value:'FFFFFF',
  22337. plain:true,
  22338. allowReselect: true,
  22339. selectHandler: function(cp, color){
  22340. if(Ext.isGecko){
  22341. this.execCmd('useCSS', false);
  22342. this.execCmd('hilitecolor', color);
  22343. this.execCmd('useCSS', true);
  22344. this.deferFocus();
  22345. }else{
  22346. this.execCmd(Ext.isOpera ? 'hilitecolor' : 'backcolor', Ext.isSafari || Ext.isIE ? '#'+color : color);
  22347. this.deferFocus();
  22348. }
  22349. },
  22350. scope:this,
  22351. clickEvent:'mousedown'
  22352. })
  22353. }
  22354. );
  22355. };
  22356. if(this.enableAlignments){
  22357. tb.add(
  22358. '-',
  22359. btn('justifyleft'),
  22360. btn('justifycenter'),
  22361. btn('justifyright')
  22362. );
  22363. };
  22364. if(!Ext.isSafari){
  22365. if(this.enableLinks){
  22366. tb.add(
  22367. '-',
  22368. btn('createlink', false, this.createLink)
  22369. );
  22370. };
  22371. if(this.enableLists){
  22372. tb.add(
  22373. '-',
  22374. btn('insertorderedlist'),
  22375. btn('insertunorderedlist')
  22376. );
  22377. }
  22378. if(this.enableSourceEdit){
  22379. tb.add(
  22380. '-',
  22381. btn('sourceedit', true, function(btn){
  22382. this.toggleSourceEdit(btn.pressed);
  22383. })
  22384. );
  22385. }
  22386. }
  22387. this.tb = tb;
  22388. },
  22389. getDocMarkup : function(){
  22390. return '<html><head><style type="text/css">body{border:0;margin:0;padding:3px;height:98%;cursor:text;}</style></head><body></body></html>';
  22391. },
  22392. getEditorBody : function(){
  22393. return this.doc.body || this.doc.documentElement;
  22394. },
  22395. onRender : function(ct, position){
  22396. Ext.form.HtmlEditor.superclass.onRender.call(this, ct, position);
  22397. this.el.dom.style.border = '0 none';
  22398. this.el.dom.setAttribute('tabIndex', -1);
  22399. this.el.addClass('x-hidden');
  22400. if(Ext.isIE){
  22401. this.el.applyStyles('margin-top:-1px;margin-bottom:-1px;')
  22402. }
  22403. this.wrap = this.el.wrap({
  22404. cls:'x-html-editor-wrap', cn:{cls:'x-html-editor-tb'}
  22405. });
  22406. this.createToolbar(this);
  22407. this.tb.items.each(function(item){
  22408. if(item.itemId != 'sourceedit'){
  22409. item.disable();
  22410. }
  22411. });
  22412. var iframe = document.createElement('iframe');
  22413. iframe.name = Ext.id();
  22414. iframe.frameBorder = 'no';
  22415. iframe.src=(Ext.SSL_SECURE_URL || "javascript:false");
  22416. this.wrap.dom.appendChild(iframe);
  22417. this.iframe = iframe;
  22418. if(Ext.isIE){
  22419. iframe.contentWindow.document.designMode = 'on';
  22420. this.doc = iframe.contentWindow.document;
  22421. this.win = iframe.contentWindow;
  22422. } else {
  22423. this.doc = (iframe.contentDocument || window.frames[iframe.name].document);
  22424. this.win = window.frames[iframe.name];
  22425. this.doc.designMode = 'on';
  22426. }
  22427. this.doc.open();
  22428. this.doc.write(this.getDocMarkup())
  22429. this.doc.close();
  22430. var task = {
  22431. run : function(){
  22432. if(this.doc.body || this.doc.readyState == 'complete'){
  22433. Ext.TaskMgr.stop(task);
  22434. this.doc.designMode="on";
  22435. this.initEditor.defer(10, this);
  22436. }
  22437. },
  22438. interval : 10,
  22439. duration:10000,
  22440. scope: this
  22441. };
  22442. Ext.TaskMgr.start(task);
  22443. if(!this.width){
  22444. this.setSize(this.el.getSize());
  22445. }
  22446. },
  22447. onResize : function(w, h){
  22448. Ext.form.HtmlEditor.superclass.onResize.apply(this, arguments);
  22449. if(this.el && this.iframe){
  22450. if(typeof w == 'number'){
  22451. var aw = w - this.wrap.getFrameWidth('lr');
  22452. this.el.setWidth(this.adjustWidth('textarea', aw));
  22453. this.iframe.style.width = aw + 'px';
  22454. }
  22455. if(typeof h == 'number'){
  22456. var ah = h - this.wrap.getFrameWidth('tb') - this.tb.el.getHeight();
  22457. this.el.setHeight(this.adjustWidth('textarea', ah));
  22458. this.iframe.style.height = ah + 'px';
  22459. if(this.doc){
  22460. this.getEditorBody().style.height = (ah - (this.iframePad*2)) + 'px';
  22461. }
  22462. }
  22463. }
  22464. },
  22465. toggleSourceEdit : function(sourceEditMode){
  22466. if(sourceEditMode === undefined){
  22467. sourceEditMode = !this.sourceEditMode;
  22468. }
  22469. this.sourceEditMode = sourceEditMode === true;
  22470. var btn = this.tb.items.get('sourceedit');
  22471. if(btn.pressed !== this.sourceEditMode){
  22472. btn.toggle(this.sourceEditMode);
  22473. return;
  22474. }
  22475. if(this.sourceEditMode){
  22476. this.tb.items.each(function(item){
  22477. if(item.itemId != 'sourceedit'){
  22478. item.disable();
  22479. }
  22480. });
  22481. this.syncValue();
  22482. this.iframe.className = 'x-hidden';
  22483. this.el.removeClass('x-hidden');
  22484. this.el.dom.removeAttribute('tabIndex');
  22485. this.el.focus();
  22486. }else{
  22487. if(this.initialized){
  22488. this.tb.items.each(function(item){
  22489. item.enable();
  22490. });
  22491. }
  22492. this.pushValue();
  22493. this.iframe.className = '';
  22494. this.el.addClass('x-hidden');
  22495. this.el.dom.setAttribute('tabIndex', -1);
  22496. this.deferFocus();
  22497. }
  22498. var lastSize = this.lastSize;
  22499. if(lastSize){
  22500. delete this.lastSize;
  22501. this.setSize(lastSize);
  22502. }
  22503. this.fireEvent('editmodechange', this, this.sourceEditMode);
  22504. },
  22505. createLink : function(){
  22506. var url = prompt(this.createLinkText, this.defaultLinkValue);
  22507. if(url && url != 'http:/'+'/'){
  22508. this.relayCmd('createlink', url);
  22509. }
  22510. },
  22511. adjustSize : Ext.BoxComponent.prototype.adjustSize,
  22512. getResizeEl : function(){
  22513. return this.wrap;
  22514. },
  22515. getPositionEl : function(){
  22516. return this.wrap;
  22517. },
  22518. initEvents : function(){
  22519. this.originalValue = this.getValue();
  22520. },
  22521. markInvalid : Ext.emptyFn,
  22522. clearInvalid : Ext.emptyFn,
  22523. setValue : function(v){
  22524. Ext.form.HtmlEditor.superclass.setValue.call(this, v);
  22525. this.pushValue();
  22526. },
  22527. cleanHtml : function(html){
  22528. html = String(html);
  22529. if(html.length > 5){
  22530. if(Ext.isSafari){
  22531. html = html.replace(/\sclass="(?:Apple-style-span|khtml-block-placeholder)"/gi, '');
  22532. }
  22533. }
  22534. if(html == '&nbsp;'){
  22535. html = '';
  22536. }
  22537. return html;
  22538. },
  22539. syncValue : function(){
  22540. if(this.initialized){
  22541. var bd = this.getEditorBody();
  22542. var html = bd.innerHTML;
  22543. if(Ext.isSafari){
  22544. var bs = bd.getAttribute('style');
  22545. var m = bs.match(/text-align:(.*?);/i);
  22546. if(m && m[1]){
  22547. html = '<div style="'+m[0]+'">' + html + '</div>';
  22548. }
  22549. }
  22550. html = this.cleanHtml(html);
  22551. if(this.fireEvent('beforesync', this, html) !== false){
  22552. this.el.dom.value = html;
  22553. this.fireEvent('sync', this, html);
  22554. }
  22555. }
  22556. },
  22557. pushValue : function(){
  22558. if(this.initialized){
  22559. var v = this.el.dom.value;
  22560. if(!this.activated && v.length < 1){
  22561. v = '&nbsp;';
  22562. }
  22563. if(this.fireEvent('beforepush', this, v) !== false){
  22564. this.getEditorBody().innerHTML = v;
  22565. this.fireEvent('push', this, v);
  22566. }
  22567. }
  22568. },
  22569. deferFocus : function(){
  22570. this.focus.defer(10, this);
  22571. },
  22572. focus : function(){
  22573. if(this.win && !this.sourceEditMode){
  22574. this.win.focus();
  22575. }else{
  22576. this.el.focus();
  22577. }
  22578. },
  22579. initEditor : function(){
  22580. var dbody = this.getEditorBody();
  22581. var ss = this.el.getStyles('font-size', 'font-family', 'background-image', 'background-repeat');
  22582. ss['background-attachment'] = 'fixed';
  22583. dbody.bgProperties = 'fixed';
  22584. Ext.DomHelper.applyStyles(dbody, ss);
  22585. Ext.EventManager.on(this.doc, {
  22586. 'mousedown': this.onEditorEvent,
  22587. 'dblclick': this.onEditorEvent,
  22588. 'click': this.onEditorEvent,
  22589. 'keyup': this.onEditorEvent,
  22590. buffer:100,
  22591. scope: this
  22592. });
  22593. if(Ext.isGecko){
  22594. Ext.EventManager.on(this.doc, 'keypress', this.applyCommand, this);
  22595. }
  22596. if(Ext.isIE || Ext.isSafari || Ext.isOpera){
  22597. Ext.EventManager.on(this.doc, 'keydown', this.fixKeys, this);
  22598. }
  22599. this.initialized = true;
  22600. this.fireEvent('initialize', this);
  22601. this.pushValue();
  22602. },
  22603. onDestroy : function(){
  22604. if(this.rendered){
  22605. this.tb.items.each(function(item){
  22606. if(item.menu){
  22607. item.menu.removeAll();
  22608. if(item.menu.el){
  22609. item.menu.el.destroy();
  22610. }
  22611. }
  22612. item.destroy();
  22613. });
  22614. this.wrap.dom.innerHTML = '';
  22615. this.wrap.remove();
  22616. }
  22617. },
  22618. onFirstFocus : function(){
  22619. this.activated = true;
  22620. this.tb.items.each(function(item){
  22621. item.enable();
  22622. });
  22623. if(Ext.isGecko){
  22624. this.win.focus();
  22625. var s = this.win.getSelection();
  22626. if(!s.focusNode || s.focusNode.nodeType != 3){
  22627. var r = s.getRangeAt(0);
  22628. r.selectNodeContents(this.getEditorBody());
  22629. r.collapse(true);
  22630. this.deferFocus();
  22631. }
  22632. try{
  22633. this.execCmd('useCSS', true);
  22634. this.execCmd('styleWithCSS', false);
  22635. }catch(e){}
  22636. }
  22637. this.fireEvent('activate', this);
  22638. },
  22639. adjustFont: function(btn){
  22640. var adjust = btn.itemId == 'increasefontsize' ? 1 : -1;
  22641. var v = parseInt(this.doc.queryCommandValue('FontSize') || 2, 10);
  22642. if(Ext.isSafari3 || Ext.isAir){
  22643. if(v <= 10){
  22644. v = 1 + adjust;
  22645. }else if(v <= 13){
  22646. v = 2 + adjust;
  22647. }else if(v <= 16){
  22648. v = 3 + adjust;
  22649. }else if(v <= 18){
  22650. v = 4 + adjust;
  22651. }else if(v <= 24){
  22652. v = 5 + adjust;
  22653. }else {
  22654. v = 6 + adjust;
  22655. }
  22656. v = v.constrain(1, 6);
  22657. }else{
  22658. if(Ext.isSafari){
  22659. adjust *= 2;
  22660. }
  22661. v = Math.max(1, v+adjust) + (Ext.isSafari ? 'px' : 0);
  22662. }
  22663. this.execCmd('FontSize', v);
  22664. },
  22665. onEditorEvent : function(e){
  22666. this.updateToolbar();
  22667. },
  22668. updateToolbar: function(){
  22669. if(!this.activated){
  22670. this.onFirstFocus();
  22671. return;
  22672. }
  22673. var btns = this.tb.items.map, doc = this.doc;
  22674. if(this.enableFont && !Ext.isSafari){
  22675. var name = (this.doc.queryCommandValue('FontName')||this.defaultFont).toLowerCase();
  22676. if(name != this.fontSelect.dom.value){
  22677. this.fontSelect.dom.value = name;
  22678. }
  22679. }
  22680. if(this.enableFormat){
  22681. btns.bold.toggle(doc.queryCommandState('bold'));
  22682. btns.italic.toggle(doc.queryCommandState('italic'));
  22683. btns.underline.toggle(doc.queryCommandState('underline'));
  22684. }
  22685. if(this.enableAlignments){
  22686. btns.justifyleft.toggle(doc.queryCommandState('justifyleft'));
  22687. btns.justifycenter.toggle(doc.queryCommandState('justifycenter'));
  22688. btns.justifyright.toggle(doc.queryCommandState('justifyright'));
  22689. }
  22690. if(!Ext.isSafari && this.enableLists){
  22691. btns.insertorderedlist.toggle(doc.queryCommandState('insertorderedlist'));
  22692. btns.insertunorderedlist.toggle(doc.queryCommandState('insertunorderedlist'));
  22693. }
  22694. Ext.menu.MenuMgr.hideAll();
  22695. this.syncValue();
  22696. },
  22697. relayBtnCmd : function(btn){
  22698. this.relayCmd(btn.itemId);
  22699. },
  22700. relayCmd : function(cmd, value){
  22701. this.win.focus();
  22702. this.execCmd(cmd, value);
  22703. this.updateToolbar();
  22704. this.deferFocus();
  22705. },
  22706. execCmd : function(cmd, value){
  22707. this.doc.execCommand(cmd, false, value === undefined ? null : value);
  22708. this.syncValue();
  22709. },
  22710. applyCommand : function(e){
  22711. if(e.ctrlKey){
  22712. var c = e.getCharCode(), cmd;
  22713. if(c > 0){
  22714. c = String.fromCharCode(c);
  22715. switch(c){
  22716. case 'b':
  22717. cmd = 'bold';
  22718. break;
  22719. case 'i':
  22720. cmd = 'italic';
  22721. break;
  22722. case 'u':
  22723. cmd = 'underline';
  22724. break;
  22725. }
  22726. if(cmd){
  22727. this.win.focus();
  22728. this.execCmd(cmd);
  22729. this.deferFocus();
  22730. e.preventDefault();
  22731. }
  22732. }
  22733. }
  22734. },
  22735. insertAtCursor : function(text){
  22736. if(!this.activated){
  22737. return;
  22738. }
  22739. if(Ext.isIE){
  22740. this.win.focus();
  22741. var r = this.doc.selection.createRange();
  22742. if(r){
  22743. r.collapse(true);
  22744. r.pasteHTML(text);
  22745. this.syncValue();
  22746. this.deferFocus();
  22747. }
  22748. }else if(Ext.isGecko || Ext.isOpera){
  22749. this.win.focus();
  22750. this.execCmd('InsertHTML', text);
  22751. this.deferFocus();
  22752. }else if(Ext.isSafari){
  22753. this.execCmd('InsertText', text);
  22754. this.deferFocus();
  22755. }
  22756. },
  22757. fixKeys : function(){
  22758. if(Ext.isIE){
  22759. return function(e){
  22760. var k = e.getKey(), r;
  22761. if(k == e.TAB){
  22762. e.stopEvent();
  22763. r = this.doc.selection.createRange();
  22764. if(r){
  22765. r.collapse(true);
  22766. r.pasteHTML('&nbsp;&nbsp;&nbsp;&nbsp;');
  22767. this.deferFocus();
  22768. }
  22769. }else if(k == e.ENTER){
  22770. r = this.doc.selection.createRange();
  22771. if(r){
  22772. var target = r.parentElement();
  22773. if(!target || target.tagName.toLowerCase() != 'li'){
  22774. e.stopEvent();
  22775. r.pasteHTML('<br />');
  22776. r.collapse(false);
  22777. r.select();
  22778. }
  22779. }
  22780. }
  22781. };
  22782. }else if(Ext.isOpera){
  22783. return function(e){
  22784. var k = e.getKey();
  22785. if(k == e.TAB){
  22786. e.stopEvent();
  22787. this.win.focus();
  22788. this.execCmd('InsertHTML','&nbsp;&nbsp;&nbsp;&nbsp;');
  22789. this.deferFocus();
  22790. }
  22791. };
  22792. }else if(Ext.isSafari){
  22793. return function(e){
  22794. var k = e.getKey();
  22795. if(k == e.TAB){
  22796. e.stopEvent();
  22797. this.execCmd('InsertText','\t');
  22798. this.deferFocus();
  22799. }
  22800. };
  22801. }
  22802. }(),
  22803. getToolbar : function(){
  22804. return this.tb;
  22805. },
  22806. buttonTips : {
  22807. bold : {
  22808. title: 'Bold (Ctrl+B)',
  22809. text: 'Make the selected text bold.',
  22810. cls: 'x-html-editor-tip'
  22811. },
  22812. italic : {
  22813. title: 'Italic (Ctrl+I)',
  22814. text: 'Make the selected text italic.',
  22815. cls: 'x-html-editor-tip'
  22816. },
  22817. underline : {
  22818. title: 'Underline (Ctrl+U)',
  22819. text: 'Underline the selected text.',
  22820. cls: 'x-html-editor-tip'
  22821. },
  22822. increasefontsize : {
  22823. title: 'Grow Text',
  22824. text: 'Increase the font size.',
  22825. cls: 'x-html-editor-tip'
  22826. },
  22827. decreasefontsize : {
  22828. title: 'Shrink Text',
  22829. text: 'Decrease the font size.',
  22830. cls: 'x-html-editor-tip'
  22831. },
  22832. backcolor : {
  22833. title: 'Text Highlight Color',
  22834. text: 'Change the background color of the selected text.',
  22835. cls: 'x-html-editor-tip'
  22836. },
  22837. forecolor : {
  22838. title: 'Font Color',
  22839. text: 'Change the color of the selected text.',
  22840. cls: 'x-html-editor-tip'
  22841. },
  22842. justifyleft : {
  22843. title: 'Align Text Left',
  22844. text: 'Align text to the left.',
  22845. cls: 'x-html-editor-tip'
  22846. },
  22847. justifycenter : {
  22848. title: 'Center Text',
  22849. text: 'Center text in the editor.',
  22850. cls: 'x-html-editor-tip'
  22851. },
  22852. justifyright : {
  22853. title: 'Align Text Right',
  22854. text: 'Align text to the right.',
  22855. cls: 'x-html-editor-tip'
  22856. },
  22857. insertunorderedlist : {
  22858. title: 'Bullet List',
  22859. text: 'Start a bulleted list.',
  22860. cls: 'x-html-editor-tip'
  22861. },
  22862. insertorderedlist : {
  22863. title: 'Numbered List',
  22864. text: 'Start a numbered list.',
  22865. cls: 'x-html-editor-tip'
  22866. },
  22867. createlink : {
  22868. title: 'Hyperlink',
  22869. text: 'Make the selected text a hyperlink.',
  22870. cls: 'x-html-editor-tip'
  22871. },
  22872. sourceedit : {
  22873. title: 'Source Edit',
  22874. text: 'Switch to source editing mode.',
  22875. cls: 'x-html-editor-tip'
  22876. }
  22877. }
  22878. });
  22879. Ext.reg('htmleditor', Ext.form.HtmlEditor);
  22880. Ext.form.TimeField = Ext.extend(Ext.form.ComboBox, {
  22881. minValue : null,
  22882. maxValue : null,
  22883. minText : "The time in this field must be equal to or after {0}",
  22884. maxText : "The time in this field must be equal to or before {0}",
  22885. invalidText : "{0} is not a valid time",
  22886. format : "g:i A",
  22887. altFormats : "g:ia|g:iA|g:i a|g:i A|h:i|g:i|H:i|ga|ha|gA|h a|g a|g A|gi|hi|gia|hia|g|H",
  22888. increment: 15,
  22889. mode: 'local',
  22890. triggerAction: 'all',
  22891. typeAhead: false,
  22892. initComponent : function(){
  22893. Ext.form.TimeField.superclass.initComponent.call(this);
  22894. if(typeof this.minValue == "string"){
  22895. this.minValue = this.parseDate(this.minValue);
  22896. }
  22897. if(typeof this.maxValue == "string"){
  22898. this.maxValue = this.parseDate(this.maxValue);
  22899. }
  22900. if(!this.store){
  22901. var min = this.parseDate(this.minValue);
  22902. if(!min){
  22903. min = new Date().clearTime();
  22904. }
  22905. var max = this.parseDate(this.maxValue);
  22906. if(!max){
  22907. max = new Date().clearTime().add('mi', (24 * 60) - 1);
  22908. }
  22909. var times = [];
  22910. while(min <= max){
  22911. times.push([min.dateFormat(this.format)]);
  22912. min = min.add('mi', this.increment);
  22913. }
  22914. this.store = new Ext.data.SimpleStore({
  22915. fields: ['text'],
  22916. data : times
  22917. });
  22918. this.displayField = 'text';
  22919. }
  22920. },
  22921. getValue : function(){
  22922. var v = Ext.form.TimeField.superclass.getValue.call(this);
  22923. return this.formatDate(this.parseDate(v)) || '';
  22924. },
  22925. setValue : function(value){
  22926. Ext.form.TimeField.superclass.setValue.call(this, this.formatDate(this.parseDate(value)));
  22927. },
  22928. validateValue : Ext.form.DateField.prototype.validateValue,
  22929. parseDate : Ext.form.DateField.prototype.parseDate,
  22930. formatDate : Ext.form.DateField.prototype.formatDate,
  22931. beforeBlur : function(){
  22932. var v = this.parseDate(this.getRawValue());
  22933. if(v){
  22934. this.setValue(v.dateFormat(this.format));
  22935. }
  22936. }
  22937. });
  22938. Ext.reg('timefield', Ext.form.TimeField);
  22939. Ext.form.Label = Ext.extend(Ext.BoxComponent, {
  22940. onRender : function(ct, position){
  22941. if(!this.el){
  22942. this.el = document.createElement('label');
  22943. this.el.innerHTML = this.text ? Ext.util.Format.htmlEncode(this.text) : (this.html || '');
  22944. if(this.forId){
  22945. this.el.setAttribute('htmlFor', this.forId);
  22946. }
  22947. }
  22948. Ext.form.Label.superclass.onRender.call(this, ct, position);
  22949. }
  22950. });
  22951. Ext.reg('label', Ext.form.Label);
  22952. Ext.form.Action = function(form, options){
  22953. this.form = form;
  22954. this.options = options || {};
  22955. };
  22956. Ext.form.Action.CLIENT_INVALID = 'client';
  22957. Ext.form.Action.SERVER_INVALID = 'server';
  22958. Ext.form.Action.CONNECT_FAILURE = 'connect';
  22959. Ext.form.Action.LOAD_FAILURE = 'load';
  22960. Ext.form.Action.prototype = {
  22961. type : 'default',
  22962. run : function(options){
  22963. },
  22964. success : function(response){
  22965. },
  22966. handleResponse : function(response){
  22967. },
  22968. failure : function(response){
  22969. this.response = response;
  22970. this.failureType = Ext.form.Action.CONNECT_FAILURE;
  22971. this.form.afterAction(this, false);
  22972. },
  22973. processResponse : function(response){
  22974. this.response = response;
  22975. if(!response.responseText){
  22976. return true;
  22977. }
  22978. this.result = this.handleResponse(response);
  22979. return this.result;
  22980. },
  22981. getUrl : function(appendParams){
  22982. var url = this.options.url || this.form.url || this.form.el.dom.action;
  22983. if(appendParams){
  22984. var p = this.getParams();
  22985. if(p){
  22986. url += (url.indexOf('?') != -1 ? '&' : '?') + p;
  22987. }
  22988. }
  22989. return url;
  22990. },
  22991. getMethod : function(){
  22992. return (this.options.method || this.form.method || this.form.el.dom.method || 'POST').toUpperCase();
  22993. },
  22994. getParams : function(){
  22995. var bp = this.form.baseParams;
  22996. var p = this.options.params;
  22997. if(p){
  22998. if(typeof p == "object"){
  22999. p = Ext.urlEncode(Ext.applyIf(p, bp));
  23000. }else if(typeof p == 'string' && bp){
  23001. p += '&' + Ext.urlEncode(bp);
  23002. }
  23003. }else if(bp){
  23004. p = Ext.urlEncode(bp);
  23005. }
  23006. return p;
  23007. },
  23008. createCallback : function(opts){
  23009. var opts = opts || {};
  23010. return {
  23011. success: this.success,
  23012. failure: this.failure,
  23013. scope: this,
  23014. timeout: (opts.timeout*1000) || (this.form.timeout*1000),
  23015. upload: this.form.fileUpload ? this.success : undefined
  23016. };
  23017. }
  23018. };
  23019. Ext.form.Action.Submit = function(form, options){
  23020. Ext.form.Action.Submit.superclass.constructor.call(this, form, options);
  23021. };
  23022. Ext.extend(Ext.form.Action.Submit, Ext.form.Action, {
  23023. type : 'submit',
  23024. run : function(){
  23025. var o = this.options;
  23026. var method = this.getMethod();
  23027. var isPost = method == 'POST';
  23028. if(o.clientValidation === false || this.form.isValid()){
  23029. Ext.Ajax.request(Ext.apply(this.createCallback(o), {
  23030. form:this.form.el.dom,
  23031. url:this.getUrl(!isPost),
  23032. method: method,
  23033. params:isPost ? this.getParams() : null,
  23034. isUpload: this.form.fileUpload
  23035. }));
  23036. }else if (o.clientValidation !== false){ this.failureType = Ext.form.Action.CLIENT_INVALID;
  23037. this.form.afterAction(this, false);
  23038. }
  23039. },
  23040. success : function(response){
  23041. var result = this.processResponse(response);
  23042. if(result === true || result.success){
  23043. this.form.afterAction(this, true);
  23044. return;
  23045. }
  23046. if(result.errors){
  23047. this.form.markInvalid(result.errors);
  23048. this.failureType = Ext.form.Action.SERVER_INVALID;
  23049. }
  23050. this.form.afterAction(this, false);
  23051. },
  23052. handleResponse : function(response){
  23053. if(this.form.errorReader){
  23054. var rs = this.form.errorReader.read(response);
  23055. var errors = [];
  23056. if(rs.records){
  23057. for(var i = 0, len = rs.records.length; i < len; i++) {
  23058. var r = rs.records[i];
  23059. errors[i] = r.data;
  23060. }
  23061. }
  23062. if(errors.length < 1){
  23063. errors = null;
  23064. }
  23065. return {
  23066. success : rs.success,
  23067. errors : errors
  23068. };
  23069. }
  23070. return Ext.decode(response.responseText);
  23071. }
  23072. });
  23073. Ext.form.Action.Load = function(form, options){
  23074. Ext.form.Action.Load.superclass.constructor.call(this, form, options);
  23075. this.reader = this.form.reader;
  23076. };
  23077. Ext.extend(Ext.form.Action.Load, Ext.form.Action, {
  23078. type : 'load',
  23079. run : function(){
  23080. Ext.Ajax.request(Ext.apply(
  23081. this.createCallback(this.options), {
  23082. method:this.getMethod(),
  23083. url:this.getUrl(false),
  23084. params:this.getParams()
  23085. }));
  23086. },
  23087. success : function(response){
  23088. var result = this.processResponse(response);
  23089. if(result === true || !result.success || !result.data){
  23090. this.failureType = Ext.form.Action.LOAD_FAILURE;
  23091. this.form.afterAction(this, false);
  23092. return;
  23093. }
  23094. this.form.clearInvalid();
  23095. this.form.setValues(result.data);
  23096. this.form.afterAction(this, true);
  23097. },
  23098. handleResponse : function(response){
  23099. if(this.form.reader){
  23100. var rs = this.form.reader.read(response);
  23101. var data = rs.records && rs.records[0] ? rs.records[0].data : null;
  23102. return {
  23103. success : rs.success,
  23104. data : data
  23105. };
  23106. }
  23107. return Ext.decode(response.responseText);
  23108. }
  23109. });
  23110. Ext.form.Action.ACTION_TYPES = {
  23111. 'load' : Ext.form.Action.Load,
  23112. 'submit' : Ext.form.Action.Submit
  23113. };
  23114. Ext.form.VTypes = function(){
  23115. var alpha = /^[a-zA-Z_]+$/;
  23116. var alphanum = /^[a-zA-Z0-9_]+$/;
  23117. var email = /^([\w]+)(.[\w]+)*@([\w-]+\.){1,5}([A-Za-z]){2,4}$/;
  23118. var url = /(((https?)|(ftp)):\/\/([\-\w]+\.)+\w{2,3}(\/[%\-\w]+(\.\w{2,})?)*(([\w\-\.\?\\\/+@&#;`~=%!]*)(\.\w{2,})?)*\/?)/i;
  23119. return {
  23120. 'email' : function(v){
  23121. return email.test(v);
  23122. },
  23123. 'emailText' : 'This field should be an e-mail address in the format "user@domain.com"',
  23124. 'emailMask' : /[a-z0-9_\.\-@]/i,
  23125. 'url' : function(v){
  23126. return url.test(v);
  23127. },
  23128. 'urlText' : 'This field should be a URL in the format "http:/'+'/www.domain.com"',
  23129. 'alpha' : function(v){
  23130. return alpha.test(v);
  23131. },
  23132. 'alphaText' : 'This field should only contain letters and _',
  23133. 'alphaMask' : /[a-z_]/i,
  23134. 'alphanum' : function(v){
  23135. return alphanum.test(v);
  23136. },
  23137. 'alphanumText' : 'This field should only contain letters, numbers and _',
  23138. 'alphanumMask' : /[a-z0-9_]/i
  23139. };
  23140. }();
  23141. Ext.grid.GridPanel = Ext.extend(Ext.Panel, {
  23142. ddText : "{0} selected row{1}",
  23143. minColumnWidth : 25,
  23144. trackMouseOver : true,
  23145. enableDragDrop : false,
  23146. enableColumnMove : true,
  23147. enableColumnHide : true,
  23148. enableHdMenu : true,
  23149. stripeRows : false,
  23150. autoExpandColumn : false,
  23151. autoExpandMin : 50,
  23152. autoExpandMax : 1000,
  23153. view : null,
  23154. loadMask : false,
  23155. rendered : false,
  23156. viewReady: false,
  23157. stateEvents: ["columnmove", "columnresize", "sortchange"],
  23158. initComponent : function(){
  23159. Ext.grid.GridPanel.superclass.initComponent.call(this);
  23160. this.autoScroll = false;
  23161. this.autoWidth = false;
  23162. if(Ext.isArray(this.columns)){
  23163. this.colModel = new Ext.grid.ColumnModel(this.columns);
  23164. delete this.columns;
  23165. }
  23166. if(this.ds){
  23167. this.store = this.ds;
  23168. delete this.ds;
  23169. }
  23170. if(this.cm){
  23171. this.colModel = this.cm;
  23172. delete this.cm;
  23173. }
  23174. if(this.sm){
  23175. this.selModel = this.sm;
  23176. delete this.sm;
  23177. }
  23178. this.store = Ext.StoreMgr.lookup(this.store);
  23179. this.addEvents(
  23180. "click",
  23181. "dblclick",
  23182. "contextmenu",
  23183. "mousedown",
  23184. "mouseup",
  23185. "mouseover",
  23186. "mouseout",
  23187. "keypress",
  23188. "keydown",
  23189. "cellmousedown",
  23190. "rowmousedown",
  23191. "headermousedown",
  23192. "cellclick",
  23193. "celldblclick",
  23194. "rowclick",
  23195. "rowdblclick",
  23196. "headerclick",
  23197. "headerdblclick",
  23198. "rowcontextmenu",
  23199. "cellcontextmenu",
  23200. "headercontextmenu",
  23201. "bodyscroll",
  23202. "columnresize",
  23203. "columnmove",
  23204. "sortchange"
  23205. );
  23206. },
  23207. onRender : function(ct, position){
  23208. Ext.grid.GridPanel.superclass.onRender.apply(this, arguments);
  23209. var c = this.body;
  23210. this.el.addClass('x-grid-panel');
  23211. var view = this.getView();
  23212. view.init(this);
  23213. c.on("mousedown", this.onMouseDown, this);
  23214. c.on("click", this.onClick, this);
  23215. c.on("dblclick", this.onDblClick, this);
  23216. c.on("contextmenu", this.onContextMenu, this);
  23217. c.on("keydown", this.onKeyDown, this);
  23218. this.relayEvents(c, ["mousedown","mouseup","mouseover","mouseout","keypress"]);
  23219. this.getSelectionModel().init(this);
  23220. this.view.render();
  23221. },
  23222. initEvents : function(){
  23223. Ext.grid.GridPanel.superclass.initEvents.call(this);
  23224. if(this.loadMask){
  23225. this.loadMask = new Ext.LoadMask(this.bwrap,
  23226. Ext.apply({store:this.store}, this.loadMask));
  23227. }
  23228. },
  23229. initStateEvents : function(){
  23230. Ext.grid.GridPanel.superclass.initStateEvents.call(this);
  23231. this.colModel.on('hiddenchange', this.saveState, this, {delay: 100});
  23232. },
  23233. applyState : function(state){
  23234. var cm = this.colModel;
  23235. var cs = state.columns;
  23236. if(cs){
  23237. for(var i = 0, len = cs.length; i < len; i++){
  23238. var s = cs[i];
  23239. var c = cm.getColumnById(s.id);
  23240. if(c){
  23241. c.hidden = s.hidden;
  23242. c.width = s.width;
  23243. var oldIndex = cm.getIndexById(s.id);
  23244. if(oldIndex != i){
  23245. cm.moveColumn(oldIndex, i);
  23246. }
  23247. }
  23248. }
  23249. }
  23250. if(state.sort){
  23251. this.store[this.store.remoteSort ? 'setDefaultSort' : 'sort'](state.sort.field, state.sort.direction);
  23252. }
  23253. },
  23254. getState : function(){
  23255. var o = {columns: []};
  23256. for(var i = 0, c; c = this.colModel.config[i]; i++){
  23257. o.columns[i] = {
  23258. id: c.id,
  23259. width: c.width
  23260. };
  23261. if(c.hidden){
  23262. o.columns[i].hidden = true;
  23263. }
  23264. }
  23265. var ss = this.store.getSortState();
  23266. if(ss){
  23267. o.sort = ss;
  23268. }
  23269. return o;
  23270. },
  23271. afterRender : function(){
  23272. Ext.grid.GridPanel.superclass.afterRender.call(this);
  23273. this.view.layout();
  23274. this.viewReady = true;
  23275. },
  23276. reconfigure : function(store, colModel){
  23277. if(this.loadMask){
  23278. this.loadMask.destroy();
  23279. this.loadMask = new Ext.LoadMask(this.bwrap,
  23280. Ext.apply({store:store}, this.initialConfig.loadMask));
  23281. }
  23282. this.view.bind(store, colModel);
  23283. this.store = store;
  23284. this.colModel = colModel;
  23285. if(this.rendered){
  23286. this.view.refresh(true);
  23287. }
  23288. },
  23289. onKeyDown : function(e){
  23290. this.fireEvent("keydown", e);
  23291. },
  23292. onDestroy : function(){
  23293. if(this.rendered){
  23294. if(this.loadMask){
  23295. this.loadMask.destroy();
  23296. }
  23297. var c = this.body;
  23298. c.removeAllListeners();
  23299. this.view.destroy();
  23300. c.update("");
  23301. }
  23302. this.colModel.purgeListeners();
  23303. Ext.grid.GridPanel.superclass.onDestroy.call(this);
  23304. },
  23305. processEvent : function(name, e){
  23306. this.fireEvent(name, e);
  23307. var t = e.getTarget();
  23308. var v = this.view;
  23309. var header = v.findHeaderIndex(t);
  23310. if(header !== false){
  23311. this.fireEvent("header" + name, this, header, e);
  23312. }else{
  23313. var row = v.findRowIndex(t);
  23314. var cell = v.findCellIndex(t);
  23315. if(row !== false){
  23316. this.fireEvent("row" + name, this, row, e);
  23317. if(cell !== false){
  23318. this.fireEvent("cell" + name, this, row, cell, e);
  23319. }
  23320. }
  23321. }
  23322. },
  23323. onClick : function(e){
  23324. this.processEvent("click", e);
  23325. },
  23326. onMouseDown : function(e){
  23327. this.processEvent("mousedown", e);
  23328. },
  23329. onContextMenu : function(e, t){
  23330. this.processEvent("contextmenu", e);
  23331. },
  23332. onDblClick : function(e){
  23333. this.processEvent("dblclick", e);
  23334. },
  23335. walkCells : function(row, col, step, fn, scope){
  23336. var cm = this.colModel, clen = cm.getColumnCount();
  23337. var ds = this.store, rlen = ds.getCount(), first = true;
  23338. if(step < 0){
  23339. if(col < 0){
  23340. row--;
  23341. first = false;
  23342. }
  23343. while(row >= 0){
  23344. if(!first){
  23345. col = clen-1;
  23346. }
  23347. first = false;
  23348. while(col >= 0){
  23349. if(fn.call(scope || this, row, col, cm) === true){
  23350. return [row, col];
  23351. }
  23352. col--;
  23353. }
  23354. row--;
  23355. }
  23356. } else {
  23357. if(col >= clen){
  23358. row++;
  23359. first = false;
  23360. }
  23361. while(row < rlen){
  23362. if(!first){
  23363. col = 0;
  23364. }
  23365. first = false;
  23366. while(col < clen){
  23367. if(fn.call(scope || this, row, col, cm) === true){
  23368. return [row, col];
  23369. }
  23370. col++;
  23371. }
  23372. row++;
  23373. }
  23374. }
  23375. return null;
  23376. },
  23377. getSelections : function(){
  23378. return this.selModel.getSelections();
  23379. },
  23380. onResize : function(){
  23381. Ext.grid.GridPanel.superclass.onResize.apply(this, arguments);
  23382. if(this.viewReady){
  23383. this.view.layout();
  23384. }
  23385. },
  23386. getGridEl : function(){
  23387. return this.body;
  23388. },
  23389. stopEditing : function(){},
  23390. getSelectionModel : function(){
  23391. if(!this.selModel){
  23392. this.selModel = new Ext.grid.RowSelectionModel(
  23393. this.disableSelection ? {selectRow: Ext.emptyFn} : null);
  23394. }
  23395. return this.selModel;
  23396. },
  23397. getStore : function(){
  23398. return this.store;
  23399. },
  23400. getColumnModel : function(){
  23401. return this.colModel;
  23402. },
  23403. getView : function(){
  23404. if(!this.view){
  23405. this.view = new Ext.grid.GridView(this.viewConfig);
  23406. }
  23407. return this.view;
  23408. },
  23409. getDragDropText : function(){
  23410. var count = this.selModel.getCount();
  23411. return String.format(this.ddText, count, count == 1 ? '' : 's');
  23412. }
  23413. });
  23414. Ext.reg('grid', Ext.grid.GridPanel);
  23415. Ext.grid.GridView = function(config){
  23416. Ext.apply(this, config);
  23417. this.addEvents(
  23418. "beforerowremoved",
  23419. "beforerowsinserted",
  23420. "beforerefresh",
  23421. "rowremoved",
  23422. "rowsinserted",
  23423. "rowupdated",
  23424. "refresh"
  23425. );
  23426. Ext.grid.GridView.superclass.constructor.call(this);
  23427. };
  23428. Ext.extend(Ext.grid.GridView, Ext.util.Observable, {
  23429. scrollOffset: 19,
  23430. autoFill: false,
  23431. forceFit: false,
  23432. sortClasses : ["sort-asc", "sort-desc"],
  23433. sortAscText : "Sort Ascending",
  23434. sortDescText : "Sort Descending",
  23435. columnsText : "Columns",
  23436. borderWidth: 2,
  23437. initTemplates : function(){
  23438. var ts = this.templates || {};
  23439. if(!ts.master){
  23440. ts.master = new Ext.Template(
  23441. '<div class="x-grid3" hidefocus="true">',
  23442. '<div class="x-grid3-viewport">',
  23443. '<div class="x-grid3-header"><div class="x-grid3-header-inner"><div class="x-grid3-header-offset">{header}</div></div><div class="x-clear"></div></div>',
  23444. '<div class="x-grid3-scroller"><div class="x-grid3-body">{body}</div><a href="#" class="x-grid3-focus" tabIndex="-1"></a></div>',
  23445. "</div>",
  23446. '<div class="x-grid3-resize-marker">&#160;</div>',
  23447. '<div class="x-grid3-resize-proxy">&#160;</div>',
  23448. "</div>"
  23449. );
  23450. }
  23451. if(!ts.header){
  23452. ts.header = new Ext.Template(
  23453. '<table border="0" cellspacing="0" cellpadding="0" style="{tstyle}">',
  23454. '<thead><tr class="x-grid3-hd-row">{cells}</tr></thead>',
  23455. "</table>"
  23456. );
  23457. }
  23458. if(!ts.hcell){
  23459. ts.hcell = new Ext.Template(
  23460. '<td class="x-grid3-hd x-grid3-cell x-grid3-td-{id}" style="{style}"><div {tooltip} {attr} class="x-grid3-hd-inner x-grid3-hd-{id}" unselectable="on" style="{istyle}">', this.grid.enableHdMenu ? '<a class="x-grid3-hd-btn" href="#"></a>' : '',
  23461. '{value}<img class="x-grid3-sort-icon" src="', Ext.BLANK_IMAGE_URL, '" />',
  23462. "</div></td>"
  23463. );
  23464. }
  23465. if(!ts.body){
  23466. ts.body = new Ext.Template('{rows}');
  23467. }
  23468. if(!ts.row){
  23469. ts.row = new Ext.Template(
  23470. '<div class="x-grid3-row {alt}" style="{tstyle}"><table class="x-grid3-row-table" border="0" cellspacing="0" cellpadding="0" style="{tstyle}">',
  23471. '<tbody><tr>{cells}</tr>',
  23472. (this.enableRowBody ? '<tr class="x-grid3-row-body-tr" style="{bodyStyle}"><td colspan="{cols}" class="x-grid3-body-cell" tabIndex="0" hidefocus="on"><div class="x-grid3-row-body">{body}</div></td></tr>' : ''),
  23473. '</tbody></table></div>'
  23474. );
  23475. }
  23476. if(!ts.cell){
  23477. ts.cell = new Ext.Template(
  23478. '<td class="x-grid3-col x-grid3-cell x-grid3-td-{id} {css}" style="{style}" tabIndex="0" {cellAttr}>',
  23479. '<div class="x-grid3-cell-inner x-grid3-col-{id}" unselectable="on" {attr}>{value}</div>',
  23480. "</td>"
  23481. );
  23482. }
  23483. for(var k in ts){
  23484. var t = ts[k];
  23485. if(t && typeof t.compile == 'function' && !t.compiled){
  23486. t.disableFormats = true;
  23487. t.compile();
  23488. }
  23489. }
  23490. this.templates = ts;
  23491. this.tdClass = 'x-grid3-cell';
  23492. this.cellSelector = 'td.x-grid3-cell';
  23493. this.hdCls = 'x-grid3-hd';
  23494. this.rowSelector = 'div.x-grid3-row';
  23495. this.colRe = new RegExp("x-grid3-td-([^\\s]+)", "");
  23496. },
  23497. fly : function(el){
  23498. if(!this._flyweight){
  23499. this._flyweight = new Ext.Element.Flyweight(document.body);
  23500. }
  23501. this._flyweight.dom = el;
  23502. return this._flyweight;
  23503. },
  23504. getEditorParent : function(ed){
  23505. return this.scroller.dom;
  23506. },
  23507. initElements : function(){
  23508. var E = Ext.Element;
  23509. var el = this.grid.getGridEl().dom.firstChild;
  23510. var cs = el.childNodes;
  23511. this.el = new E(el);
  23512. this.mainWrap = new E(cs[0]);
  23513. this.mainHd = new E(this.mainWrap.dom.firstChild);
  23514. if(this.grid.hideHeaders){
  23515. this.mainHd.setDisplayed(false);
  23516. }
  23517. this.innerHd = this.mainHd.dom.firstChild;
  23518. this.scroller = new E(this.mainWrap.dom.childNodes[1]);
  23519. if(this.forceFit){
  23520. this.scroller.setStyle('overflow-x', 'hidden');
  23521. }
  23522. this.mainBody = new E(this.scroller.dom.firstChild);
  23523. this.focusEl = new E(this.scroller.dom.childNodes[1]);
  23524. this.focusEl.swallowEvent("click", true);
  23525. this.resizeMarker = new E(cs[1]);
  23526. this.resizeProxy = new E(cs[2]);
  23527. },
  23528. getRows : function(){
  23529. return this.hasRows() ? this.mainBody.dom.childNodes : [];
  23530. },
  23531. findCell : function(el){
  23532. if(!el){
  23533. return false;
  23534. }
  23535. return this.fly(el).findParent(this.cellSelector, 3);
  23536. },
  23537. findCellIndex : function(el, requiredCls){
  23538. var cell = this.findCell(el);
  23539. if(cell && (!requiredCls || this.fly(cell).hasClass(requiredCls))){
  23540. return this.getCellIndex(cell);
  23541. }
  23542. return false;
  23543. },
  23544. getCellIndex : function(el){
  23545. if(el){
  23546. var m = el.className.match(this.colRe);
  23547. if(m && m[1]){
  23548. return this.cm.getIndexById(m[1]);
  23549. }
  23550. }
  23551. return false;
  23552. },
  23553. findHeaderCell : function(el){
  23554. var cell = this.findCell(el);
  23555. return cell && this.fly(cell).hasClass(this.hdCls) ? cell : null;
  23556. },
  23557. findHeaderIndex : function(el){
  23558. return this.findCellIndex(el, this.hdCls);
  23559. },
  23560. findRow : function(el){
  23561. if(!el){
  23562. return false;
  23563. }
  23564. return this.fly(el).findParent(this.rowSelector, 10);
  23565. },
  23566. findRowIndex : function(el){
  23567. var r = this.findRow(el);
  23568. return r ? r.rowIndex : false;
  23569. },
  23570. getRow : function(row){
  23571. return this.getRows()[row];
  23572. },
  23573. getCell : function(row, col){
  23574. return this.getRow(row).getElementsByTagName('td')[col];
  23575. },
  23576. getHeaderCell : function(index){
  23577. return this.mainHd.dom.getElementsByTagName('td')[index];
  23578. },
  23579. addRowClass : function(row, cls){
  23580. var r = this.getRow(row);
  23581. if(r){
  23582. this.fly(r).addClass(cls);
  23583. }
  23584. },
  23585. removeRowClass : function(row, cls){
  23586. var r = this.getRow(row);
  23587. if(r){
  23588. this.fly(r).removeClass(cls);
  23589. }
  23590. },
  23591. removeRow : function(row){
  23592. Ext.removeNode(this.getRow(row));
  23593. },
  23594. removeRows : function(firstRow, lastRow){
  23595. var bd = this.mainBody.dom;
  23596. for(var rowIndex = firstRow; rowIndex <= lastRow; rowIndex++){
  23597. Ext.removeNode(bd.childNodes[firstRow]);
  23598. }
  23599. },
  23600. getScrollState : function(){
  23601. var sb = this.scroller.dom;
  23602. return {left: sb.scrollLeft, top: sb.scrollTop};
  23603. },
  23604. restoreScroll : function(state){
  23605. var sb = this.scroller.dom;
  23606. sb.scrollLeft = state.left;
  23607. sb.scrollTop = state.top;
  23608. },
  23609. scrollToTop : function(){
  23610. this.scroller.dom.scrollTop = 0;
  23611. this.scroller.dom.scrollLeft = 0;
  23612. },
  23613. syncScroll : function(){
  23614. this.syncHeaderScroll();
  23615. var mb = this.scroller.dom;
  23616. this.grid.fireEvent("bodyscroll", mb.scrollLeft, mb.scrollTop);
  23617. },
  23618. syncHeaderScroll : function(){
  23619. var mb = this.scroller.dom;
  23620. this.innerHd.scrollLeft = mb.scrollLeft;
  23621. this.innerHd.scrollLeft = mb.scrollLeft; },
  23622. updateSortIcon : function(col, dir){
  23623. var sc = this.sortClasses;
  23624. var hds = this.mainHd.select('td').removeClass(sc);
  23625. hds.item(col).addClass(sc[dir == "DESC" ? 1 : 0]);
  23626. },
  23627. updateAllColumnWidths : function(){
  23628. var tw = this.getTotalWidth();
  23629. var clen = this.cm.getColumnCount();
  23630. var ws = [];
  23631. for(var i = 0; i < clen; i++){
  23632. ws[i] = this.getColumnWidth(i);
  23633. }
  23634. this.innerHd.firstChild.firstChild.style.width = tw;
  23635. for(var i = 0; i < clen; i++){
  23636. var hd = this.getHeaderCell(i);
  23637. hd.style.width = ws[i];
  23638. }
  23639. var ns = this.getRows();
  23640. for(var i = 0, len = ns.length; i < len; i++){
  23641. ns[i].style.width = tw;
  23642. ns[i].firstChild.style.width = tw;
  23643. var row = ns[i].firstChild.rows[0];
  23644. for(var j = 0; j < clen; j++){
  23645. row.childNodes[j].style.width = ws[j];
  23646. }
  23647. }
  23648. this.onAllColumnWidthsUpdated(ws, tw);
  23649. },
  23650. updateColumnWidth : function(col, width){
  23651. var w = this.getColumnWidth(col);
  23652. var tw = this.getTotalWidth();
  23653. this.innerHd.firstChild.firstChild.style.width = tw;
  23654. var hd = this.getHeaderCell(col);
  23655. hd.style.width = w;
  23656. var ns = this.getRows();
  23657. for(var i = 0, len = ns.length; i < len; i++){
  23658. ns[i].style.width = tw;
  23659. ns[i].firstChild.style.width = tw;
  23660. ns[i].firstChild.rows[0].childNodes[col].style.width = w;
  23661. }
  23662. this.onColumnWidthUpdated(col, w, tw);
  23663. },
  23664. updateColumnHidden : function(col, hidden){
  23665. var tw = this.getTotalWidth();
  23666. this.innerHd.firstChild.firstChild.style.width = tw;
  23667. var display = hidden ? 'none' : '';
  23668. var hd = this.getHeaderCell(col);
  23669. hd.style.display = display;
  23670. var ns = this.getRows();
  23671. for(var i = 0, len = ns.length; i < len; i++){
  23672. ns[i].style.width = tw;
  23673. ns[i].firstChild.style.width = tw;
  23674. ns[i].firstChild.rows[0].childNodes[col].style.display = display;
  23675. }
  23676. this.onColumnHiddenUpdated(col, hidden, tw);
  23677. delete this.lastViewWidth; this.layout();
  23678. },
  23679. doRender : function(cs, rs, ds, startRow, colCount, stripe){
  23680. var ts = this.templates, ct = ts.cell, rt = ts.row, last = colCount-1;
  23681. var tstyle = 'width:'+this.getTotalWidth()+';';
  23682. var buf = [], cb, c, p = {}, rp = {tstyle: tstyle}, r;
  23683. for(var j = 0, len = rs.length; j < len; j++){
  23684. r = rs[j]; cb = [];
  23685. var rowIndex = (j+startRow);
  23686. for(var i = 0; i < colCount; i++){
  23687. c = cs[i];
  23688. p.id = c.id;
  23689. p.css = i == 0 ? 'x-grid3-cell-first ' : (i == last ? 'x-grid3-cell-last ' : '');
  23690. p.attr = p.cellAttr = "";
  23691. p.value = c.renderer(r.data[c.name], p, r, rowIndex, i, ds);
  23692. p.style = c.style;
  23693. if(p.value == undefined || p.value === "") p.value = "&#160;";
  23694. if(r.dirty && typeof r.modified[c.name] !== 'undefined'){
  23695. p.css += ' x-grid3-dirty-cell';
  23696. }
  23697. cb[cb.length] = ct.apply(p);
  23698. }
  23699. var alt = [];
  23700. if(stripe && ((rowIndex+1) % 2 == 0)){
  23701. alt[0] = "x-grid3-row-alt";
  23702. }
  23703. if(r.dirty){
  23704. alt[1] = " x-grid3-dirty-row";
  23705. }
  23706. rp.cols = colCount;
  23707. if(this.getRowClass){
  23708. alt[2] = this.getRowClass(r, rowIndex, rp, ds);
  23709. }
  23710. rp.alt = alt.join(" ");
  23711. rp.cells = cb.join("");
  23712. buf[buf.length] = rt.apply(rp);
  23713. }
  23714. return buf.join("");
  23715. },
  23716. processRows : function(startRow, skipStripe){
  23717. if(this.ds.getCount() < 1){
  23718. return;
  23719. }
  23720. skipStripe = skipStripe || !this.grid.stripeRows;
  23721. startRow = startRow || 0;
  23722. var rows = this.getRows();
  23723. var cls = ' x-grid3-row-alt ';
  23724. for(var i = startRow, len = rows.length; i < len; i++){
  23725. var row = rows[i];
  23726. row.rowIndex = i;
  23727. if(!skipStripe){
  23728. var isAlt = ((i+1) % 2 == 0);
  23729. var hasAlt = (' '+row.className + ' ').indexOf(cls) != -1;
  23730. if(isAlt == hasAlt){
  23731. continue;
  23732. }
  23733. if(isAlt){
  23734. row.className += " x-grid3-row-alt";
  23735. }else{
  23736. row.className = row.className.replace("x-grid3-row-alt", "");
  23737. }
  23738. }
  23739. }
  23740. },
  23741. renderUI : function(){
  23742. var header = this.renderHeaders();
  23743. var body = this.templates.body.apply({rows:''});
  23744. var html = this.templates.master.apply({
  23745. body: body,
  23746. header: header
  23747. });
  23748. var g = this.grid;
  23749. g.getGridEl().dom.innerHTML = html;
  23750. this.initElements();
  23751. this.mainBody.dom.innerHTML = this.renderRows();
  23752. this.processRows(0, true);
  23753. Ext.fly(this.innerHd).on("click", this.handleHdDown, this);
  23754. this.mainHd.on("mouseover", this.handleHdOver, this);
  23755. this.mainHd.on("mouseout", this.handleHdOut, this);
  23756. this.mainHd.on("mousemove", this.handleHdMove, this);
  23757. this.scroller.on('scroll', this.syncScroll, this);
  23758. if(g.enableColumnResize !== false){
  23759. this.splitone = new Ext.grid.GridView.SplitDragZone(g, this.mainHd.dom);
  23760. }
  23761. if(g.enableColumnMove){
  23762. this.columnDrag = new Ext.grid.GridView.ColumnDragZone(g, this.innerHd);
  23763. this.columnDrop = new Ext.grid.HeaderDropZone(g, this.mainHd.dom);
  23764. }
  23765. if(g.enableHdMenu !== false){
  23766. if(g.enableColumnHide !== false){
  23767. this.colMenu = new Ext.menu.Menu({id:g.id + "-hcols-menu"});
  23768. this.colMenu.on("beforeshow", this.beforeColMenuShow, this);
  23769. this.colMenu.on("itemclick", this.handleHdMenuClick, this);
  23770. }
  23771. this.hmenu = new Ext.menu.Menu({id: g.id + "-hctx"});
  23772. this.hmenu.add(
  23773. {id:"asc", text: this.sortAscText, cls: "xg-hmenu-sort-asc"},
  23774. {id:"desc", text: this.sortDescText, cls: "xg-hmenu-sort-desc"}
  23775. );
  23776. if(g.enableColumnHide !== false){
  23777. this.hmenu.add('-',
  23778. {id:"columns", text: this.columnsText, menu: this.colMenu, iconCls: 'x-cols-icon'}
  23779. );
  23780. }
  23781. this.hmenu.on("itemclick", this.handleHdMenuClick, this);
  23782. }
  23783. if(g.enableDragDrop || g.enableDrag){
  23784. var dd = new Ext.grid.GridDragZone(g, {
  23785. ddGroup : g.ddGroup || 'GridDD'
  23786. });
  23787. }
  23788. this.updateHeaderSortState();
  23789. },
  23790. layout : function(){
  23791. if(!this.mainBody){
  23792. return; }
  23793. var g = this.grid;
  23794. var c = g.getGridEl(), cm = this.cm,
  23795. expandCol = g.autoExpandColumn,
  23796. gv = this;
  23797. var csize = c.getSize(true);
  23798. var vw = csize.width;
  23799. if(vw < 20 || csize.height < 20){ return;
  23800. }
  23801. if(g.autoHeight){
  23802. this.scroller.dom.style.overflow = 'visible';
  23803. }else{
  23804. this.el.setSize(csize.width, csize.height);
  23805. var hdHeight = this.mainHd.getHeight();
  23806. var vh = csize.height - (hdHeight);
  23807. this.scroller.setSize(vw, vh);
  23808. if(this.innerHd){
  23809. this.innerHd.style.width = (vw)+'px';
  23810. }
  23811. }
  23812. if(this.forceFit){
  23813. if(this.lastViewWidth != vw){
  23814. this.fitColumns(false, false);
  23815. this.lastViewWidth = vw;
  23816. }
  23817. }else {
  23818. this.autoExpand();
  23819. this.syncHeaderScroll();
  23820. }
  23821. this.onLayout(vw, vh);
  23822. },
  23823. onLayout : function(vw, vh){
  23824. },
  23825. onColumnWidthUpdated : function(col, w, tw){
  23826. },
  23827. onAllColumnWidthsUpdated : function(ws, tw){
  23828. },
  23829. onColumnHiddenUpdated : function(col, hidden, tw){
  23830. },
  23831. updateColumnText : function(col, text){
  23832. },
  23833. afterMove : function(colIndex){
  23834. },
  23835. init: function(grid){
  23836. this.grid = grid;
  23837. this.initTemplates();
  23838. this.initData(grid.store, grid.colModel);
  23839. this.initUI(grid);
  23840. },
  23841. getColumnId : function(index){
  23842. return this.cm.getColumnId(index);
  23843. },
  23844. renderHeaders : function(){
  23845. var cm = this.cm, ts = this.templates;
  23846. var ct = ts.hcell;
  23847. var cb = [], sb = [], p = {};
  23848. for(var i = 0, len = cm.getColumnCount(); i < len; i++){
  23849. p.id = cm.getColumnId(i);
  23850. p.value = cm.getColumnHeader(i) || "";
  23851. p.style = this.getColumnStyle(i, true);
  23852. p.tooltip = this.getColumnTooltip(i);
  23853. if(cm.config[i].align == 'right'){
  23854. p.istyle = 'padding-right:16px';
  23855. } else {
  23856. delete p.istyle;
  23857. }
  23858. cb[cb.length] = ct.apply(p);
  23859. }
  23860. return ts.header.apply({cells: cb.join(""), tstyle:'width:'+this.getTotalWidth()+';'});
  23861. },
  23862. getColumnTooltip : function(i){
  23863. var tt = this.cm.getColumnTooltip(i);
  23864. if(tt){
  23865. if(Ext.QuickTips.isEnabled()){
  23866. return 'ext:qtip="'+tt+'"';
  23867. }else{
  23868. return 'title="'+tt+'"';
  23869. }
  23870. }
  23871. return "";
  23872. },
  23873. beforeUpdate : function(){
  23874. this.grid.stopEditing(true);
  23875. },
  23876. updateHeaders : function(){
  23877. this.innerHd.firstChild.innerHTML = this.renderHeaders();
  23878. },
  23879. focusRow : function(row){
  23880. this.focusCell(row, 0, false);
  23881. },
  23882. focusCell : function(row, col, hscroll){
  23883. var xy = this.ensureVisible(row, col, hscroll);
  23884. this.focusEl.setXY(xy);
  23885. if(Ext.isGecko){
  23886. this.focusEl.focus();
  23887. }else{
  23888. this.focusEl.focus.defer(1, this.focusEl);
  23889. }
  23890. },
  23891. ensureVisible : function(row, col, hscroll){
  23892. if(typeof row != "number"){
  23893. row = row.rowIndex;
  23894. }
  23895. if(!this.ds){
  23896. return;
  23897. }
  23898. if(row < 0 || row >= this.ds.getCount()){
  23899. return;
  23900. }
  23901. col = (col !== undefined ? col : 0);
  23902. var rowEl = this.getRow(row), cellEl;
  23903. if(!(hscroll === false && col === 0)){
  23904. while(this.cm.isHidden(col)){
  23905. col++;
  23906. }
  23907. cellEl = this.getCell(row, col);
  23908. }
  23909. if(!rowEl){
  23910. return;
  23911. }
  23912. var c = this.scroller.dom;
  23913. var ctop = 0;
  23914. var p = rowEl, stop = this.el.dom;
  23915. while(p && p != stop){
  23916. ctop += p.offsetTop;
  23917. p = p.offsetParent;
  23918. }
  23919. ctop -= this.mainHd.dom.offsetHeight;
  23920. var cbot = ctop + rowEl.offsetHeight;
  23921. var ch = c.clientHeight;
  23922. var stop = parseInt(c.scrollTop, 10);
  23923. var sbot = stop + ch;
  23924. if(ctop < stop){
  23925. c.scrollTop = ctop;
  23926. }else if(cbot > sbot){
  23927. c.scrollTop = cbot-ch;
  23928. }
  23929. if(hscroll !== false){
  23930. var cleft = parseInt(cellEl.offsetLeft, 10);
  23931. var cright = cleft + cellEl.offsetWidth;
  23932. var sleft = parseInt(c.scrollLeft, 10);
  23933. var sright = sleft + c.clientWidth;
  23934. if(cleft < sleft){
  23935. c.scrollLeft = cleft;
  23936. }else if(cright > sright){
  23937. c.scrollLeft = cright-c.clientWidth;
  23938. }
  23939. }
  23940. return cellEl ? Ext.fly(cellEl).getXY() : [c.scrollLeft, Ext.fly(rowEl).getY()];
  23941. },
  23942. insertRows : function(dm, firstRow, lastRow, isUpdate){
  23943. if(!isUpdate && firstRow === 0 && lastRow == dm.getCount()-1){
  23944. this.refresh();
  23945. }else{
  23946. if(!isUpdate){
  23947. this.fireEvent("beforerowsinserted", this, firstRow, lastRow);
  23948. }
  23949. var html = this.renderRows(firstRow, lastRow);
  23950. var before = this.getRow(firstRow);
  23951. if(before){
  23952. Ext.DomHelper.insertHtml('beforeBegin', before, html);
  23953. }else{
  23954. Ext.DomHelper.insertHtml('beforeEnd', this.mainBody.dom, html);
  23955. }
  23956. if(!isUpdate){
  23957. this.fireEvent("rowsinserted", this, firstRow, lastRow);
  23958. this.processRows(firstRow);
  23959. }
  23960. }
  23961. },
  23962. deleteRows : function(dm, firstRow, lastRow){
  23963. if(dm.getRowCount()<1){
  23964. this.refresh();
  23965. }else{
  23966. this.fireEvent("beforerowsdeleted", this, firstRow, lastRow);
  23967. this.removeRows(firstRow, lastRow);
  23968. this.processRows(firstRow);
  23969. this.fireEvent("rowsdeleted", this, firstRow, lastRow);
  23970. }
  23971. },
  23972. getColumnStyle : function(col, isHeader){
  23973. var style = !isHeader ? (this.cm.config[col].css || '') : '';
  23974. style += 'width:'+this.getColumnWidth(col)+';';
  23975. if(this.cm.isHidden(col)){
  23976. style += 'display:none;';
  23977. }
  23978. var align = this.cm.config[col].align;
  23979. if(align){
  23980. style += 'text-align:'+align+';';
  23981. }
  23982. return style;
  23983. },
  23984. getColumnWidth : function(col){
  23985. var w = this.cm.getColumnWidth(col);
  23986. if(typeof w == 'number'){
  23987. return (Ext.isBorderBox ? w : (w-this.borderWidth > 0 ? w-this.borderWidth:0)) + 'px';
  23988. }
  23989. return w;
  23990. },
  23991. getTotalWidth : function(){
  23992. return this.cm.getTotalWidth()+'px';
  23993. },
  23994. fitColumns : function(preventRefresh, onlyExpand, omitColumn){
  23995. var cm = this.cm, leftOver, dist, i;
  23996. var tw = cm.getTotalWidth(false);
  23997. var aw = this.grid.getGridEl().getWidth(true)-this.scrollOffset;
  23998. if(aw < 20){ return;
  23999. }
  24000. var extra = aw - tw;
  24001. if(extra === 0){
  24002. return false;
  24003. }
  24004. var vc = cm.getColumnCount(true);
  24005. var ac = vc-(typeof omitColumn == 'number' ? 1 : 0);
  24006. if(ac === 0){
  24007. ac = 1;
  24008. omitColumn = undefined;
  24009. }
  24010. var colCount = cm.getColumnCount();
  24011. var cols = [];
  24012. var extraCol = 0;
  24013. var width = 0;
  24014. var w;
  24015. for (i = 0; i < colCount; i++){
  24016. if(!cm.isHidden(i) && !cm.isFixed(i) && i !== omitColumn){
  24017. w = cm.getColumnWidth(i);
  24018. cols.push(i);
  24019. extraCol = i;
  24020. cols.push(w);
  24021. width += w;
  24022. }
  24023. }
  24024. var frac = (aw - cm.getTotalWidth())/width;
  24025. while (cols.length){
  24026. w = cols.pop();
  24027. i = cols.pop();
  24028. cm.setColumnWidth(i, Math.max(this.grid.minColumnWidth, Math.floor(w + w*frac)), true);
  24029. }
  24030. if((tw = cm.getTotalWidth(false)) > aw){
  24031. var adjustCol = ac != vc ? omitColumn : extraCol;
  24032. cm.setColumnWidth(adjustCol, Math.max(1,
  24033. cm.getColumnWidth(adjustCol)- (tw-aw)), true);
  24034. }
  24035. if(preventRefresh !== true){
  24036. this.updateAllColumnWidths();
  24037. }
  24038. return true;
  24039. },
  24040. autoExpand : function(preventUpdate){
  24041. var g = this.grid, cm = this.cm;
  24042. if(!this.userResized && g.autoExpandColumn){
  24043. var tw = cm.getTotalWidth(false);
  24044. var aw = this.grid.getGridEl().getWidth(true)-this.scrollOffset;
  24045. if(tw != aw){
  24046. var ci = cm.getIndexById(g.autoExpandColumn);
  24047. var currentWidth = cm.getColumnWidth(ci);
  24048. var cw = Math.min(Math.max(((aw-tw)+currentWidth), g.autoExpandMin), g.autoExpandMax);
  24049. if(cw != currentWidth){
  24050. cm.setColumnWidth(ci, cw, true);
  24051. if(preventUpdate !== true){
  24052. this.updateColumnWidth(ci, cw);
  24053. }
  24054. }
  24055. }
  24056. }
  24057. },
  24058. getColumnData : function(){
  24059. var cs = [], cm = this.cm, colCount = cm.getColumnCount();
  24060. for(var i = 0; i < colCount; i++){
  24061. var name = cm.getDataIndex(i);
  24062. cs[i] = {
  24063. name : (typeof name == 'undefined' ? this.ds.fields.get(i).name : name),
  24064. renderer : cm.getRenderer(i),
  24065. id : cm.getColumnId(i),
  24066. style : this.getColumnStyle(i)
  24067. };
  24068. }
  24069. return cs;
  24070. },
  24071. renderRows : function(startRow, endRow){
  24072. var g = this.grid, cm = g.colModel, ds = g.store, stripe = g.stripeRows;
  24073. var colCount = cm.getColumnCount();
  24074. if(ds.getCount() < 1){
  24075. return "";
  24076. }
  24077. var cs = this.getColumnData();
  24078. startRow = startRow || 0;
  24079. endRow = typeof endRow == "undefined"? ds.getCount()-1 : endRow;
  24080. var rs = ds.getRange(startRow, endRow);
  24081. return this.doRender(cs, rs, ds, startRow, colCount, stripe);
  24082. },
  24083. renderBody : function(){
  24084. var markup = this.renderRows();
  24085. return this.templates.body.apply({rows: markup});
  24086. },
  24087. refreshRow : function(record){
  24088. var ds = this.ds, index;
  24089. if(typeof record == 'number'){
  24090. index = record;
  24091. record = ds.getAt(index);
  24092. }else{
  24093. index = ds.indexOf(record);
  24094. }
  24095. var cls = [];
  24096. this.insertRows(ds, index, index, true);
  24097. this.getRow(index).rowIndex = index;
  24098. this.onRemove(ds, record, index+1, true);
  24099. this.fireEvent("rowupdated", this, index, record);
  24100. },
  24101. refresh : function(headersToo){
  24102. this.fireEvent("beforerefresh", this);
  24103. this.grid.stopEditing(true);
  24104. var result = this.renderBody();
  24105. this.mainBody.update(result);
  24106. if(headersToo === true){
  24107. this.updateHeaders();
  24108. this.updateHeaderSortState();
  24109. }
  24110. this.processRows(0, true);
  24111. this.layout();
  24112. this.applyEmptyText();
  24113. this.fireEvent("refresh", this);
  24114. },
  24115. applyEmptyText : function(){
  24116. if(this.emptyText && !this.hasRows()){
  24117. this.mainBody.update('<div class="x-grid-empty">' + this.emptyText + '</div>');
  24118. }
  24119. },
  24120. updateHeaderSortState : function(){
  24121. var state = this.ds.getSortState();
  24122. if(!state){
  24123. return;
  24124. }
  24125. if(!this.sortState || (this.sortState.field != state.field || this.sortState.direction != state.direction)){
  24126. this.grid.fireEvent('sortchange', this.grid, state);
  24127. }
  24128. this.sortState = state;
  24129. var sortColumn = this.cm.findColumnIndex(state.field);
  24130. if(sortColumn != -1){
  24131. var sortDir = state.direction;
  24132. this.updateSortIcon(sortColumn, sortDir);
  24133. }
  24134. },
  24135. destroy : function(){
  24136. if(this.colMenu){
  24137. this.colMenu.removeAll();
  24138. Ext.menu.MenuMgr.unregister(this.colMenu);
  24139. this.colMenu.getEl().remove();
  24140. delete this.colMenu;
  24141. }
  24142. if(this.hmenu){
  24143. this.hmenu.removeAll();
  24144. Ext.menu.MenuMgr.unregister(this.hmenu);
  24145. this.hmenu.getEl().remove();
  24146. delete this.hmenu;
  24147. }
  24148. if(this.grid.enableColumnMove){
  24149. var dds = Ext.dd.DDM.ids['gridHeader' + this.grid.getGridEl().id];
  24150. if(dds){
  24151. for(var dd in dds){
  24152. if(!dds[dd].config.isTarget && dds[dd].dragElId){
  24153. var elid = dds[dd].dragElId;
  24154. dds[dd].unreg();
  24155. Ext.get(elid).remove();
  24156. } else if(dds[dd].config.isTarget){
  24157. dds[dd].proxyTop.remove();
  24158. dds[dd].proxyBottom.remove();
  24159. dds[dd].unreg();
  24160. }
  24161. if(Ext.dd.DDM.locationCache[dd]){
  24162. delete Ext.dd.DDM.locationCache[dd];
  24163. }
  24164. }
  24165. delete Ext.dd.DDM.ids['gridHeader' + this.grid.getGridEl().id];
  24166. }
  24167. }
  24168. Ext.destroy(this.resizeMarker, this.resizeProxy);
  24169. this.initData(null, null);
  24170. Ext.EventManager.removeResizeListener(this.onWindowResize, this);
  24171. },
  24172. onDenyColumnHide : function(){
  24173. },
  24174. render : function(){
  24175. var cm = this.cm;
  24176. var colCount = cm.getColumnCount();
  24177. if(this.autoFill){
  24178. this.fitColumns(true, true);
  24179. }else if(this.forceFit){
  24180. this.fitColumns(true, false);
  24181. }else if(this.grid.autoExpandColumn){
  24182. this.autoExpand(true);
  24183. }
  24184. this.renderUI();
  24185. },
  24186. initData : function(ds, cm){
  24187. if(this.ds){
  24188. this.ds.un("load", this.onLoad, this);
  24189. this.ds.un("datachanged", this.onDataChange, this);
  24190. this.ds.un("add", this.onAdd, this);
  24191. this.ds.un("remove", this.onRemove, this);
  24192. this.ds.un("update", this.onUpdate, this);
  24193. this.ds.un("clear", this.onClear, this);
  24194. }
  24195. if(ds){
  24196. ds.on("load", this.onLoad, this);
  24197. ds.on("datachanged", this.onDataChange, this);
  24198. ds.on("add", this.onAdd, this);
  24199. ds.on("remove", this.onRemove, this);
  24200. ds.on("update", this.onUpdate, this);
  24201. ds.on("clear", this.onClear, this);
  24202. }
  24203. this.ds = ds;
  24204. if(this.cm){
  24205. this.cm.un("configchange", this.onColConfigChange, this);
  24206. this.cm.un("widthchange", this.onColWidthChange, this);
  24207. this.cm.un("headerchange", this.onHeaderChange, this);
  24208. this.cm.un("hiddenchange", this.onHiddenChange, this);
  24209. this.cm.un("columnmoved", this.onColumnMove, this);
  24210. this.cm.un("columnlockchange", this.onColumnLock, this);
  24211. }
  24212. if(cm){
  24213. cm.on("configchange", this.onColConfigChange, this);
  24214. cm.on("widthchange", this.onColWidthChange, this);
  24215. cm.on("headerchange", this.onHeaderChange, this);
  24216. cm.on("hiddenchange", this.onHiddenChange, this);
  24217. cm.on("columnmoved", this.onColumnMove, this);
  24218. cm.on("columnlockchange", this.onColumnLock, this);
  24219. }
  24220. this.cm = cm;
  24221. },
  24222. onDataChange : function(){
  24223. this.refresh();
  24224. this.updateHeaderSortState();
  24225. },
  24226. onClear : function(){
  24227. this.refresh();
  24228. },
  24229. onUpdate : function(ds, record){
  24230. this.refreshRow(record);
  24231. },
  24232. onAdd : function(ds, records, index){
  24233. this.insertRows(ds, index, index + (records.length-1));
  24234. },
  24235. onRemove : function(ds, record, index, isUpdate){
  24236. if(isUpdate !== true){
  24237. this.fireEvent("beforerowremoved", this, index, record);
  24238. }
  24239. this.removeRow(index);
  24240. if(isUpdate !== true){
  24241. this.processRows(index);
  24242. this.applyEmptyText();
  24243. this.fireEvent("rowremoved", this, index, record);
  24244. }
  24245. },
  24246. onLoad : function(){
  24247. this.scrollToTop();
  24248. },
  24249. onColWidthChange : function(cm, col, width){
  24250. this.updateColumnWidth(col, width);
  24251. },
  24252. onHeaderChange : function(cm, col, text){
  24253. this.updateHeaders();
  24254. },
  24255. onHiddenChange : function(cm, col, hidden){
  24256. this.updateColumnHidden(col, hidden);
  24257. },
  24258. onColumnMove : function(cm, oldIndex, newIndex){
  24259. this.indexMap = null;
  24260. var s = this.getScrollState();
  24261. this.refresh(true);
  24262. this.restoreScroll(s);
  24263. this.afterMove(newIndex);
  24264. },
  24265. onColConfigChange : function(){
  24266. delete this.lastViewWidth;
  24267. this.indexMap = null;
  24268. this.refresh(true);
  24269. },
  24270. initUI : function(grid){
  24271. grid.on("headerclick", this.onHeaderClick, this);
  24272. if(grid.trackMouseOver){
  24273. grid.on("mouseover", this.onRowOver, this);
  24274. grid.on("mouseout", this.onRowOut, this);
  24275. }
  24276. },
  24277. initEvents : function(){
  24278. },
  24279. onHeaderClick : function(g, index){
  24280. if(this.headersDisabled || !this.cm.isSortable(index)){
  24281. return;
  24282. }
  24283. g.stopEditing(true);
  24284. g.store.sort(this.cm.getDataIndex(index));
  24285. },
  24286. onRowOver : function(e, t){
  24287. var row;
  24288. if((row = this.findRowIndex(t)) !== false){
  24289. this.addRowClass(row, "x-grid3-row-over");
  24290. }
  24291. },
  24292. onRowOut : function(e, t){
  24293. var row;
  24294. if((row = this.findRowIndex(t)) !== false && row !== this.findRowIndex(e.getRelatedTarget())){
  24295. this.removeRowClass(row, "x-grid3-row-over");
  24296. }
  24297. },
  24298. handleWheel : function(e){
  24299. e.stopPropagation();
  24300. },
  24301. onRowSelect : function(row){
  24302. this.addRowClass(row, "x-grid3-row-selected");
  24303. },
  24304. onRowDeselect : function(row){
  24305. this.removeRowClass(row, "x-grid3-row-selected");
  24306. },
  24307. onCellSelect : function(row, col){
  24308. var cell = this.getCell(row, col);
  24309. if(cell){
  24310. this.fly(cell).addClass("x-grid3-cell-selected");
  24311. }
  24312. },
  24313. onCellDeselect : function(row, col){
  24314. var cell = this.getCell(row, col);
  24315. if(cell){
  24316. this.fly(cell).removeClass("x-grid3-cell-selected");
  24317. }
  24318. },
  24319. onColumnSplitterMoved : function(i, w){
  24320. this.userResized = true;
  24321. var cm = this.grid.colModel;
  24322. cm.setColumnWidth(i, w, true);
  24323. if(this.forceFit){
  24324. this.fitColumns(true, false, i);
  24325. this.updateAllColumnWidths();
  24326. }else{
  24327. this.updateColumnWidth(i, w);
  24328. }
  24329. this.grid.fireEvent("columnresize", i, w);
  24330. },
  24331. handleHdMenuClick : function(item){
  24332. var index = this.hdCtxIndex;
  24333. var cm = this.cm, ds = this.ds;
  24334. switch(item.id){
  24335. case "asc":
  24336. ds.sort(cm.getDataIndex(index), "ASC");
  24337. break;
  24338. case "desc":
  24339. ds.sort(cm.getDataIndex(index), "DESC");
  24340. break;
  24341. default:
  24342. index = cm.getIndexById(item.id.substr(4));
  24343. if(index != -1){
  24344. if(item.checked && cm.getColumnsBy(this.isHideableColumn, this).length <= 1){
  24345. this.onDenyColumnHide();
  24346. return false;
  24347. }
  24348. cm.setHidden(index, item.checked);
  24349. }
  24350. }
  24351. return true;
  24352. },
  24353. isHideableColumn : function(c){
  24354. return !c.hidden && !c.fixed;
  24355. },
  24356. beforeColMenuShow : function(){
  24357. var cm = this.cm, colCount = cm.getColumnCount();
  24358. this.colMenu.removeAll();
  24359. for(var i = 0; i < colCount; i++){
  24360. if(cm.config[i].fixed !== true && cm.config[i].hideable !== false){
  24361. this.colMenu.add(new Ext.menu.CheckItem({
  24362. id: "col-"+cm.getColumnId(i),
  24363. text: cm.getColumnHeader(i),
  24364. checked: !cm.isHidden(i),
  24365. hideOnClick:false,
  24366. disabled: cm.config[i].hideable === false
  24367. }));
  24368. }
  24369. }
  24370. },
  24371. handleHdDown : function(e, t){
  24372. if(Ext.fly(t).hasClass('x-grid3-hd-btn')){
  24373. e.stopEvent();
  24374. var hd = this.findHeaderCell(t);
  24375. Ext.fly(hd).addClass('x-grid3-hd-menu-open');
  24376. var index = this.getCellIndex(hd);
  24377. this.hdCtxIndex = index;
  24378. var ms = this.hmenu.items, cm = this.cm;
  24379. ms.get("asc").setDisabled(!cm.isSortable(index));
  24380. ms.get("desc").setDisabled(!cm.isSortable(index));
  24381. this.hmenu.on("hide", function(){
  24382. Ext.fly(hd).removeClass('x-grid3-hd-menu-open');
  24383. }, this, {single:true});
  24384. this.hmenu.show(t, "tl-bl?");
  24385. }
  24386. },
  24387. handleHdOver : function(e, t){
  24388. var hd = this.findHeaderCell(t);
  24389. if(hd && !this.headersDisabled){
  24390. this.activeHd = hd;
  24391. this.activeHdIndex = this.getCellIndex(hd);
  24392. var fly = this.fly(hd);
  24393. this.activeHdRegion = fly.getRegion();
  24394. if(!this.cm.isMenuDisabled(this.activeHdIndex)){
  24395. fly.addClass("x-grid3-hd-over");
  24396. this.activeHdBtn = fly.child('.x-grid3-hd-btn');
  24397. if(this.activeHdBtn){
  24398. this.activeHdBtn.dom.style.height = (hd.firstChild.offsetHeight-1)+'px';
  24399. }
  24400. }
  24401. }
  24402. },
  24403. handleHdMove : function(e, t){
  24404. if(this.activeHd && !this.headersDisabled){
  24405. var hw = this.splitHandleWidth || 5;
  24406. var r = this.activeHdRegion;
  24407. var x = e.getPageX();
  24408. var ss = this.activeHd.style;
  24409. if(x - r.left <= hw && this.cm.isResizable(this.activeHdIndex-1)){
  24410. ss.cursor = Ext.isAir ? 'move' : Ext.isSafari ? 'e-resize' : 'col-resize'; }else if(r.right - x <= (!this.activeHdBtn ? hw : 2) && this.cm.isResizable(this.activeHdIndex)){
  24411. ss.cursor = Ext.isAir ? 'move' : Ext.isSafari ? 'w-resize' : 'col-resize';
  24412. }else{
  24413. ss.cursor = '';
  24414. }
  24415. }
  24416. },
  24417. handleHdOut : function(e, t){
  24418. var hd = this.findHeaderCell(t);
  24419. if(hd && (!Ext.isIE || !e.within(hd, true))){
  24420. this.activeHd = null;
  24421. this.fly(hd).removeClass("x-grid3-hd-over");
  24422. hd.style.cursor = '';
  24423. }
  24424. },
  24425. hasRows : function(){
  24426. var fc = this.mainBody.dom.firstChild;
  24427. return fc && fc.className != 'x-grid-empty';
  24428. },
  24429. bind : function(d, c){
  24430. this.initData(d, c);
  24431. }
  24432. });
  24433. Ext.grid.GridView.SplitDragZone = function(grid, hd){
  24434. this.grid = grid;
  24435. this.view = grid.getView();
  24436. this.marker = this.view.resizeMarker;
  24437. this.proxy = this.view.resizeProxy;
  24438. Ext.grid.GridView.SplitDragZone.superclass.constructor.call(this, hd,
  24439. "gridSplitters" + this.grid.getGridEl().id, {
  24440. dragElId : Ext.id(this.proxy.dom), resizeFrame:false
  24441. });
  24442. this.scroll = false;
  24443. this.hw = this.view.splitHandleWidth || 5;
  24444. };
  24445. Ext.extend(Ext.grid.GridView.SplitDragZone, Ext.dd.DDProxy, {
  24446. b4StartDrag : function(x, y){
  24447. this.view.headersDisabled = true;
  24448. var h = this.view.mainWrap.getHeight();
  24449. this.marker.setHeight(h);
  24450. this.marker.show();
  24451. this.marker.alignTo(this.view.getHeaderCell(this.cellIndex), 'tl-tl', [-2, 0]);
  24452. this.proxy.setHeight(h);
  24453. var w = this.cm.getColumnWidth(this.cellIndex);
  24454. var minw = Math.max(w-this.grid.minColumnWidth, 0);
  24455. this.resetConstraints();
  24456. this.setXConstraint(minw, 1000);
  24457. this.setYConstraint(0, 0);
  24458. this.minX = x - minw;
  24459. this.maxX = x + 1000;
  24460. this.startPos = x;
  24461. Ext.dd.DDProxy.prototype.b4StartDrag.call(this, x, y);
  24462. },
  24463. handleMouseDown : function(e){
  24464. var t = this.view.findHeaderCell(e.getTarget());
  24465. if(t){
  24466. var xy = this.view.fly(t).getXY(), x = xy[0], y = xy[1];
  24467. var exy = e.getXY(), ex = exy[0], ey = exy[1];
  24468. var w = t.offsetWidth, adjust = false;
  24469. if((ex - x) <= this.hw){
  24470. adjust = -1;
  24471. }else if((x+w) - ex <= this.hw){
  24472. adjust = 0;
  24473. }
  24474. if(adjust !== false){
  24475. this.cm = this.grid.colModel;
  24476. var ci = this.view.getCellIndex(t);
  24477. if(adjust == -1){
  24478. if (ci + adjust < 0) {
  24479. return;
  24480. }
  24481. while(this.cm.isHidden(ci+adjust)){
  24482. --adjust;
  24483. if(ci+adjust < 0){
  24484. return;
  24485. }
  24486. }
  24487. }
  24488. this.cellIndex = ci+adjust;
  24489. this.split = t.dom;
  24490. if(this.cm.isResizable(this.cellIndex) && !this.cm.isFixed(this.cellIndex)){
  24491. Ext.grid.GridView.SplitDragZone.superclass.handleMouseDown.apply(this, arguments);
  24492. }
  24493. }else if(this.view.columnDrag){
  24494. this.view.columnDrag.callHandleMouseDown(e);
  24495. }
  24496. }
  24497. },
  24498. endDrag : function(e){
  24499. this.marker.hide();
  24500. var v = this.view;
  24501. var endX = Math.max(this.minX, e.getPageX());
  24502. var diff = endX - this.startPos;
  24503. v.onColumnSplitterMoved(this.cellIndex, this.cm.getColumnWidth(this.cellIndex)+diff);
  24504. setTimeout(function(){
  24505. v.headersDisabled = false;
  24506. }, 50);
  24507. },
  24508. autoOffset : function(){
  24509. this.setDelta(0,0);
  24510. }
  24511. });
  24512. Ext.grid.GroupingView = Ext.extend(Ext.grid.GridView, {
  24513. hideGroupedColumn:false,
  24514. showGroupName:true,
  24515. startCollapsed:false,
  24516. enableGrouping:true,
  24517. enableGroupingMenu:true,
  24518. enableNoGroups:true,
  24519. emptyGroupText : '(None)',
  24520. ignoreAdd: false,
  24521. groupTextTpl : '{text}',
  24522. gidSeed : 1000,
  24523. initTemplates : function(){
  24524. Ext.grid.GroupingView.superclass.initTemplates.call(this);
  24525. this.state = {};
  24526. var sm = this.grid.getSelectionModel();
  24527. sm.on(sm.selectRow ? 'beforerowselect' : 'beforecellselect',
  24528. this.onBeforeRowSelect, this);
  24529. if(!this.startGroup){
  24530. this.startGroup = new Ext.XTemplate(
  24531. '<div id="{groupId}" class="x-grid-group {cls}">',
  24532. '<div id="{groupId}-hd" class="x-grid-group-hd" style="{style}"><div>', this.groupTextTpl ,'</div></div>',
  24533. '<div id="{groupId}-bd" class="x-grid-group-body">'
  24534. );
  24535. }
  24536. this.startGroup.compile();
  24537. this.endGroup = '</div></div>';
  24538. },
  24539. findGroup : function(el){
  24540. return Ext.fly(el).up('.x-grid-group', this.mainBody.dom);
  24541. },
  24542. getGroups : function(){
  24543. return this.hasRows() ? this.mainBody.dom.childNodes : [];
  24544. },
  24545. onAdd : function(){
  24546. if(this.enableGrouping && !this.ignoreAdd){
  24547. var ss = this.getScrollState();
  24548. this.refresh();
  24549. this.restoreScroll(ss);
  24550. }else if(!this.enableGrouping){
  24551. Ext.grid.GroupingView.superclass.onAdd.apply(this, arguments);
  24552. }
  24553. },
  24554. onRemove : function(ds, record, index, isUpdate){
  24555. Ext.grid.GroupingView.superclass.onRemove.apply(this, arguments);
  24556. var g = document.getElementById(record._groupId);
  24557. if(g && g.childNodes[1].childNodes.length < 1){
  24558. Ext.removeNode(g);
  24559. }
  24560. this.applyEmptyText();
  24561. },
  24562. refreshRow : function(record){
  24563. if(this.ds.getCount()==1){
  24564. this.refresh();
  24565. }else{
  24566. this.isUpdating = true;
  24567. Ext.grid.GroupingView.superclass.refreshRow.apply(this, arguments);
  24568. this.isUpdating = false;
  24569. }
  24570. },
  24571. beforeMenuShow : function(){
  24572. var field = this.getGroupField();
  24573. var g = this.hmenu.items.get('groupBy');
  24574. if(g){
  24575. g.setDisabled(this.cm.config[this.hdCtxIndex].groupable === false);
  24576. }
  24577. var s = this.hmenu.items.get('showGroups');
  24578. if(s){
  24579. if (!!field){
  24580. s.setDisabled(this.cm.config[this.hdCtxIndex].groupable === false)
  24581. }
  24582. s.setChecked(!!field);
  24583. }
  24584. },
  24585. renderUI : function(){
  24586. Ext.grid.GroupingView.superclass.renderUI.call(this);
  24587. this.mainBody.on('mousedown', this.interceptMouse, this);
  24588. if(this.enableGroupingMenu && this.hmenu){
  24589. this.hmenu.add('-',{
  24590. id:'groupBy',
  24591. text: this.groupByText,
  24592. handler: this.onGroupByClick,
  24593. scope: this,
  24594. iconCls:'x-group-by-icon'
  24595. });
  24596. if(this.enableNoGroups){
  24597. this.hmenu.add({
  24598. id:'showGroups',
  24599. text: this.showGroupsText,
  24600. checked: true,
  24601. checkHandler: this.onShowGroupsClick,
  24602. scope: this
  24603. });
  24604. }
  24605. this.hmenu.on('beforeshow', this.beforeMenuShow, this);
  24606. }
  24607. },
  24608. onGroupByClick : function(){
  24609. this.grid.store.groupBy(this.cm.getDataIndex(this.hdCtxIndex));
  24610. this.beforeMenuShow();
  24611. },
  24612. onShowGroupsClick : function(mi, checked){
  24613. if(checked){
  24614. this.onGroupByClick();
  24615. }else{
  24616. this.grid.store.clearGrouping();
  24617. }
  24618. },
  24619. toggleGroup : function(group, expanded){
  24620. this.grid.stopEditing(true);
  24621. group = Ext.getDom(group);
  24622. var gel = Ext.fly(group);
  24623. expanded = expanded !== undefined ?
  24624. expanded : gel.hasClass('x-grid-group-collapsed');
  24625. this.state[gel.dom.id] = expanded;
  24626. gel[expanded ? 'removeClass' : 'addClass']('x-grid-group-collapsed');
  24627. },
  24628. toggleAllGroups : function(expanded){
  24629. var groups = this.getGroups();
  24630. for(var i = 0, len = groups.length; i < len; i++){
  24631. this.toggleGroup(groups[i], expanded);
  24632. }
  24633. },
  24634. expandAllGroups : function(){
  24635. this.toggleAllGroups(true);
  24636. },
  24637. collapseAllGroups : function(){
  24638. this.toggleAllGroups(false);
  24639. },
  24640. interceptMouse : function(e){
  24641. var hd = e.getTarget('.x-grid-group-hd', this.mainBody);
  24642. if(hd){
  24643. e.stopEvent();
  24644. this.toggleGroup(hd.parentNode);
  24645. }
  24646. },
  24647. getGroup : function(v, r, groupRenderer, rowIndex, colIndex, ds){
  24648. var g = groupRenderer ? groupRenderer(v, {}, r, rowIndex, colIndex, ds) : String(v);
  24649. if(g === ''){
  24650. g = this.cm.config[colIndex].emptyGroupText || this.emptyGroupText;
  24651. }
  24652. return g;
  24653. },
  24654. getGroupField : function(){
  24655. return this.grid.store.getGroupState();
  24656. },
  24657. renderRows : function(){
  24658. var groupField = this.getGroupField();
  24659. var eg = !!groupField;
  24660. if(this.hideGroupedColumn) {
  24661. var colIndex = this.cm.findColumnIndex(groupField);
  24662. if(!eg && this.lastGroupField !== undefined) {
  24663. this.mainBody.update('');
  24664. this.cm.setHidden(this.cm.findColumnIndex(this.lastGroupField), false);
  24665. delete this.lastGroupField;
  24666. }else if (eg && this.lastGroupField === undefined) {
  24667. this.lastGroupField = groupField;
  24668. this.cm.setHidden(colIndex, true);
  24669. }else if (eg && this.lastGroupField !== undefined && groupField !== this.lastGroupField) {
  24670. this.mainBody.update('');
  24671. var oldIndex = this.cm.findColumnIndex(this.lastGroupField);
  24672. this.cm.setHidden(oldIndex, false);
  24673. this.lastGroupField = groupField;
  24674. this.cm.setHidden(colIndex, true);
  24675. }
  24676. }
  24677. return Ext.grid.GroupingView.superclass.renderRows.apply(
  24678. this, arguments);
  24679. },
  24680. doRender : function(cs, rs, ds, startRow, colCount, stripe){
  24681. if(rs.length < 1){
  24682. return '';
  24683. }
  24684. var groupField = this.getGroupField();
  24685. var colIndex = this.cm.findColumnIndex(groupField);
  24686. this.enableGrouping = !!groupField;
  24687. if(!this.enableGrouping || this.isUpdating){
  24688. return Ext.grid.GroupingView.superclass.doRender.apply(
  24689. this, arguments);
  24690. }
  24691. var gstyle = 'width:'+this.getTotalWidth()+';';
  24692. var gidPrefix = this.grid.getGridEl().id;
  24693. var cfg = this.cm.config[colIndex];
  24694. var groupRenderer = cfg.groupRenderer || cfg.renderer;
  24695. var prefix = this.showGroupName ?
  24696. (cfg.groupName || cfg.header)+': ' : '';
  24697. var groups = [], curGroup, i, len, gid;
  24698. for(i = 0, len = rs.length; i < len; i++){
  24699. var rowIndex = startRow + i;
  24700. var r = rs[i],
  24701. gvalue = r.data[groupField],
  24702. g = this.getGroup(gvalue, r, groupRenderer, rowIndex, colIndex, ds);
  24703. if(!curGroup || curGroup.group != g){
  24704. gid = gidPrefix + '-gp-' + groupField + '-' + Ext.util.Format.htmlEncode(g);
  24705. var isCollapsed = typeof this.state[gid] !== 'undefined' ? !this.state[gid] : this.startCollapsed;
  24706. var gcls = isCollapsed ? 'x-grid-group-collapsed' : '';
  24707. curGroup = {
  24708. group: g,
  24709. gvalue: gvalue,
  24710. text: prefix + g,
  24711. groupId: gid,
  24712. startRow: rowIndex,
  24713. rs: [r],
  24714. cls: gcls,
  24715. style: gstyle
  24716. };
  24717. groups.push(curGroup);
  24718. }else{
  24719. curGroup.rs.push(r);
  24720. }
  24721. r._groupId = gid;
  24722. }
  24723. var buf = [];
  24724. for(i = 0, len = groups.length; i < len; i++){
  24725. var g = groups[i];
  24726. this.doGroupStart(buf, g, cs, ds, colCount);
  24727. buf[buf.length] = Ext.grid.GroupingView.superclass.doRender.call(
  24728. this, cs, g.rs, ds, g.startRow, colCount, stripe);
  24729. this.doGroupEnd(buf, g, cs, ds, colCount);
  24730. }
  24731. return buf.join('');
  24732. },
  24733. getGroupId : function(value){
  24734. var gidPrefix = this.grid.getGridEl().id;
  24735. var groupField = this.getGroupField();
  24736. var colIndex = this.cm.findColumnIndex(groupField);
  24737. var cfg = this.cm.config[colIndex];
  24738. var groupRenderer = cfg.groupRenderer || cfg.renderer;
  24739. var gtext = this.getGroup(value, {data:{}}, groupRenderer, 0, colIndex, this.ds);
  24740. return gidPrefix + '-gp-' + groupField + '-' + Ext.util.Format.htmlEncode(value);
  24741. },
  24742. doGroupStart : function(buf, g, cs, ds, colCount){
  24743. buf[buf.length] = this.startGroup.apply(g);
  24744. },
  24745. doGroupEnd : function(buf, g, cs, ds, colCount){
  24746. buf[buf.length] = this.endGroup;
  24747. },
  24748. getRows : function(){
  24749. if(!this.enableGrouping){
  24750. return Ext.grid.GroupingView.superclass.getRows.call(this);
  24751. }
  24752. var r = [];
  24753. var g, gs = this.getGroups();
  24754. for(var i = 0, len = gs.length; i < len; i++){
  24755. g = gs[i].childNodes[1].childNodes;
  24756. for(var j = 0, jlen = g.length; j < jlen; j++){
  24757. r[r.length] = g[j];
  24758. }
  24759. }
  24760. return r;
  24761. },
  24762. updateGroupWidths : function(){
  24763. if(!this.enableGrouping || !this.hasRows()){
  24764. return;
  24765. }
  24766. var tw = Math.max(this.cm.getTotalWidth(), this.el.dom.offsetWidth-this.scrollOffset) +'px';
  24767. var gs = this.getGroups();
  24768. for(var i = 0, len = gs.length; i < len; i++){
  24769. gs[i].firstChild.style.width = tw;
  24770. }
  24771. },
  24772. onColumnWidthUpdated : function(col, w, tw){
  24773. this.updateGroupWidths();
  24774. },
  24775. onAllColumnWidthsUpdated : function(ws, tw){
  24776. this.updateGroupWidths();
  24777. },
  24778. onColumnHiddenUpdated : function(col, hidden, tw){
  24779. this.updateGroupWidths();
  24780. },
  24781. onLayout : function(){
  24782. this.updateGroupWidths();
  24783. },
  24784. onBeforeRowSelect : function(sm, rowIndex){
  24785. if(!this.enableGrouping){
  24786. return;
  24787. }
  24788. var row = this.getRow(rowIndex);
  24789. if(row && !row.offsetParent){
  24790. var g = this.findGroup(row);
  24791. this.toggleGroup(g, true);
  24792. }
  24793. },
  24794. groupByText: 'Group By This Field',
  24795. showGroupsText: 'Show in Groups'
  24796. });
  24797. Ext.grid.GroupingView.GROUP_ID = 1000;
  24798. Ext.grid.HeaderDragZone = function(grid, hd, hd2){
  24799. this.grid = grid;
  24800. this.view = grid.getView();
  24801. this.ddGroup = "gridHeader" + this.grid.getGridEl().id;
  24802. Ext.grid.HeaderDragZone.superclass.constructor.call(this, hd);
  24803. if(hd2){
  24804. this.setHandleElId(Ext.id(hd));
  24805. this.setOuterHandleElId(Ext.id(hd2));
  24806. }
  24807. this.scroll = false;
  24808. };
  24809. Ext.extend(Ext.grid.HeaderDragZone, Ext.dd.DragZone, {
  24810. maxDragWidth: 120,
  24811. getDragData : function(e){
  24812. var t = Ext.lib.Event.getTarget(e);
  24813. var h = this.view.findHeaderCell(t);
  24814. if(h){
  24815. return {ddel: h.firstChild, header:h};
  24816. }
  24817. return false;
  24818. },
  24819. onInitDrag : function(e){
  24820. this.view.headersDisabled = true;
  24821. var clone = this.dragData.ddel.cloneNode(true);
  24822. clone.id = Ext.id();
  24823. clone.style.width = Math.min(this.dragData.header.offsetWidth,this.maxDragWidth) + "px";
  24824. this.proxy.update(clone);
  24825. return true;
  24826. },
  24827. afterValidDrop : function(){
  24828. var v = this.view;
  24829. setTimeout(function(){
  24830. v.headersDisabled = false;
  24831. }, 50);
  24832. },
  24833. afterInvalidDrop : function(){
  24834. var v = this.view;
  24835. setTimeout(function(){
  24836. v.headersDisabled = false;
  24837. }, 50);
  24838. }
  24839. });
  24840. Ext.grid.HeaderDropZone = function(grid, hd, hd2){
  24841. this.grid = grid;
  24842. this.view = grid.getView();
  24843. this.proxyTop = Ext.DomHelper.append(document.body, {
  24844. cls:"col-move-top", html:"&#160;"
  24845. }, true);
  24846. this.proxyBottom = Ext.DomHelper.append(document.body, {
  24847. cls:"col-move-bottom", html:"&#160;"
  24848. }, true);
  24849. this.proxyTop.hide = this.proxyBottom.hide = function(){
  24850. this.setLeftTop(-100,-100);
  24851. this.setStyle("visibility", "hidden");
  24852. };
  24853. this.ddGroup = "gridHeader" + this.grid.getGridEl().id;
  24854. Ext.grid.HeaderDropZone.superclass.constructor.call(this, grid.getGridEl().dom);
  24855. };
  24856. Ext.extend(Ext.grid.HeaderDropZone, Ext.dd.DropZone, {
  24857. proxyOffsets : [-4, -9],
  24858. fly: Ext.Element.fly,
  24859. getTargetFromEvent : function(e){
  24860. var t = Ext.lib.Event.getTarget(e);
  24861. var cindex = this.view.findCellIndex(t);
  24862. if(cindex !== false){
  24863. return this.view.getHeaderCell(cindex);
  24864. }
  24865. },
  24866. nextVisible : function(h){
  24867. var v = this.view, cm = this.grid.colModel;
  24868. h = h.nextSibling;
  24869. while(h){
  24870. if(!cm.isHidden(v.getCellIndex(h))){
  24871. return h;
  24872. }
  24873. h = h.nextSibling;
  24874. }
  24875. return null;
  24876. },
  24877. prevVisible : function(h){
  24878. var v = this.view, cm = this.grid.colModel;
  24879. h = h.prevSibling;
  24880. while(h){
  24881. if(!cm.isHidden(v.getCellIndex(h))){
  24882. return h;
  24883. }
  24884. h = h.prevSibling;
  24885. }
  24886. return null;
  24887. },
  24888. positionIndicator : function(h, n, e){
  24889. var x = Ext.lib.Event.getPageX(e);
  24890. var r = Ext.lib.Dom.getRegion(n.firstChild);
  24891. var px, pt, py = r.top + this.proxyOffsets[1];
  24892. if((r.right - x) <= (r.right-r.left)/2){
  24893. px = r.right+this.view.borderWidth;
  24894. pt = "after";
  24895. }else{
  24896. px = r.left;
  24897. pt = "before";
  24898. }
  24899. var oldIndex = this.view.getCellIndex(h);
  24900. var newIndex = this.view.getCellIndex(n);
  24901. if(this.grid.colModel.isFixed(newIndex)){
  24902. return false;
  24903. }
  24904. var locked = this.grid.colModel.isLocked(newIndex);
  24905. if(pt == "after"){
  24906. newIndex++;
  24907. }
  24908. if(oldIndex < newIndex){
  24909. newIndex--;
  24910. }
  24911. if(oldIndex == newIndex && (locked == this.grid.colModel.isLocked(oldIndex))){
  24912. return false;
  24913. }
  24914. px += this.proxyOffsets[0];
  24915. this.proxyTop.setLeftTop(px, py);
  24916. this.proxyTop.show();
  24917. if(!this.bottomOffset){
  24918. this.bottomOffset = this.view.mainHd.getHeight();
  24919. }
  24920. this.proxyBottom.setLeftTop(px, py+this.proxyTop.dom.offsetHeight+this.bottomOffset);
  24921. this.proxyBottom.show();
  24922. return pt;
  24923. },
  24924. onNodeEnter : function(n, dd, e, data){
  24925. if(data.header != n){
  24926. this.positionIndicator(data.header, n, e);
  24927. }
  24928. },
  24929. onNodeOver : function(n, dd, e, data){
  24930. var result = false;
  24931. if(data.header != n){
  24932. result = this.positionIndicator(data.header, n, e);
  24933. }
  24934. if(!result){
  24935. this.proxyTop.hide();
  24936. this.proxyBottom.hide();
  24937. }
  24938. return result ? this.dropAllowed : this.dropNotAllowed;
  24939. },
  24940. onNodeOut : function(n, dd, e, data){
  24941. this.proxyTop.hide();
  24942. this.proxyBottom.hide();
  24943. },
  24944. onNodeDrop : function(n, dd, e, data){
  24945. var h = data.header;
  24946. if(h != n){
  24947. var cm = this.grid.colModel;
  24948. var x = Ext.lib.Event.getPageX(e);
  24949. var r = Ext.lib.Dom.getRegion(n.firstChild);
  24950. var pt = (r.right - x) <= ((r.right-r.left)/2) ? "after" : "before";
  24951. var oldIndex = this.view.getCellIndex(h);
  24952. var newIndex = this.view.getCellIndex(n);
  24953. var locked = cm.isLocked(newIndex);
  24954. if(pt == "after"){
  24955. newIndex++;
  24956. }
  24957. if(oldIndex < newIndex){
  24958. newIndex--;
  24959. }
  24960. if(oldIndex == newIndex && (locked == cm.isLocked(oldIndex))){
  24961. return false;
  24962. }
  24963. cm.setLocked(oldIndex, locked, true);
  24964. cm.moveColumn(oldIndex, newIndex);
  24965. this.grid.fireEvent("columnmove", oldIndex, newIndex);
  24966. return true;
  24967. }
  24968. return false;
  24969. }
  24970. });
  24971. Ext.grid.GridView.ColumnDragZone = function(grid, hd){
  24972. Ext.grid.GridView.ColumnDragZone.superclass.constructor.call(this, grid, hd, null);
  24973. this.proxy.el.addClass('x-grid3-col-dd');
  24974. };
  24975. Ext.extend(Ext.grid.GridView.ColumnDragZone, Ext.grid.HeaderDragZone, {
  24976. handleMouseDown : function(e){
  24977. },
  24978. callHandleMouseDown : function(e){
  24979. Ext.grid.GridView.ColumnDragZone.superclass.handleMouseDown.call(this, e);
  24980. }
  24981. });
  24982. Ext.grid.SplitDragZone = function(grid, hd, hd2){
  24983. this.grid = grid;
  24984. this.view = grid.getView();
  24985. this.proxy = this.view.resizeProxy;
  24986. Ext.grid.SplitDragZone.superclass.constructor.call(this, hd,
  24987. "gridSplitters" + this.grid.getGridEl().id, {
  24988. dragElId : Ext.id(this.proxy.dom), resizeFrame:false
  24989. });
  24990. this.setHandleElId(Ext.id(hd));
  24991. this.setOuterHandleElId(Ext.id(hd2));
  24992. this.scroll = false;
  24993. };
  24994. Ext.extend(Ext.grid.SplitDragZone, Ext.dd.DDProxy, {
  24995. fly: Ext.Element.fly,
  24996. b4StartDrag : function(x, y){
  24997. this.view.headersDisabled = true;
  24998. this.proxy.setHeight(this.view.mainWrap.getHeight());
  24999. var w = this.cm.getColumnWidth(this.cellIndex);
  25000. var minw = Math.max(w-this.grid.minColumnWidth, 0);
  25001. this.resetConstraints();
  25002. this.setXConstraint(minw, 1000);
  25003. this.setYConstraint(0, 0);
  25004. this.minX = x - minw;
  25005. this.maxX = x + 1000;
  25006. this.startPos = x;
  25007. Ext.dd.DDProxy.prototype.b4StartDrag.call(this, x, y);
  25008. },
  25009. handleMouseDown : function(e){
  25010. ev = Ext.EventObject.setEvent(e);
  25011. var t = this.fly(ev.getTarget());
  25012. if(t.hasClass("x-grid-split")){
  25013. this.cellIndex = this.view.getCellIndex(t.dom);
  25014. this.split = t.dom;
  25015. this.cm = this.grid.colModel;
  25016. if(this.cm.isResizable(this.cellIndex) && !this.cm.isFixed(this.cellIndex)){
  25017. Ext.grid.SplitDragZone.superclass.handleMouseDown.apply(this, arguments);
  25018. }
  25019. }
  25020. },
  25021. endDrag : function(e){
  25022. this.view.headersDisabled = false;
  25023. var endX = Math.max(this.minX, Ext.lib.Event.getPageX(e));
  25024. var diff = endX - this.startPos;
  25025. this.view.onColumnSplitterMoved(this.cellIndex, this.cm.getColumnWidth(this.cellIndex)+diff);
  25026. },
  25027. autoOffset : function(){
  25028. this.setDelta(0,0);
  25029. }
  25030. });
  25031. Ext.grid.GridDragZone = function(grid, config){
  25032. this.view = grid.getView();
  25033. Ext.grid.GridDragZone.superclass.constructor.call(this, this.view.mainBody.dom, config);
  25034. if(this.view.lockedBody){
  25035. this.setHandleElId(Ext.id(this.view.mainBody.dom));
  25036. this.setOuterHandleElId(Ext.id(this.view.lockedBody.dom));
  25037. }
  25038. this.scroll = false;
  25039. this.grid = grid;
  25040. this.ddel = document.createElement('div');
  25041. this.ddel.className = 'x-grid-dd-wrap';
  25042. };
  25043. Ext.extend(Ext.grid.GridDragZone, Ext.dd.DragZone, {
  25044. ddGroup : "GridDD",
  25045. getDragData : function(e){
  25046. var t = Ext.lib.Event.getTarget(e);
  25047. var rowIndex = this.view.findRowIndex(t);
  25048. if(rowIndex !== false){
  25049. var sm = this.grid.selModel;
  25050. if(!sm.isSelected(rowIndex) || e.hasModifier()){
  25051. sm.handleMouseDown(this.grid, rowIndex, e);
  25052. }
  25053. return {grid: this.grid, ddel: this.ddel, rowIndex: rowIndex, selections:sm.getSelections()};
  25054. }
  25055. return false;
  25056. },
  25057. onInitDrag : function(e){
  25058. var data = this.dragData;
  25059. this.ddel.innerHTML = this.grid.getDragDropText();
  25060. this.proxy.update(this.ddel);
  25061. },
  25062. afterRepair : function(){
  25063. this.dragging = false;
  25064. },
  25065. getRepairXY : function(e, data){
  25066. return false;
  25067. },
  25068. onEndDrag : function(data, e){
  25069. },
  25070. onValidDrop : function(dd, e, id){
  25071. this.hideProxy();
  25072. },
  25073. beforeInvalidDrop : function(e, id){
  25074. }
  25075. });
  25076. Ext.grid.ColumnModel = function(config){
  25077. this.defaultWidth = 100;
  25078. this.defaultSortable = false;
  25079. if(config.columns){
  25080. Ext.apply(this, config);
  25081. this.setConfig(config.columns, true);
  25082. }else{
  25083. this.setConfig(config, true);
  25084. }
  25085. this.addEvents(
  25086. "widthchange",
  25087. "headerchange",
  25088. "hiddenchange",
  25089. "columnmoved",
  25090. "columnlockchange",
  25091. "configchange"
  25092. );
  25093. Ext.grid.ColumnModel.superclass.constructor.call(this);
  25094. };
  25095. Ext.extend(Ext.grid.ColumnModel, Ext.util.Observable, {
  25096. getColumnId : function(index){
  25097. return this.config[index].id;
  25098. },
  25099. setConfig : function(config, initial){
  25100. if(!initial){
  25101. delete this.totalWidth;
  25102. for(var i = 0, len = this.config.length; i < len; i++){
  25103. var c = this.config[i];
  25104. if(c.editor){
  25105. c.editor.destroy();
  25106. }
  25107. }
  25108. }
  25109. this.config = config;
  25110. this.lookup = {};
  25111. for(var i = 0, len = config.length; i < len; i++){
  25112. var c = config[i];
  25113. if(typeof c.renderer == "string"){
  25114. c.renderer = Ext.util.Format[c.renderer];
  25115. }
  25116. if(typeof c.id == "undefined"){
  25117. c.id = i;
  25118. }
  25119. if(c.editor && c.editor.isFormField){
  25120. c.editor = new Ext.grid.GridEditor(c.editor);
  25121. }
  25122. this.lookup[c.id] = c;
  25123. }
  25124. if(!initial){
  25125. this.fireEvent('configchange', this);
  25126. }
  25127. },
  25128. getColumnById : function(id){
  25129. return this.lookup[id];
  25130. },
  25131. getIndexById : function(id){
  25132. for(var i = 0, len = this.config.length; i < len; i++){
  25133. if(this.config[i].id == id){
  25134. return i;
  25135. }
  25136. }
  25137. return -1;
  25138. },
  25139. moveColumn : function(oldIndex, newIndex){
  25140. var c = this.config[oldIndex];
  25141. this.config.splice(oldIndex, 1);
  25142. this.config.splice(newIndex, 0, c);
  25143. this.dataMap = null;
  25144. this.fireEvent("columnmoved", this, oldIndex, newIndex);
  25145. },
  25146. isLocked : function(colIndex){
  25147. return this.config[colIndex].locked === true;
  25148. },
  25149. setLocked : function(colIndex, value, suppressEvent){
  25150. if(this.isLocked(colIndex) == value){
  25151. return;
  25152. }
  25153. this.config[colIndex].locked = value;
  25154. if(!suppressEvent){
  25155. this.fireEvent("columnlockchange", this, colIndex, value);
  25156. }
  25157. },
  25158. getTotalLockedWidth : function(){
  25159. var totalWidth = 0;
  25160. for(var i = 0; i < this.config.length; i++){
  25161. if(this.isLocked(i) && !this.isHidden(i)){
  25162. this.totalWidth += this.getColumnWidth(i);
  25163. }
  25164. }
  25165. return totalWidth;
  25166. },
  25167. getLockedCount : function(){
  25168. for(var i = 0, len = this.config.length; i < len; i++){
  25169. if(!this.isLocked(i)){
  25170. return i;
  25171. }
  25172. }
  25173. },
  25174. getColumnCount : function(visibleOnly){
  25175. if(visibleOnly === true){
  25176. var c = 0;
  25177. for(var i = 0, len = this.config.length; i < len; i++){
  25178. if(!this.isHidden(i)){
  25179. c++;
  25180. }
  25181. }
  25182. return c;
  25183. }
  25184. return this.config.length;
  25185. },
  25186. getColumnsBy : function(fn, scope){
  25187. var r = [];
  25188. for(var i = 0, len = this.config.length; i < len; i++){
  25189. var c = this.config[i];
  25190. if(fn.call(scope||this, c, i) === true){
  25191. r[r.length] = c;
  25192. }
  25193. }
  25194. return r;
  25195. },
  25196. isSortable : function(col){
  25197. if(typeof this.config[col].sortable == "undefined"){
  25198. return this.defaultSortable;
  25199. }
  25200. return this.config[col].sortable;
  25201. },
  25202. isMenuDisabled : function(col){
  25203. return !!this.config[col].menuDisabled;
  25204. },
  25205. getRenderer : function(col){
  25206. if(!this.config[col].renderer){
  25207. return Ext.grid.ColumnModel.defaultRenderer;
  25208. }
  25209. return this.config[col].renderer;
  25210. },
  25211. setRenderer : function(col, fn){
  25212. this.config[col].renderer = fn;
  25213. },
  25214. getColumnWidth : function(col){
  25215. return this.config[col].width || this.defaultWidth;
  25216. },
  25217. setColumnWidth : function(col, width, suppressEvent){
  25218. this.config[col].width = width;
  25219. this.totalWidth = null;
  25220. if(!suppressEvent){
  25221. this.fireEvent("widthchange", this, col, width);
  25222. }
  25223. },
  25224. getTotalWidth : function(includeHidden){
  25225. if(!this.totalWidth){
  25226. this.totalWidth = 0;
  25227. for(var i = 0, len = this.config.length; i < len; i++){
  25228. if(includeHidden || !this.isHidden(i)){
  25229. this.totalWidth += this.getColumnWidth(i);
  25230. }
  25231. }
  25232. }
  25233. return this.totalWidth;
  25234. },
  25235. getColumnHeader : function(col){
  25236. return this.config[col].header;
  25237. },
  25238. setColumnHeader : function(col, header){
  25239. this.config[col].header = header;
  25240. this.fireEvent("headerchange", this, col, header);
  25241. },
  25242. getColumnTooltip : function(col){
  25243. return this.config[col].tooltip;
  25244. },
  25245. setColumnTooltip : function(col, tooltip){
  25246. this.config[col].tooltip = tooltip;
  25247. },
  25248. getDataIndex : function(col){
  25249. return this.config[col].dataIndex;
  25250. },
  25251. setDataIndex : function(col, dataIndex){
  25252. this.config[col].dataIndex = dataIndex;
  25253. },
  25254. findColumnIndex : function(dataIndex){
  25255. var c = this.config;
  25256. for(var i = 0, len = c.length; i < len; i++){
  25257. if(c[i].dataIndex == dataIndex){
  25258. return i;
  25259. }
  25260. }
  25261. return -1;
  25262. },
  25263. isCellEditable : function(colIndex, rowIndex){
  25264. return (this.config[colIndex].editable || (typeof this.config[colIndex].editable == "undefined" && this.config[colIndex].editor)) ? true : false;
  25265. },
  25266. getCellEditor : function(colIndex, rowIndex){
  25267. return this.config[colIndex].editor;
  25268. },
  25269. setEditable : function(col, editable){
  25270. this.config[col].editable = editable;
  25271. },
  25272. isHidden : function(colIndex){
  25273. return this.config[colIndex].hidden;
  25274. },
  25275. isFixed : function(colIndex){
  25276. return this.config[colIndex].fixed;
  25277. },
  25278. isResizable : function(colIndex){
  25279. return colIndex >= 0 && this.config[colIndex].resizable !== false && this.config[colIndex].fixed !== true;
  25280. },
  25281. setHidden : function(colIndex, hidden){
  25282. var c = this.config[colIndex];
  25283. if(c.hidden !== hidden){
  25284. c.hidden = hidden;
  25285. this.totalWidth = null;
  25286. this.fireEvent("hiddenchange", this, colIndex, hidden);
  25287. }
  25288. },
  25289. setEditor : function(col, editor){
  25290. this.config[col].editor = editor;
  25291. }
  25292. });
  25293. Ext.grid.ColumnModel.defaultRenderer = function(value){
  25294. if(typeof value == "string" && value.length < 1){
  25295. return "&#160;";
  25296. }
  25297. return value;
  25298. };
  25299. Ext.grid.DefaultColumnModel = Ext.grid.ColumnModel;
  25300. Ext.grid.AbstractSelectionModel = function(){
  25301. this.locked = false;
  25302. Ext.grid.AbstractSelectionModel.superclass.constructor.call(this);
  25303. };
  25304. Ext.extend(Ext.grid.AbstractSelectionModel, Ext.util.Observable, {
  25305. init : function(grid){
  25306. this.grid = grid;
  25307. this.initEvents();
  25308. },
  25309. lock : function(){
  25310. this.locked = true;
  25311. },
  25312. unlock : function(){
  25313. this.locked = false;
  25314. },
  25315. isLocked : function(){
  25316. return this.locked;
  25317. }
  25318. });
  25319. Ext.grid.RowSelectionModel = function(config){
  25320. Ext.apply(this, config);
  25321. this.selections = new Ext.util.MixedCollection(false, function(o){
  25322. return o.id;
  25323. });
  25324. this.last = false;
  25325. this.lastActive = false;
  25326. this.addEvents(
  25327. "selectionchange",
  25328. "beforerowselect",
  25329. "rowselect",
  25330. "rowdeselect"
  25331. );
  25332. Ext.grid.RowSelectionModel.superclass.constructor.call(this);
  25333. };
  25334. Ext.extend(Ext.grid.RowSelectionModel, Ext.grid.AbstractSelectionModel, {
  25335. singleSelect : false,
  25336. initEvents : function(){
  25337. if(!this.grid.enableDragDrop && !this.grid.enableDrag){
  25338. this.grid.on("rowmousedown", this.handleMouseDown, this);
  25339. }else{ this.grid.on("rowclick", function(grid, rowIndex, e) {
  25340. if(e.button === 0 && !e.shiftKey && !e.ctrlKey) {
  25341. this.selectRow(rowIndex, false);
  25342. grid.view.focusRow(rowIndex);
  25343. }
  25344. }, this);
  25345. }
  25346. this.rowNav = new Ext.KeyNav(this.grid.getGridEl(), {
  25347. "up" : function(e){
  25348. if(!e.shiftKey){
  25349. this.selectPrevious(e.shiftKey);
  25350. }else if(this.last !== false && this.lastActive !== false){
  25351. var last = this.last;
  25352. this.selectRange(this.last, this.lastActive-1);
  25353. this.grid.getView().focusRow(this.lastActive);
  25354. if(last !== false){
  25355. this.last = last;
  25356. }
  25357. }else{
  25358. this.selectFirstRow();
  25359. }
  25360. },
  25361. "down" : function(e){
  25362. if(!e.shiftKey){
  25363. this.selectNext(e.shiftKey);
  25364. }else if(this.last !== false && this.lastActive !== false){
  25365. var last = this.last;
  25366. this.selectRange(this.last, this.lastActive+1);
  25367. this.grid.getView().focusRow(this.lastActive);
  25368. if(last !== false){
  25369. this.last = last;
  25370. }
  25371. }else{
  25372. this.selectFirstRow();
  25373. }
  25374. },
  25375. scope: this
  25376. });
  25377. var view = this.grid.view;
  25378. view.on("refresh", this.onRefresh, this);
  25379. view.on("rowupdated", this.onRowUpdated, this);
  25380. view.on("rowremoved", this.onRemove, this);
  25381. },
  25382. onRefresh : function(){
  25383. var ds = this.grid.store, index;
  25384. var s = this.getSelections();
  25385. this.clearSelections(true);
  25386. for(var i = 0, len = s.length; i < len; i++){
  25387. var r = s[i];
  25388. if((index = ds.indexOfId(r.id)) != -1){
  25389. this.selectRow(index, true);
  25390. }
  25391. }
  25392. if(s.length != this.selections.getCount()){
  25393. this.fireEvent("selectionchange", this);
  25394. }
  25395. },
  25396. onRemove : function(v, index, r){
  25397. if(this.selections.remove(r) !== false){
  25398. this.fireEvent('selectionchange', this);
  25399. }
  25400. },
  25401. onRowUpdated : function(v, index, r){
  25402. if(this.isSelected(r)){
  25403. v.onRowSelect(index);
  25404. }
  25405. },
  25406. selectRecords : function(records, keepExisting){
  25407. if(!keepExisting){
  25408. this.clearSelections();
  25409. }
  25410. var ds = this.grid.store;
  25411. for(var i = 0, len = records.length; i < len; i++){
  25412. this.selectRow(ds.indexOf(records[i]), true);
  25413. }
  25414. },
  25415. getCount : function(){
  25416. return this.selections.length;
  25417. },
  25418. selectFirstRow : function(){
  25419. this.selectRow(0);
  25420. },
  25421. selectLastRow : function(keepExisting){
  25422. this.selectRow(this.grid.store.getCount() - 1, keepExisting);
  25423. },
  25424. selectNext : function(keepExisting){
  25425. if(this.hasNext()){
  25426. this.selectRow(this.last+1, keepExisting);
  25427. this.grid.getView().focusRow(this.last);
  25428. return true;
  25429. }
  25430. return false;
  25431. },
  25432. selectPrevious : function(keepExisting){
  25433. if(this.hasPrevious()){
  25434. this.selectRow(this.last-1, keepExisting);
  25435. this.grid.getView().focusRow(this.last);
  25436. return true;
  25437. }
  25438. return false;
  25439. },
  25440. hasNext : function(){
  25441. return this.last !== false && (this.last+1) < this.grid.store.getCount();
  25442. },
  25443. hasPrevious : function(){
  25444. return !!this.last;
  25445. },
  25446. getSelections : function(){
  25447. return [].concat(this.selections.items);
  25448. },
  25449. getSelected : function(){
  25450. return this.selections.itemAt(0);
  25451. },
  25452. each : function(fn, scope){
  25453. var s = this.getSelections();
  25454. for(var i = 0, len = s.length; i < len; i++){
  25455. if(fn.call(scope || this, s[i], i) === false){
  25456. return false;
  25457. }
  25458. }
  25459. return true;
  25460. },
  25461. clearSelections : function(fast){
  25462. if(this.locked) return;
  25463. if(fast !== true){
  25464. var ds = this.grid.store;
  25465. var s = this.selections;
  25466. s.each(function(r){
  25467. this.deselectRow(ds.indexOfId(r.id));
  25468. }, this);
  25469. s.clear();
  25470. }else{
  25471. this.selections.clear();
  25472. }
  25473. this.last = false;
  25474. },
  25475. selectAll : function(){
  25476. if(this.locked) return;
  25477. this.selections.clear();
  25478. for(var i = 0, len = this.grid.store.getCount(); i < len; i++){
  25479. this.selectRow(i, true);
  25480. }
  25481. },
  25482. hasSelection : function(){
  25483. return this.selections.length > 0;
  25484. },
  25485. isSelected : function(index){
  25486. var r = typeof index == "number" ? this.grid.store.getAt(index) : index;
  25487. return (r && this.selections.key(r.id) ? true : false);
  25488. },
  25489. isIdSelected : function(id){
  25490. return (this.selections.key(id) ? true : false);
  25491. },
  25492. handleMouseDown : function(g, rowIndex, e){
  25493. if(e.button !== 0 || this.isLocked()){
  25494. return;
  25495. };
  25496. var view = this.grid.getView();
  25497. if(e.shiftKey && this.last !== false){
  25498. var last = this.last;
  25499. this.selectRange(last, rowIndex, e.ctrlKey);
  25500. this.last = last; view.focusRow(rowIndex);
  25501. }else{
  25502. var isSelected = this.isSelected(rowIndex);
  25503. if(e.ctrlKey && isSelected){
  25504. this.deselectRow(rowIndex);
  25505. }else if(!isSelected || this.getCount() > 1){
  25506. this.selectRow(rowIndex, e.ctrlKey || e.shiftKey);
  25507. view.focusRow(rowIndex);
  25508. }
  25509. }
  25510. },
  25511. selectRows : function(rows, keepExisting){
  25512. if(!keepExisting){
  25513. this.clearSelections();
  25514. }
  25515. for(var i = 0, len = rows.length; i < len; i++){
  25516. this.selectRow(rows[i], true);
  25517. }
  25518. },
  25519. selectRange : function(startRow, endRow, keepExisting){
  25520. if(this.locked) return;
  25521. if(!keepExisting){
  25522. this.clearSelections();
  25523. }
  25524. if(startRow <= endRow){
  25525. for(var i = startRow; i <= endRow; i++){
  25526. this.selectRow(i, true);
  25527. }
  25528. }else{
  25529. for(var i = startRow; i >= endRow; i--){
  25530. this.selectRow(i, true);
  25531. }
  25532. }
  25533. },
  25534. deselectRange : function(startRow, endRow, preventViewNotify){
  25535. if(this.locked) return;
  25536. for(var i = startRow; i <= endRow; i++){
  25537. this.deselectRow(i, preventViewNotify);
  25538. }
  25539. },
  25540. selectRow : function(index, keepExisting, preventViewNotify){
  25541. if(this.locked || (index < 0 || index >= this.grid.store.getCount())) return;
  25542. var r = this.grid.store.getAt(index);
  25543. if(r && this.fireEvent("beforerowselect", this, index, keepExisting, r) !== false){
  25544. if(!keepExisting || this.singleSelect){
  25545. this.clearSelections();
  25546. }
  25547. this.selections.add(r);
  25548. this.last = this.lastActive = index;
  25549. if(!preventViewNotify){
  25550. this.grid.getView().onRowSelect(index);
  25551. }
  25552. this.fireEvent("rowselect", this, index, r);
  25553. this.fireEvent("selectionchange", this);
  25554. }
  25555. },
  25556. deselectRow : function(index, preventViewNotify){
  25557. if(this.locked) return;
  25558. if(this.last == index){
  25559. this.last = false;
  25560. }
  25561. if(this.lastActive == index){
  25562. this.lastActive = false;
  25563. }
  25564. var r = this.grid.store.getAt(index);
  25565. if(r){
  25566. this.selections.remove(r);
  25567. if(!preventViewNotify){
  25568. this.grid.getView().onRowDeselect(index);
  25569. }
  25570. this.fireEvent("rowdeselect", this, index, r);
  25571. this.fireEvent("selectionchange", this);
  25572. }
  25573. },
  25574. restoreLast : function(){
  25575. if(this._last){
  25576. this.last = this._last;
  25577. }
  25578. },
  25579. acceptsNav : function(row, col, cm){
  25580. return !cm.isHidden(col) && cm.isCellEditable(col, row);
  25581. },
  25582. onEditorKey : function(field, e){
  25583. var k = e.getKey(), newCell, g = this.grid, ed = g.activeEditor;
  25584. var shift = e.shiftKey;
  25585. if(k == e.TAB){
  25586. e.stopEvent();
  25587. ed.completeEdit();
  25588. if(shift){
  25589. newCell = g.walkCells(ed.row, ed.col-1, -1, this.acceptsNav, this);
  25590. }else{
  25591. newCell = g.walkCells(ed.row, ed.col+1, 1, this.acceptsNav, this);
  25592. }
  25593. }else if(k == e.ENTER){
  25594. e.stopEvent();
  25595. ed.completeEdit();
  25596. if(this.moveEditorOnEnter !== false){
  25597. if(shift){
  25598. newCell = g.walkCells(ed.row - 1, ed.col, -1, this.acceptsNav, this);
  25599. }else{
  25600. newCell = g.walkCells(ed.row + 1, ed.col, 1, this.acceptsNav, this);
  25601. }
  25602. }
  25603. }else if(k == e.ESC){
  25604. ed.cancelEdit();
  25605. }
  25606. if(newCell){
  25607. g.startEditing(newCell[0], newCell[1]);
  25608. }
  25609. }
  25610. });
  25611. Ext.grid.CellSelectionModel = function(config){
  25612. Ext.apply(this, config);
  25613. this.selection = null;
  25614. this.addEvents(
  25615. "beforecellselect",
  25616. "cellselect",
  25617. "selectionchange"
  25618. );
  25619. Ext.grid.CellSelectionModel.superclass.constructor.call(this);
  25620. };
  25621. Ext.extend(Ext.grid.CellSelectionModel, Ext.grid.AbstractSelectionModel, {
  25622. initEvents : function(){
  25623. this.grid.on("cellmousedown", this.handleMouseDown, this);
  25624. this.grid.getGridEl().on(Ext.isIE ? "keydown" : "keypress", this.handleKeyDown, this);
  25625. var view = this.grid.view;
  25626. view.on("refresh", this.onViewChange, this);
  25627. view.on("rowupdated", this.onRowUpdated, this);
  25628. view.on("beforerowremoved", this.clearSelections, this);
  25629. view.on("beforerowsinserted", this.clearSelections, this);
  25630. if(this.grid.isEditor){
  25631. this.grid.on("beforeedit", this.beforeEdit, this);
  25632. }
  25633. },
  25634. beforeEdit : function(e){
  25635. this.select(e.row, e.column, false, true, e.record);
  25636. },
  25637. onRowUpdated : function(v, index, r){
  25638. if(this.selection && this.selection.record == r){
  25639. v.onCellSelect(index, this.selection.cell[1]);
  25640. }
  25641. },
  25642. onViewChange : function(){
  25643. this.clearSelections(true);
  25644. },
  25645. getSelectedCell : function(){
  25646. return this.selection ? this.selection.cell : null;
  25647. },
  25648. clearSelections : function(preventNotify){
  25649. var s = this.selection;
  25650. if(s){
  25651. if(preventNotify !== true){
  25652. this.grid.view.onCellDeselect(s.cell[0], s.cell[1]);
  25653. }
  25654. this.selection = null;
  25655. this.fireEvent("selectionchange", this, null);
  25656. }
  25657. },
  25658. hasSelection : function(){
  25659. return this.selection ? true : false;
  25660. },
  25661. handleMouseDown : function(g, row, cell, e){
  25662. if(e.button !== 0 || this.isLocked()){
  25663. return;
  25664. };
  25665. this.select(row, cell);
  25666. },
  25667. select : function(rowIndex, colIndex, preventViewNotify, preventFocus, r){
  25668. if(this.fireEvent("beforecellselect", this, rowIndex, colIndex) !== false){
  25669. this.clearSelections();
  25670. r = r || this.grid.store.getAt(rowIndex);
  25671. this.selection = {
  25672. record : r,
  25673. cell : [rowIndex, colIndex]
  25674. };
  25675. if(!preventViewNotify){
  25676. var v = this.grid.getView();
  25677. v.onCellSelect(rowIndex, colIndex);
  25678. if(preventFocus !== true){
  25679. v.focusCell(rowIndex, colIndex);
  25680. }
  25681. }
  25682. this.fireEvent("cellselect", this, rowIndex, colIndex);
  25683. this.fireEvent("selectionchange", this, this.selection);
  25684. }
  25685. },
  25686. isSelectable : function(rowIndex, colIndex, cm){
  25687. return !cm.isHidden(colIndex);
  25688. },
  25689. handleKeyDown : function(e){
  25690. if(!e.isNavKeyPress()){
  25691. return;
  25692. }
  25693. var g = this.grid, s = this.selection;
  25694. if(!s){
  25695. e.stopEvent();
  25696. var cell = g.walkCells(0, 0, 1, this.isSelectable, this);
  25697. if(cell){
  25698. this.select(cell[0], cell[1]);
  25699. }
  25700. return;
  25701. }
  25702. var sm = this;
  25703. var walk = function(row, col, step){
  25704. return g.walkCells(row, col, step, sm.isSelectable, sm);
  25705. };
  25706. var k = e.getKey(), r = s.cell[0], c = s.cell[1];
  25707. var newCell;
  25708. switch(k){
  25709. case e.TAB:
  25710. if(e.shiftKey){
  25711. newCell = walk(r, c-1, -1);
  25712. }else{
  25713. newCell = walk(r, c+1, 1);
  25714. }
  25715. break;
  25716. case e.DOWN:
  25717. newCell = walk(r+1, c, 1);
  25718. break;
  25719. case e.UP:
  25720. newCell = walk(r-1, c, -1);
  25721. break;
  25722. case e.RIGHT:
  25723. newCell = walk(r, c+1, 1);
  25724. break;
  25725. case e.LEFT:
  25726. newCell = walk(r, c-1, -1);
  25727. break;
  25728. case e.ENTER:
  25729. if(g.isEditor && !g.editing){
  25730. g.startEditing(r, c);
  25731. e.stopEvent();
  25732. return;
  25733. }
  25734. break;
  25735. };
  25736. if(newCell){
  25737. this.select(newCell[0], newCell[1]);
  25738. e.stopEvent();
  25739. }
  25740. },
  25741. acceptsNav : function(row, col, cm){
  25742. return !cm.isHidden(col) && cm.isCellEditable(col, row);
  25743. },
  25744. onEditorKey : function(field, e){
  25745. var k = e.getKey(), newCell, g = this.grid, ed = g.activeEditor;
  25746. if(k == e.TAB){
  25747. if(e.shiftKey){
  25748. newCell = g.walkCells(ed.row, ed.col-1, -1, this.acceptsNav, this);
  25749. }else{
  25750. newCell = g.walkCells(ed.row, ed.col+1, 1, this.acceptsNav, this);
  25751. }
  25752. e.stopEvent();
  25753. }else if(k == e.ENTER){
  25754. ed.completeEdit();
  25755. e.stopEvent();
  25756. }else if(k == e.ESC){
  25757. e.stopEvent();
  25758. ed.cancelEdit();
  25759. }
  25760. if(newCell){
  25761. g.startEditing(newCell[0], newCell[1]);
  25762. }
  25763. }
  25764. });
  25765. Ext.grid.EditorGridPanel = Ext.extend(Ext.grid.GridPanel, {
  25766. clicksToEdit: 2,
  25767. isEditor : true,
  25768. detectEdit: false,
  25769. autoEncode : false,
  25770. trackMouseOver: false,
  25771. initComponent : function(){
  25772. Ext.grid.EditorGridPanel.superclass.initComponent.call(this);
  25773. if(!this.selModel){
  25774. this.selModel = new Ext.grid.CellSelectionModel();
  25775. }
  25776. this.activeEditor = null;
  25777. this.addEvents(
  25778. "beforeedit",
  25779. "afteredit",
  25780. "validateedit"
  25781. );
  25782. },
  25783. initEvents : function(){
  25784. Ext.grid.EditorGridPanel.superclass.initEvents.call(this);
  25785. this.on("bodyscroll", this.stopEditing, this, [true]);
  25786. if(this.clicksToEdit == 1){
  25787. this.on("cellclick", this.onCellDblClick, this);
  25788. }else {
  25789. if(this.clicksToEdit == 'auto' && this.view.mainBody){
  25790. this.view.mainBody.on("mousedown", this.onAutoEditClick, this);
  25791. }
  25792. this.on("celldblclick", this.onCellDblClick, this);
  25793. }
  25794. this.getGridEl().addClass("xedit-grid");
  25795. },
  25796. onCellDblClick : function(g, row, col){
  25797. this.startEditing(row, col);
  25798. },
  25799. onAutoEditClick : function(e, t){
  25800. if(e.button !== 0){
  25801. return;
  25802. }
  25803. var row = this.view.findRowIndex(t);
  25804. var col = this.view.findCellIndex(t);
  25805. if(row !== false && col !== false){
  25806. this.stopEditing();
  25807. if(this.selModel.getSelectedCell){
  25808. var sc = this.selModel.getSelectedCell();
  25809. if(sc && sc.cell[0] === row && sc.cell[1] === col){
  25810. this.startEditing(row, col);
  25811. }
  25812. }else{
  25813. if(this.selModel.isSelected(row)){
  25814. this.startEditing(row, col);
  25815. }
  25816. }
  25817. }
  25818. },
  25819. onEditComplete : function(ed, value, startValue){
  25820. this.editing = false;
  25821. this.activeEditor = null;
  25822. ed.un("specialkey", this.selModel.onEditorKey, this.selModel);
  25823. var r = ed.record;
  25824. var field = this.colModel.getDataIndex(ed.col);
  25825. value = this.postEditValue(value, startValue, r, field);
  25826. if(String(value) !== String(startValue)){
  25827. var e = {
  25828. grid: this,
  25829. record: r,
  25830. field: field,
  25831. originalValue: startValue,
  25832. value: value,
  25833. row: ed.row,
  25834. column: ed.col,
  25835. cancel:false
  25836. };
  25837. if(this.fireEvent("validateedit", e) !== false && !e.cancel){
  25838. r.set(field, e.value);
  25839. delete e.cancel;
  25840. this.fireEvent("afteredit", e);
  25841. }
  25842. }
  25843. this.view.focusCell(ed.row, ed.col);
  25844. },
  25845. startEditing : function(row, col){
  25846. this.stopEditing();
  25847. if(this.colModel.isCellEditable(col, row)){
  25848. this.view.ensureVisible(row, col, true);
  25849. var r = this.store.getAt(row);
  25850. var field = this.colModel.getDataIndex(col);
  25851. var e = {
  25852. grid: this,
  25853. record: r,
  25854. field: field,
  25855. value: r.data[field],
  25856. row: row,
  25857. column: col,
  25858. cancel:false
  25859. };
  25860. if(this.fireEvent("beforeedit", e) !== false && !e.cancel){
  25861. this.editing = true;
  25862. var ed = this.colModel.getCellEditor(col, row);
  25863. if(!ed.rendered){
  25864. ed.render(this.view.getEditorParent(ed));
  25865. }
  25866. (function(){
  25867. ed.row = row;
  25868. ed.col = col;
  25869. ed.record = r;
  25870. ed.on("complete", this.onEditComplete, this, {single: true});
  25871. ed.on("specialkey", this.selModel.onEditorKey, this.selModel);
  25872. this.activeEditor = ed;
  25873. var v = this.preEditValue(r, field);
  25874. ed.startEdit(this.view.getCell(row, col), v);
  25875. }).defer(50, this);
  25876. }
  25877. }
  25878. },
  25879. preEditValue : function(r, field){
  25880. return this.autoEncode && typeof value == 'string' ? Ext.util.Format.htmlDecode(r.data[field]) : r.data[field];
  25881. },
  25882. postEditValue : function(value, originalValue, r, field){
  25883. return this.autoEncode && typeof value == 'string' ? Ext.util.Format.htmlEncode(value) : value;
  25884. },
  25885. stopEditing : function(cancel){
  25886. if(this.activeEditor){
  25887. this.activeEditor[cancel === true ? 'cancelEdit' : 'completeEdit']();
  25888. }
  25889. this.activeEditor = null;
  25890. }
  25891. });
  25892. Ext.reg('editorgrid', Ext.grid.EditorGridPanel);
  25893. Ext.grid.GridEditor = function(field, config){
  25894. Ext.grid.GridEditor.superclass.constructor.call(this, field, config);
  25895. field.monitorTab = false;
  25896. };
  25897. Ext.extend(Ext.grid.GridEditor, Ext.Editor, {
  25898. alignment: "tl-tl",
  25899. autoSize: "width",
  25900. hideEl : false,
  25901. cls: "x-small-editor x-grid-editor",
  25902. shim:false,
  25903. shadow:false
  25904. });
  25905. Ext.grid.PropertyRecord = Ext.data.Record.create([
  25906. {name:'name',type:'string'}, 'value'
  25907. ]);
  25908. Ext.grid.PropertyStore = function(grid, source){
  25909. this.grid = grid;
  25910. this.store = new Ext.data.Store({
  25911. recordType : Ext.grid.PropertyRecord
  25912. });
  25913. this.store.on('update', this.onUpdate, this);
  25914. if(source){
  25915. this.setSource(source);
  25916. }
  25917. Ext.grid.PropertyStore.superclass.constructor.call(this);
  25918. };
  25919. Ext.extend(Ext.grid.PropertyStore, Ext.util.Observable, {
  25920. setSource : function(o){
  25921. this.source = o;
  25922. this.store.removeAll();
  25923. var data = [];
  25924. for(var k in o){
  25925. if(this.isEditableValue(o[k])){
  25926. data.push(new Ext.grid.PropertyRecord({name: k, value: o[k]}, k));
  25927. }
  25928. }
  25929. this.store.loadRecords({records: data}, {}, true);
  25930. },
  25931. onUpdate : function(ds, record, type){
  25932. if(type == Ext.data.Record.EDIT){
  25933. var v = record.data['value'];
  25934. var oldValue = record.modified['value'];
  25935. if(this.grid.fireEvent('beforepropertychange', this.source, record.id, v, oldValue) !== false){
  25936. this.source[record.id] = v;
  25937. record.commit();
  25938. this.grid.fireEvent('propertychange', this.source, record.id, v, oldValue);
  25939. }else{
  25940. record.reject();
  25941. }
  25942. }
  25943. },
  25944. getProperty : function(row){
  25945. return this.store.getAt(row);
  25946. },
  25947. isEditableValue: function(val){
  25948. if(Ext.isDate(val)){
  25949. return true;
  25950. }else if(typeof val == 'object' || typeof val == 'function'){
  25951. return false;
  25952. }
  25953. return true;
  25954. },
  25955. setValue : function(prop, value){
  25956. this.source[prop] = value;
  25957. this.store.getById(prop).set('value', value);
  25958. },
  25959. getSource : function(){
  25960. return this.source;
  25961. }
  25962. });
  25963. Ext.grid.PropertyColumnModel = function(grid, store){
  25964. this.grid = grid;
  25965. var g = Ext.grid;
  25966. g.PropertyColumnModel.superclass.constructor.call(this, [
  25967. {header: this.nameText, width:50, sortable: true, dataIndex:'name', id: 'name', menuDisabled:true},
  25968. {header: this.valueText, width:50, resizable:false, dataIndex: 'value', id: 'value', menuDisabled:true}
  25969. ]);
  25970. this.store = store;
  25971. this.bselect = Ext.DomHelper.append(document.body, {
  25972. tag: 'select', cls: 'x-grid-editor x-hide-display', children: [
  25973. {tag: 'option', value: 'true', html: 'true'},
  25974. {tag: 'option', value: 'false', html: 'false'}
  25975. ]
  25976. });
  25977. var f = Ext.form;
  25978. var bfield = new f.Field({
  25979. el:this.bselect,
  25980. bselect : this.bselect,
  25981. autoShow: true,
  25982. getValue : function(){
  25983. return this.bselect.value == 'true';
  25984. }
  25985. });
  25986. this.editors = {
  25987. 'date' : new g.GridEditor(new f.DateField({selectOnFocus:true})),
  25988. 'string' : new g.GridEditor(new f.TextField({selectOnFocus:true})),
  25989. 'number' : new g.GridEditor(new f.NumberField({selectOnFocus:true, style:'text-align:left;'})),
  25990. 'boolean' : new g.GridEditor(bfield)
  25991. };
  25992. this.renderCellDelegate = this.renderCell.createDelegate(this);
  25993. this.renderPropDelegate = this.renderProp.createDelegate(this);
  25994. };
  25995. Ext.extend(Ext.grid.PropertyColumnModel, Ext.grid.ColumnModel, {
  25996. nameText : 'Name',
  25997. valueText : 'Value',
  25998. dateFormat : 'm/j/Y',
  25999. renderDate : function(dateVal){
  26000. return dateVal.dateFormat(this.dateFormat);
  26001. },
  26002. renderBool : function(bVal){
  26003. return bVal ? 'true' : 'false';
  26004. },
  26005. isCellEditable : function(colIndex, rowIndex){
  26006. return colIndex == 1;
  26007. },
  26008. getRenderer : function(col){
  26009. return col == 1 ?
  26010. this.renderCellDelegate : this.renderPropDelegate;
  26011. },
  26012. renderProp : function(v){
  26013. return this.getPropertyName(v);
  26014. },
  26015. renderCell : function(val){
  26016. var rv = val;
  26017. if(Ext.isDate(val)){
  26018. rv = this.renderDate(val);
  26019. }else if(typeof val == 'boolean'){
  26020. rv = this.renderBool(val);
  26021. }
  26022. return Ext.util.Format.htmlEncode(rv);
  26023. },
  26024. getPropertyName : function(name){
  26025. var pn = this.grid.propertyNames;
  26026. return pn && pn[name] ? pn[name] : name;
  26027. },
  26028. getCellEditor : function(colIndex, rowIndex){
  26029. var p = this.store.getProperty(rowIndex);
  26030. var n = p.data['name'], val = p.data['value'];
  26031. if(this.grid.customEditors[n]){
  26032. return this.grid.customEditors[n];
  26033. }
  26034. if(Ext.isDate(val)){
  26035. return this.editors['date'];
  26036. }else if(typeof val == 'number'){
  26037. return this.editors['number'];
  26038. }else if(typeof val == 'boolean'){
  26039. return this.editors['boolean'];
  26040. }else{
  26041. return this.editors['string'];
  26042. }
  26043. }
  26044. });
  26045. Ext.grid.PropertyGrid = Ext.extend(Ext.grid.EditorGridPanel, {
  26046. enableColumnMove:false,
  26047. stripeRows:false,
  26048. trackMouseOver: false,
  26049. clicksToEdit:1,
  26050. enableHdMenu : false,
  26051. viewConfig : {
  26052. forceFit:true
  26053. },
  26054. initComponent : function(){
  26055. this.customEditors = this.customEditors || {};
  26056. this.lastEditRow = null;
  26057. var store = new Ext.grid.PropertyStore(this);
  26058. this.propStore = store;
  26059. var cm = new Ext.grid.PropertyColumnModel(this, store);
  26060. store.store.sort('name', 'ASC');
  26061. this.addEvents(
  26062. 'beforepropertychange',
  26063. 'propertychange'
  26064. );
  26065. this.cm = cm;
  26066. this.ds = store.store;
  26067. Ext.grid.PropertyGrid.superclass.initComponent.call(this);
  26068. this.selModel.on('beforecellselect', function(sm, rowIndex, colIndex){
  26069. if(colIndex === 0){
  26070. this.startEditing.defer(200, this, [rowIndex, 1]);
  26071. return false;
  26072. }
  26073. }, this);
  26074. },
  26075. onRender : function(){
  26076. Ext.grid.PropertyGrid.superclass.onRender.apply(this, arguments);
  26077. this.getGridEl().addClass('x-props-grid');
  26078. },
  26079. afterRender: function(){
  26080. Ext.grid.PropertyGrid.superclass.afterRender.apply(this, arguments);
  26081. if(this.source){
  26082. this.setSource(this.source);
  26083. }
  26084. },
  26085. setSource : function(source){
  26086. this.propStore.setSource(source);
  26087. },
  26088. getSource : function(){
  26089. return this.propStore.getSource();
  26090. }
  26091. });
  26092. Ext.grid.RowNumberer = function(config){
  26093. Ext.apply(this, config);
  26094. if(this.rowspan){
  26095. this.renderer = this.renderer.createDelegate(this);
  26096. }
  26097. };
  26098. Ext.grid.RowNumberer.prototype = {
  26099. header: "",
  26100. width: 23,
  26101. sortable: false,
  26102. fixed:true,
  26103. menuDisabled:true,
  26104. dataIndex: '',
  26105. id: 'numberer',
  26106. rowspan: undefined,
  26107. renderer : function(v, p, record, rowIndex){
  26108. if(this.rowspan){
  26109. p.cellAttr = 'rowspan="'+this.rowspan+'"';
  26110. }
  26111. return rowIndex+1;
  26112. }
  26113. };
  26114. Ext.grid.CheckboxSelectionModel = Ext.extend(Ext.grid.RowSelectionModel, {
  26115. header: '<div class="x-grid3-hd-checker">&#160;</div>',
  26116. width: 20,
  26117. sortable: false,
  26118. menuDisabled:true,
  26119. fixed:true,
  26120. dataIndex: '',
  26121. id: 'checker',
  26122. initEvents : function(){
  26123. Ext.grid.CheckboxSelectionModel.superclass.initEvents.call(this);
  26124. this.grid.on('render', function(){
  26125. var view = this.grid.getView();
  26126. view.mainBody.on('mousedown', this.onMouseDown, this);
  26127. Ext.fly(view.innerHd).on('mousedown', this.onHdMouseDown, this);
  26128. }, this);
  26129. },
  26130. onMouseDown : function(e, t){
  26131. if(e.button === 0 && t.className == 'x-grid3-row-checker'){
  26132. e.stopEvent();
  26133. var row = e.getTarget('.x-grid3-row');
  26134. if(row){
  26135. var index = row.rowIndex;
  26136. if(this.isSelected(index)){
  26137. this.deselectRow(index);
  26138. }else{
  26139. this.selectRow(index, true);
  26140. }
  26141. }
  26142. }
  26143. },
  26144. onHdMouseDown : function(e, t){
  26145. if(t.className == 'x-grid3-hd-checker'){
  26146. e.stopEvent();
  26147. var hd = Ext.fly(t.parentNode);
  26148. var isChecked = hd.hasClass('x-grid3-hd-checker-on');
  26149. if(isChecked){
  26150. hd.removeClass('x-grid3-hd-checker-on');
  26151. this.clearSelections();
  26152. }else{
  26153. hd.addClass('x-grid3-hd-checker-on');
  26154. this.selectAll();
  26155. }
  26156. }
  26157. },
  26158. renderer : function(v, p, record){
  26159. return '<div class="x-grid3-row-checker">&#160;</div>';
  26160. }
  26161. });
  26162. Ext.LoadMask = function(el, config){
  26163. this.el = Ext.get(el);
  26164. Ext.apply(this, config);
  26165. if(this.store){
  26166. this.store.on('beforeload', this.onBeforeLoad, this);
  26167. this.store.on('load', this.onLoad, this);
  26168. this.store.on('loadexception', this.onLoad, this);
  26169. this.removeMask = Ext.value(this.removeMask, false);
  26170. }else{
  26171. var um = this.el.getUpdater();
  26172. um.showLoadIndicator = false; um.on('beforeupdate', this.onBeforeLoad, this);
  26173. um.on('update', this.onLoad, this);
  26174. um.on('failure', this.onLoad, this);
  26175. this.removeMask = Ext.value(this.removeMask, true);
  26176. }
  26177. };
  26178. Ext.LoadMask.prototype = {
  26179. msg : 'Loading...',
  26180. msgCls : 'x-mask-loading',
  26181. disabled: false,
  26182. disable : function(){
  26183. this.disabled = true;
  26184. },
  26185. enable : function(){
  26186. this.disabled = false;
  26187. },
  26188. onLoad : function(){
  26189. this.el.unmask(this.removeMask);
  26190. },
  26191. onBeforeLoad : function(){
  26192. if(!this.disabled){
  26193. this.el.mask(this.msg, this.msgCls);
  26194. }
  26195. },
  26196. show: function(){
  26197. this.onBeforeLoad();
  26198. },
  26199. hide: function(){
  26200. this.onLoad();
  26201. },
  26202. destroy : function(){
  26203. if(this.store){
  26204. this.store.un('beforeload', this.onBeforeLoad, this);
  26205. this.store.un('load', this.onLoad, this);
  26206. this.store.un('loadexception', this.onLoad, this);
  26207. }else{
  26208. var um = this.el.getUpdater();
  26209. um.un('beforeupdate', this.onBeforeLoad, this);
  26210. um.un('update', this.onLoad, this);
  26211. um.un('failure', this.onLoad, this);
  26212. }
  26213. }
  26214. };
  26215. Ext.ProgressBar = Ext.extend(Ext.BoxComponent, {
  26216. baseCls : 'x-progress',
  26217. waitTimer : null,
  26218. initComponent : function(){
  26219. Ext.ProgressBar.superclass.initComponent.call(this);
  26220. this.addEvents(
  26221. "update"
  26222. );
  26223. },
  26224. onRender : function(ct, position){
  26225. Ext.ProgressBar.superclass.onRender.call(this, ct, position);
  26226. var tpl = new Ext.Template(
  26227. '<div class="{cls}-wrap">',
  26228. '<div class="{cls}-inner">',
  26229. '<div class="{cls}-bar">',
  26230. '<div class="{cls}-text">',
  26231. '<div>&#160;</div>',
  26232. '</div>',
  26233. '</div>',
  26234. '<div class="{cls}-text {cls}-text-back">',
  26235. '<div>&#160;</div>',
  26236. '</div>',
  26237. '</div>',
  26238. '</div>'
  26239. );
  26240. if(position){
  26241. this.el = tpl.insertBefore(position, {cls: this.baseCls}, true);
  26242. }else{
  26243. this.el = tpl.append(ct, {cls: this.baseCls}, true);
  26244. }
  26245. if(this.id){
  26246. this.el.dom.id = this.id;
  26247. }
  26248. var inner = this.el.dom.firstChild;
  26249. this.progressBar = Ext.get(inner.firstChild);
  26250. if(this.textEl){
  26251. this.textEl = Ext.get(this.textEl);
  26252. delete this.textTopEl;
  26253. }else{
  26254. this.textTopEl = Ext.get(this.progressBar.dom.firstChild);
  26255. var textBackEl = Ext.get(inner.childNodes[1]);
  26256. this.textTopEl.setStyle("z-index", 99).addClass('x-hidden');
  26257. this.textEl = new Ext.CompositeElement([this.textTopEl.dom.firstChild, textBackEl.dom.firstChild]);
  26258. this.textEl.setWidth(inner.offsetWidth);
  26259. }
  26260. if(this.value){
  26261. this.updateProgress(this.value, this.text);
  26262. }else{
  26263. this.updateText(this.text);
  26264. }
  26265. this.setSize(this.width || 'auto', 'auto');
  26266. this.progressBar.setHeight(inner.offsetHeight);
  26267. },
  26268. updateProgress : function(value, text){
  26269. this.value = value || 0;
  26270. if(text){
  26271. this.updateText(text);
  26272. }
  26273. var w = Math.floor(value*this.el.dom.firstChild.offsetWidth);
  26274. this.progressBar.setWidth(w);
  26275. if(this.textTopEl){
  26276. this.textTopEl.removeClass('x-hidden').setWidth(w);
  26277. }
  26278. this.fireEvent('update', this, value, text);
  26279. return this;
  26280. },
  26281. wait : function(o){
  26282. if(!this.waitTimer){
  26283. var scope = this;
  26284. o = o || {};
  26285. this.waitTimer = Ext.TaskMgr.start({
  26286. run: function(i){
  26287. var inc = o.increment || 10;
  26288. this.updateProgress(((((i+inc)%inc)+1)*(100/inc))*.01);
  26289. },
  26290. interval: o.interval || 1000,
  26291. duration: o.duration,
  26292. onStop: function(){
  26293. if(o.fn){
  26294. o.fn.apply(o.scope || this);
  26295. }
  26296. this.reset();
  26297. },
  26298. scope: scope
  26299. });
  26300. }
  26301. return this;
  26302. },
  26303. isWaiting : function(){
  26304. return this.waitTimer != null;
  26305. },
  26306. updateText : function(text){
  26307. this.text = text || '&#160;';
  26308. this.textEl.update(this.text);
  26309. return this;
  26310. },
  26311. setSize : function(w, h){
  26312. Ext.ProgressBar.superclass.setSize.call(this, w, h);
  26313. if(this.textTopEl){
  26314. var inner = this.el.dom.firstChild;
  26315. this.textEl.setSize(inner.offsetWidth, inner.offsetHeight);
  26316. }
  26317. return this;
  26318. },
  26319. reset : function(hide){
  26320. this.updateProgress(0);
  26321. if(this.textTopEl){
  26322. this.textTopEl.addClass('x-hidden');
  26323. }
  26324. if(this.waitTimer){
  26325. this.waitTimer.onStop = null;
  26326. Ext.TaskMgr.stop(this.waitTimer);
  26327. this.waitTimer = null;
  26328. }
  26329. if(hide === true){
  26330. this.hide();
  26331. }
  26332. return this;
  26333. }
  26334. });
  26335. Ext.reg('progress', Ext.ProgressBar);
  26336. Ext.debug = {};
  26337. (function(){
  26338. var cp;
  26339. function createConsole(){
  26340. var scriptPanel = new Ext.debug.ScriptsPanel();
  26341. var logView = new Ext.debug.LogPanel();
  26342. var tree = new Ext.debug.DomTree();
  26343. var tabs = new Ext.TabPanel({
  26344. activeTab: 0,
  26345. border: false,
  26346. tabPosition: 'bottom',
  26347. items: [{
  26348. title: 'Debug Console',
  26349. layout:'border',
  26350. items: [logView, scriptPanel]
  26351. },{
  26352. title: 'DOM Inspector',
  26353. layout:'border',
  26354. items: [tree]
  26355. }]
  26356. });
  26357. cp = new Ext.Panel({
  26358. id: 'x-debug-browser',
  26359. title: 'Console',
  26360. collapsible: true,
  26361. animCollapse: false,
  26362. style: 'position:absolute;left:0;bottom:0;',
  26363. height:200,
  26364. logView: logView,
  26365. layout: 'fit',
  26366. tools:[{
  26367. id: 'close',
  26368. handler: function(){
  26369. cp.destroy();
  26370. cp = null;
  26371. Ext.EventManager.removeResizeListener(handleResize);
  26372. }
  26373. }],
  26374. items: tabs
  26375. });
  26376. cp.render(document.body);
  26377. cp.resizer = new Ext.Resizable(cp.el, {
  26378. minHeight:50,
  26379. handles: "n",
  26380. pinned: true,
  26381. transparent:true,
  26382. resizeElement : function(){
  26383. var box = this.proxy.getBox();
  26384. this.proxy.hide();
  26385. cp.setHeight(box.height);
  26386. return box;
  26387. }
  26388. });
  26389. function handleResize(){
  26390. cp.setWidth(Ext.getBody().getViewSize().width);
  26391. }
  26392. Ext.EventManager.onWindowResize(handleResize);
  26393. handleResize();
  26394. }
  26395. Ext.apply(Ext, {
  26396. log : function(){
  26397. if(!cp){
  26398. createConsole();
  26399. }
  26400. cp.logView.log.apply(cp.logView, arguments);
  26401. },
  26402. logf : function(format, arg1, arg2, etc){
  26403. Ext.log(String.format.apply(String, arguments));
  26404. },
  26405. dump : function(o){
  26406. if(typeof o == 'string' || typeof o == 'number' || typeof o == 'undefined' || Ext.isDate(o)){
  26407. Ext.log(o);
  26408. }else if(!o){
  26409. Ext.log("null");
  26410. }else if(typeof o != "object"){
  26411. Ext.log('Unknown return type');
  26412. }else if(Ext.isArray(o)){
  26413. Ext.log('['+o.join(',')+']');
  26414. }else{
  26415. var b = ["{\n"];
  26416. for(var key in o){
  26417. var to = typeof o[key];
  26418. if(to != "function" && to != "object"){
  26419. b.push(String.format(" {0}: {1},\n", key, o[key]));
  26420. }
  26421. }
  26422. var s = b.join("");
  26423. if(s.length > 3){
  26424. s = s.substr(0, s.length-2);
  26425. }
  26426. Ext.log(s + "\n}");
  26427. }
  26428. },
  26429. _timers : {},
  26430. time : function(name){
  26431. name = name || "def";
  26432. Ext._timers[name] = new Date().getTime();
  26433. },
  26434. timeEnd : function(name, printResults){
  26435. var t = new Date().getTime();
  26436. name = name || "def";
  26437. var v = String.format("{0} ms", t-Ext._timers[name]);
  26438. Ext._timers[name] = new Date().getTime();
  26439. if(printResults !== false){
  26440. Ext.log('Timer ' + (name == "def" ? v : name + ": " + v));
  26441. }
  26442. return v;
  26443. }
  26444. });
  26445. })();
  26446. Ext.debug.ScriptsPanel = Ext.extend(Ext.Panel, {
  26447. id:'x-debug-scripts',
  26448. region: 'east',
  26449. minWidth: 200,
  26450. split: true,
  26451. width: 350,
  26452. border: false,
  26453. layout:'anchor',
  26454. style:'border-width:0 0 0 1px;',
  26455. initComponent : function(){
  26456. this.scriptField = new Ext.form.TextArea({
  26457. anchor: '100% -26',
  26458. style:'border-width:0;'
  26459. });
  26460. this.trapBox = new Ext.form.Checkbox({
  26461. id: 'console-trap',
  26462. boxLabel: 'Trap Errors',
  26463. checked: true
  26464. });
  26465. this.toolbar = new Ext.Toolbar([{
  26466. text: 'Run',
  26467. scope: this,
  26468. handler: this.evalScript
  26469. },{
  26470. text: 'Clear',
  26471. scope: this,
  26472. handler: this.clear
  26473. },
  26474. '->',
  26475. this.trapBox,
  26476. ' ', ' '
  26477. ]);
  26478. this.items = [this.toolbar, this.scriptField];
  26479. Ext.debug.ScriptsPanel.superclass.initComponent.call(this);
  26480. },
  26481. evalScript : function(){
  26482. var s = this.scriptField.getValue();
  26483. if(this.trapBox.getValue()){
  26484. try{
  26485. var rt = eval(s);
  26486. Ext.dump(rt === undefined? '(no return)' : rt);
  26487. }catch(e){
  26488. Ext.log(e.message || e.descript);
  26489. }
  26490. }else{
  26491. var rt = eval(s);
  26492. Ext.dump(rt === undefined? '(no return)' : rt);
  26493. }
  26494. },
  26495. clear : function(){
  26496. this.scriptField.setValue('');
  26497. this.scriptField.focus();
  26498. }
  26499. });
  26500. Ext.debug.LogPanel = Ext.extend(Ext.Panel, {
  26501. autoScroll: true,
  26502. region: 'center',
  26503. border: false,
  26504. style:'border-width:0 1px 0 0',
  26505. log : function(){
  26506. var markup = [ '<div style="padding:5px !important;border-bottom:1px solid #ccc;">',
  26507. Ext.util.Format.htmlEncode(Array.prototype.join.call(arguments, ', ')).replace(/\n/g, '<br />').replace(/\s/g, '&#160;'),
  26508. '</div>'].join('');
  26509. this.body.insertHtml('beforeend', markup);
  26510. this.body.scrollTo('top', 100000);
  26511. },
  26512. clear : function(){
  26513. this.body.update('');
  26514. this.body.dom.scrollTop = 0;
  26515. }
  26516. });
  26517. Ext.debug.DomTree = Ext.extend(Ext.tree.TreePanel, {
  26518. enableDD:false ,
  26519. lines:false,
  26520. rootVisible:false,
  26521. animate:false,
  26522. hlColor:'ffff9c',
  26523. autoScroll: true,
  26524. region:'center',
  26525. border:false,
  26526. initComponent : function(){
  26527. Ext.debug.DomTree.superclass.initComponent.call(this);
  26528. var styles = false, hnode;
  26529. var nonSpace = /^\s*$/;
  26530. var html = Ext.util.Format.htmlEncode;
  26531. var ellipsis = Ext.util.Format.ellipsis;
  26532. var styleRe = /\s?([a-z\-]*)\:([^;]*)(?:[;\s\n\r]*)/gi;
  26533. function findNode(n){
  26534. if(!n || n.nodeType != 1 || n == document.body || n == document){
  26535. return false;
  26536. }
  26537. var pn = [n], p = n;
  26538. while((p = p.parentNode) && p.nodeType == 1 && p.tagName.toUpperCase() != 'HTML'){
  26539. pn.unshift(p);
  26540. }
  26541. var cn = hnode;
  26542. for(var i = 0, len = pn.length; i < len; i++){
  26543. cn.expand();
  26544. cn = cn.findChild('htmlNode', pn[i]);
  26545. if(!cn){ return false;
  26546. }
  26547. }
  26548. cn.select();
  26549. var a = cn.ui.anchor;
  26550. treeEl.dom.scrollTop = Math.max(0 ,a.offsetTop-10);
  26551. cn.highlight();
  26552. return true;
  26553. }
  26554. function nodeTitle(n){
  26555. var s = n.tagName;
  26556. if(n.id){
  26557. s += '#'+n.id;
  26558. }else if(n.className){
  26559. s += '.'+n.className;
  26560. }
  26561. return s;
  26562. }
  26563. function onNodeSelect(t, n, last){
  26564. return;
  26565. if(last && last.unframe){
  26566. last.unframe();
  26567. }
  26568. var props = {};
  26569. if(n && n.htmlNode){
  26570. if(frameEl.pressed){
  26571. n.frame();
  26572. }
  26573. if(inspecting){
  26574. return;
  26575. }
  26576. addStyle.enable();
  26577. reload.setDisabled(n.leaf);
  26578. var dom = n.htmlNode;
  26579. stylePanel.setTitle(nodeTitle(dom));
  26580. if(styles && !showAll.pressed){
  26581. var s = dom.style ? dom.style.cssText : '';
  26582. if(s){
  26583. var m;
  26584. while ((m = styleRe.exec(s)) != null){
  26585. props[m[1].toLowerCase()] = m[2];
  26586. }
  26587. }
  26588. }else if(styles){
  26589. var cl = Ext.debug.cssList;
  26590. var s = dom.style, fly = Ext.fly(dom);
  26591. if(s){
  26592. for(var i = 0, len = cl.length; i<len; i++){
  26593. var st = cl[i];
  26594. var v = s[st] || fly.getStyle(st);
  26595. if(v != undefined && v !== null && v !== ''){
  26596. props[st] = v;
  26597. }
  26598. }
  26599. }
  26600. }else{
  26601. for(var a in dom){
  26602. var v = dom[a];
  26603. if((isNaN(a+10)) && v != undefined && v !== null && v !== '' && !(Ext.isGecko && a[0] == a[0].toUpperCase())){
  26604. props[a] = v;
  26605. }
  26606. }
  26607. }
  26608. }else{
  26609. if(inspecting){
  26610. return;
  26611. }
  26612. addStyle.disable();
  26613. reload.disabled();
  26614. }
  26615. stylesGrid.setSource(props);
  26616. stylesGrid.treeNode = n;
  26617. stylesGrid.view.fitColumns();
  26618. }
  26619. this.loader = new Ext.tree.TreeLoader();
  26620. this.loader.load = function(n, cb){
  26621. var isBody = n.htmlNode == document.body;
  26622. var cn = n.htmlNode.childNodes;
  26623. for(var i = 0, c; c = cn[i]; i++){
  26624. if(isBody && c.id == 'x-debug-browser'){
  26625. continue;
  26626. }
  26627. if(c.nodeType == 1){
  26628. n.appendChild(new Ext.debug.HtmlNode(c));
  26629. }else if(c.nodeType == 3 && !nonSpace.test(c.nodeValue)){
  26630. n.appendChild(new Ext.tree.TreeNode({
  26631. text:'<em>' + ellipsis(html(String(c.nodeValue)), 35) + '</em>',
  26632. cls: 'x-tree-noicon'
  26633. }));
  26634. }
  26635. }
  26636. cb();
  26637. };
  26638. this.root = this.setRootNode(new Ext.tree.TreeNode('Ext'));
  26639. hnode = this.root.appendChild(new Ext.debug.HtmlNode(
  26640. document.getElementsByTagName('html')[0]
  26641. ));
  26642. }
  26643. });
  26644. Ext.debug.HtmlNode = function(){
  26645. var html = Ext.util.Format.htmlEncode;
  26646. var ellipsis = Ext.util.Format.ellipsis;
  26647. var nonSpace = /^\s*$/;
  26648. var attrs = [
  26649. {n: 'id', v: 'id'},
  26650. {n: 'className', v: 'class'},
  26651. {n: 'name', v: 'name'},
  26652. {n: 'type', v: 'type'},
  26653. {n: 'src', v: 'src'},
  26654. {n: 'href', v: 'href'}
  26655. ];
  26656. function hasChild(n){
  26657. for(var i = 0, c; c = n.childNodes[i]; i++){
  26658. if(c.nodeType == 1){
  26659. return true;
  26660. }
  26661. }
  26662. return false;
  26663. }
  26664. function renderNode(n, leaf){
  26665. var tag = n.tagName.toLowerCase();
  26666. var s = '&lt;' + tag;
  26667. for(var i = 0, len = attrs.length; i < len; i++){
  26668. var a = attrs[i];
  26669. var v = n[a.n];
  26670. if(v && !nonSpace.test(v)){
  26671. s += ' ' + a.v + '=&quot;<i>' + html(v) +'</i>&quot;';
  26672. }
  26673. }
  26674. var style = n.style ? n.style.cssText : '';
  26675. if(style){
  26676. s += ' style=&quot;<i>' + html(style.toLowerCase()) +'</i>&quot;';
  26677. }
  26678. if(leaf && n.childNodes.length > 0){
  26679. s+='&gt;<em>' + ellipsis(html(String(n.innerHTML)), 35) + '</em>&lt;/'+tag+'&gt;';
  26680. }else if(leaf){
  26681. s += ' /&gt;';
  26682. }else{
  26683. s += '&gt;';
  26684. }
  26685. return s;
  26686. }
  26687. var HtmlNode = function(n){
  26688. var leaf = !hasChild(n);
  26689. this.htmlNode = n;
  26690. this.tagName = n.tagName.toLowerCase();
  26691. var attr = {
  26692. text : renderNode(n, leaf),
  26693. leaf : leaf,
  26694. cls: 'x-tree-noicon'
  26695. };
  26696. HtmlNode.superclass.constructor.call(this, attr);
  26697. this.attributes.htmlNode = n; if(!leaf){
  26698. this.on('expand', this.onExpand, this);
  26699. this.on('collapse', this.onCollapse, this);
  26700. }
  26701. };
  26702. Ext.extend(HtmlNode, Ext.tree.AsyncTreeNode, {
  26703. cls: 'x-tree-noicon',
  26704. preventHScroll: true,
  26705. refresh : function(highlight){
  26706. var leaf = !hasChild(this.htmlNode);
  26707. this.setText(renderNode(this.htmlNode, leaf));
  26708. if(highlight){
  26709. Ext.fly(this.ui.textNode).highlight();
  26710. }
  26711. },
  26712. onExpand : function(){
  26713. if(!this.closeNode && this.parentNode){
  26714. this.closeNode = this.parentNode.insertBefore(new Ext.tree.TreeNode({
  26715. text:'&lt;/' + this.tagName + '&gt;',
  26716. cls: 'x-tree-noicon'
  26717. }), this.nextSibling);
  26718. }else if(this.closeNode){
  26719. this.closeNode.ui.show();
  26720. }
  26721. },
  26722. onCollapse : function(){
  26723. if(this.closeNode){
  26724. this.closeNode.ui.hide();
  26725. }
  26726. },
  26727. render : function(bulkRender){
  26728. HtmlNode.superclass.render.call(this, bulkRender);
  26729. },
  26730. highlightNode : function(){
  26731. },
  26732. highlight : function(){
  26733. },
  26734. frame : function(){
  26735. this.htmlNode.style.border = '1px solid #0000ff';
  26736. },
  26737. unframe : function(){
  26738. this.htmlNode.style.border = '';
  26739. }
  26740. });
  26741. return HtmlNode;
  26742. }();