ext-debug-w-comments.js 941 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813
  1. /*
  2. Ext JS 4.1 - JavaScript Library
  3. Copyright (c) 2006-2012, Sencha Inc.
  4. All rights reserved.
  5. licensing@sencha.com
  6. http://www.sencha.com/license
  7. Open Source License
  8. ------------------------------------------------------------------------------------------
  9. This version of Ext JS is licensed under the terms of the Open Source GPL 3.0 license.
  10. http://www.gnu.org/licenses/gpl.html
  11. There are several FLOSS exceptions available for use with this release for
  12. open source applications that are distributed under a license other than GPL.
  13. * Open Source License Exception for Applications
  14. http://www.sencha.com/products/floss-exception.php
  15. * Open Source License Exception for Development
  16. http://www.sencha.com/products/ux-exception.php
  17. Alternate Licensing
  18. ------------------------------------------------------------------------------------------
  19. Commercial and OEM Licenses are available for an alternate download of Ext JS.
  20. This is the appropriate option if you are creating proprietary applications and you are
  21. not prepared to distribute and share the source code of your application under the
  22. GPL v3 license. Please visit http://www.sencha.com/license for more details.
  23. --
  24. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT OF THIRD-PARTY INTELLECTUAL PROPERTY RIGHTS. See the GNU General Public License for more details.
  25. */
  26. //@tag foundation,core
  27. /**
  28. * @class Ext
  29. * @singleton
  30. */
  31. var Ext = Ext || {};
  32. Ext._startTime = new Date().getTime();
  33. (function() {
  34. var global = this,
  35. objectPrototype = Object.prototype,
  36. toString = objectPrototype.toString,
  37. enumerables = true,
  38. enumerablesTest = { toString: 1 },
  39. emptyFn = function () {},
  40. // This is the "$previous" method of a hook function on an instance. When called, it
  41. // calls through the class prototype by the name of the called method.
  42. callOverrideParent = function () {
  43. var method = callOverrideParent.caller.caller; // skip callParent (our caller)
  44. return method.$owner.prototype[method.$name].apply(this, arguments);
  45. },
  46. i;
  47. Ext.global = global;
  48. for (i in enumerablesTest) {
  49. enumerables = null;
  50. }
  51. if (enumerables) {
  52. enumerables = ['hasOwnProperty', 'valueOf', 'isPrototypeOf', 'propertyIsEnumerable',
  53. 'toLocaleString', 'toString', 'constructor'];
  54. }
  55. /**
  56. * An array containing extra enumerables for old browsers
  57. * @property {String[]}
  58. */
  59. Ext.enumerables = enumerables;
  60. /**
  61. * Copies all the properties of config to the specified object.
  62. * Note that if recursive merging and cloning without referencing the original objects / arrays is needed, use
  63. * {@link Ext.Object#merge} instead.
  64. * @param {Object} object The receiver of the properties
  65. * @param {Object} config The source of the properties
  66. * @param {Object} [defaults] A different object that will also be applied for default values
  67. * @return {Object} returns obj
  68. */
  69. Ext.apply = function(object, config, defaults) {
  70. if (defaults) {
  71. Ext.apply(object, defaults);
  72. }
  73. if (object && config && typeof config === 'object') {
  74. var i, j, k;
  75. for (i in config) {
  76. object[i] = config[i];
  77. }
  78. if (enumerables) {
  79. for (j = enumerables.length; j--;) {
  80. k = enumerables[j];
  81. if (config.hasOwnProperty(k)) {
  82. object[k] = config[k];
  83. }
  84. }
  85. }
  86. }
  87. return object;
  88. };
  89. Ext.buildSettings = Ext.apply({
  90. baseCSSPrefix: 'x-',
  91. scopeResetCSS: false
  92. }, Ext.buildSettings || {});
  93. Ext.apply(Ext, {
  94. /**
  95. * @property {String} [name='Ext']
  96. * <p>The name of the property in the global namespace (The <code>window</code> in browser environments) which refers to the current instance of Ext.</p>
  97. * <p>This is usually <code>"Ext"</code>, but if a sandboxed build of ExtJS is being used, this will be an alternative name.</p>
  98. * <p>If code is being generated for use by <code>eval</code> or to create a <code>new Function</code>, and the global instance
  99. * of Ext must be referenced, this is the name that should be built into the code.</p>
  100. */
  101. name: Ext.sandboxName || 'Ext',
  102. /**
  103. * A reusable empty function
  104. */
  105. emptyFn: emptyFn,
  106. /**
  107. * A zero length string which will pass a truth test. Useful for passing to methods
  108. * which use a truth test to reject <i>falsy</i> values where a string value must be cleared.
  109. */
  110. emptyString: new String(),
  111. baseCSSPrefix: Ext.buildSettings.baseCSSPrefix,
  112. /**
  113. * Copies all the properties of config to object if they don't already exist.
  114. * @param {Object} object The receiver of the properties
  115. * @param {Object} config The source of the properties
  116. * @return {Object} returns obj
  117. */
  118. applyIf: function(object, config) {
  119. var property;
  120. if (object) {
  121. for (property in config) {
  122. if (object[property] === undefined) {
  123. object[property] = config[property];
  124. }
  125. }
  126. }
  127. return object;
  128. },
  129. /**
  130. * Iterates either an array or an object. This method delegates to
  131. * {@link Ext.Array#each Ext.Array.each} if the given value is iterable, and {@link Ext.Object#each Ext.Object.each} otherwise.
  132. *
  133. * @param {Object/Array} object The object or array to be iterated.
  134. * @param {Function} fn The function to be called for each iteration. See and {@link Ext.Array#each Ext.Array.each} and
  135. * {@link Ext.Object#each Ext.Object.each} for detailed lists of arguments passed to this function depending on the given object
  136. * type that is being iterated.
  137. * @param {Object} scope (Optional) The scope (`this` reference) in which the specified function is executed.
  138. * Defaults to the object being iterated itself.
  139. * @markdown
  140. */
  141. iterate: function(object, fn, scope) {
  142. if (Ext.isEmpty(object)) {
  143. return;
  144. }
  145. if (scope === undefined) {
  146. scope = object;
  147. }
  148. if (Ext.isIterable(object)) {
  149. Ext.Array.each.call(Ext.Array, object, fn, scope);
  150. }
  151. else {
  152. Ext.Object.each.call(Ext.Object, object, fn, scope);
  153. }
  154. }
  155. });
  156. Ext.apply(Ext, {
  157. /**
  158. * This method deprecated. Use {@link Ext#define Ext.define} instead.
  159. * @method
  160. * @param {Function} superclass
  161. * @param {Object} overrides
  162. * @return {Function} The subclass constructor from the <tt>overrides</tt> parameter, or a generated one if not provided.
  163. * @deprecated 4.0.0 Use {@link Ext#define Ext.define} instead
  164. */
  165. extend: (function() {
  166. // inline overrides
  167. var objectConstructor = objectPrototype.constructor,
  168. inlineOverrides = function(o) {
  169. for (var m in o) {
  170. if (!o.hasOwnProperty(m)) {
  171. continue;
  172. }
  173. this[m] = o[m];
  174. }
  175. };
  176. return function(subclass, superclass, overrides) {
  177. // First we check if the user passed in just the superClass with overrides
  178. if (Ext.isObject(superclass)) {
  179. overrides = superclass;
  180. superclass = subclass;
  181. subclass = overrides.constructor !== objectConstructor ? overrides.constructor : function() {
  182. superclass.apply(this, arguments);
  183. };
  184. }
  185. // We create a new temporary class
  186. var F = function() {},
  187. subclassProto, superclassProto = superclass.prototype;
  188. F.prototype = superclassProto;
  189. subclassProto = subclass.prototype = new F();
  190. subclassProto.constructor = subclass;
  191. subclass.superclass = superclassProto;
  192. if (superclassProto.constructor === objectConstructor) {
  193. superclassProto.constructor = superclass;
  194. }
  195. subclass.override = function(overrides) {
  196. Ext.override(subclass, overrides);
  197. };
  198. subclassProto.override = inlineOverrides;
  199. subclassProto.proto = subclassProto;
  200. subclass.override(overrides);
  201. subclass.extend = function(o) {
  202. return Ext.extend(subclass, o);
  203. };
  204. return subclass;
  205. };
  206. }()),
  207. /**
  208. * Overrides members of the specified `target` with the given values.
  209. *
  210. * If the `target` is a class declared using {@link Ext#define Ext.define}, the
  211. * `override` method of that class is called (see {@link Ext.Base#override}) given
  212. * the `overrides`.
  213. *
  214. * If the `target` is a function, it is assumed to be a constructor and the contents
  215. * of `overrides` are applied to its `prototype` using {@link Ext#apply Ext.apply}.
  216. *
  217. * If the `target` is an instance of a class declared using {@link Ext#define Ext.define},
  218. * the `overrides` are applied to only that instance. In this case, methods are
  219. * specially processed to allow them to use {@link Ext.Base#callParent}.
  220. *
  221. * var panel = new Ext.Panel({ ... });
  222. *
  223. * Ext.override(panel, {
  224. * initComponent: function () {
  225. * // extra processing...
  226. *
  227. * this.callParent();
  228. * }
  229. * });
  230. *
  231. * If the `target` is none of these, the `overrides` are applied to the `target`
  232. * using {@link Ext#apply Ext.apply}.
  233. *
  234. * Please refer to {@link Ext#define Ext.define} and {@link Ext.Base#override} for
  235. * further details.
  236. *
  237. * @param {Object} target The target to override.
  238. * @param {Object} overrides The properties to add or replace on `target`.
  239. * @method override
  240. */
  241. override: function (target, overrides) {
  242. if (target.$isClass) {
  243. target.override(overrides);
  244. } else if (typeof target == 'function') {
  245. Ext.apply(target.prototype, overrides);
  246. } else {
  247. var owner = target.self,
  248. name, value;
  249. if (owner && owner.$isClass) { // if (instance of Ext.define'd class)
  250. for (name in overrides) {
  251. if (overrides.hasOwnProperty(name)) {
  252. value = overrides[name];
  253. if (typeof value == 'function') {
  254. value.$name = name;
  255. value.$owner = owner;
  256. value.$previous = target.hasOwnProperty(name)
  257. ? target[name] // already hooked, so call previous hook
  258. : callOverrideParent; // calls by name on prototype
  259. }
  260. target[name] = value;
  261. }
  262. }
  263. } else {
  264. Ext.apply(target, overrides);
  265. }
  266. }
  267. return target;
  268. }
  269. });
  270. // A full set of static methods to do type checking
  271. Ext.apply(Ext, {
  272. /**
  273. * Returns the given value itself if it's not empty, as described in {@link Ext#isEmpty}; returns the default
  274. * value (second argument) otherwise.
  275. *
  276. * @param {Object} value The value to test
  277. * @param {Object} defaultValue The value to return if the original value is empty
  278. * @param {Boolean} allowBlank (optional) true to allow zero length strings to qualify as non-empty (defaults to false)
  279. * @return {Object} value, if non-empty, else defaultValue
  280. */
  281. valueFrom: function(value, defaultValue, allowBlank){
  282. return Ext.isEmpty(value, allowBlank) ? defaultValue : value;
  283. },
  284. /**
  285. * Returns the type of the given variable in string format. List of possible values are:
  286. *
  287. * - `undefined`: If the given value is `undefined`
  288. * - `null`: If the given value is `null`
  289. * - `string`: If the given value is a string
  290. * - `number`: If the given value is a number
  291. * - `boolean`: If the given value is a boolean value
  292. * - `date`: If the given value is a `Date` object
  293. * - `function`: If the given value is a function reference
  294. * - `object`: If the given value is an object
  295. * - `array`: If the given value is an array
  296. * - `regexp`: If the given value is a regular expression
  297. * - `element`: If the given value is a DOM Element
  298. * - `textnode`: If the given value is a DOM text node and contains something other than whitespace
  299. * - `whitespace`: If the given value is a DOM text node and contains only whitespace
  300. *
  301. * @param {Object} value
  302. * @return {String}
  303. * @markdown
  304. */
  305. typeOf: function(value) {
  306. var type,
  307. typeToString;
  308. if (value === null) {
  309. return 'null';
  310. }
  311. type = typeof value;
  312. if (type === 'undefined' || type === 'string' || type === 'number' || type === 'boolean') {
  313. return type;
  314. }
  315. typeToString = toString.call(value);
  316. switch(typeToString) {
  317. case '[object Array]':
  318. return 'array';
  319. case '[object Date]':
  320. return 'date';
  321. case '[object Boolean]':
  322. return 'boolean';
  323. case '[object Number]':
  324. return 'number';
  325. case '[object RegExp]':
  326. return 'regexp';
  327. }
  328. if (type === 'function') {
  329. return 'function';
  330. }
  331. if (type === 'object') {
  332. if (value.nodeType !== undefined) {
  333. if (value.nodeType === 3) {
  334. return (/\S/).test(value.nodeValue) ? 'textnode' : 'whitespace';
  335. }
  336. else {
  337. return 'element';
  338. }
  339. }
  340. return 'object';
  341. }
  342. },
  343. /**
  344. * Returns true if the passed value is empty, false otherwise. The value is deemed to be empty if it is either:
  345. *
  346. * - `null`
  347. * - `undefined`
  348. * - a zero-length array
  349. * - a zero-length string (Unless the `allowEmptyString` parameter is set to `true`)
  350. *
  351. * @param {Object} value The value to test
  352. * @param {Boolean} allowEmptyString (optional) true to allow empty strings (defaults to false)
  353. * @return {Boolean}
  354. * @markdown
  355. */
  356. isEmpty: function(value, allowEmptyString) {
  357. return (value === null) || (value === undefined) || (!allowEmptyString ? value === '' : false) || (Ext.isArray(value) && value.length === 0);
  358. },
  359. /**
  360. * Returns true if the passed value is a JavaScript Array, false otherwise.
  361. *
  362. * @param {Object} target The target to test
  363. * @return {Boolean}
  364. * @method
  365. */
  366. isArray: ('isArray' in Array) ? Array.isArray : function(value) {
  367. return toString.call(value) === '[object Array]';
  368. },
  369. /**
  370. * Returns true if the passed value is a JavaScript Date object, false otherwise.
  371. * @param {Object} object The object to test
  372. * @return {Boolean}
  373. */
  374. isDate: function(value) {
  375. return toString.call(value) === '[object Date]';
  376. },
  377. /**
  378. * Returns true if the passed value is a JavaScript Object, false otherwise.
  379. * @param {Object} value The value to test
  380. * @return {Boolean}
  381. * @method
  382. */
  383. isObject: (toString.call(null) === '[object Object]') ?
  384. function(value) {
  385. // check ownerDocument here as well to exclude DOM nodes
  386. return value !== null && value !== undefined && toString.call(value) === '[object Object]' && value.ownerDocument === undefined;
  387. } :
  388. function(value) {
  389. return toString.call(value) === '[object Object]';
  390. },
  391. /**
  392. * @private
  393. */
  394. isSimpleObject: function(value) {
  395. return value instanceof Object && value.constructor === Object;
  396. },
  397. /**
  398. * Returns true if the passed value is a JavaScript 'primitive', a string, number or boolean.
  399. * @param {Object} value The value to test
  400. * @return {Boolean}
  401. */
  402. isPrimitive: function(value) {
  403. var type = typeof value;
  404. return type === 'string' || type === 'number' || type === 'boolean';
  405. },
  406. /**
  407. * Returns true if the passed value is a JavaScript Function, false otherwise.
  408. * @param {Object} value The value to test
  409. * @return {Boolean}
  410. * @method
  411. */
  412. isFunction:
  413. // Safari 3.x and 4.x returns 'function' for typeof <NodeList>, hence we need to fall back to using
  414. // Object.prototype.toString (slower)
  415. (typeof document !== 'undefined' && typeof document.getElementsByTagName('body') === 'function') ? function(value) {
  416. return toString.call(value) === '[object Function]';
  417. } : function(value) {
  418. return typeof value === 'function';
  419. },
  420. /**
  421. * Returns true if the passed value is a number. Returns false for non-finite numbers.
  422. * @param {Object} value The value to test
  423. * @return {Boolean}
  424. */
  425. isNumber: function(value) {
  426. return typeof value === 'number' && isFinite(value);
  427. },
  428. /**
  429. * Validates that a value is numeric.
  430. * @param {Object} value Examples: 1, '1', '2.34'
  431. * @return {Boolean} True if numeric, false otherwise
  432. */
  433. isNumeric: function(value) {
  434. return !isNaN(parseFloat(value)) && isFinite(value);
  435. },
  436. /**
  437. * Returns true if the passed value is a string.
  438. * @param {Object} value The value to test
  439. * @return {Boolean}
  440. */
  441. isString: function(value) {
  442. return typeof value === 'string';
  443. },
  444. /**
  445. * Returns true if the passed value is a boolean.
  446. *
  447. * @param {Object} value The value to test
  448. * @return {Boolean}
  449. */
  450. isBoolean: function(value) {
  451. return typeof value === 'boolean';
  452. },
  453. /**
  454. * Returns true if the passed value is an HTMLElement
  455. * @param {Object} value The value to test
  456. * @return {Boolean}
  457. */
  458. isElement: function(value) {
  459. return value ? value.nodeType === 1 : false;
  460. },
  461. /**
  462. * Returns true if the passed value is a TextNode
  463. * @param {Object} value The value to test
  464. * @return {Boolean}
  465. */
  466. isTextNode: function(value) {
  467. return value ? value.nodeName === "#text" : false;
  468. },
  469. /**
  470. * Returns true if the passed value is defined.
  471. * @param {Object} value The value to test
  472. * @return {Boolean}
  473. */
  474. isDefined: function(value) {
  475. return typeof value !== 'undefined';
  476. },
  477. /**
  478. * Returns true if the passed value is iterable, false otherwise
  479. * @param {Object} value The value to test
  480. * @return {Boolean}
  481. */
  482. isIterable: function(value) {
  483. var type = typeof value,
  484. checkLength = false;
  485. if (value && type != 'string') {
  486. // Functions have a length property, so we need to filter them out
  487. if (type == 'function') {
  488. // In Safari, NodeList/HTMLCollection both return "function" when using typeof, so we need
  489. // to explicitly check them here.
  490. if (Ext.isSafari) {
  491. checkLength = value instanceof NodeList || value instanceof HTMLCollection;
  492. }
  493. } else {
  494. checkLength = true;
  495. }
  496. }
  497. return checkLength ? value.length !== undefined : false;
  498. }
  499. });
  500. Ext.apply(Ext, {
  501. /**
  502. * Clone simple variables including array, {}-like objects, DOM nodes and Date without keeping the old reference.
  503. * A reference for the object itself is returned if it's not a direct decendant of Object. For model cloning,
  504. * see {@link Ext.data.Model#copy Model.copy}.
  505. *
  506. * @param {Object} item The variable to clone
  507. * @return {Object} clone
  508. */
  509. clone: function(item) {
  510. var type,
  511. i,
  512. j,
  513. k,
  514. clone,
  515. key;
  516. if (item === null || item === undefined) {
  517. return item;
  518. }
  519. // DOM nodes
  520. // TODO proxy this to Ext.Element.clone to handle automatic id attribute changing
  521. // recursively
  522. if (item.nodeType && item.cloneNode) {
  523. return item.cloneNode(true);
  524. }
  525. type = toString.call(item);
  526. // Date
  527. if (type === '[object Date]') {
  528. return new Date(item.getTime());
  529. }
  530. // Array
  531. if (type === '[object Array]') {
  532. i = item.length;
  533. clone = [];
  534. while (i--) {
  535. clone[i] = Ext.clone(item[i]);
  536. }
  537. }
  538. // Object
  539. else if (type === '[object Object]' && item.constructor === Object) {
  540. clone = {};
  541. for (key in item) {
  542. clone[key] = Ext.clone(item[key]);
  543. }
  544. if (enumerables) {
  545. for (j = enumerables.length; j--;) {
  546. k = enumerables[j];
  547. clone[k] = item[k];
  548. }
  549. }
  550. }
  551. return clone || item;
  552. },
  553. /**
  554. * @private
  555. * Generate a unique reference of Ext in the global scope, useful for sandboxing
  556. */
  557. getUniqueGlobalNamespace: function() {
  558. var uniqueGlobalNamespace = this.uniqueGlobalNamespace,
  559. i;
  560. if (uniqueGlobalNamespace === undefined) {
  561. i = 0;
  562. do {
  563. uniqueGlobalNamespace = 'ExtBox' + (++i);
  564. } while (Ext.global[uniqueGlobalNamespace] !== undefined);
  565. Ext.global[uniqueGlobalNamespace] = Ext;
  566. this.uniqueGlobalNamespace = uniqueGlobalNamespace;
  567. }
  568. return uniqueGlobalNamespace;
  569. },
  570. /**
  571. * @private
  572. */
  573. functionFactoryCache: {},
  574. cacheableFunctionFactory: function() {
  575. var me = this,
  576. args = Array.prototype.slice.call(arguments),
  577. cache = me.functionFactoryCache,
  578. idx, fn, ln;
  579. if (Ext.isSandboxed) {
  580. ln = args.length;
  581. if (ln > 0) {
  582. ln--;
  583. args[ln] = 'var Ext=window.' + Ext.name + ';' + args[ln];
  584. }
  585. }
  586. idx = args.join('');
  587. fn = cache[idx];
  588. if (!fn) {
  589. fn = Function.prototype.constructor.apply(Function.prototype, args);
  590. cache[idx] = fn;
  591. }
  592. return fn;
  593. },
  594. functionFactory: function() {
  595. var me = this,
  596. args = Array.prototype.slice.call(arguments),
  597. ln;
  598. if (Ext.isSandboxed) {
  599. ln = args.length;
  600. if (ln > 0) {
  601. ln--;
  602. args[ln] = 'var Ext=window.' + Ext.name + ';' + args[ln];
  603. }
  604. }
  605. return Function.prototype.constructor.apply(Function.prototype, args);
  606. },
  607. /**
  608. * @private
  609. * @property
  610. */
  611. Logger: {
  612. verbose: emptyFn,
  613. log: emptyFn,
  614. info: emptyFn,
  615. warn: emptyFn,
  616. error: function(message) {
  617. throw new Error(message);
  618. },
  619. deprecate: emptyFn
  620. }
  621. });
  622. /**
  623. * Old alias to {@link Ext#typeOf}
  624. * @deprecated 4.0.0 Use {@link Ext#typeOf} instead
  625. * @method
  626. * @inheritdoc Ext#typeOf
  627. */
  628. Ext.type = Ext.typeOf;
  629. }());
  630. /*
  631. * This method evaluates the given code free of any local variable. In some browsers this
  632. * will be at global scope, in others it will be in a function.
  633. * @parma {String} code The code to evaluate.
  634. * @private
  635. * @method
  636. */
  637. Ext.globalEval = Ext.global.execScript
  638. ? function(code) {
  639. execScript(code);
  640. }
  641. : function($$code) {
  642. // IMPORTANT: because we use eval we cannot place this in the above function or it
  643. // will break the compressor's ability to rename local variables...
  644. (function(){
  645. eval($$code);
  646. }());
  647. };
  648. //@tag foundation,core
  649. //@require ../Ext.js
  650. /**
  651. * @author Jacky Nguyen <jacky@sencha.com>
  652. * @docauthor Jacky Nguyen <jacky@sencha.com>
  653. * @class Ext.Version
  654. *
  655. * A utility class that wrap around a string version number and provide convenient
  656. * method to perform comparison. See also: {@link Ext.Version#compare compare}. Example:
  657. *
  658. * var version = new Ext.Version('1.0.2beta');
  659. * console.log("Version is " + version); // Version is 1.0.2beta
  660. *
  661. * console.log(version.getMajor()); // 1
  662. * console.log(version.getMinor()); // 0
  663. * console.log(version.getPatch()); // 2
  664. * console.log(version.getBuild()); // 0
  665. * console.log(version.getRelease()); // beta
  666. *
  667. * console.log(version.isGreaterThan('1.0.1')); // True
  668. * console.log(version.isGreaterThan('1.0.2alpha')); // True
  669. * console.log(version.isGreaterThan('1.0.2RC')); // False
  670. * console.log(version.isGreaterThan('1.0.2')); // False
  671. * console.log(version.isLessThan('1.0.2')); // True
  672. *
  673. * console.log(version.match(1.0)); // True
  674. * console.log(version.match('1.0.2')); // True
  675. *
  676. */
  677. (function() {
  678. // Current core version
  679. var version = '4.1.1.1', Version;
  680. Ext.Version = Version = Ext.extend(Object, {
  681. /**
  682. * @param {String/Number} version The version number in the following standard format:
  683. *
  684. * major[.minor[.patch[.build[release]]]]
  685. *
  686. * Examples:
  687. *
  688. * 1.0
  689. * 1.2.3beta
  690. * 1.2.3.4RC
  691. *
  692. * @return {Ext.Version} this
  693. */
  694. constructor: function(version) {
  695. var parts, releaseStartIndex;
  696. if (version instanceof Version) {
  697. return version;
  698. }
  699. this.version = this.shortVersion = String(version).toLowerCase().replace(/_/g, '.').replace(/[\-+]/g, '');
  700. releaseStartIndex = this.version.search(/([^\d\.])/);
  701. if (releaseStartIndex !== -1) {
  702. this.release = this.version.substr(releaseStartIndex, version.length);
  703. this.shortVersion = this.version.substr(0, releaseStartIndex);
  704. }
  705. this.shortVersion = this.shortVersion.replace(/[^\d]/g, '');
  706. parts = this.version.split('.');
  707. this.major = parseInt(parts.shift() || 0, 10);
  708. this.minor = parseInt(parts.shift() || 0, 10);
  709. this.patch = parseInt(parts.shift() || 0, 10);
  710. this.build = parseInt(parts.shift() || 0, 10);
  711. return this;
  712. },
  713. /**
  714. * Override the native toString method
  715. * @private
  716. * @return {String} version
  717. */
  718. toString: function() {
  719. return this.version;
  720. },
  721. /**
  722. * Override the native valueOf method
  723. * @private
  724. * @return {String} version
  725. */
  726. valueOf: function() {
  727. return this.version;
  728. },
  729. /**
  730. * Returns the major component value
  731. * @return {Number} major
  732. */
  733. getMajor: function() {
  734. return this.major || 0;
  735. },
  736. /**
  737. * Returns the minor component value
  738. * @return {Number} minor
  739. */
  740. getMinor: function() {
  741. return this.minor || 0;
  742. },
  743. /**
  744. * Returns the patch component value
  745. * @return {Number} patch
  746. */
  747. getPatch: function() {
  748. return this.patch || 0;
  749. },
  750. /**
  751. * Returns the build component value
  752. * @return {Number} build
  753. */
  754. getBuild: function() {
  755. return this.build || 0;
  756. },
  757. /**
  758. * Returns the release component value
  759. * @return {Number} release
  760. */
  761. getRelease: function() {
  762. return this.release || '';
  763. },
  764. /**
  765. * Returns whether this version if greater than the supplied argument
  766. * @param {String/Number} target The version to compare with
  767. * @return {Boolean} True if this version if greater than the target, false otherwise
  768. */
  769. isGreaterThan: function(target) {
  770. return Version.compare(this.version, target) === 1;
  771. },
  772. /**
  773. * Returns whether this version if greater than or equal to the supplied argument
  774. * @param {String/Number} target The version to compare with
  775. * @return {Boolean} True if this version if greater than or equal to the target, false otherwise
  776. */
  777. isGreaterThanOrEqual: function(target) {
  778. return Version.compare(this.version, target) >= 0;
  779. },
  780. /**
  781. * Returns whether this version if smaller than the supplied argument
  782. * @param {String/Number} target The version to compare with
  783. * @return {Boolean} True if this version if smaller than the target, false otherwise
  784. */
  785. isLessThan: function(target) {
  786. return Version.compare(this.version, target) === -1;
  787. },
  788. /**
  789. * Returns whether this version if less than or equal to the supplied argument
  790. * @param {String/Number} target The version to compare with
  791. * @return {Boolean} True if this version if less than or equal to the target, false otherwise
  792. */
  793. isLessThanOrEqual: function(target) {
  794. return Version.compare(this.version, target) <= 0;
  795. },
  796. /**
  797. * Returns whether this version equals to the supplied argument
  798. * @param {String/Number} target The version to compare with
  799. * @return {Boolean} True if this version equals to the target, false otherwise
  800. */
  801. equals: function(target) {
  802. return Version.compare(this.version, target) === 0;
  803. },
  804. /**
  805. * Returns whether this version matches the supplied argument. Example:
  806. *
  807. * var version = new Ext.Version('1.0.2beta');
  808. * console.log(version.match(1)); // True
  809. * console.log(version.match(1.0)); // True
  810. * console.log(version.match('1.0.2')); // True
  811. * console.log(version.match('1.0.2RC')); // False
  812. *
  813. * @param {String/Number} target The version to compare with
  814. * @return {Boolean} True if this version matches the target, false otherwise
  815. */
  816. match: function(target) {
  817. target = String(target);
  818. return this.version.substr(0, target.length) === target;
  819. },
  820. /**
  821. * Returns this format: [major, minor, patch, build, release]. Useful for comparison
  822. * @return {Number[]}
  823. */
  824. toArray: function() {
  825. return [this.getMajor(), this.getMinor(), this.getPatch(), this.getBuild(), this.getRelease()];
  826. },
  827. /**
  828. * Returns shortVersion version without dots and release
  829. * @return {String}
  830. */
  831. getShortVersion: function() {
  832. return this.shortVersion;
  833. },
  834. /**
  835. * Convenient alias to {@link Ext.Version#isGreaterThan isGreaterThan}
  836. * @param {String/Number} target
  837. * @return {Boolean}
  838. */
  839. gt: function() {
  840. return this.isGreaterThan.apply(this, arguments);
  841. },
  842. /**
  843. * Convenient alias to {@link Ext.Version#isLessThan isLessThan}
  844. * @param {String/Number} target
  845. * @return {Boolean}
  846. */
  847. lt: function() {
  848. return this.isLessThan.apply(this, arguments);
  849. },
  850. /**
  851. * Convenient alias to {@link Ext.Version#isGreaterThanOrEqual isGreaterThanOrEqual}
  852. * @param {String/Number} target
  853. * @return {Boolean}
  854. */
  855. gtEq: function() {
  856. return this.isGreaterThanOrEqual.apply(this, arguments);
  857. },
  858. /**
  859. * Convenient alias to {@link Ext.Version#isLessThanOrEqual isLessThanOrEqual}
  860. * @param {String/Number} target
  861. * @return {Boolean}
  862. */
  863. ltEq: function() {
  864. return this.isLessThanOrEqual.apply(this, arguments);
  865. }
  866. });
  867. Ext.apply(Version, {
  868. // @private
  869. releaseValueMap: {
  870. 'dev': -6,
  871. 'alpha': -5,
  872. 'a': -5,
  873. 'beta': -4,
  874. 'b': -4,
  875. 'rc': -3,
  876. '#': -2,
  877. 'p': -1,
  878. 'pl': -1
  879. },
  880. /**
  881. * Converts a version component to a comparable value
  882. *
  883. * @static
  884. * @param {Object} value The value to convert
  885. * @return {Object}
  886. */
  887. getComponentValue: function(value) {
  888. return !value ? 0 : (isNaN(value) ? this.releaseValueMap[value] || value : parseInt(value, 10));
  889. },
  890. /**
  891. * Compare 2 specified versions, starting from left to right. If a part contains special version strings,
  892. * they are handled in the following order:
  893. * 'dev' < 'alpha' = 'a' < 'beta' = 'b' < 'RC' = 'rc' < '#' < 'pl' = 'p' < 'anything else'
  894. *
  895. * @static
  896. * @param {String} current The current version to compare to
  897. * @param {String} target The target version to compare to
  898. * @return {Number} Returns -1 if the current version is smaller than the target version, 1 if greater, and 0 if they're equivalent
  899. */
  900. compare: function(current, target) {
  901. var currentValue, targetValue, i;
  902. current = new Version(current).toArray();
  903. target = new Version(target).toArray();
  904. for (i = 0; i < Math.max(current.length, target.length); i++) {
  905. currentValue = this.getComponentValue(current[i]);
  906. targetValue = this.getComponentValue(target[i]);
  907. if (currentValue < targetValue) {
  908. return -1;
  909. } else if (currentValue > targetValue) {
  910. return 1;
  911. }
  912. }
  913. return 0;
  914. }
  915. });
  916. /**
  917. * @class Ext
  918. */
  919. Ext.apply(Ext, {
  920. /**
  921. * @private
  922. */
  923. versions: {},
  924. /**
  925. * @private
  926. */
  927. lastRegisteredVersion: null,
  928. /**
  929. * Set version number for the given package name.
  930. *
  931. * @param {String} packageName The package name, for example: 'core', 'touch', 'extjs'
  932. * @param {String/Ext.Version} version The version, for example: '1.2.3alpha', '2.4.0-dev'
  933. * @return {Ext}
  934. */
  935. setVersion: function(packageName, version) {
  936. Ext.versions[packageName] = new Version(version);
  937. Ext.lastRegisteredVersion = Ext.versions[packageName];
  938. return this;
  939. },
  940. /**
  941. * Get the version number of the supplied package name; will return the last registered version
  942. * (last Ext.setVersion call) if there's no package name given.
  943. *
  944. * @param {String} packageName (Optional) The package name, for example: 'core', 'touch', 'extjs'
  945. * @return {Ext.Version} The version
  946. */
  947. getVersion: function(packageName) {
  948. if (packageName === undefined) {
  949. return Ext.lastRegisteredVersion;
  950. }
  951. return Ext.versions[packageName];
  952. },
  953. /**
  954. * Create a closure for deprecated code.
  955. *
  956. * // This means Ext.oldMethod is only supported in 4.0.0beta and older.
  957. * // If Ext.getVersion('extjs') returns a version that is later than '4.0.0beta', for example '4.0.0RC',
  958. * // the closure will not be invoked
  959. * Ext.deprecate('extjs', '4.0.0beta', function() {
  960. * Ext.oldMethod = Ext.newMethod;
  961. *
  962. * ...
  963. * });
  964. *
  965. * @param {String} packageName The package name
  966. * @param {String} since The last version before it's deprecated
  967. * @param {Function} closure The callback function to be executed with the specified version is less than the current version
  968. * @param {Object} scope The execution scope (`this`) if the closure
  969. */
  970. deprecate: function(packageName, since, closure, scope) {
  971. if (Version.compare(Ext.getVersion(packageName), since) < 1) {
  972. closure.call(scope);
  973. }
  974. }
  975. }); // End Versioning
  976. Ext.setVersion('core', version);
  977. }());
  978. //@tag foundation,core
  979. //@require ../version/Version.js
  980. /**
  981. * @class Ext.String
  982. *
  983. * A collection of useful static methods to deal with strings
  984. * @singleton
  985. */
  986. Ext.String = (function() {
  987. var trimRegex = /^[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u2028\u2029\u202f\u205f\u3000]+|[\x09\x0a\x0b\x0c\x0d\x20\xa0\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u2028\u2029\u202f\u205f\u3000]+$/g,
  988. escapeRe = /('|\\)/g,
  989. formatRe = /\{(\d+)\}/g,
  990. escapeRegexRe = /([-.*+?\^${}()|\[\]\/\\])/g,
  991. basicTrimRe = /^\s+|\s+$/g,
  992. whitespaceRe = /\s+/,
  993. varReplace = /(^[^a-z]*|[^\w])/gi,
  994. charToEntity,
  995. entityToChar,
  996. charToEntityRegex,
  997. entityToCharRegex,
  998. htmlEncodeReplaceFn = function(match, capture) {
  999. return charToEntity[capture];
  1000. },
  1001. htmlDecodeReplaceFn = function(match, capture) {
  1002. return (capture in entityToChar) ? entityToChar[capture] : String.fromCharCode(parseInt(capture.substr(2), 10));
  1003. };
  1004. return {
  1005. /**
  1006. * Converts a string of characters into a legal, parseable Javascript `var` name as long as the passed
  1007. * string contains at least one alphabetic character. Non alphanumeric characters, and *leading* non alphabetic
  1008. * characters will be removed.
  1009. * @param {String} s A string to be converted into a `var` name.
  1010. * @return {String} A legal Javascript `var` name.
  1011. */
  1012. createVarName: function(s) {
  1013. return s.replace(varReplace, '');
  1014. },
  1015. /**
  1016. * Convert certain characters (&, <, >, ', and ") to their HTML character equivalents for literal display in web pages.
  1017. * @param {String} value The string to encode
  1018. * @return {String} The encoded text
  1019. * @method
  1020. */
  1021. htmlEncode: function(value) {
  1022. return (!value) ? value : String(value).replace(charToEntityRegex, htmlEncodeReplaceFn);
  1023. },
  1024. /**
  1025. * Convert certain characters (&, <, >, ', and ") from their HTML character equivalents.
  1026. * @param {String} value The string to decode
  1027. * @return {String} The decoded text
  1028. * @method
  1029. */
  1030. htmlDecode: function(value) {
  1031. return (!value) ? value : String(value).replace(entityToCharRegex, htmlDecodeReplaceFn);
  1032. },
  1033. /**
  1034. * Adds a set of character entity definitions to the set used by
  1035. * {@link Ext.String#htmlEncode} and {@link Ext.String#htmlDecode}.
  1036. *
  1037. * This object should be keyed by the entity name sequence,
  1038. * with the value being the textual representation of the entity.
  1039. *
  1040. * Ext.String.addCharacterEntities({
  1041. * '&amp;Uuml;':'Ü',
  1042. * '&amp;ccedil;':'ç',
  1043. * '&amp;ntilde;':'ñ',
  1044. * '&amp;egrave;':'è'
  1045. * });
  1046. * var s = Ext.String.htmlEncode("A string with entities: èÜçñ");
  1047. *
  1048. * Note: the values of the character entites defined on this object are expected
  1049. * to be single character values. As such, the actual values represented by the
  1050. * characters are sensitive to the character encoding of the javascript source
  1051. * file when defined in string literal form. Script tasgs referencing server
  1052. * resources with character entities must ensure that the 'charset' attribute
  1053. * of the script node is consistent with the actual character encoding of the
  1054. * server resource.
  1055. *
  1056. * The set of character entities may be reset back to the default state by using
  1057. * the {@link Ext.String#resetCharacterEntities} method
  1058. *
  1059. * @param {Object} entities The set of character entities to add to the current
  1060. * definitions.
  1061. */
  1062. addCharacterEntities: function(newEntities) {
  1063. var charKeys = [],
  1064. entityKeys = [],
  1065. key, echar;
  1066. for (key in newEntities) {
  1067. echar = newEntities[key];
  1068. entityToChar[key] = echar;
  1069. charToEntity[echar] = key;
  1070. charKeys.push(echar);
  1071. entityKeys.push(key);
  1072. }
  1073. charToEntityRegex = new RegExp('(' + charKeys.join('|') + ')', 'g');
  1074. entityToCharRegex = new RegExp('(' + entityKeys.join('|') + '|&#[0-9]{1,5};' + ')', 'g');
  1075. },
  1076. /**
  1077. * Resets the set of character entity definitions used by
  1078. * {@link Ext.String#htmlEncode} and {@link Ext.String#htmlDecode} back to the
  1079. * default state.
  1080. */
  1081. resetCharacterEntities: function() {
  1082. charToEntity = {};
  1083. entityToChar = {};
  1084. // add the default set
  1085. this.addCharacterEntities({
  1086. '&amp;' : '&',
  1087. '&gt;' : '>',
  1088. '&lt;' : '<',
  1089. '&quot;' : '"',
  1090. '&#39;' : "'"
  1091. });
  1092. },
  1093. /**
  1094. * Appends content to the query string of a URL, handling logic for whether to place
  1095. * a question mark or ampersand.
  1096. * @param {String} url The URL to append to.
  1097. * @param {String} string The content to append to the URL.
  1098. * @return {String} The resulting URL
  1099. */
  1100. urlAppend : function(url, string) {
  1101. if (!Ext.isEmpty(string)) {
  1102. return url + (url.indexOf('?') === -1 ? '?' : '&') + string;
  1103. }
  1104. return url;
  1105. },
  1106. /**
  1107. * Trims whitespace from either end of a string, leaving spaces within the string intact. Example:
  1108. * @example
  1109. var s = ' foo bar ';
  1110. alert('-' + s + '-'); //alerts "- foo bar -"
  1111. alert('-' + Ext.String.trim(s) + '-'); //alerts "-foo bar-"
  1112. * @param {String} string The string to escape
  1113. * @return {String} The trimmed string
  1114. */
  1115. trim: function(string) {
  1116. return string.replace(trimRegex, "");
  1117. },
  1118. /**
  1119. * Capitalize the given string
  1120. * @param {String} string
  1121. * @return {String}
  1122. */
  1123. capitalize: function(string) {
  1124. return string.charAt(0).toUpperCase() + string.substr(1);
  1125. },
  1126. /**
  1127. * Uncapitalize the given string
  1128. * @param {String} string
  1129. * @return {String}
  1130. */
  1131. uncapitalize: function(string) {
  1132. return string.charAt(0).toLowerCase() + string.substr(1);
  1133. },
  1134. /**
  1135. * Truncate a string and add an ellipsis ('...') to the end if it exceeds the specified length
  1136. * @param {String} value The string to truncate
  1137. * @param {Number} length The maximum length to allow before truncating
  1138. * @param {Boolean} word True to try to find a common word break
  1139. * @return {String} The converted text
  1140. */
  1141. ellipsis: function(value, len, word) {
  1142. if (value && value.length > len) {
  1143. if (word) {
  1144. var vs = value.substr(0, len - 2),
  1145. index = Math.max(vs.lastIndexOf(' '), vs.lastIndexOf('.'), vs.lastIndexOf('!'), vs.lastIndexOf('?'));
  1146. if (index !== -1 && index >= (len - 15)) {
  1147. return vs.substr(0, index) + "...";
  1148. }
  1149. }
  1150. return value.substr(0, len - 3) + "...";
  1151. }
  1152. return value;
  1153. },
  1154. /**
  1155. * Escapes the passed string for use in a regular expression
  1156. * @param {String} string
  1157. * @return {String}
  1158. */
  1159. escapeRegex: function(string) {
  1160. return string.replace(escapeRegexRe, "\\$1");
  1161. },
  1162. /**
  1163. * Escapes the passed string for ' and \
  1164. * @param {String} string The string to escape
  1165. * @return {String} The escaped string
  1166. */
  1167. escape: function(string) {
  1168. return string.replace(escapeRe, "\\$1");
  1169. },
  1170. /**
  1171. * Utility function that allows you to easily switch a string between two alternating values. The passed value
  1172. * is compared to the current string, and if they are equal, the other value that was passed in is returned. If
  1173. * they are already different, the first value passed in is returned. Note that this method returns the new value
  1174. * but does not change the current string.
  1175. * <pre><code>
  1176. // alternate sort directions
  1177. sort = Ext.String.toggle(sort, 'ASC', 'DESC');
  1178. // instead of conditional logic:
  1179. sort = (sort == 'ASC' ? 'DESC' : 'ASC');
  1180. </code></pre>
  1181. * @param {String} string The current string
  1182. * @param {String} value The value to compare to the current string
  1183. * @param {String} other The new value to use if the string already equals the first value passed in
  1184. * @return {String} The new value
  1185. */
  1186. toggle: function(string, value, other) {
  1187. return string === value ? other : value;
  1188. },
  1189. /**
  1190. * Pads the left side of a string with a specified character. This is especially useful
  1191. * for normalizing number and date strings. Example usage:
  1192. *
  1193. * <pre><code>
  1194. var s = Ext.String.leftPad('123', 5, '0');
  1195. // s now contains the string: '00123'
  1196. </code></pre>
  1197. * @param {String} string The original string
  1198. * @param {Number} size The total length of the output string
  1199. * @param {String} character (optional) The character with which to pad the original string (defaults to empty string " ")
  1200. * @return {String} The padded string
  1201. */
  1202. leftPad: function(string, size, character) {
  1203. var result = String(string);
  1204. character = character || " ";
  1205. while (result.length < size) {
  1206. result = character + result;
  1207. }
  1208. return result;
  1209. },
  1210. /**
  1211. * Allows you to define a tokenized string and pass an arbitrary number of arguments to replace the tokens. Each
  1212. * token must be unique, and must increment in the format {0}, {1}, etc. Example usage:
  1213. * <pre><code>
  1214. var cls = 'my-class', text = 'Some text';
  1215. var s = Ext.String.format('&lt;div class="{0}">{1}&lt;/div>', cls, text);
  1216. // s now contains the string: '&lt;div class="my-class">Some text&lt;/div>'
  1217. </code></pre>
  1218. * @param {String} string The tokenized string to be formatted
  1219. * @param {String} value1 The value to replace token {0}
  1220. * @param {String} value2 Etc...
  1221. * @return {String} The formatted string
  1222. */
  1223. format: function(format) {
  1224. var args = Ext.Array.toArray(arguments, 1);
  1225. return format.replace(formatRe, function(m, i) {
  1226. return args[i];
  1227. });
  1228. },
  1229. /**
  1230. * Returns a string with a specified number of repititions a given string pattern.
  1231. * The pattern be separated by a different string.
  1232. *
  1233. * var s = Ext.String.repeat('---', 4); // = '------------'
  1234. * var t = Ext.String.repeat('--', 3, '/'); // = '--/--/--'
  1235. *
  1236. * @param {String} pattern The pattern to repeat.
  1237. * @param {Number} count The number of times to repeat the pattern (may be 0).
  1238. * @param {String} sep An option string to separate each pattern.
  1239. */
  1240. repeat: function(pattern, count, sep) {
  1241. for (var buf = [], i = count; i--; ) {
  1242. buf.push(pattern);
  1243. }
  1244. return buf.join(sep || '');
  1245. },
  1246. /**
  1247. * Splits a string of space separated words into an array, trimming as needed. If the
  1248. * words are already an array, it is returned.
  1249. *
  1250. * @param {String/Array} words
  1251. */
  1252. splitWords: function (words) {
  1253. if (words && typeof words == 'string') {
  1254. return words.replace(basicTrimRe, '').split(whitespaceRe);
  1255. }
  1256. return words || [];
  1257. }
  1258. };
  1259. }());
  1260. // initialize the default encode / decode entities
  1261. Ext.String.resetCharacterEntities();
  1262. /**
  1263. * Old alias to {@link Ext.String#htmlEncode}
  1264. * @deprecated Use {@link Ext.String#htmlEncode} instead
  1265. * @method
  1266. * @member Ext
  1267. * @inheritdoc Ext.String#htmlEncode
  1268. */
  1269. Ext.htmlEncode = Ext.String.htmlEncode;
  1270. /**
  1271. * Old alias to {@link Ext.String#htmlDecode}
  1272. * @deprecated Use {@link Ext.String#htmlDecode} instead
  1273. * @method
  1274. * @member Ext
  1275. * @inheritdoc Ext.String#htmlDecode
  1276. */
  1277. Ext.htmlDecode = Ext.String.htmlDecode;
  1278. /**
  1279. * Old alias to {@link Ext.String#urlAppend}
  1280. * @deprecated Use {@link Ext.String#urlAppend} instead
  1281. * @method
  1282. * @member Ext
  1283. * @inheritdoc Ext.String#urlAppend
  1284. */
  1285. Ext.urlAppend = Ext.String.urlAppend;
  1286. //@tag foundation,core
  1287. //@require String.js
  1288. //@define Ext.Number
  1289. /**
  1290. * @class Ext.Number
  1291. *
  1292. * A collection of useful static methods to deal with numbers
  1293. * @singleton
  1294. */
  1295. Ext.Number = new function() {
  1296. var me = this,
  1297. isToFixedBroken = (0.9).toFixed() !== '1',
  1298. math = Math;
  1299. Ext.apply(this, {
  1300. /**
  1301. * Checks whether or not the passed number is within a desired range. If the number is already within the
  1302. * range it is returned, otherwise the min or max value is returned depending on which side of the range is
  1303. * exceeded. Note that this method returns the constrained value but does not change the current number.
  1304. * @param {Number} number The number to check
  1305. * @param {Number} min The minimum number in the range
  1306. * @param {Number} max The maximum number in the range
  1307. * @return {Number} The constrained value if outside the range, otherwise the current value
  1308. */
  1309. constrain: function(number, min, max) {
  1310. var x = parseFloat(number);
  1311. // Watch out for NaN in Chrome 18
  1312. // V8bug: http://code.google.com/p/v8/issues/detail?id=2056
  1313. // Operators are faster than Math.min/max. See http://jsperf.com/number-constrain
  1314. // ... and (x < Nan) || (x < undefined) == false
  1315. // ... same for (x > NaN) || (x > undefined)
  1316. // so if min or max are undefined or NaN, we never return them... sadly, this
  1317. // is not true of null (but even Math.max(-1,null)==0 and isNaN(null)==false)
  1318. return (x < min) ? min : ((x > max) ? max : x);
  1319. },
  1320. /**
  1321. * Snaps the passed number between stopping points based upon a passed increment value.
  1322. *
  1323. * The difference between this and {@link #snapInRange} is that {@link #snapInRange} uses the minValue
  1324. * when calculating snap points:
  1325. *
  1326. * r = Ext.Number.snap(56, 2, 55, 65); // Returns 56 - snap points are zero based
  1327. *
  1328. * r = Ext.Number.snapInRange(56, 2, 55, 65); // Returns 57 - snap points are based from minValue
  1329. *
  1330. * @param {Number} value The unsnapped value.
  1331. * @param {Number} increment The increment by which the value must move.
  1332. * @param {Number} minValue The minimum value to which the returned value must be constrained. Overrides the increment.
  1333. * @param {Number} maxValue The maximum value to which the returned value must be constrained. Overrides the increment.
  1334. * @return {Number} The value of the nearest snap target.
  1335. */
  1336. snap : function(value, increment, minValue, maxValue) {
  1337. var m;
  1338. // If no value passed, or minValue was passed and value is less than minValue (anything < undefined is false)
  1339. // Then use the minValue (or zero if the value was undefined)
  1340. if (value === undefined || value < minValue) {
  1341. return minValue || 0;
  1342. }
  1343. if (increment) {
  1344. m = value % increment;
  1345. if (m !== 0) {
  1346. value -= m;
  1347. if (m * 2 >= increment) {
  1348. value += increment;
  1349. } else if (m * 2 < -increment) {
  1350. value -= increment;
  1351. }
  1352. }
  1353. }
  1354. return me.constrain(value, minValue, maxValue);
  1355. },
  1356. /**
  1357. * Snaps the passed number between stopping points based upon a passed increment value.
  1358. *
  1359. * The difference between this and {@link #snap} is that {@link #snap} does not use the minValue
  1360. * when calculating snap points:
  1361. *
  1362. * r = Ext.Number.snap(56, 2, 55, 65); // Returns 56 - snap points are zero based
  1363. *
  1364. * r = Ext.Number.snapInRange(56, 2, 55, 65); // Returns 57 - snap points are based from minValue
  1365. *
  1366. * @param {Number} value The unsnapped value.
  1367. * @param {Number} increment The increment by which the value must move.
  1368. * @param {Number} [minValue=0] The minimum value to which the returned value must be constrained.
  1369. * @param {Number} [maxValue=Infinity] The maximum value to which the returned value must be constrained.
  1370. * @return {Number} The value of the nearest snap target.
  1371. */
  1372. snapInRange : function(value, increment, minValue, maxValue) {
  1373. var tween;
  1374. // default minValue to zero
  1375. minValue = (minValue || 0);
  1376. // If value is undefined, or less than minValue, use minValue
  1377. if (value === undefined || value < minValue) {
  1378. return minValue;
  1379. }
  1380. // Calculate how many snap points from the minValue the passed value is.
  1381. if (increment && (tween = ((value - minValue) % increment))) {
  1382. value -= tween;
  1383. tween *= 2;
  1384. if (tween >= increment) {
  1385. value += increment;
  1386. }
  1387. }
  1388. // If constraining within a maximum, ensure the maximum is on a snap point
  1389. if (maxValue !== undefined) {
  1390. if (value > (maxValue = me.snapInRange(maxValue, increment, minValue))) {
  1391. value = maxValue;
  1392. }
  1393. }
  1394. return value;
  1395. },
  1396. /**
  1397. * Formats a number using fixed-point notation
  1398. * @param {Number} value The number to format
  1399. * @param {Number} precision The number of digits to show after the decimal point
  1400. */
  1401. toFixed: isToFixedBroken ? function(value, precision) {
  1402. precision = precision || 0;
  1403. var pow = math.pow(10, precision);
  1404. return (math.round(value * pow) / pow).toFixed(precision);
  1405. } : function(value, precision) {
  1406. return value.toFixed(precision);
  1407. },
  1408. /**
  1409. * Validate that a value is numeric and convert it to a number if necessary. Returns the specified default value if
  1410. * it is not.
  1411. Ext.Number.from('1.23', 1); // returns 1.23
  1412. Ext.Number.from('abc', 1); // returns 1
  1413. * @param {Object} value
  1414. * @param {Number} defaultValue The value to return if the original value is non-numeric
  1415. * @return {Number} value, if numeric, defaultValue otherwise
  1416. */
  1417. from: function(value, defaultValue) {
  1418. if (isFinite(value)) {
  1419. value = parseFloat(value);
  1420. }
  1421. return !isNaN(value) ? value : defaultValue;
  1422. },
  1423. /**
  1424. * Returns a random integer between the specified range (inclusive)
  1425. * @param {Number} from Lowest value to return.
  1426. * @param {Number} to Highst value to return.
  1427. * @return {Number} A random integer within the specified range.
  1428. */
  1429. randomInt: function (from, to) {
  1430. return math.floor(math.random() * (to - from + 1) + from);
  1431. }
  1432. });
  1433. /**
  1434. * @deprecated 4.0.0 Please use {@link Ext.Number#from} instead.
  1435. * @member Ext
  1436. * @method num
  1437. * @inheritdoc Ext.Number#from
  1438. */
  1439. Ext.num = function() {
  1440. return me.from.apply(this, arguments);
  1441. };
  1442. };
  1443. //@tag foundation,core
  1444. //@require Number.js
  1445. /**
  1446. * @class Ext.Array
  1447. * @singleton
  1448. * @author Jacky Nguyen <jacky@sencha.com>
  1449. * @docauthor Jacky Nguyen <jacky@sencha.com>
  1450. *
  1451. * A set of useful static methods to deal with arrays; provide missing methods for older browsers.
  1452. */
  1453. (function() {
  1454. var arrayPrototype = Array.prototype,
  1455. slice = arrayPrototype.slice,
  1456. supportsSplice = (function () {
  1457. var array = [],
  1458. lengthBefore,
  1459. j = 20;
  1460. if (!array.splice) {
  1461. return false;
  1462. }
  1463. // This detects a bug in IE8 splice method:
  1464. // see http://social.msdn.microsoft.com/Forums/en-US/iewebdevelopment/thread/6e946d03-e09f-4b22-a4dd-cd5e276bf05a/
  1465. while (j--) {
  1466. array.push("A");
  1467. }
  1468. array.splice(15, 0, "F", "F", "F", "F", "F","F","F","F","F","F","F","F","F","F","F","F","F","F","F","F","F");
  1469. lengthBefore = array.length; //41
  1470. array.splice(13, 0, "XXX"); // add one element
  1471. if (lengthBefore+1 != array.length) {
  1472. return false;
  1473. }
  1474. // end IE8 bug
  1475. return true;
  1476. }()),
  1477. supportsForEach = 'forEach' in arrayPrototype,
  1478. supportsMap = 'map' in arrayPrototype,
  1479. supportsIndexOf = 'indexOf' in arrayPrototype,
  1480. supportsEvery = 'every' in arrayPrototype,
  1481. supportsSome = 'some' in arrayPrototype,
  1482. supportsFilter = 'filter' in arrayPrototype,
  1483. supportsSort = (function() {
  1484. var a = [1,2,3,4,5].sort(function(){ return 0; });
  1485. return a[0] === 1 && a[1] === 2 && a[2] === 3 && a[3] === 4 && a[4] === 5;
  1486. }()),
  1487. supportsSliceOnNodeList = true,
  1488. ExtArray,
  1489. erase,
  1490. replace,
  1491. splice;
  1492. try {
  1493. // IE 6 - 8 will throw an error when using Array.prototype.slice on NodeList
  1494. if (typeof document !== 'undefined') {
  1495. slice.call(document.getElementsByTagName('body'));
  1496. }
  1497. } catch (e) {
  1498. supportsSliceOnNodeList = false;
  1499. }
  1500. function fixArrayIndex (array, index) {
  1501. return (index < 0) ? Math.max(0, array.length + index)
  1502. : Math.min(array.length, index);
  1503. }
  1504. /*
  1505. Does the same work as splice, but with a slightly more convenient signature. The splice
  1506. method has bugs in IE8, so this is the implementation we use on that platform.
  1507. The rippling of items in the array can be tricky. Consider two use cases:
  1508. index=2
  1509. removeCount=2
  1510. /=====\
  1511. +---+---+---+---+---+---+---+---+
  1512. | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
  1513. +---+---+---+---+---+---+---+---+
  1514. / \/ \/ \/ \
  1515. / /\ /\ /\ \
  1516. / / \/ \/ \ +--------------------------+
  1517. / / /\ /\ +--------------------------+ \
  1518. / / / \/ +--------------------------+ \ \
  1519. / / / /+--------------------------+ \ \ \
  1520. / / / / \ \ \ \
  1521. v v v v v v v v
  1522. +---+---+---+---+---+---+ +---+---+---+---+---+---+---+---+---+
  1523. | 0 | 1 | 4 | 5 | 6 | 7 | | 0 | 1 | a | b | c | 4 | 5 | 6 | 7 |
  1524. +---+---+---+---+---+---+ +---+---+---+---+---+---+---+---+---+
  1525. A B \=========/
  1526. insert=[a,b,c]
  1527. In case A, it is obvious that copying of [4,5,6,7] must be left-to-right so
  1528. that we don't end up with [0,1,6,7,6,7]. In case B, we have the opposite; we
  1529. must go right-to-left or else we would end up with [0,1,a,b,c,4,4,4,4].
  1530. */
  1531. function replaceSim (array, index, removeCount, insert) {
  1532. var add = insert ? insert.length : 0,
  1533. length = array.length,
  1534. pos = fixArrayIndex(array, index),
  1535. remove,
  1536. tailOldPos,
  1537. tailNewPos,
  1538. tailCount,
  1539. lengthAfterRemove,
  1540. i;
  1541. // we try to use Array.push when we can for efficiency...
  1542. if (pos === length) {
  1543. if (add) {
  1544. array.push.apply(array, insert);
  1545. }
  1546. } else {
  1547. remove = Math.min(removeCount, length - pos);
  1548. tailOldPos = pos + remove;
  1549. tailNewPos = tailOldPos + add - remove;
  1550. tailCount = length - tailOldPos;
  1551. lengthAfterRemove = length - remove;
  1552. if (tailNewPos < tailOldPos) { // case A
  1553. for (i = 0; i < tailCount; ++i) {
  1554. array[tailNewPos+i] = array[tailOldPos+i];
  1555. }
  1556. } else if (tailNewPos > tailOldPos) { // case B
  1557. for (i = tailCount; i--; ) {
  1558. array[tailNewPos+i] = array[tailOldPos+i];
  1559. }
  1560. } // else, add == remove (nothing to do)
  1561. if (add && pos === lengthAfterRemove) {
  1562. array.length = lengthAfterRemove; // truncate array
  1563. array.push.apply(array, insert);
  1564. } else {
  1565. array.length = lengthAfterRemove + add; // reserves space
  1566. for (i = 0; i < add; ++i) {
  1567. array[pos+i] = insert[i];
  1568. }
  1569. }
  1570. }
  1571. return array;
  1572. }
  1573. function replaceNative (array, index, removeCount, insert) {
  1574. if (insert && insert.length) {
  1575. if (index < array.length) {
  1576. array.splice.apply(array, [index, removeCount].concat(insert));
  1577. } else {
  1578. array.push.apply(array, insert);
  1579. }
  1580. } else {
  1581. array.splice(index, removeCount);
  1582. }
  1583. return array;
  1584. }
  1585. function eraseSim (array, index, removeCount) {
  1586. return replaceSim(array, index, removeCount);
  1587. }
  1588. function eraseNative (array, index, removeCount) {
  1589. array.splice(index, removeCount);
  1590. return array;
  1591. }
  1592. function spliceSim (array, index, removeCount) {
  1593. var pos = fixArrayIndex(array, index),
  1594. removed = array.slice(index, fixArrayIndex(array, pos+removeCount));
  1595. if (arguments.length < 4) {
  1596. replaceSim(array, pos, removeCount);
  1597. } else {
  1598. replaceSim(array, pos, removeCount, slice.call(arguments, 3));
  1599. }
  1600. return removed;
  1601. }
  1602. function spliceNative (array) {
  1603. return array.splice.apply(array, slice.call(arguments, 1));
  1604. }
  1605. erase = supportsSplice ? eraseNative : eraseSim;
  1606. replace = supportsSplice ? replaceNative : replaceSim;
  1607. splice = supportsSplice ? spliceNative : spliceSim;
  1608. // NOTE: from here on, use erase, replace or splice (not native methods)...
  1609. ExtArray = Ext.Array = {
  1610. /**
  1611. * Iterates an array or an iterable value and invoke the given callback function for each item.
  1612. *
  1613. * var countries = ['Vietnam', 'Singapore', 'United States', 'Russia'];
  1614. *
  1615. * Ext.Array.each(countries, function(name, index, countriesItSelf) {
  1616. * console.log(name);
  1617. * });
  1618. *
  1619. * var sum = function() {
  1620. * var sum = 0;
  1621. *
  1622. * Ext.Array.each(arguments, function(value) {
  1623. * sum += value;
  1624. * });
  1625. *
  1626. * return sum;
  1627. * };
  1628. *
  1629. * sum(1, 2, 3); // returns 6
  1630. *
  1631. * The iteration can be stopped by returning false in the function callback.
  1632. *
  1633. * Ext.Array.each(countries, function(name, index, countriesItSelf) {
  1634. * if (name === 'Singapore') {
  1635. * return false; // break here
  1636. * }
  1637. * });
  1638. *
  1639. * {@link Ext#each Ext.each} is alias for {@link Ext.Array#each Ext.Array.each}
  1640. *
  1641. * @param {Array/NodeList/Object} iterable The value to be iterated. If this
  1642. * argument is not iterable, the callback function is called once.
  1643. * @param {Function} fn The callback function. If it returns false, the iteration stops and this method returns
  1644. * the current `index`.
  1645. * @param {Object} fn.item The item at the current `index` in the passed `array`
  1646. * @param {Number} fn.index The current `index` within the `array`
  1647. * @param {Array} fn.allItems The `array` itself which was passed as the first argument
  1648. * @param {Boolean} fn.return Return false to stop iteration.
  1649. * @param {Object} scope (Optional) The scope (`this` reference) in which the specified function is executed.
  1650. * @param {Boolean} reverse (Optional) Reverse the iteration order (loop from the end to the beginning)
  1651. * Defaults false
  1652. * @return {Boolean} See description for the `fn` parameter.
  1653. */
  1654. each: function(array, fn, scope, reverse) {
  1655. array = ExtArray.from(array);
  1656. var i,
  1657. ln = array.length;
  1658. if (reverse !== true) {
  1659. for (i = 0; i < ln; i++) {
  1660. if (fn.call(scope || array[i], array[i], i, array) === false) {
  1661. return i;
  1662. }
  1663. }
  1664. }
  1665. else {
  1666. for (i = ln - 1; i > -1; i--) {
  1667. if (fn.call(scope || array[i], array[i], i, array) === false) {
  1668. return i;
  1669. }
  1670. }
  1671. }
  1672. return true;
  1673. },
  1674. /**
  1675. * Iterates an array and invoke the given callback function for each item. Note that this will simply
  1676. * delegate to the native Array.prototype.forEach method if supported. It doesn't support stopping the
  1677. * iteration by returning false in the callback function like {@link Ext.Array#each}. However, performance
  1678. * could be much better in modern browsers comparing with {@link Ext.Array#each}
  1679. *
  1680. * @param {Array} array The array to iterate
  1681. * @param {Function} fn The callback function.
  1682. * @param {Object} fn.item The item at the current `index` in the passed `array`
  1683. * @param {Number} fn.index The current `index` within the `array`
  1684. * @param {Array} fn.allItems The `array` itself which was passed as the first argument
  1685. * @param {Object} scope (Optional) The execution scope (`this`) in which the specified function is executed.
  1686. */
  1687. forEach: supportsForEach ? function(array, fn, scope) {
  1688. return array.forEach(fn, scope);
  1689. } : function(array, fn, scope) {
  1690. var i = 0,
  1691. ln = array.length;
  1692. for (; i < ln; i++) {
  1693. fn.call(scope, array[i], i, array);
  1694. }
  1695. },
  1696. /**
  1697. * Get the index of the provided `item` in the given `array`, a supplement for the
  1698. * missing arrayPrototype.indexOf in Internet Explorer.
  1699. *
  1700. * @param {Array} array The array to check
  1701. * @param {Object} item The item to look for
  1702. * @param {Number} from (Optional) The index at which to begin the search
  1703. * @return {Number} The index of item in the array (or -1 if it is not found)
  1704. */
  1705. indexOf: supportsIndexOf ? function(array, item, from) {
  1706. return array.indexOf(item, from);
  1707. } : function(array, item, from) {
  1708. var i, length = array.length;
  1709. for (i = (from < 0) ? Math.max(0, length + from) : from || 0; i < length; i++) {
  1710. if (array[i] === item) {
  1711. return i;
  1712. }
  1713. }
  1714. return -1;
  1715. },
  1716. /**
  1717. * Checks whether or not the given `array` contains the specified `item`
  1718. *
  1719. * @param {Array} array The array to check
  1720. * @param {Object} item The item to look for
  1721. * @return {Boolean} True if the array contains the item, false otherwise
  1722. */
  1723. contains: supportsIndexOf ? function(array, item) {
  1724. return array.indexOf(item) !== -1;
  1725. } : function(array, item) {
  1726. var i, ln;
  1727. for (i = 0, ln = array.length; i < ln; i++) {
  1728. if (array[i] === item) {
  1729. return true;
  1730. }
  1731. }
  1732. return false;
  1733. },
  1734. /**
  1735. * Converts any iterable (numeric indices and a length property) into a true array.
  1736. *
  1737. * function test() {
  1738. * var args = Ext.Array.toArray(arguments),
  1739. * fromSecondToLastArgs = Ext.Array.toArray(arguments, 1);
  1740. *
  1741. * alert(args.join(' '));
  1742. * alert(fromSecondToLastArgs.join(' '));
  1743. * }
  1744. *
  1745. * test('just', 'testing', 'here'); // alerts 'just testing here';
  1746. * // alerts 'testing here';
  1747. *
  1748. * Ext.Array.toArray(document.getElementsByTagName('div')); // will convert the NodeList into an array
  1749. * Ext.Array.toArray('splitted'); // returns ['s', 'p', 'l', 'i', 't', 't', 'e', 'd']
  1750. * Ext.Array.toArray('splitted', 0, 3); // returns ['s', 'p', 'l']
  1751. *
  1752. * {@link Ext#toArray Ext.toArray} is alias for {@link Ext.Array#toArray Ext.Array.toArray}
  1753. *
  1754. * @param {Object} iterable the iterable object to be turned into a true Array.
  1755. * @param {Number} start (Optional) a zero-based index that specifies the start of extraction. Defaults to 0
  1756. * @param {Number} end (Optional) a 1-based index that specifies the end of extraction. Defaults to the last
  1757. * index of the iterable value
  1758. * @return {Array} array
  1759. */
  1760. toArray: function(iterable, start, end){
  1761. if (!iterable || !iterable.length) {
  1762. return [];
  1763. }
  1764. if (typeof iterable === 'string') {
  1765. iterable = iterable.split('');
  1766. }
  1767. if (supportsSliceOnNodeList) {
  1768. return slice.call(iterable, start || 0, end || iterable.length);
  1769. }
  1770. var array = [],
  1771. i;
  1772. start = start || 0;
  1773. end = end ? ((end < 0) ? iterable.length + end : end) : iterable.length;
  1774. for (i = start; i < end; i++) {
  1775. array.push(iterable[i]);
  1776. }
  1777. return array;
  1778. },
  1779. /**
  1780. * Plucks the value of a property from each item in the Array. Example:
  1781. *
  1782. * Ext.Array.pluck(Ext.query("p"), "className"); // [el1.className, el2.className, ..., elN.className]
  1783. *
  1784. * @param {Array/NodeList} array The Array of items to pluck the value from.
  1785. * @param {String} propertyName The property name to pluck from each element.
  1786. * @return {Array} The value from each item in the Array.
  1787. */
  1788. pluck: function(array, propertyName) {
  1789. var ret = [],
  1790. i, ln, item;
  1791. for (i = 0, ln = array.length; i < ln; i++) {
  1792. item = array[i];
  1793. ret.push(item[propertyName]);
  1794. }
  1795. return ret;
  1796. },
  1797. /**
  1798. * Creates a new array with the results of calling a provided function on every element in this array.
  1799. *
  1800. * @param {Array} array
  1801. * @param {Function} fn Callback function for each item
  1802. * @param {Object} scope Callback function scope
  1803. * @return {Array} results
  1804. */
  1805. map: supportsMap ? function(array, fn, scope) {
  1806. return array.map(fn, scope);
  1807. } : function(array, fn, scope) {
  1808. var results = [],
  1809. i = 0,
  1810. len = array.length;
  1811. for (; i < len; i++) {
  1812. results[i] = fn.call(scope, array[i], i, array);
  1813. }
  1814. return results;
  1815. },
  1816. /**
  1817. * Executes the specified function for each array element until the function returns a falsy value.
  1818. * If such an item is found, the function will return false immediately.
  1819. * Otherwise, it will return true.
  1820. *
  1821. * @param {Array} array
  1822. * @param {Function} fn Callback function for each item
  1823. * @param {Object} scope Callback function scope
  1824. * @return {Boolean} True if no false value is returned by the callback function.
  1825. */
  1826. every: supportsEvery ? function(array, fn, scope) {
  1827. return array.every(fn, scope);
  1828. } : function(array, fn, scope) {
  1829. var i = 0,
  1830. ln = array.length;
  1831. for (; i < ln; ++i) {
  1832. if (!fn.call(scope, array[i], i, array)) {
  1833. return false;
  1834. }
  1835. }
  1836. return true;
  1837. },
  1838. /**
  1839. * Executes the specified function for each array element until the function returns a truthy value.
  1840. * If such an item is found, the function will return true immediately. Otherwise, it will return false.
  1841. *
  1842. * @param {Array} array
  1843. * @param {Function} fn Callback function for each item
  1844. * @param {Object} scope Callback function scope
  1845. * @return {Boolean} True if the callback function returns a truthy value.
  1846. */
  1847. some: supportsSome ? function(array, fn, scope) {
  1848. return array.some(fn, scope);
  1849. } : function(array, fn, scope) {
  1850. var i = 0,
  1851. ln = array.length;
  1852. for (; i < ln; ++i) {
  1853. if (fn.call(scope, array[i], i, array)) {
  1854. return true;
  1855. }
  1856. }
  1857. return false;
  1858. },
  1859. /**
  1860. * Filter through an array and remove empty item as defined in {@link Ext#isEmpty Ext.isEmpty}
  1861. *
  1862. * See {@link Ext.Array#filter}
  1863. *
  1864. * @param {Array} array
  1865. * @return {Array} results
  1866. */
  1867. clean: function(array) {
  1868. var results = [],
  1869. i = 0,
  1870. ln = array.length,
  1871. item;
  1872. for (; i < ln; i++) {
  1873. item = array[i];
  1874. if (!Ext.isEmpty(item)) {
  1875. results.push(item);
  1876. }
  1877. }
  1878. return results;
  1879. },
  1880. /**
  1881. * Returns a new array with unique items
  1882. *
  1883. * @param {Array} array
  1884. * @return {Array} results
  1885. */
  1886. unique: function(array) {
  1887. var clone = [],
  1888. i = 0,
  1889. ln = array.length,
  1890. item;
  1891. for (; i < ln; i++) {
  1892. item = array[i];
  1893. if (ExtArray.indexOf(clone, item) === -1) {
  1894. clone.push(item);
  1895. }
  1896. }
  1897. return clone;
  1898. },
  1899. /**
  1900. * Creates a new array with all of the elements of this array for which
  1901. * the provided filtering function returns true.
  1902. *
  1903. * @param {Array} array
  1904. * @param {Function} fn Callback function for each item
  1905. * @param {Object} scope Callback function scope
  1906. * @return {Array} results
  1907. */
  1908. filter: supportsFilter ? function(array, fn, scope) {
  1909. return array.filter(fn, scope);
  1910. } : function(array, fn, scope) {
  1911. var results = [],
  1912. i = 0,
  1913. ln = array.length;
  1914. for (; i < ln; i++) {
  1915. if (fn.call(scope, array[i], i, array)) {
  1916. results.push(array[i]);
  1917. }
  1918. }
  1919. return results;
  1920. },
  1921. /**
  1922. * Converts a value to an array if it's not already an array; returns:
  1923. *
  1924. * - An empty array if given value is `undefined` or `null`
  1925. * - Itself if given value is already an array
  1926. * - An array copy if given value is {@link Ext#isIterable iterable} (arguments, NodeList and alike)
  1927. * - An array with one item which is the given value, otherwise
  1928. *
  1929. * @param {Object} value The value to convert to an array if it's not already is an array
  1930. * @param {Boolean} newReference (Optional) True to clone the given array and return a new reference if necessary,
  1931. * defaults to false
  1932. * @return {Array} array
  1933. */
  1934. from: function(value, newReference) {
  1935. if (value === undefined || value === null) {
  1936. return [];
  1937. }
  1938. if (Ext.isArray(value)) {
  1939. return (newReference) ? slice.call(value) : value;
  1940. }
  1941. var type = typeof value;
  1942. // Both strings and functions will have a length property. In phantomJS, NodeList
  1943. // instances report typeof=='function' but don't have an apply method...
  1944. if (value && value.length !== undefined && type !== 'string' && (type !== 'function' || !value.apply)) {
  1945. return ExtArray.toArray(value);
  1946. }
  1947. return [value];
  1948. },
  1949. /**
  1950. * Removes the specified item from the array if it exists
  1951. *
  1952. * @param {Array} array The array
  1953. * @param {Object} item The item to remove
  1954. * @return {Array} The passed array itself
  1955. */
  1956. remove: function(array, item) {
  1957. var index = ExtArray.indexOf(array, item);
  1958. if (index !== -1) {
  1959. erase(array, index, 1);
  1960. }
  1961. return array;
  1962. },
  1963. /**
  1964. * Push an item into the array only if the array doesn't contain it yet
  1965. *
  1966. * @param {Array} array The array
  1967. * @param {Object} item The item to include
  1968. */
  1969. include: function(array, item) {
  1970. if (!ExtArray.contains(array, item)) {
  1971. array.push(item);
  1972. }
  1973. },
  1974. /**
  1975. * Clone a flat array without referencing the previous one. Note that this is different
  1976. * from Ext.clone since it doesn't handle recursive cloning. It's simply a convenient, easy-to-remember method
  1977. * for Array.prototype.slice.call(array)
  1978. *
  1979. * @param {Array} array The array
  1980. * @return {Array} The clone array
  1981. */
  1982. clone: function(array) {
  1983. return slice.call(array);
  1984. },
  1985. /**
  1986. * Merge multiple arrays into one with unique items.
  1987. *
  1988. * {@link Ext.Array#union} is alias for {@link Ext.Array#merge}
  1989. *
  1990. * @param {Array} array1
  1991. * @param {Array} array2
  1992. * @param {Array} etc
  1993. * @return {Array} merged
  1994. */
  1995. merge: function() {
  1996. var args = slice.call(arguments),
  1997. array = [],
  1998. i, ln;
  1999. for (i = 0, ln = args.length; i < ln; i++) {
  2000. array = array.concat(args[i]);
  2001. }
  2002. return ExtArray.unique(array);
  2003. },
  2004. /**
  2005. * Merge multiple arrays into one with unique items that exist in all of the arrays.
  2006. *
  2007. * @param {Array} array1
  2008. * @param {Array} array2
  2009. * @param {Array} etc
  2010. * @return {Array} intersect
  2011. */
  2012. intersect: function() {
  2013. var intersection = [],
  2014. arrays = slice.call(arguments),
  2015. arraysLength,
  2016. array,
  2017. arrayLength,
  2018. minArray,
  2019. minArrayIndex,
  2020. minArrayCandidate,
  2021. minArrayLength,
  2022. element,
  2023. elementCandidate,
  2024. elementCount,
  2025. i, j, k;
  2026. if (!arrays.length) {
  2027. return intersection;
  2028. }
  2029. // Find the smallest array
  2030. arraysLength = arrays.length;
  2031. for (i = minArrayIndex = 0; i < arraysLength; i++) {
  2032. minArrayCandidate = arrays[i];
  2033. if (!minArray || minArrayCandidate.length < minArray.length) {
  2034. minArray = minArrayCandidate;
  2035. minArrayIndex = i;
  2036. }
  2037. }
  2038. minArray = ExtArray.unique(minArray);
  2039. erase(arrays, minArrayIndex, 1);
  2040. // Use the smallest unique'd array as the anchor loop. If the other array(s) do contain
  2041. // an item in the small array, we're likely to find it before reaching the end
  2042. // of the inner loop and can terminate the search early.
  2043. minArrayLength = minArray.length;
  2044. arraysLength = arrays.length;
  2045. for (i = 0; i < minArrayLength; i++) {
  2046. element = minArray[i];
  2047. elementCount = 0;
  2048. for (j = 0; j < arraysLength; j++) {
  2049. array = arrays[j];
  2050. arrayLength = array.length;
  2051. for (k = 0; k < arrayLength; k++) {
  2052. elementCandidate = array[k];
  2053. if (element === elementCandidate) {
  2054. elementCount++;
  2055. break;
  2056. }
  2057. }
  2058. }
  2059. if (elementCount === arraysLength) {
  2060. intersection.push(element);
  2061. }
  2062. }
  2063. return intersection;
  2064. },
  2065. /**
  2066. * Perform a set difference A-B by subtracting all items in array B from array A.
  2067. *
  2068. * @param {Array} arrayA
  2069. * @param {Array} arrayB
  2070. * @return {Array} difference
  2071. */
  2072. difference: function(arrayA, arrayB) {
  2073. var clone = slice.call(arrayA),
  2074. ln = clone.length,
  2075. i, j, lnB;
  2076. for (i = 0,lnB = arrayB.length; i < lnB; i++) {
  2077. for (j = 0; j < ln; j++) {
  2078. if (clone[j] === arrayB[i]) {
  2079. erase(clone, j, 1);
  2080. j--;
  2081. ln--;
  2082. }
  2083. }
  2084. }
  2085. return clone;
  2086. },
  2087. /**
  2088. * Returns a shallow copy of a part of an array. This is equivalent to the native
  2089. * call "Array.prototype.slice.call(array, begin, end)". This is often used when "array"
  2090. * is "arguments" since the arguments object does not supply a slice method but can
  2091. * be the context object to Array.prototype.slice.
  2092. *
  2093. * @param {Array} array The array (or arguments object).
  2094. * @param {Number} begin The index at which to begin. Negative values are offsets from
  2095. * the end of the array.
  2096. * @param {Number} end The index at which to end. The copied items do not include
  2097. * end. Negative values are offsets from the end of the array. If end is omitted,
  2098. * all items up to the end of the array are copied.
  2099. * @return {Array} The copied piece of the array.
  2100. * @method slice
  2101. */
  2102. // Note: IE6 will return [] on slice.call(x, undefined).
  2103. slice: ([1,2].slice(1, undefined).length ?
  2104. function (array, begin, end) {
  2105. return slice.call(array, begin, end);
  2106. } :
  2107. // at least IE6 uses arguments.length for variadic signature
  2108. function (array, begin, end) {
  2109. // After tested for IE 6, the one below is of the best performance
  2110. // see http://jsperf.com/slice-fix
  2111. if (typeof begin === 'undefined') {
  2112. return slice.call(array);
  2113. }
  2114. if (typeof end === 'undefined') {
  2115. return slice.call(array, begin);
  2116. }
  2117. return slice.call(array, begin, end);
  2118. }
  2119. ),
  2120. /**
  2121. * Sorts the elements of an Array.
  2122. * By default, this method sorts the elements alphabetically and ascending.
  2123. *
  2124. * @param {Array} array The array to sort.
  2125. * @param {Function} sortFn (optional) The comparison function.
  2126. * @return {Array} The sorted array.
  2127. */
  2128. sort: supportsSort ? function(array, sortFn) {
  2129. if (sortFn) {
  2130. return array.sort(sortFn);
  2131. } else {
  2132. return array.sort();
  2133. }
  2134. } : function(array, sortFn) {
  2135. var length = array.length,
  2136. i = 0,
  2137. comparison,
  2138. j, min, tmp;
  2139. for (; i < length; i++) {
  2140. min = i;
  2141. for (j = i + 1; j < length; j++) {
  2142. if (sortFn) {
  2143. comparison = sortFn(array[j], array[min]);
  2144. if (comparison < 0) {
  2145. min = j;
  2146. }
  2147. } else if (array[j] < array[min]) {
  2148. min = j;
  2149. }
  2150. }
  2151. if (min !== i) {
  2152. tmp = array[i];
  2153. array[i] = array[min];
  2154. array[min] = tmp;
  2155. }
  2156. }
  2157. return array;
  2158. },
  2159. /**
  2160. * Recursively flattens into 1-d Array. Injects Arrays inline.
  2161. *
  2162. * @param {Array} array The array to flatten
  2163. * @return {Array} The 1-d array.
  2164. */
  2165. flatten: function(array) {
  2166. var worker = [];
  2167. function rFlatten(a) {
  2168. var i, ln, v;
  2169. for (i = 0, ln = a.length; i < ln; i++) {
  2170. v = a[i];
  2171. if (Ext.isArray(v)) {
  2172. rFlatten(v);
  2173. } else {
  2174. worker.push(v);
  2175. }
  2176. }
  2177. return worker;
  2178. }
  2179. return rFlatten(array);
  2180. },
  2181. /**
  2182. * Returns the minimum value in the Array.
  2183. *
  2184. * @param {Array/NodeList} array The Array from which to select the minimum value.
  2185. * @param {Function} comparisonFn (optional) a function to perform the comparision which determines minimization.
  2186. * If omitted the "<" operator will be used. Note: gt = 1; eq = 0; lt = -1
  2187. * @return {Object} minValue The minimum value
  2188. */
  2189. min: function(array, comparisonFn) {
  2190. var min = array[0],
  2191. i, ln, item;
  2192. for (i = 0, ln = array.length; i < ln; i++) {
  2193. item = array[i];
  2194. if (comparisonFn) {
  2195. if (comparisonFn(min, item) === 1) {
  2196. min = item;
  2197. }
  2198. }
  2199. else {
  2200. if (item < min) {
  2201. min = item;
  2202. }
  2203. }
  2204. }
  2205. return min;
  2206. },
  2207. /**
  2208. * Returns the maximum value in the Array.
  2209. *
  2210. * @param {Array/NodeList} array The Array from which to select the maximum value.
  2211. * @param {Function} comparisonFn (optional) a function to perform the comparision which determines maximization.
  2212. * If omitted the ">" operator will be used. Note: gt = 1; eq = 0; lt = -1
  2213. * @return {Object} maxValue The maximum value
  2214. */
  2215. max: function(array, comparisonFn) {
  2216. var max = array[0],
  2217. i, ln, item;
  2218. for (i = 0, ln = array.length; i < ln; i++) {
  2219. item = array[i];
  2220. if (comparisonFn) {
  2221. if (comparisonFn(max, item) === -1) {
  2222. max = item;
  2223. }
  2224. }
  2225. else {
  2226. if (item > max) {
  2227. max = item;
  2228. }
  2229. }
  2230. }
  2231. return max;
  2232. },
  2233. /**
  2234. * Calculates the mean of all items in the array.
  2235. *
  2236. * @param {Array} array The Array to calculate the mean value of.
  2237. * @return {Number} The mean.
  2238. */
  2239. mean: function(array) {
  2240. return array.length > 0 ? ExtArray.sum(array) / array.length : undefined;
  2241. },
  2242. /**
  2243. * Calculates the sum of all items in the given array.
  2244. *
  2245. * @param {Array} array The Array to calculate the sum value of.
  2246. * @return {Number} The sum.
  2247. */
  2248. sum: function(array) {
  2249. var sum = 0,
  2250. i, ln, item;
  2251. for (i = 0,ln = array.length; i < ln; i++) {
  2252. item = array[i];
  2253. sum += item;
  2254. }
  2255. return sum;
  2256. },
  2257. /**
  2258. * Creates a map (object) keyed by the elements of the given array. The values in
  2259. * the map are the index+1 of the array element. For example:
  2260. *
  2261. * var map = Ext.Array.toMap(['a','b','c']);
  2262. *
  2263. * // map = { a: 1, b: 2, c: 3 };
  2264. *
  2265. * Or a key property can be specified:
  2266. *
  2267. * var map = Ext.Array.toMap([
  2268. * { name: 'a' },
  2269. * { name: 'b' },
  2270. * { name: 'c' }
  2271. * ], 'name');
  2272. *
  2273. * // map = { a: 1, b: 2, c: 3 };
  2274. *
  2275. * Lastly, a key extractor can be provided:
  2276. *
  2277. * var map = Ext.Array.toMap([
  2278. * { name: 'a' },
  2279. * { name: 'b' },
  2280. * { name: 'c' }
  2281. * ], function (obj) { return obj.name.toUpperCase(); });
  2282. *
  2283. * // map = { A: 1, B: 2, C: 3 };
  2284. */
  2285. toMap: function(array, getKey, scope) {
  2286. var map = {},
  2287. i = array.length;
  2288. if (!getKey) {
  2289. while (i--) {
  2290. map[array[i]] = i+1;
  2291. }
  2292. } else if (typeof getKey == 'string') {
  2293. while (i--) {
  2294. map[array[i][getKey]] = i+1;
  2295. }
  2296. } else {
  2297. while (i--) {
  2298. map[getKey.call(scope, array[i])] = i+1;
  2299. }
  2300. }
  2301. return map;
  2302. },
  2303. /**
  2304. * Removes items from an array. This is functionally equivalent to the splice method
  2305. * of Array, but works around bugs in IE8's splice method and does not copy the
  2306. * removed elements in order to return them (because very often they are ignored).
  2307. *
  2308. * @param {Array} array The Array on which to replace.
  2309. * @param {Number} index The index in the array at which to operate.
  2310. * @param {Number} removeCount The number of items to remove at index.
  2311. * @return {Array} The array passed.
  2312. * @method
  2313. */
  2314. erase: erase,
  2315. /**
  2316. * Inserts items in to an array.
  2317. *
  2318. * @param {Array} array The Array in which to insert.
  2319. * @param {Number} index The index in the array at which to operate.
  2320. * @param {Array} items The array of items to insert at index.
  2321. * @return {Array} The array passed.
  2322. */
  2323. insert: function (array, index, items) {
  2324. return replace(array, index, 0, items);
  2325. },
  2326. /**
  2327. * Replaces items in an array. This is functionally equivalent to the splice method
  2328. * of Array, but works around bugs in IE8's splice method and is often more convenient
  2329. * to call because it accepts an array of items to insert rather than use a variadic
  2330. * argument list.
  2331. *
  2332. * @param {Array} array The Array on which to replace.
  2333. * @param {Number} index The index in the array at which to operate.
  2334. * @param {Number} removeCount The number of items to remove at index (can be 0).
  2335. * @param {Array} insert (optional) An array of items to insert at index.
  2336. * @return {Array} The array passed.
  2337. * @method
  2338. */
  2339. replace: replace,
  2340. /**
  2341. * Replaces items in an array. This is equivalent to the splice method of Array, but
  2342. * works around bugs in IE8's splice method. The signature is exactly the same as the
  2343. * splice method except that the array is the first argument. All arguments following
  2344. * removeCount are inserted in the array at index.
  2345. *
  2346. * @param {Array} array The Array on which to replace.
  2347. * @param {Number} index The index in the array at which to operate.
  2348. * @param {Number} removeCount The number of items to remove at index (can be 0).
  2349. * @param {Object...} elements The elements to add to the array. If you don't specify
  2350. * any elements, splice simply removes elements from the array.
  2351. * @return {Array} An array containing the removed items.
  2352. * @method
  2353. */
  2354. splice: splice,
  2355. /**
  2356. * Pushes new items onto the end of an Array.
  2357. *
  2358. * Passed parameters may be single items, or arrays of items. If an Array is found in the argument list, all its
  2359. * elements are pushed into the end of the target Array.
  2360. *
  2361. * @param {Array} target The Array onto which to push new items
  2362. * @param {Object...} elements The elements to add to the array. Each parameter may
  2363. * be an Array, in which case all the elements of that Array will be pushed into the end of the
  2364. * destination Array.
  2365. * @return {Array} An array containing all the new items push onto the end.
  2366. *
  2367. */
  2368. push: function(array) {
  2369. var len = arguments.length,
  2370. i = 1,
  2371. newItem;
  2372. if (array === undefined) {
  2373. array = [];
  2374. } else if (!Ext.isArray(array)) {
  2375. array = [array];
  2376. }
  2377. for (; i < len; i++) {
  2378. newItem = arguments[i];
  2379. Array.prototype.push[Ext.isArray(newItem) ? 'apply' : 'call'](array, newItem);
  2380. }
  2381. return array;
  2382. }
  2383. };
  2384. /**
  2385. * @method
  2386. * @member Ext
  2387. * @inheritdoc Ext.Array#each
  2388. */
  2389. Ext.each = ExtArray.each;
  2390. /**
  2391. * @method
  2392. * @member Ext.Array
  2393. * @inheritdoc Ext.Array#merge
  2394. */
  2395. ExtArray.union = ExtArray.merge;
  2396. /**
  2397. * Old alias to {@link Ext.Array#min}
  2398. * @deprecated 4.0.0 Use {@link Ext.Array#min} instead
  2399. * @method
  2400. * @member Ext
  2401. * @inheritdoc Ext.Array#min
  2402. */
  2403. Ext.min = ExtArray.min;
  2404. /**
  2405. * Old alias to {@link Ext.Array#max}
  2406. * @deprecated 4.0.0 Use {@link Ext.Array#max} instead
  2407. * @method
  2408. * @member Ext
  2409. * @inheritdoc Ext.Array#max
  2410. */
  2411. Ext.max = ExtArray.max;
  2412. /**
  2413. * Old alias to {@link Ext.Array#sum}
  2414. * @deprecated 4.0.0 Use {@link Ext.Array#sum} instead
  2415. * @method
  2416. * @member Ext
  2417. * @inheritdoc Ext.Array#sum
  2418. */
  2419. Ext.sum = ExtArray.sum;
  2420. /**
  2421. * Old alias to {@link Ext.Array#mean}
  2422. * @deprecated 4.0.0 Use {@link Ext.Array#mean} instead
  2423. * @method
  2424. * @member Ext
  2425. * @inheritdoc Ext.Array#mean
  2426. */
  2427. Ext.mean = ExtArray.mean;
  2428. /**
  2429. * Old alias to {@link Ext.Array#flatten}
  2430. * @deprecated 4.0.0 Use {@link Ext.Array#flatten} instead
  2431. * @method
  2432. * @member Ext
  2433. * @inheritdoc Ext.Array#flatten
  2434. */
  2435. Ext.flatten = ExtArray.flatten;
  2436. /**
  2437. * Old alias to {@link Ext.Array#clean}
  2438. * @deprecated 4.0.0 Use {@link Ext.Array#clean} instead
  2439. * @method
  2440. * @member Ext
  2441. * @inheritdoc Ext.Array#clean
  2442. */
  2443. Ext.clean = ExtArray.clean;
  2444. /**
  2445. * Old alias to {@link Ext.Array#unique}
  2446. * @deprecated 4.0.0 Use {@link Ext.Array#unique} instead
  2447. * @method
  2448. * @member Ext
  2449. * @inheritdoc Ext.Array#unique
  2450. */
  2451. Ext.unique = ExtArray.unique;
  2452. /**
  2453. * Old alias to {@link Ext.Array#pluck Ext.Array.pluck}
  2454. * @deprecated 4.0.0 Use {@link Ext.Array#pluck Ext.Array.pluck} instead
  2455. * @method
  2456. * @member Ext
  2457. * @inheritdoc Ext.Array#pluck
  2458. */
  2459. Ext.pluck = ExtArray.pluck;
  2460. /**
  2461. * @method
  2462. * @member Ext
  2463. * @inheritdoc Ext.Array#toArray
  2464. */
  2465. Ext.toArray = function() {
  2466. return ExtArray.toArray.apply(ExtArray, arguments);
  2467. };
  2468. }());
  2469. //@tag foundation,core
  2470. //@require Array.js
  2471. /**
  2472. * @class Ext.Function
  2473. *
  2474. * A collection of useful static methods to deal with function callbacks
  2475. * @singleton
  2476. * @alternateClassName Ext.util.Functions
  2477. */
  2478. Ext.Function = {
  2479. /**
  2480. * A very commonly used method throughout the framework. It acts as a wrapper around another method
  2481. * which originally accepts 2 arguments for `name` and `value`.
  2482. * The wrapped function then allows "flexible" value setting of either:
  2483. *
  2484. * - `name` and `value` as 2 arguments
  2485. * - one single object argument with multiple key - value pairs
  2486. *
  2487. * For example:
  2488. *
  2489. * var setValue = Ext.Function.flexSetter(function(name, value) {
  2490. * this[name] = value;
  2491. * });
  2492. *
  2493. * // Afterwards
  2494. * // Setting a single name - value
  2495. * setValue('name1', 'value1');
  2496. *
  2497. * // Settings multiple name - value pairs
  2498. * setValue({
  2499. * name1: 'value1',
  2500. * name2: 'value2',
  2501. * name3: 'value3'
  2502. * });
  2503. *
  2504. * @param {Function} setter
  2505. * @returns {Function} flexSetter
  2506. */
  2507. flexSetter: function(fn) {
  2508. return function(a, b) {
  2509. var k, i;
  2510. if (a === null) {
  2511. return this;
  2512. }
  2513. if (typeof a !== 'string') {
  2514. for (k in a) {
  2515. if (a.hasOwnProperty(k)) {
  2516. fn.call(this, k, a[k]);
  2517. }
  2518. }
  2519. if (Ext.enumerables) {
  2520. for (i = Ext.enumerables.length; i--;) {
  2521. k = Ext.enumerables[i];
  2522. if (a.hasOwnProperty(k)) {
  2523. fn.call(this, k, a[k]);
  2524. }
  2525. }
  2526. }
  2527. } else {
  2528. fn.call(this, a, b);
  2529. }
  2530. return this;
  2531. };
  2532. },
  2533. /**
  2534. * Create a new function from the provided `fn`, change `this` to the provided scope, optionally
  2535. * overrides arguments for the call. (Defaults to the arguments passed by the caller)
  2536. *
  2537. * {@link Ext#bind Ext.bind} is alias for {@link Ext.Function#bind Ext.Function.bind}
  2538. *
  2539. * @param {Function} fn The function to delegate.
  2540. * @param {Object} scope (optional) The scope (`this` reference) in which the function is executed.
  2541. * **If omitted, defaults to the default global environment object (usually the browser window).**
  2542. * @param {Array} args (optional) Overrides arguments for the call. (Defaults to the arguments passed by the caller)
  2543. * @param {Boolean/Number} appendArgs (optional) if True args are appended to call args instead of overriding,
  2544. * if a number the args are inserted at the specified position
  2545. * @return {Function} The new function
  2546. */
  2547. bind: function(fn, scope, args, appendArgs) {
  2548. if (arguments.length === 2) {
  2549. return function() {
  2550. return fn.apply(scope, arguments);
  2551. };
  2552. }
  2553. var method = fn,
  2554. slice = Array.prototype.slice;
  2555. return function() {
  2556. var callArgs = args || arguments;
  2557. if (appendArgs === true) {
  2558. callArgs = slice.call(arguments, 0);
  2559. callArgs = callArgs.concat(args);
  2560. }
  2561. else if (typeof appendArgs == 'number') {
  2562. callArgs = slice.call(arguments, 0); // copy arguments first
  2563. Ext.Array.insert(callArgs, appendArgs, args);
  2564. }
  2565. return method.apply(scope || Ext.global, callArgs);
  2566. };
  2567. },
  2568. /**
  2569. * Create a new function from the provided `fn`, the arguments of which are pre-set to `args`.
  2570. * New arguments passed to the newly created callback when it's invoked are appended after the pre-set ones.
  2571. * This is especially useful when creating callbacks.
  2572. *
  2573. * For example:
  2574. *
  2575. * var originalFunction = function(){
  2576. * alert(Ext.Array.from(arguments).join(' '));
  2577. * };
  2578. *
  2579. * var callback = Ext.Function.pass(originalFunction, ['Hello', 'World']);
  2580. *
  2581. * callback(); // alerts 'Hello World'
  2582. * callback('by Me'); // alerts 'Hello World by Me'
  2583. *
  2584. * {@link Ext#pass Ext.pass} is alias for {@link Ext.Function#pass Ext.Function.pass}
  2585. *
  2586. * @param {Function} fn The original function
  2587. * @param {Array} args The arguments to pass to new callback
  2588. * @param {Object} scope (optional) The scope (`this` reference) in which the function is executed.
  2589. * @return {Function} The new callback function
  2590. */
  2591. pass: function(fn, args, scope) {
  2592. if (!Ext.isArray(args)) {
  2593. if (Ext.isIterable(args)) {
  2594. args = Ext.Array.clone(args);
  2595. } else {
  2596. args = args !== undefined ? [args] : [];
  2597. }
  2598. }
  2599. return function() {
  2600. var fnArgs = [].concat(args);
  2601. fnArgs.push.apply(fnArgs, arguments);
  2602. return fn.apply(scope || this, fnArgs);
  2603. };
  2604. },
  2605. /**
  2606. * Create an alias to the provided method property with name `methodName` of `object`.
  2607. * Note that the execution scope will still be bound to the provided `object` itself.
  2608. *
  2609. * @param {Object/Function} object
  2610. * @param {String} methodName
  2611. * @return {Function} aliasFn
  2612. */
  2613. alias: function(object, methodName) {
  2614. return function() {
  2615. return object[methodName].apply(object, arguments);
  2616. };
  2617. },
  2618. /**
  2619. * Create a "clone" of the provided method. The returned method will call the given
  2620. * method passing along all arguments and the "this" pointer and return its result.
  2621. *
  2622. * @param {Function} method
  2623. * @return {Function} cloneFn
  2624. */
  2625. clone: function(method) {
  2626. return function() {
  2627. return method.apply(this, arguments);
  2628. };
  2629. },
  2630. /**
  2631. * Creates an interceptor function. The passed function is called before the original one. If it returns false,
  2632. * the original one is not called. The resulting function returns the results of the original function.
  2633. * The passed function is called with the parameters of the original function. Example usage:
  2634. *
  2635. * var sayHi = function(name){
  2636. * alert('Hi, ' + name);
  2637. * }
  2638. *
  2639. * sayHi('Fred'); // alerts "Hi, Fred"
  2640. *
  2641. * // create a new function that validates input without
  2642. * // directly modifying the original function:
  2643. * var sayHiToFriend = Ext.Function.createInterceptor(sayHi, function(name){
  2644. * return name == 'Brian';
  2645. * });
  2646. *
  2647. * sayHiToFriend('Fred'); // no alert
  2648. * sayHiToFriend('Brian'); // alerts "Hi, Brian"
  2649. *
  2650. * @param {Function} origFn The original function.
  2651. * @param {Function} newFn The function to call before the original
  2652. * @param {Object} scope (optional) The scope (`this` reference) in which the passed function is executed.
  2653. * **If omitted, defaults to the scope in which the original function is called or the browser window.**
  2654. * @param {Object} returnValue (optional) The value to return if the passed function return false (defaults to null).
  2655. * @return {Function} The new function
  2656. */
  2657. createInterceptor: function(origFn, newFn, scope, returnValue) {
  2658. var method = origFn;
  2659. if (!Ext.isFunction(newFn)) {
  2660. return origFn;
  2661. }
  2662. else {
  2663. return function() {
  2664. var me = this,
  2665. args = arguments;
  2666. newFn.target = me;
  2667. newFn.method = origFn;
  2668. return (newFn.apply(scope || me || Ext.global, args) !== false) ? origFn.apply(me || Ext.global, args) : returnValue || null;
  2669. };
  2670. }
  2671. },
  2672. /**
  2673. * Creates a delegate (callback) which, when called, executes after a specific delay.
  2674. *
  2675. * @param {Function} fn The function which will be called on a delay when the returned function is called.
  2676. * Optionally, a replacement (or additional) argument list may be specified.
  2677. * @param {Number} delay The number of milliseconds to defer execution by whenever called.
  2678. * @param {Object} scope (optional) The scope (`this` reference) used by the function at execution time.
  2679. * @param {Array} args (optional) Override arguments for the call. (Defaults to the arguments passed by the caller)
  2680. * @param {Boolean/Number} appendArgs (optional) if True args are appended to call args instead of overriding,
  2681. * if a number the args are inserted at the specified position.
  2682. * @return {Function} A function which, when called, executes the original function after the specified delay.
  2683. */
  2684. createDelayed: function(fn, delay, scope, args, appendArgs) {
  2685. if (scope || args) {
  2686. fn = Ext.Function.bind(fn, scope, args, appendArgs);
  2687. }
  2688. return function() {
  2689. var me = this,
  2690. args = Array.prototype.slice.call(arguments);
  2691. setTimeout(function() {
  2692. fn.apply(me, args);
  2693. }, delay);
  2694. };
  2695. },
  2696. /**
  2697. * Calls this function after the number of millseconds specified, optionally in a specific scope. Example usage:
  2698. *
  2699. * var sayHi = function(name){
  2700. * alert('Hi, ' + name);
  2701. * }
  2702. *
  2703. * // executes immediately:
  2704. * sayHi('Fred');
  2705. *
  2706. * // executes after 2 seconds:
  2707. * Ext.Function.defer(sayHi, 2000, this, ['Fred']);
  2708. *
  2709. * // this syntax is sometimes useful for deferring
  2710. * // execution of an anonymous function:
  2711. * Ext.Function.defer(function(){
  2712. * alert('Anonymous');
  2713. * }, 100);
  2714. *
  2715. * {@link Ext#defer Ext.defer} is alias for {@link Ext.Function#defer Ext.Function.defer}
  2716. *
  2717. * @param {Function} fn The function to defer.
  2718. * @param {Number} millis The number of milliseconds for the setTimeout call
  2719. * (if less than or equal to 0 the function is executed immediately)
  2720. * @param {Object} scope (optional) The scope (`this` reference) in which the function is executed.
  2721. * **If omitted, defaults to the browser window.**
  2722. * @param {Array} args (optional) Overrides arguments for the call. (Defaults to the arguments passed by the caller)
  2723. * @param {Boolean/Number} appendArgs (optional) if True args are appended to call args instead of overriding,
  2724. * if a number the args are inserted at the specified position
  2725. * @return {Number} The timeout id that can be used with clearTimeout
  2726. */
  2727. defer: function(fn, millis, scope, args, appendArgs) {
  2728. fn = Ext.Function.bind(fn, scope, args, appendArgs);
  2729. if (millis > 0) {
  2730. return setTimeout(Ext.supports.TimeoutActualLateness ? function () {
  2731. fn();
  2732. } : fn, millis);
  2733. }
  2734. fn();
  2735. return 0;
  2736. },
  2737. /**
  2738. * Create a combined function call sequence of the original function + the passed function.
  2739. * The resulting function returns the results of the original function.
  2740. * The passed function is called with the parameters of the original function. Example usage:
  2741. *
  2742. * var sayHi = function(name){
  2743. * alert('Hi, ' + name);
  2744. * }
  2745. *
  2746. * sayHi('Fred'); // alerts "Hi, Fred"
  2747. *
  2748. * var sayGoodbye = Ext.Function.createSequence(sayHi, function(name){
  2749. * alert('Bye, ' + name);
  2750. * });
  2751. *
  2752. * sayGoodbye('Fred'); // both alerts show
  2753. *
  2754. * @param {Function} originalFn The original function.
  2755. * @param {Function} newFn The function to sequence
  2756. * @param {Object} scope (optional) The scope (`this` reference) in which the passed function is executed.
  2757. * If omitted, defaults to the scope in which the original function is called or the default global environment object (usually the browser window).
  2758. * @return {Function} The new function
  2759. */
  2760. createSequence: function(originalFn, newFn, scope) {
  2761. if (!newFn) {
  2762. return originalFn;
  2763. }
  2764. else {
  2765. return function() {
  2766. var result = originalFn.apply(this, arguments);
  2767. newFn.apply(scope || this, arguments);
  2768. return result;
  2769. };
  2770. }
  2771. },
  2772. /**
  2773. * Creates a delegate function, optionally with a bound scope which, when called, buffers
  2774. * the execution of the passed function for the configured number of milliseconds.
  2775. * If called again within that period, the impending invocation will be canceled, and the
  2776. * timeout period will begin again.
  2777. *
  2778. * @param {Function} fn The function to invoke on a buffered timer.
  2779. * @param {Number} buffer The number of milliseconds by which to buffer the invocation of the
  2780. * function.
  2781. * @param {Object} scope (optional) The scope (`this` reference) in which
  2782. * the passed function is executed. If omitted, defaults to the scope specified by the caller.
  2783. * @param {Array} args (optional) Override arguments for the call. Defaults to the arguments
  2784. * passed by the caller.
  2785. * @return {Function} A function which invokes the passed function after buffering for the specified time.
  2786. */
  2787. createBuffered: function(fn, buffer, scope, args) {
  2788. var timerId;
  2789. return function() {
  2790. var callArgs = args || Array.prototype.slice.call(arguments, 0),
  2791. me = scope || this;
  2792. if (timerId) {
  2793. clearTimeout(timerId);
  2794. }
  2795. timerId = setTimeout(function(){
  2796. fn.apply(me, callArgs);
  2797. }, buffer);
  2798. };
  2799. },
  2800. /**
  2801. * Creates a throttled version of the passed function which, when called repeatedly and
  2802. * rapidly, invokes the passed function only after a certain interval has elapsed since the
  2803. * previous invocation.
  2804. *
  2805. * This is useful for wrapping functions which may be called repeatedly, such as
  2806. * a handler of a mouse move event when the processing is expensive.
  2807. *
  2808. * @param {Function} fn The function to execute at a regular time interval.
  2809. * @param {Number} interval The interval **in milliseconds** on which the passed function is executed.
  2810. * @param {Object} scope (optional) The scope (`this` reference) in which
  2811. * the passed function is executed. If omitted, defaults to the scope specified by the caller.
  2812. * @returns {Function} A function which invokes the passed function at the specified interval.
  2813. */
  2814. createThrottled: function(fn, interval, scope) {
  2815. var lastCallTime, elapsed, lastArgs, timer, execute = function() {
  2816. fn.apply(scope || this, lastArgs);
  2817. lastCallTime = new Date().getTime();
  2818. };
  2819. return function() {
  2820. elapsed = new Date().getTime() - lastCallTime;
  2821. lastArgs = arguments;
  2822. clearTimeout(timer);
  2823. if (!lastCallTime || (elapsed >= interval)) {
  2824. execute();
  2825. } else {
  2826. timer = setTimeout(execute, interval - elapsed);
  2827. }
  2828. };
  2829. },
  2830. /**
  2831. * Adds behavior to an existing method that is executed before the
  2832. * original behavior of the function. For example:
  2833. *
  2834. * var soup = {
  2835. * contents: [],
  2836. * add: function(ingredient) {
  2837. * this.contents.push(ingredient);
  2838. * }
  2839. * };
  2840. * Ext.Function.interceptBefore(soup, "add", function(ingredient){
  2841. * if (!this.contents.length && ingredient !== "water") {
  2842. * // Always add water to start with
  2843. * this.contents.push("water");
  2844. * }
  2845. * });
  2846. * soup.add("onions");
  2847. * soup.add("salt");
  2848. * soup.contents; // will contain: water, onions, salt
  2849. *
  2850. * @param {Object} object The target object
  2851. * @param {String} methodName Name of the method to override
  2852. * @param {Function} fn Function with the new behavior. It will
  2853. * be called with the same arguments as the original method. The
  2854. * return value of this function will be the return value of the
  2855. * new method.
  2856. * @param {Object} [scope] The scope to execute the interceptor function. Defaults to the object.
  2857. * @return {Function} The new function just created.
  2858. */
  2859. interceptBefore: function(object, methodName, fn, scope) {
  2860. var method = object[methodName] || Ext.emptyFn;
  2861. return (object[methodName] = function() {
  2862. var ret = fn.apply(scope || this, arguments);
  2863. method.apply(this, arguments);
  2864. return ret;
  2865. });
  2866. },
  2867. /**
  2868. * Adds behavior to an existing method that is executed after the
  2869. * original behavior of the function. For example:
  2870. *
  2871. * var soup = {
  2872. * contents: [],
  2873. * add: function(ingredient) {
  2874. * this.contents.push(ingredient);
  2875. * }
  2876. * };
  2877. * Ext.Function.interceptAfter(soup, "add", function(ingredient){
  2878. * // Always add a bit of extra salt
  2879. * this.contents.push("salt");
  2880. * });
  2881. * soup.add("water");
  2882. * soup.add("onions");
  2883. * soup.contents; // will contain: water, salt, onions, salt
  2884. *
  2885. * @param {Object} object The target object
  2886. * @param {String} methodName Name of the method to override
  2887. * @param {Function} fn Function with the new behavior. It will
  2888. * be called with the same arguments as the original method. The
  2889. * return value of this function will be the return value of the
  2890. * new method.
  2891. * @param {Object} [scope] The scope to execute the interceptor function. Defaults to the object.
  2892. * @return {Function} The new function just created.
  2893. */
  2894. interceptAfter: function(object, methodName, fn, scope) {
  2895. var method = object[methodName] || Ext.emptyFn;
  2896. return (object[methodName] = function() {
  2897. method.apply(this, arguments);
  2898. return fn.apply(scope || this, arguments);
  2899. });
  2900. }
  2901. };
  2902. /**
  2903. * @method
  2904. * @member Ext
  2905. * @inheritdoc Ext.Function#defer
  2906. */
  2907. Ext.defer = Ext.Function.alias(Ext.Function, 'defer');
  2908. /**
  2909. * @method
  2910. * @member Ext
  2911. * @inheritdoc Ext.Function#pass
  2912. */
  2913. Ext.pass = Ext.Function.alias(Ext.Function, 'pass');
  2914. /**
  2915. * @method
  2916. * @member Ext
  2917. * @inheritdoc Ext.Function#bind
  2918. */
  2919. Ext.bind = Ext.Function.alias(Ext.Function, 'bind');
  2920. //@tag foundation,core
  2921. //@require Function.js
  2922. /**
  2923. * @author Jacky Nguyen <jacky@sencha.com>
  2924. * @docauthor Jacky Nguyen <jacky@sencha.com>
  2925. * @class Ext.Object
  2926. *
  2927. * A collection of useful static methods to deal with objects.
  2928. *
  2929. * @singleton
  2930. */
  2931. (function() {
  2932. // The "constructor" for chain:
  2933. var TemplateClass = function(){},
  2934. ExtObject = Ext.Object = {
  2935. /**
  2936. * Returns a new object with the given object as the prototype chain.
  2937. * @param {Object} object The prototype chain for the new object.
  2938. */
  2939. chain: function (object) {
  2940. TemplateClass.prototype = object;
  2941. var result = new TemplateClass();
  2942. TemplateClass.prototype = null;
  2943. return result;
  2944. },
  2945. /**
  2946. * Converts a `name` - `value` pair to an array of objects with support for nested structures. Useful to construct
  2947. * query strings. For example:
  2948. *
  2949. * var objects = Ext.Object.toQueryObjects('hobbies', ['reading', 'cooking', 'swimming']);
  2950. *
  2951. * // objects then equals:
  2952. * [
  2953. * { name: 'hobbies', value: 'reading' },
  2954. * { name: 'hobbies', value: 'cooking' },
  2955. * { name: 'hobbies', value: 'swimming' },
  2956. * ];
  2957. *
  2958. * var objects = Ext.Object.toQueryObjects('dateOfBirth', {
  2959. * day: 3,
  2960. * month: 8,
  2961. * year: 1987,
  2962. * extra: {
  2963. * hour: 4
  2964. * minute: 30
  2965. * }
  2966. * }, true); // Recursive
  2967. *
  2968. * // objects then equals:
  2969. * [
  2970. * { name: 'dateOfBirth[day]', value: 3 },
  2971. * { name: 'dateOfBirth[month]', value: 8 },
  2972. * { name: 'dateOfBirth[year]', value: 1987 },
  2973. * { name: 'dateOfBirth[extra][hour]', value: 4 },
  2974. * { name: 'dateOfBirth[extra][minute]', value: 30 },
  2975. * ];
  2976. *
  2977. * @param {String} name
  2978. * @param {Object/Array} value
  2979. * @param {Boolean} [recursive=false] True to traverse object recursively
  2980. * @return {Array}
  2981. */
  2982. toQueryObjects: function(name, value, recursive) {
  2983. var self = ExtObject.toQueryObjects,
  2984. objects = [],
  2985. i, ln;
  2986. if (Ext.isArray(value)) {
  2987. for (i = 0, ln = value.length; i < ln; i++) {
  2988. if (recursive) {
  2989. objects = objects.concat(self(name + '[' + i + ']', value[i], true));
  2990. }
  2991. else {
  2992. objects.push({
  2993. name: name,
  2994. value: value[i]
  2995. });
  2996. }
  2997. }
  2998. }
  2999. else if (Ext.isObject(value)) {
  3000. for (i in value) {
  3001. if (value.hasOwnProperty(i)) {
  3002. if (recursive) {
  3003. objects = objects.concat(self(name + '[' + i + ']', value[i], true));
  3004. }
  3005. else {
  3006. objects.push({
  3007. name: name,
  3008. value: value[i]
  3009. });
  3010. }
  3011. }
  3012. }
  3013. }
  3014. else {
  3015. objects.push({
  3016. name: name,
  3017. value: value
  3018. });
  3019. }
  3020. return objects;
  3021. },
  3022. /**
  3023. * Takes an object and converts it to an encoded query string.
  3024. *
  3025. * Non-recursive:
  3026. *
  3027. * Ext.Object.toQueryString({foo: 1, bar: 2}); // returns "foo=1&bar=2"
  3028. * Ext.Object.toQueryString({foo: null, bar: 2}); // returns "foo=&bar=2"
  3029. * Ext.Object.toQueryString({'some price': '$300'}); // returns "some%20price=%24300"
  3030. * Ext.Object.toQueryString({date: new Date(2011, 0, 1)}); // returns "date=%222011-01-01T00%3A00%3A00%22"
  3031. * Ext.Object.toQueryString({colors: ['red', 'green', 'blue']}); // returns "colors=red&colors=green&colors=blue"
  3032. *
  3033. * Recursive:
  3034. *
  3035. * Ext.Object.toQueryString({
  3036. * username: 'Jacky',
  3037. * dateOfBirth: {
  3038. * day: 1,
  3039. * month: 2,
  3040. * year: 1911
  3041. * },
  3042. * hobbies: ['coding', 'eating', 'sleeping', ['nested', 'stuff']]
  3043. * }, true); // returns the following string (broken down and url-decoded for ease of reading purpose):
  3044. * // username=Jacky
  3045. * // &dateOfBirth[day]=1&dateOfBirth[month]=2&dateOfBirth[year]=1911
  3046. * // &hobbies[0]=coding&hobbies[1]=eating&hobbies[2]=sleeping&hobbies[3][0]=nested&hobbies[3][1]=stuff
  3047. *
  3048. * @param {Object} object The object to encode
  3049. * @param {Boolean} [recursive=false] Whether or not to interpret the object in recursive format.
  3050. * (PHP / Ruby on Rails servers and similar).
  3051. * @return {String} queryString
  3052. */
  3053. toQueryString: function(object, recursive) {
  3054. var paramObjects = [],
  3055. params = [],
  3056. i, j, ln, paramObject, value;
  3057. for (i in object) {
  3058. if (object.hasOwnProperty(i)) {
  3059. paramObjects = paramObjects.concat(ExtObject.toQueryObjects(i, object[i], recursive));
  3060. }
  3061. }
  3062. for (j = 0, ln = paramObjects.length; j < ln; j++) {
  3063. paramObject = paramObjects[j];
  3064. value = paramObject.value;
  3065. if (Ext.isEmpty(value)) {
  3066. value = '';
  3067. }
  3068. else if (Ext.isDate(value)) {
  3069. value = Ext.Date.toString(value);
  3070. }
  3071. params.push(encodeURIComponent(paramObject.name) + '=' + encodeURIComponent(String(value)));
  3072. }
  3073. return params.join('&');
  3074. },
  3075. /**
  3076. * Converts a query string back into an object.
  3077. *
  3078. * Non-recursive:
  3079. *
  3080. * Ext.Object.fromQueryString("foo=1&bar=2"); // returns {foo: 1, bar: 2}
  3081. * Ext.Object.fromQueryString("foo=&bar=2"); // returns {foo: null, bar: 2}
  3082. * Ext.Object.fromQueryString("some%20price=%24300"); // returns {'some price': '$300'}
  3083. * Ext.Object.fromQueryString("colors=red&colors=green&colors=blue"); // returns {colors: ['red', 'green', 'blue']}
  3084. *
  3085. * Recursive:
  3086. *
  3087. * Ext.Object.fromQueryString(
  3088. * "username=Jacky&"+
  3089. * "dateOfBirth[day]=1&dateOfBirth[month]=2&dateOfBirth[year]=1911&"+
  3090. * "hobbies[0]=coding&hobbies[1]=eating&hobbies[2]=sleeping&"+
  3091. * "hobbies[3][0]=nested&hobbies[3][1]=stuff", true);
  3092. *
  3093. * // returns
  3094. * {
  3095. * username: 'Jacky',
  3096. * dateOfBirth: {
  3097. * day: '1',
  3098. * month: '2',
  3099. * year: '1911'
  3100. * },
  3101. * hobbies: ['coding', 'eating', 'sleeping', ['nested', 'stuff']]
  3102. * }
  3103. *
  3104. * @param {String} queryString The query string to decode
  3105. * @param {Boolean} [recursive=false] Whether or not to recursively decode the string. This format is supported by
  3106. * PHP / Ruby on Rails servers and similar.
  3107. * @return {Object}
  3108. */
  3109. fromQueryString: function(queryString, recursive) {
  3110. var parts = queryString.replace(/^\?/, '').split('&'),
  3111. object = {},
  3112. temp, components, name, value, i, ln,
  3113. part, j, subLn, matchedKeys, matchedName,
  3114. keys, key, nextKey;
  3115. for (i = 0, ln = parts.length; i < ln; i++) {
  3116. part = parts[i];
  3117. if (part.length > 0) {
  3118. components = part.split('=');
  3119. name = decodeURIComponent(components[0]);
  3120. value = (components[1] !== undefined) ? decodeURIComponent(components[1]) : '';
  3121. if (!recursive) {
  3122. if (object.hasOwnProperty(name)) {
  3123. if (!Ext.isArray(object[name])) {
  3124. object[name] = [object[name]];
  3125. }
  3126. object[name].push(value);
  3127. }
  3128. else {
  3129. object[name] = value;
  3130. }
  3131. }
  3132. else {
  3133. matchedKeys = name.match(/(\[):?([^\]]*)\]/g);
  3134. matchedName = name.match(/^([^\[]+)/);
  3135. name = matchedName[0];
  3136. keys = [];
  3137. if (matchedKeys === null) {
  3138. object[name] = value;
  3139. continue;
  3140. }
  3141. for (j = 0, subLn = matchedKeys.length; j < subLn; j++) {
  3142. key = matchedKeys[j];
  3143. key = (key.length === 2) ? '' : key.substring(1, key.length - 1);
  3144. keys.push(key);
  3145. }
  3146. keys.unshift(name);
  3147. temp = object;
  3148. for (j = 0, subLn = keys.length; j < subLn; j++) {
  3149. key = keys[j];
  3150. if (j === subLn - 1) {
  3151. if (Ext.isArray(temp) && key === '') {
  3152. temp.push(value);
  3153. }
  3154. else {
  3155. temp[key] = value;
  3156. }
  3157. }
  3158. else {
  3159. if (temp[key] === undefined || typeof temp[key] === 'string') {
  3160. nextKey = keys[j+1];
  3161. temp[key] = (Ext.isNumeric(nextKey) || nextKey === '') ? [] : {};
  3162. }
  3163. temp = temp[key];
  3164. }
  3165. }
  3166. }
  3167. }
  3168. }
  3169. return object;
  3170. },
  3171. /**
  3172. * Iterates through an object and invokes the given callback function for each iteration.
  3173. * The iteration can be stopped by returning `false` in the callback function. For example:
  3174. *
  3175. * var person = {
  3176. * name: 'Jacky'
  3177. * hairColor: 'black'
  3178. * loves: ['food', 'sleeping', 'wife']
  3179. * };
  3180. *
  3181. * Ext.Object.each(person, function(key, value, myself) {
  3182. * console.log(key + ":" + value);
  3183. *
  3184. * if (key === 'hairColor') {
  3185. * return false; // stop the iteration
  3186. * }
  3187. * });
  3188. *
  3189. * @param {Object} object The object to iterate
  3190. * @param {Function} fn The callback function.
  3191. * @param {String} fn.key
  3192. * @param {Object} fn.value
  3193. * @param {Object} fn.object The object itself
  3194. * @param {Object} [scope] The execution scope (`this`) of the callback function
  3195. */
  3196. each: function(object, fn, scope) {
  3197. for (var property in object) {
  3198. if (object.hasOwnProperty(property)) {
  3199. if (fn.call(scope || object, property, object[property], object) === false) {
  3200. return;
  3201. }
  3202. }
  3203. }
  3204. },
  3205. /**
  3206. * Merges any number of objects recursively without referencing them or their children.
  3207. *
  3208. * var extjs = {
  3209. * companyName: 'Ext JS',
  3210. * products: ['Ext JS', 'Ext GWT', 'Ext Designer'],
  3211. * isSuperCool: true,
  3212. * office: {
  3213. * size: 2000,
  3214. * location: 'Palo Alto',
  3215. * isFun: true
  3216. * }
  3217. * };
  3218. *
  3219. * var newStuff = {
  3220. * companyName: 'Sencha Inc.',
  3221. * products: ['Ext JS', 'Ext GWT', 'Ext Designer', 'Sencha Touch', 'Sencha Animator'],
  3222. * office: {
  3223. * size: 40000,
  3224. * location: 'Redwood City'
  3225. * }
  3226. * };
  3227. *
  3228. * var sencha = Ext.Object.merge(extjs, newStuff);
  3229. *
  3230. * // extjs and sencha then equals to
  3231. * {
  3232. * companyName: 'Sencha Inc.',
  3233. * products: ['Ext JS', 'Ext GWT', 'Ext Designer', 'Sencha Touch', 'Sencha Animator'],
  3234. * isSuperCool: true,
  3235. * office: {
  3236. * size: 40000,
  3237. * location: 'Redwood City',
  3238. * isFun: true
  3239. * }
  3240. * }
  3241. *
  3242. * @param {Object} destination The object into which all subsequent objects are merged.
  3243. * @param {Object...} object Any number of objects to merge into the destination.
  3244. * @return {Object} merged The destination object with all passed objects merged in.
  3245. */
  3246. merge: function(destination) {
  3247. var i = 1,
  3248. ln = arguments.length,
  3249. mergeFn = ExtObject.merge,
  3250. cloneFn = Ext.clone,
  3251. object, key, value, sourceKey;
  3252. for (; i < ln; i++) {
  3253. object = arguments[i];
  3254. for (key in object) {
  3255. value = object[key];
  3256. if (value && value.constructor === Object) {
  3257. sourceKey = destination[key];
  3258. if (sourceKey && sourceKey.constructor === Object) {
  3259. mergeFn(sourceKey, value);
  3260. }
  3261. else {
  3262. destination[key] = cloneFn(value);
  3263. }
  3264. }
  3265. else {
  3266. destination[key] = value;
  3267. }
  3268. }
  3269. }
  3270. return destination;
  3271. },
  3272. /**
  3273. * @private
  3274. * @param destination
  3275. */
  3276. mergeIf: function(destination) {
  3277. var i = 1,
  3278. ln = arguments.length,
  3279. cloneFn = Ext.clone,
  3280. object, key, value;
  3281. for (; i < ln; i++) {
  3282. object = arguments[i];
  3283. for (key in object) {
  3284. if (!(key in destination)) {
  3285. value = object[key];
  3286. if (value && value.constructor === Object) {
  3287. destination[key] = cloneFn(value);
  3288. }
  3289. else {
  3290. destination[key] = value;
  3291. }
  3292. }
  3293. }
  3294. }
  3295. return destination;
  3296. },
  3297. /**
  3298. * Returns the first matching key corresponding to the given value.
  3299. * If no matching value is found, null is returned.
  3300. *
  3301. * var person = {
  3302. * name: 'Jacky',
  3303. * loves: 'food'
  3304. * };
  3305. *
  3306. * alert(Ext.Object.getKey(person, 'food')); // alerts 'loves'
  3307. *
  3308. * @param {Object} object
  3309. * @param {Object} value The value to find
  3310. */
  3311. getKey: function(object, value) {
  3312. for (var property in object) {
  3313. if (object.hasOwnProperty(property) && object[property] === value) {
  3314. return property;
  3315. }
  3316. }
  3317. return null;
  3318. },
  3319. /**
  3320. * Gets all values of the given object as an array.
  3321. *
  3322. * var values = Ext.Object.getValues({
  3323. * name: 'Jacky',
  3324. * loves: 'food'
  3325. * }); // ['Jacky', 'food']
  3326. *
  3327. * @param {Object} object
  3328. * @return {Array} An array of values from the object
  3329. */
  3330. getValues: function(object) {
  3331. var values = [],
  3332. property;
  3333. for (property in object) {
  3334. if (object.hasOwnProperty(property)) {
  3335. values.push(object[property]);
  3336. }
  3337. }
  3338. return values;
  3339. },
  3340. /**
  3341. * Gets all keys of the given object as an array.
  3342. *
  3343. * var values = Ext.Object.getKeys({
  3344. * name: 'Jacky',
  3345. * loves: 'food'
  3346. * }); // ['name', 'loves']
  3347. *
  3348. * @param {Object} object
  3349. * @return {String[]} An array of keys from the object
  3350. * @method
  3351. */
  3352. getKeys: (typeof Object.keys == 'function')
  3353. ? function(object){
  3354. if (!object) {
  3355. return [];
  3356. }
  3357. return Object.keys(object);
  3358. }
  3359. : function(object) {
  3360. var keys = [],
  3361. property;
  3362. for (property in object) {
  3363. if (object.hasOwnProperty(property)) {
  3364. keys.push(property);
  3365. }
  3366. }
  3367. return keys;
  3368. },
  3369. /**
  3370. * Gets the total number of this object's own properties
  3371. *
  3372. * var size = Ext.Object.getSize({
  3373. * name: 'Jacky',
  3374. * loves: 'food'
  3375. * }); // size equals 2
  3376. *
  3377. * @param {Object} object
  3378. * @return {Number} size
  3379. */
  3380. getSize: function(object) {
  3381. var size = 0,
  3382. property;
  3383. for (property in object) {
  3384. if (object.hasOwnProperty(property)) {
  3385. size++;
  3386. }
  3387. }
  3388. return size;
  3389. },
  3390. /**
  3391. * @private
  3392. */
  3393. classify: function(object) {
  3394. var prototype = object,
  3395. objectProperties = [],
  3396. propertyClassesMap = {},
  3397. objectClass = function() {
  3398. var i = 0,
  3399. ln = objectProperties.length,
  3400. property;
  3401. for (; i < ln; i++) {
  3402. property = objectProperties[i];
  3403. this[property] = new propertyClassesMap[property]();
  3404. }
  3405. },
  3406. key, value;
  3407. for (key in object) {
  3408. if (object.hasOwnProperty(key)) {
  3409. value = object[key];
  3410. if (value && value.constructor === Object) {
  3411. objectProperties.push(key);
  3412. propertyClassesMap[key] = ExtObject.classify(value);
  3413. }
  3414. }
  3415. }
  3416. objectClass.prototype = prototype;
  3417. return objectClass;
  3418. }
  3419. };
  3420. /**
  3421. * A convenient alias method for {@link Ext.Object#merge}.
  3422. *
  3423. * @member Ext
  3424. * @method merge
  3425. * @inheritdoc Ext.Object#merge
  3426. */
  3427. Ext.merge = Ext.Object.merge;
  3428. /**
  3429. * @private
  3430. * @member Ext
  3431. */
  3432. Ext.mergeIf = Ext.Object.mergeIf;
  3433. /**
  3434. *
  3435. * @member Ext
  3436. * @method urlEncode
  3437. * @inheritdoc Ext.Object#toQueryString
  3438. * @deprecated 4.0.0 Use {@link Ext.Object#toQueryString} instead
  3439. */
  3440. Ext.urlEncode = function() {
  3441. var args = Ext.Array.from(arguments),
  3442. prefix = '';
  3443. // Support for the old `pre` argument
  3444. if ((typeof args[1] === 'string')) {
  3445. prefix = args[1] + '&';
  3446. args[1] = false;
  3447. }
  3448. return prefix + ExtObject.toQueryString.apply(ExtObject, args);
  3449. };
  3450. /**
  3451. * Alias for {@link Ext.Object#fromQueryString}.
  3452. *
  3453. * @member Ext
  3454. * @method urlDecode
  3455. * @inheritdoc Ext.Object#fromQueryString
  3456. * @deprecated 4.0.0 Use {@link Ext.Object#fromQueryString} instead
  3457. */
  3458. Ext.urlDecode = function() {
  3459. return ExtObject.fromQueryString.apply(ExtObject, arguments);
  3460. };
  3461. }());
  3462. //@tag foundation,core
  3463. //@require Object.js
  3464. //@define Ext.Date
  3465. /**
  3466. * @class Ext.Date
  3467. * A set of useful static methods to deal with date
  3468. * Note that if Ext.Date is required and loaded, it will copy all methods / properties to
  3469. * this object for convenience
  3470. *
  3471. * The date parsing and formatting syntax contains a subset of
  3472. * <a href="http://www.php.net/date">PHP's date() function</a>, and the formats that are
  3473. * supported will provide results equivalent to their PHP versions.
  3474. *
  3475. * The following is a list of all currently supported formats:
  3476. * <pre class="">
  3477. Format Description Example returned values
  3478. ------ ----------------------------------------------------------------------- -----------------------
  3479. d Day of the month, 2 digits with leading zeros 01 to 31
  3480. D A short textual representation of the day of the week Mon to Sun
  3481. j Day of the month without leading zeros 1 to 31
  3482. l A full textual representation of the day of the week Sunday to Saturday
  3483. N ISO-8601 numeric representation of the day of the week 1 (for Monday) through 7 (for Sunday)
  3484. S English ordinal suffix for the day of the month, 2 characters st, nd, rd or th. Works well with j
  3485. w Numeric representation of the day of the week 0 (for Sunday) to 6 (for Saturday)
  3486. z The day of the year (starting from 0) 0 to 364 (365 in leap years)
  3487. W ISO-8601 week number of year, weeks starting on Monday 01 to 53
  3488. F A full textual representation of a month, such as January or March January to December
  3489. m Numeric representation of a month, with leading zeros 01 to 12
  3490. M A short textual representation of a month Jan to Dec
  3491. n Numeric representation of a month, without leading zeros 1 to 12
  3492. t Number of days in the given month 28 to 31
  3493. L Whether it&#39;s a leap year 1 if it is a leap year, 0 otherwise.
  3494. o ISO-8601 year number (identical to (Y), but if the ISO week number (W) Examples: 1998 or 2004
  3495. belongs to the previous or next year, that year is used instead)
  3496. Y A full numeric representation of a year, 4 digits Examples: 1999 or 2003
  3497. y A two digit representation of a year Examples: 99 or 03
  3498. a Lowercase Ante meridiem and Post meridiem am or pm
  3499. A Uppercase Ante meridiem and Post meridiem AM or PM
  3500. g 12-hour format of an hour without leading zeros 1 to 12
  3501. G 24-hour format of an hour without leading zeros 0 to 23
  3502. h 12-hour format of an hour with leading zeros 01 to 12
  3503. H 24-hour format of an hour with leading zeros 00 to 23
  3504. i Minutes, with leading zeros 00 to 59
  3505. s Seconds, with leading zeros 00 to 59
  3506. u Decimal fraction of a second Examples:
  3507. (minimum 1 digit, arbitrary number of digits allowed) 001 (i.e. 0.001s) or
  3508. 100 (i.e. 0.100s) or
  3509. 999 (i.e. 0.999s) or
  3510. 999876543210 (i.e. 0.999876543210s)
  3511. O Difference to Greenwich time (GMT) in hours and minutes Example: +1030
  3512. P Difference to Greenwich time (GMT) with colon between hours and minutes Example: -08:00
  3513. T Timezone abbreviation of the machine running the code Examples: EST, MDT, PDT ...
  3514. Z Timezone offset in seconds (negative if west of UTC, positive if east) -43200 to 50400
  3515. c ISO 8601 date
  3516. Notes: Examples:
  3517. 1) If unspecified, the month / day defaults to the current month / day, 1991 or
  3518. the time defaults to midnight, while the timezone defaults to the 1992-10 or
  3519. browser's timezone. If a time is specified, it must include both hours 1993-09-20 or
  3520. and minutes. The "T" delimiter, seconds, milliseconds and timezone 1994-08-19T16:20+01:00 or
  3521. are optional. 1995-07-18T17:21:28-02:00 or
  3522. 2) The decimal fraction of a second, if specified, must contain at 1996-06-17T18:22:29.98765+03:00 or
  3523. least 1 digit (there is no limit to the maximum number 1997-05-16T19:23:30,12345-0400 or
  3524. of digits allowed), and may be delimited by either a '.' or a ',' 1998-04-15T20:24:31.2468Z or
  3525. Refer to the examples on the right for the various levels of 1999-03-14T20:24:32Z or
  3526. date-time granularity which are supported, or see 2000-02-13T21:25:33
  3527. http://www.w3.org/TR/NOTE-datetime for more info. 2001-01-12 22:26:34
  3528. U Seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) 1193432466 or -2138434463
  3529. MS Microsoft AJAX serialized dates \/Date(1238606590509)\/ (i.e. UTC milliseconds since epoch) or
  3530. \/Date(1238606590509+0800)\/
  3531. </pre>
  3532. *
  3533. * Example usage (note that you must escape format specifiers with '\\' to render them as character literals):
  3534. * <pre><code>
  3535. // Sample date:
  3536. // 'Wed Jan 10 2007 15:05:01 GMT-0600 (Central Standard Time)'
  3537. var dt = new Date('1/10/2007 03:05:01 PM GMT-0600');
  3538. console.log(Ext.Date.format(dt, 'Y-m-d')); // 2007-01-10
  3539. console.log(Ext.Date.format(dt, 'F j, Y, g:i a')); // January 10, 2007, 3:05 pm
  3540. console.log(Ext.Date.format(dt, 'l, \\t\\he jS \\of F Y h:i:s A')); // Wednesday, the 10th of January 2007 03:05:01 PM
  3541. </code></pre>
  3542. *
  3543. * Here are some standard date/time patterns that you might find helpful. They
  3544. * are not part of the source of Ext.Date, but to use them you can simply copy this
  3545. * block of code into any script that is included after Ext.Date and they will also become
  3546. * globally available on the Date object. Feel free to add or remove patterns as needed in your code.
  3547. * <pre><code>
  3548. Ext.Date.patterns = {
  3549. ISO8601Long:"Y-m-d H:i:s",
  3550. ISO8601Short:"Y-m-d",
  3551. ShortDate: "n/j/Y",
  3552. LongDate: "l, F d, Y",
  3553. FullDateTime: "l, F d, Y g:i:s A",
  3554. MonthDay: "F d",
  3555. ShortTime: "g:i A",
  3556. LongTime: "g:i:s A",
  3557. SortableDateTime: "Y-m-d\\TH:i:s",
  3558. UniversalSortableDateTime: "Y-m-d H:i:sO",
  3559. YearMonth: "F, Y"
  3560. };
  3561. </code></pre>
  3562. *
  3563. * Example usage:
  3564. * <pre><code>
  3565. var dt = new Date();
  3566. console.log(Ext.Date.format(dt, Ext.Date.patterns.ShortDate));
  3567. </code></pre>
  3568. * <p>Developer-written, custom formats may be used by supplying both a formatting and a parsing function
  3569. * which perform to specialized requirements. The functions are stored in {@link #parseFunctions} and {@link #formatFunctions}.</p>
  3570. * @singleton
  3571. */
  3572. /*
  3573. * Most of the date-formatting functions below are the excellent work of Baron Schwartz.
  3574. * (see http://www.xaprb.com/blog/2005/12/12/javascript-closures-for-runtime-efficiency/)
  3575. * They generate precompiled functions from format patterns instead of parsing and
  3576. * processing each pattern every time a date is formatted. These functions are available
  3577. * on every Date object.
  3578. */
  3579. (function() {
  3580. // create private copy of Ext's Ext.util.Format.format() method
  3581. // - to remove unnecessary dependency
  3582. // - to resolve namespace conflict with MS-Ajax's implementation
  3583. function xf(format) {
  3584. var args = Array.prototype.slice.call(arguments, 1);
  3585. return format.replace(/\{(\d+)\}/g, function(m, i) {
  3586. return args[i];
  3587. });
  3588. }
  3589. Ext.Date = {
  3590. /**
  3591. * Returns the current timestamp.
  3592. * @return {Number} Milliseconds since UNIX epoch.
  3593. * @method
  3594. */
  3595. now: Date.now || function() {
  3596. return +new Date();
  3597. },
  3598. /**
  3599. * @private
  3600. * Private for now
  3601. */
  3602. toString: function(date) {
  3603. var pad = Ext.String.leftPad;
  3604. return date.getFullYear() + "-"
  3605. + pad(date.getMonth() + 1, 2, '0') + "-"
  3606. + pad(date.getDate(), 2, '0') + "T"
  3607. + pad(date.getHours(), 2, '0') + ":"
  3608. + pad(date.getMinutes(), 2, '0') + ":"
  3609. + pad(date.getSeconds(), 2, '0');
  3610. },
  3611. /**
  3612. * Returns the number of milliseconds between two dates
  3613. * @param {Date} dateA The first date
  3614. * @param {Date} dateB (optional) The second date, defaults to now
  3615. * @return {Number} The difference in milliseconds
  3616. */
  3617. getElapsed: function(dateA, dateB) {
  3618. return Math.abs(dateA - (dateB || new Date()));
  3619. },
  3620. /**
  3621. * Global flag which determines if strict date parsing should be used.
  3622. * Strict date parsing will not roll-over invalid dates, which is the
  3623. * default behaviour of javascript Date objects.
  3624. * (see {@link #parse} for more information)
  3625. * Defaults to <tt>false</tt>.
  3626. * @type Boolean
  3627. */
  3628. useStrict: false,
  3629. // private
  3630. formatCodeToRegex: function(character, currentGroup) {
  3631. // Note: currentGroup - position in regex result array (see notes for Ext.Date.parseCodes below)
  3632. var p = utilDate.parseCodes[character];
  3633. if (p) {
  3634. p = typeof p == 'function'? p() : p;
  3635. utilDate.parseCodes[character] = p; // reassign function result to prevent repeated execution
  3636. }
  3637. return p ? Ext.applyIf({
  3638. c: p.c ? xf(p.c, currentGroup || "{0}") : p.c
  3639. }, p) : {
  3640. g: 0,
  3641. c: null,
  3642. s: Ext.String.escapeRegex(character) // treat unrecognised characters as literals
  3643. };
  3644. },
  3645. /**
  3646. * <p>An object hash in which each property is a date parsing function. The property name is the
  3647. * format string which that function parses.</p>
  3648. * <p>This object is automatically populated with date parsing functions as
  3649. * date formats are requested for Ext standard formatting strings.</p>
  3650. * <p>Custom parsing functions may be inserted into this object, keyed by a name which from then on
  3651. * may be used as a format string to {@link #parse}.<p>
  3652. * <p>Example:</p><pre><code>
  3653. Ext.Date.parseFunctions['x-date-format'] = myDateParser;
  3654. </code></pre>
  3655. * <p>A parsing function should return a Date object, and is passed the following parameters:<div class="mdetail-params"><ul>
  3656. * <li><code>date</code> : String<div class="sub-desc">The date string to parse.</div></li>
  3657. * <li><code>strict</code> : Boolean<div class="sub-desc">True to validate date strings while parsing
  3658. * (i.e. prevent javascript Date "rollover") (The default must be false).
  3659. * Invalid date strings should return null when parsed.</div></li>
  3660. * </ul></div></p>
  3661. * <p>To enable Dates to also be <i>formatted</i> according to that format, a corresponding
  3662. * formatting function must be placed into the {@link #formatFunctions} property.
  3663. * @property parseFunctions
  3664. * @type Object
  3665. */
  3666. parseFunctions: {
  3667. "MS": function(input, strict) {
  3668. // note: the timezone offset is ignored since the MS Ajax server sends
  3669. // a UTC milliseconds-since-Unix-epoch value (negative values are allowed)
  3670. var re = new RegExp('\\/Date\\(([-+])?(\\d+)(?:[+-]\\d{4})?\\)\\/'),
  3671. r = (input || '').match(re);
  3672. return r? new Date(((r[1] || '') + r[2]) * 1) : null;
  3673. }
  3674. },
  3675. parseRegexes: [],
  3676. /**
  3677. * <p>An object hash in which each property is a date formatting function. The property name is the
  3678. * format string which corresponds to the produced formatted date string.</p>
  3679. * <p>This object is automatically populated with date formatting functions as
  3680. * date formats are requested for Ext standard formatting strings.</p>
  3681. * <p>Custom formatting functions may be inserted into this object, keyed by a name which from then on
  3682. * may be used as a format string to {@link #format}. Example:</p><pre><code>
  3683. Ext.Date.formatFunctions['x-date-format'] = myDateFormatter;
  3684. </code></pre>
  3685. * <p>A formatting function should return a string representation of the passed Date object, and is passed the following parameters:<div class="mdetail-params"><ul>
  3686. * <li><code>date</code> : Date<div class="sub-desc">The Date to format.</div></li>
  3687. * </ul></div></p>
  3688. * <p>To enable date strings to also be <i>parsed</i> according to that format, a corresponding
  3689. * parsing function must be placed into the {@link #parseFunctions} property.
  3690. * @property formatFunctions
  3691. * @type Object
  3692. */
  3693. formatFunctions: {
  3694. "MS": function() {
  3695. // UTC milliseconds since Unix epoch (MS-AJAX serialized date format (MRSF))
  3696. return '\\/Date(' + this.getTime() + ')\\/';
  3697. }
  3698. },
  3699. y2kYear : 50,
  3700. /**
  3701. * Date interval constant
  3702. * @type String
  3703. */
  3704. MILLI : "ms",
  3705. /**
  3706. * Date interval constant
  3707. * @type String
  3708. */
  3709. SECOND : "s",
  3710. /**
  3711. * Date interval constant
  3712. * @type String
  3713. */
  3714. MINUTE : "mi",
  3715. /** Date interval constant
  3716. * @type String
  3717. */
  3718. HOUR : "h",
  3719. /**
  3720. * Date interval constant
  3721. * @type String
  3722. */
  3723. DAY : "d",
  3724. /**
  3725. * Date interval constant
  3726. * @type String
  3727. */
  3728. MONTH : "mo",
  3729. /**
  3730. * Date interval constant
  3731. * @type String
  3732. */
  3733. YEAR : "y",
  3734. /**
  3735. * <p>An object hash containing default date values used during date parsing.</p>
  3736. * <p>The following properties are available:<div class="mdetail-params"><ul>
  3737. * <li><code>y</code> : Number<div class="sub-desc">The default year value. (defaults to undefined)</div></li>
  3738. * <li><code>m</code> : Number<div class="sub-desc">The default 1-based month value. (defaults to undefined)</div></li>
  3739. * <li><code>d</code> : Number<div class="sub-desc">The default day value. (defaults to undefined)</div></li>
  3740. * <li><code>h</code> : Number<div class="sub-desc">The default hour value. (defaults to undefined)</div></li>
  3741. * <li><code>i</code> : Number<div class="sub-desc">The default minute value. (defaults to undefined)</div></li>
  3742. * <li><code>s</code> : Number<div class="sub-desc">The default second value. (defaults to undefined)</div></li>
  3743. * <li><code>ms</code> : Number<div class="sub-desc">The default millisecond value. (defaults to undefined)</div></li>
  3744. * </ul></div></p>
  3745. * <p>Override these properties to customize the default date values used by the {@link #parse} method.</p>
  3746. * <p><b>Note: In countries which experience Daylight Saving Time (i.e. DST), the <tt>h</tt>, <tt>i</tt>, <tt>s</tt>
  3747. * and <tt>ms</tt> properties may coincide with the exact time in which DST takes effect.
  3748. * It is the responsiblity of the developer to account for this.</b></p>
  3749. * Example Usage:
  3750. * <pre><code>
  3751. // set default day value to the first day of the month
  3752. Ext.Date.defaults.d = 1;
  3753. // parse a February date string containing only year and month values.
  3754. // setting the default day value to 1 prevents weird date rollover issues
  3755. // when attempting to parse the following date string on, for example, March 31st 2009.
  3756. Ext.Date.parse('2009-02', 'Y-m'); // returns a Date object representing February 1st 2009
  3757. </code></pre>
  3758. * @property defaults
  3759. * @type Object
  3760. */
  3761. defaults: {},
  3762. //<locale type="array">
  3763. /**
  3764. * @property {String[]} dayNames
  3765. * An array of textual day names.
  3766. * Override these values for international dates.
  3767. * Example:
  3768. * <pre><code>
  3769. Ext.Date.dayNames = [
  3770. 'SundayInYourLang',
  3771. 'MondayInYourLang',
  3772. ...
  3773. ];
  3774. </code></pre>
  3775. */
  3776. dayNames : [
  3777. "Sunday",
  3778. "Monday",
  3779. "Tuesday",
  3780. "Wednesday",
  3781. "Thursday",
  3782. "Friday",
  3783. "Saturday"
  3784. ],
  3785. //</locale>
  3786. //<locale type="array">
  3787. /**
  3788. * @property {String[]} monthNames
  3789. * An array of textual month names.
  3790. * Override these values for international dates.
  3791. * Example:
  3792. * <pre><code>
  3793. Ext.Date.monthNames = [
  3794. 'JanInYourLang',
  3795. 'FebInYourLang',
  3796. ...
  3797. ];
  3798. </code></pre>
  3799. */
  3800. monthNames : [
  3801. "January",
  3802. "February",
  3803. "March",
  3804. "April",
  3805. "May",
  3806. "June",
  3807. "July",
  3808. "August",
  3809. "September",
  3810. "October",
  3811. "November",
  3812. "December"
  3813. ],
  3814. //</locale>
  3815. //<locale type="object">
  3816. /**
  3817. * @property {Object} monthNumbers
  3818. * An object hash of zero-based javascript month numbers (with short month names as keys. note: keys are case-sensitive).
  3819. * Override these values for international dates.
  3820. * Example:
  3821. * <pre><code>
  3822. Ext.Date.monthNumbers = {
  3823. 'LongJanNameInYourLang': 0,
  3824. 'ShortJanNameInYourLang':0,
  3825. 'LongFebNameInYourLang':1,
  3826. 'ShortFebNameInYourLang':1,
  3827. ...
  3828. };
  3829. </code></pre>
  3830. */
  3831. monthNumbers : {
  3832. January: 0,
  3833. Jan: 0,
  3834. February: 1,
  3835. Feb: 1,
  3836. March: 2,
  3837. Mar: 2,
  3838. April: 3,
  3839. Apr: 3,
  3840. May: 4,
  3841. June: 5,
  3842. Jun: 5,
  3843. July: 6,
  3844. Jul: 6,
  3845. August: 7,
  3846. Aug: 7,
  3847. September: 8,
  3848. Sep: 8,
  3849. October: 9,
  3850. Oct: 9,
  3851. November: 10,
  3852. Nov: 10,
  3853. December: 11,
  3854. Dec: 11
  3855. },
  3856. //</locale>
  3857. //<locale>
  3858. /**
  3859. * @property {String} defaultFormat
  3860. * <p>The date format string that the {@link Ext.util.Format#dateRenderer}
  3861. * and {@link Ext.util.Format#date} functions use. See {@link Ext.Date} for details.</p>
  3862. * <p>This may be overridden in a locale file.</p>
  3863. */
  3864. defaultFormat : "m/d/Y",
  3865. //</locale>
  3866. //<locale type="function">
  3867. /**
  3868. * Get the short month name for the given month number.
  3869. * Override this function for international dates.
  3870. * @param {Number} month A zero-based javascript month number.
  3871. * @return {String} The short month name.
  3872. */
  3873. getShortMonthName : function(month) {
  3874. return Ext.Date.monthNames[month].substring(0, 3);
  3875. },
  3876. //</locale>
  3877. //<locale type="function">
  3878. /**
  3879. * Get the short day name for the given day number.
  3880. * Override this function for international dates.
  3881. * @param {Number} day A zero-based javascript day number.
  3882. * @return {String} The short day name.
  3883. */
  3884. getShortDayName : function(day) {
  3885. return Ext.Date.dayNames[day].substring(0, 3);
  3886. },
  3887. //</locale>
  3888. //<locale type="function">
  3889. /**
  3890. * Get the zero-based javascript month number for the given short/full month name.
  3891. * Override this function for international dates.
  3892. * @param {String} name The short/full month name.
  3893. * @return {Number} The zero-based javascript month number.
  3894. */
  3895. getMonthNumber : function(name) {
  3896. // handle camel casing for english month names (since the keys for the Ext.Date.monthNumbers hash are case sensitive)
  3897. return Ext.Date.monthNumbers[name.substring(0, 1).toUpperCase() + name.substring(1, 3).toLowerCase()];
  3898. },
  3899. //</locale>
  3900. /**
  3901. * Checks if the specified format contains hour information
  3902. * @param {String} format The format to check
  3903. * @return {Boolean} True if the format contains hour information
  3904. * @method
  3905. */
  3906. formatContainsHourInfo : (function(){
  3907. var stripEscapeRe = /(\\.)/g,
  3908. hourInfoRe = /([gGhHisucUOPZ]|MS)/;
  3909. return function(format){
  3910. return hourInfoRe.test(format.replace(stripEscapeRe, ''));
  3911. };
  3912. }()),
  3913. /**
  3914. * Checks if the specified format contains information about
  3915. * anything other than the time.
  3916. * @param {String} format The format to check
  3917. * @return {Boolean} True if the format contains information about
  3918. * date/day information.
  3919. * @method
  3920. */
  3921. formatContainsDateInfo : (function(){
  3922. var stripEscapeRe = /(\\.)/g,
  3923. dateInfoRe = /([djzmnYycU]|MS)/;
  3924. return function(format){
  3925. return dateInfoRe.test(format.replace(stripEscapeRe, ''));
  3926. };
  3927. }()),
  3928. /**
  3929. * Removes all escaping for a date format string. In date formats,
  3930. * using a '\' can be used to escape special characters.
  3931. * @param {String} format The format to unescape
  3932. * @return {String} The unescaped format
  3933. * @method
  3934. */
  3935. unescapeFormat: (function() {
  3936. var slashRe = /\\/gi;
  3937. return function(format) {
  3938. // Escape the format, since \ can be used to escape special
  3939. // characters in a date format. For example, in a spanish
  3940. // locale the format may be: 'd \\de F \\de Y'
  3941. return format.replace(slashRe, '');
  3942. }
  3943. }()),
  3944. /**
  3945. * The base format-code to formatting-function hashmap used by the {@link #format} method.
  3946. * Formatting functions are strings (or functions which return strings) which
  3947. * will return the appropriate value when evaluated in the context of the Date object
  3948. * from which the {@link #format} method is called.
  3949. * Add to / override these mappings for custom date formatting.
  3950. * Note: Ext.Date.format() treats characters as literals if an appropriate mapping cannot be found.
  3951. * Example:
  3952. * <pre><code>
  3953. Ext.Date.formatCodes.x = "Ext.util.Format.leftPad(this.getDate(), 2, '0')";
  3954. console.log(Ext.Date.format(new Date(), 'X'); // returns the current day of the month
  3955. </code></pre>
  3956. * @type Object
  3957. */
  3958. formatCodes : {
  3959. d: "Ext.String.leftPad(this.getDate(), 2, '0')",
  3960. D: "Ext.Date.getShortDayName(this.getDay())", // get localised short day name
  3961. j: "this.getDate()",
  3962. l: "Ext.Date.dayNames[this.getDay()]",
  3963. N: "(this.getDay() ? this.getDay() : 7)",
  3964. S: "Ext.Date.getSuffix(this)",
  3965. w: "this.getDay()",
  3966. z: "Ext.Date.getDayOfYear(this)",
  3967. W: "Ext.String.leftPad(Ext.Date.getWeekOfYear(this), 2, '0')",
  3968. F: "Ext.Date.monthNames[this.getMonth()]",
  3969. m: "Ext.String.leftPad(this.getMonth() + 1, 2, '0')",
  3970. M: "Ext.Date.getShortMonthName(this.getMonth())", // get localised short month name
  3971. n: "(this.getMonth() + 1)",
  3972. t: "Ext.Date.getDaysInMonth(this)",
  3973. L: "(Ext.Date.isLeapYear(this) ? 1 : 0)",
  3974. o: "(this.getFullYear() + (Ext.Date.getWeekOfYear(this) == 1 && this.getMonth() > 0 ? +1 : (Ext.Date.getWeekOfYear(this) >= 52 && this.getMonth() < 11 ? -1 : 0)))",
  3975. Y: "Ext.String.leftPad(this.getFullYear(), 4, '0')",
  3976. y: "('' + this.getFullYear()).substring(2, 4)",
  3977. a: "(this.getHours() < 12 ? 'am' : 'pm')",
  3978. A: "(this.getHours() < 12 ? 'AM' : 'PM')",
  3979. g: "((this.getHours() % 12) ? this.getHours() % 12 : 12)",
  3980. G: "this.getHours()",
  3981. h: "Ext.String.leftPad((this.getHours() % 12) ? this.getHours() % 12 : 12, 2, '0')",
  3982. H: "Ext.String.leftPad(this.getHours(), 2, '0')",
  3983. i: "Ext.String.leftPad(this.getMinutes(), 2, '0')",
  3984. s: "Ext.String.leftPad(this.getSeconds(), 2, '0')",
  3985. u: "Ext.String.leftPad(this.getMilliseconds(), 3, '0')",
  3986. O: "Ext.Date.getGMTOffset(this)",
  3987. P: "Ext.Date.getGMTOffset(this, true)",
  3988. T: "Ext.Date.getTimezone(this)",
  3989. Z: "(this.getTimezoneOffset() * -60)",
  3990. c: function() { // ISO-8601 -- GMT format
  3991. var c, code, i, l, e;
  3992. for (c = "Y-m-dTH:i:sP", code = [], i = 0, l = c.length; i < l; ++i) {
  3993. e = c.charAt(i);
  3994. code.push(e == "T" ? "'T'" : utilDate.getFormatCode(e)); // treat T as a character literal
  3995. }
  3996. return code.join(" + ");
  3997. },
  3998. /*
  3999. c: function() { // ISO-8601 -- UTC format
  4000. return [
  4001. "this.getUTCFullYear()", "'-'",
  4002. "Ext.util.Format.leftPad(this.getUTCMonth() + 1, 2, '0')", "'-'",
  4003. "Ext.util.Format.leftPad(this.getUTCDate(), 2, '0')",
  4004. "'T'",
  4005. "Ext.util.Format.leftPad(this.getUTCHours(), 2, '0')", "':'",
  4006. "Ext.util.Format.leftPad(this.getUTCMinutes(), 2, '0')", "':'",
  4007. "Ext.util.Format.leftPad(this.getUTCSeconds(), 2, '0')",
  4008. "'Z'"
  4009. ].join(" + ");
  4010. },
  4011. */
  4012. U: "Math.round(this.getTime() / 1000)"
  4013. },
  4014. /**
  4015. * Checks if the passed Date parameters will cause a javascript Date "rollover".
  4016. * @param {Number} year 4-digit year
  4017. * @param {Number} month 1-based month-of-year
  4018. * @param {Number} day Day of month
  4019. * @param {Number} hour (optional) Hour
  4020. * @param {Number} minute (optional) Minute
  4021. * @param {Number} second (optional) Second
  4022. * @param {Number} millisecond (optional) Millisecond
  4023. * @return {Boolean} true if the passed parameters do not cause a Date "rollover", false otherwise.
  4024. */
  4025. isValid : function(y, m, d, h, i, s, ms) {
  4026. // setup defaults
  4027. h = h || 0;
  4028. i = i || 0;
  4029. s = s || 0;
  4030. ms = ms || 0;
  4031. // Special handling for year < 100
  4032. var dt = utilDate.add(new Date(y < 100 ? 100 : y, m - 1, d, h, i, s, ms), utilDate.YEAR, y < 100 ? y - 100 : 0);
  4033. return y == dt.getFullYear() &&
  4034. m == dt.getMonth() + 1 &&
  4035. d == dt.getDate() &&
  4036. h == dt.getHours() &&
  4037. i == dt.getMinutes() &&
  4038. s == dt.getSeconds() &&
  4039. ms == dt.getMilliseconds();
  4040. },
  4041. /**
  4042. * Parses the passed string using the specified date format.
  4043. * Note that this function expects normal calendar dates, meaning that months are 1-based (i.e. 1 = January).
  4044. * The {@link #defaults} hash will be used for any date value (i.e. year, month, day, hour, minute, second or millisecond)
  4045. * which cannot be found in the passed string. If a corresponding default date value has not been specified in the {@link #defaults} hash,
  4046. * the current date's year, month, day or DST-adjusted zero-hour time value will be used instead.
  4047. * Keep in mind that the input date string must precisely match the specified format string
  4048. * in order for the parse operation to be successful (failed parse operations return a null value).
  4049. * <p>Example:</p><pre><code>
  4050. //dt = Fri May 25 2007 (current date)
  4051. var dt = new Date();
  4052. //dt = Thu May 25 2006 (today&#39;s month/day in 2006)
  4053. dt = Ext.Date.parse("2006", "Y");
  4054. //dt = Sun Jan 15 2006 (all date parts specified)
  4055. dt = Ext.Date.parse("2006-01-15", "Y-m-d");
  4056. //dt = Sun Jan 15 2006 15:20:01
  4057. dt = Ext.Date.parse("2006-01-15 3:20:01 PM", "Y-m-d g:i:s A");
  4058. // attempt to parse Sun Feb 29 2006 03:20:01 in strict mode
  4059. dt = Ext.Date.parse("2006-02-29 03:20:01", "Y-m-d H:i:s", true); // returns null
  4060. </code></pre>
  4061. * @param {String} input The raw date string.
  4062. * @param {String} format The expected date string format.
  4063. * @param {Boolean} strict (optional) True to validate date strings while parsing (i.e. prevents javascript Date "rollover")
  4064. (defaults to false). Invalid date strings will return null when parsed.
  4065. * @return {Date} The parsed Date.
  4066. */
  4067. parse : function(input, format, strict) {
  4068. var p = utilDate.parseFunctions;
  4069. if (p[format] == null) {
  4070. utilDate.createParser(format);
  4071. }
  4072. return p[format](input, Ext.isDefined(strict) ? strict : utilDate.useStrict);
  4073. },
  4074. // Backwards compat
  4075. parseDate: function(input, format, strict){
  4076. return utilDate.parse(input, format, strict);
  4077. },
  4078. // private
  4079. getFormatCode : function(character) {
  4080. var f = utilDate.formatCodes[character];
  4081. if (f) {
  4082. f = typeof f == 'function'? f() : f;
  4083. utilDate.formatCodes[character] = f; // reassign function result to prevent repeated execution
  4084. }
  4085. // note: unknown characters are treated as literals
  4086. return f || ("'" + Ext.String.escape(character) + "'");
  4087. },
  4088. // private
  4089. createFormat : function(format) {
  4090. var code = [],
  4091. special = false,
  4092. ch = '',
  4093. i;
  4094. for (i = 0; i < format.length; ++i) {
  4095. ch = format.charAt(i);
  4096. if (!special && ch == "\\") {
  4097. special = true;
  4098. } else if (special) {
  4099. special = false;
  4100. code.push("'" + Ext.String.escape(ch) + "'");
  4101. } else {
  4102. code.push(utilDate.getFormatCode(ch));
  4103. }
  4104. }
  4105. utilDate.formatFunctions[format] = Ext.functionFactory("return " + code.join('+'));
  4106. },
  4107. // private
  4108. createParser : (function() {
  4109. var code = [
  4110. "var dt, y, m, d, h, i, s, ms, o, z, zz, u, v,",
  4111. "def = Ext.Date.defaults,",
  4112. "results = String(input).match(Ext.Date.parseRegexes[{0}]);", // either null, or an array of matched strings
  4113. "if(results){",
  4114. "{1}",
  4115. "if(u != null){", // i.e. unix time is defined
  4116. "v = new Date(u * 1000);", // give top priority to UNIX time
  4117. "}else{",
  4118. // create Date object representing midnight of the current day;
  4119. // this will provide us with our date defaults
  4120. // (note: clearTime() handles Daylight Saving Time automatically)
  4121. "dt = Ext.Date.clearTime(new Date);",
  4122. // date calculations (note: these calculations create a dependency on Ext.Number.from())
  4123. "y = Ext.Number.from(y, Ext.Number.from(def.y, dt.getFullYear()));",
  4124. "m = Ext.Number.from(m, Ext.Number.from(def.m - 1, dt.getMonth()));",
  4125. "d = Ext.Number.from(d, Ext.Number.from(def.d, dt.getDate()));",
  4126. // time calculations (note: these calculations create a dependency on Ext.Number.from())
  4127. "h = Ext.Number.from(h, Ext.Number.from(def.h, dt.getHours()));",
  4128. "i = Ext.Number.from(i, Ext.Number.from(def.i, dt.getMinutes()));",
  4129. "s = Ext.Number.from(s, Ext.Number.from(def.s, dt.getSeconds()));",
  4130. "ms = Ext.Number.from(ms, Ext.Number.from(def.ms, dt.getMilliseconds()));",
  4131. "if(z >= 0 && y >= 0){",
  4132. // both the year and zero-based day of year are defined and >= 0.
  4133. // these 2 values alone provide sufficient info to create a full date object
  4134. // create Date object representing January 1st for the given year
  4135. // handle years < 100 appropriately
  4136. "v = Ext.Date.add(new Date(y < 100 ? 100 : y, 0, 1, h, i, s, ms), Ext.Date.YEAR, y < 100 ? y - 100 : 0);",
  4137. // then add day of year, checking for Date "rollover" if necessary
  4138. "v = !strict? v : (strict === true && (z <= 364 || (Ext.Date.isLeapYear(v) && z <= 365))? Ext.Date.add(v, Ext.Date.DAY, z) : null);",
  4139. "}else if(strict === true && !Ext.Date.isValid(y, m + 1, d, h, i, s, ms)){", // check for Date "rollover"
  4140. "v = null;", // invalid date, so return null
  4141. "}else{",
  4142. // plain old Date object
  4143. // handle years < 100 properly
  4144. "v = Ext.Date.add(new Date(y < 100 ? 100 : y, m, d, h, i, s, ms), Ext.Date.YEAR, y < 100 ? y - 100 : 0);",
  4145. "}",
  4146. "}",
  4147. "}",
  4148. "if(v){",
  4149. // favour UTC offset over GMT offset
  4150. "if(zz != null){",
  4151. // reset to UTC, then add offset
  4152. "v = Ext.Date.add(v, Ext.Date.SECOND, -v.getTimezoneOffset() * 60 - zz);",
  4153. "}else if(o){",
  4154. // reset to GMT, then add offset
  4155. "v = Ext.Date.add(v, Ext.Date.MINUTE, -v.getTimezoneOffset() + (sn == '+'? -1 : 1) * (hr * 60 + mn));",
  4156. "}",
  4157. "}",
  4158. "return v;"
  4159. ].join('\n');
  4160. return function(format) {
  4161. var regexNum = utilDate.parseRegexes.length,
  4162. currentGroup = 1,
  4163. calc = [],
  4164. regex = [],
  4165. special = false,
  4166. ch = "",
  4167. i = 0,
  4168. len = format.length,
  4169. atEnd = [],
  4170. obj;
  4171. for (; i < len; ++i) {
  4172. ch = format.charAt(i);
  4173. if (!special && ch == "\\") {
  4174. special = true;
  4175. } else if (special) {
  4176. special = false;
  4177. regex.push(Ext.String.escape(ch));
  4178. } else {
  4179. obj = utilDate.formatCodeToRegex(ch, currentGroup);
  4180. currentGroup += obj.g;
  4181. regex.push(obj.s);
  4182. if (obj.g && obj.c) {
  4183. if (obj.calcAtEnd) {
  4184. atEnd.push(obj.c);
  4185. } else {
  4186. calc.push(obj.c);
  4187. }
  4188. }
  4189. }
  4190. }
  4191. calc = calc.concat(atEnd);
  4192. utilDate.parseRegexes[regexNum] = new RegExp("^" + regex.join('') + "$", 'i');
  4193. utilDate.parseFunctions[format] = Ext.functionFactory("input", "strict", xf(code, regexNum, calc.join('')));
  4194. };
  4195. }()),
  4196. // private
  4197. parseCodes : {
  4198. /*
  4199. * Notes:
  4200. * g = {Number} calculation group (0 or 1. only group 1 contributes to date calculations.)
  4201. * c = {String} calculation method (required for group 1. null for group 0. {0} = currentGroup - position in regex result array)
  4202. * s = {String} regex pattern. all matches are stored in results[], and are accessible by the calculation mapped to 'c'
  4203. */
  4204. d: {
  4205. g:1,
  4206. c:"d = parseInt(results[{0}], 10);\n",
  4207. s:"(3[0-1]|[1-2][0-9]|0[1-9])" // day of month with leading zeroes (01 - 31)
  4208. },
  4209. j: {
  4210. g:1,
  4211. c:"d = parseInt(results[{0}], 10);\n",
  4212. s:"(3[0-1]|[1-2][0-9]|[1-9])" // day of month without leading zeroes (1 - 31)
  4213. },
  4214. D: function() {
  4215. for (var a = [], i = 0; i < 7; a.push(utilDate.getShortDayName(i)), ++i); // get localised short day names
  4216. return {
  4217. g:0,
  4218. c:null,
  4219. s:"(?:" + a.join("|") +")"
  4220. };
  4221. },
  4222. l: function() {
  4223. return {
  4224. g:0,
  4225. c:null,
  4226. s:"(?:" + utilDate.dayNames.join("|") + ")"
  4227. };
  4228. },
  4229. N: {
  4230. g:0,
  4231. c:null,
  4232. s:"[1-7]" // ISO-8601 day number (1 (monday) - 7 (sunday))
  4233. },
  4234. //<locale type="object" property="parseCodes">
  4235. S: {
  4236. g:0,
  4237. c:null,
  4238. s:"(?:st|nd|rd|th)"
  4239. },
  4240. //</locale>
  4241. w: {
  4242. g:0,
  4243. c:null,
  4244. s:"[0-6]" // javascript day number (0 (sunday) - 6 (saturday))
  4245. },
  4246. z: {
  4247. g:1,
  4248. c:"z = parseInt(results[{0}], 10);\n",
  4249. s:"(\\d{1,3})" // day of the year (0 - 364 (365 in leap years))
  4250. },
  4251. W: {
  4252. g:0,
  4253. c:null,
  4254. s:"(?:\\d{2})" // ISO-8601 week number (with leading zero)
  4255. },
  4256. F: function() {
  4257. return {
  4258. g:1,
  4259. c:"m = parseInt(Ext.Date.getMonthNumber(results[{0}]), 10);\n", // get localised month number
  4260. s:"(" + utilDate.monthNames.join("|") + ")"
  4261. };
  4262. },
  4263. M: function() {
  4264. for (var a = [], i = 0; i < 12; a.push(utilDate.getShortMonthName(i)), ++i); // get localised short month names
  4265. return Ext.applyIf({
  4266. s:"(" + a.join("|") + ")"
  4267. }, utilDate.formatCodeToRegex("F"));
  4268. },
  4269. m: {
  4270. g:1,
  4271. c:"m = parseInt(results[{0}], 10) - 1;\n",
  4272. s:"(1[0-2]|0[1-9])" // month number with leading zeros (01 - 12)
  4273. },
  4274. n: {
  4275. g:1,
  4276. c:"m = parseInt(results[{0}], 10) - 1;\n",
  4277. s:"(1[0-2]|[1-9])" // month number without leading zeros (1 - 12)
  4278. },
  4279. t: {
  4280. g:0,
  4281. c:null,
  4282. s:"(?:\\d{2})" // no. of days in the month (28 - 31)
  4283. },
  4284. L: {
  4285. g:0,
  4286. c:null,
  4287. s:"(?:1|0)"
  4288. },
  4289. o: function() {
  4290. return utilDate.formatCodeToRegex("Y");
  4291. },
  4292. Y: {
  4293. g:1,
  4294. c:"y = parseInt(results[{0}], 10);\n",
  4295. s:"(\\d{4})" // 4-digit year
  4296. },
  4297. y: {
  4298. g:1,
  4299. c:"var ty = parseInt(results[{0}], 10);\n"
  4300. + "y = ty > Ext.Date.y2kYear ? 1900 + ty : 2000 + ty;\n", // 2-digit year
  4301. s:"(\\d{1,2})"
  4302. },
  4303. /*
  4304. * In the am/pm parsing routines, we allow both upper and lower case
  4305. * even though it doesn't exactly match the spec. It gives much more flexibility
  4306. * in being able to specify case insensitive regexes.
  4307. */
  4308. //<locale type="object" property="parseCodes">
  4309. a: {
  4310. g:1,
  4311. c:"if (/(am)/i.test(results[{0}])) {\n"
  4312. + "if (!h || h == 12) { h = 0; }\n"
  4313. + "} else { if (!h || h < 12) { h = (h || 0) + 12; }}",
  4314. s:"(am|pm|AM|PM)",
  4315. calcAtEnd: true
  4316. },
  4317. //</locale>
  4318. //<locale type="object" property="parseCodes">
  4319. A: {
  4320. g:1,
  4321. c:"if (/(am)/i.test(results[{0}])) {\n"
  4322. + "if (!h || h == 12) { h = 0; }\n"
  4323. + "} else { if (!h || h < 12) { h = (h || 0) + 12; }}",
  4324. s:"(AM|PM|am|pm)",
  4325. calcAtEnd: true
  4326. },
  4327. //</locale>
  4328. g: {
  4329. g:1,
  4330. c:"h = parseInt(results[{0}], 10);\n",
  4331. s:"(1[0-2]|[0-9])" // 12-hr format of an hour without leading zeroes (1 - 12)
  4332. },
  4333. G: {
  4334. g:1,
  4335. c:"h = parseInt(results[{0}], 10);\n",
  4336. s:"(2[0-3]|1[0-9]|[0-9])" // 24-hr format of an hour without leading zeroes (0 - 23)
  4337. },
  4338. h: {
  4339. g:1,
  4340. c:"h = parseInt(results[{0}], 10);\n",
  4341. s:"(1[0-2]|0[1-9])" // 12-hr format of an hour with leading zeroes (01 - 12)
  4342. },
  4343. H: {
  4344. g:1,
  4345. c:"h = parseInt(results[{0}], 10);\n",
  4346. s:"(2[0-3]|[0-1][0-9])" // 24-hr format of an hour with leading zeroes (00 - 23)
  4347. },
  4348. i: {
  4349. g:1,
  4350. c:"i = parseInt(results[{0}], 10);\n",
  4351. s:"([0-5][0-9])" // minutes with leading zeros (00 - 59)
  4352. },
  4353. s: {
  4354. g:1,
  4355. c:"s = parseInt(results[{0}], 10);\n",
  4356. s:"([0-5][0-9])" // seconds with leading zeros (00 - 59)
  4357. },
  4358. u: {
  4359. g:1,
  4360. c:"ms = results[{0}]; ms = parseInt(ms, 10)/Math.pow(10, ms.length - 3);\n",
  4361. s:"(\\d+)" // decimal fraction of a second (minimum = 1 digit, maximum = unlimited)
  4362. },
  4363. O: {
  4364. g:1,
  4365. c:[
  4366. "o = results[{0}];",
  4367. "var sn = o.substring(0,1),", // get + / - sign
  4368. "hr = o.substring(1,3)*1 + Math.floor(o.substring(3,5) / 60),", // get hours (performs minutes-to-hour conversion also, just in case)
  4369. "mn = o.substring(3,5) % 60;", // get minutes
  4370. "o = ((-12 <= (hr*60 + mn)/60) && ((hr*60 + mn)/60 <= 14))? (sn + Ext.String.leftPad(hr, 2, '0') + Ext.String.leftPad(mn, 2, '0')) : null;\n" // -12hrs <= GMT offset <= 14hrs
  4371. ].join("\n"),
  4372. s: "([+-]\\d{4})" // GMT offset in hrs and mins
  4373. },
  4374. P: {
  4375. g:1,
  4376. c:[
  4377. "o = results[{0}];",
  4378. "var sn = o.substring(0,1),", // get + / - sign
  4379. "hr = o.substring(1,3)*1 + Math.floor(o.substring(4,6) / 60),", // get hours (performs minutes-to-hour conversion also, just in case)
  4380. "mn = o.substring(4,6) % 60;", // get minutes
  4381. "o = ((-12 <= (hr*60 + mn)/60) && ((hr*60 + mn)/60 <= 14))? (sn + Ext.String.leftPad(hr, 2, '0') + Ext.String.leftPad(mn, 2, '0')) : null;\n" // -12hrs <= GMT offset <= 14hrs
  4382. ].join("\n"),
  4383. s: "([+-]\\d{2}:\\d{2})" // GMT offset in hrs and mins (with colon separator)
  4384. },
  4385. T: {
  4386. g:0,
  4387. c:null,
  4388. s:"[A-Z]{1,4}" // timezone abbrev. may be between 1 - 4 chars
  4389. },
  4390. Z: {
  4391. g:1,
  4392. c:"zz = results[{0}] * 1;\n" // -43200 <= UTC offset <= 50400
  4393. + "zz = (-43200 <= zz && zz <= 50400)? zz : null;\n",
  4394. s:"([+-]?\\d{1,5})" // leading '+' sign is optional for UTC offset
  4395. },
  4396. c: function() {
  4397. var calc = [],
  4398. arr = [
  4399. utilDate.formatCodeToRegex("Y", 1), // year
  4400. utilDate.formatCodeToRegex("m", 2), // month
  4401. utilDate.formatCodeToRegex("d", 3), // day
  4402. utilDate.formatCodeToRegex("H", 4), // hour
  4403. utilDate.formatCodeToRegex("i", 5), // minute
  4404. utilDate.formatCodeToRegex("s", 6), // second
  4405. {c:"ms = results[7] || '0'; ms = parseInt(ms, 10)/Math.pow(10, ms.length - 3);\n"}, // decimal fraction of a second (minimum = 1 digit, maximum = unlimited)
  4406. {c:[ // allow either "Z" (i.e. UTC) or "-0530" or "+08:00" (i.e. UTC offset) timezone delimiters. assumes local timezone if no timezone is specified
  4407. "if(results[8]) {", // timezone specified
  4408. "if(results[8] == 'Z'){",
  4409. "zz = 0;", // UTC
  4410. "}else if (results[8].indexOf(':') > -1){",
  4411. utilDate.formatCodeToRegex("P", 8).c, // timezone offset with colon separator
  4412. "}else{",
  4413. utilDate.formatCodeToRegex("O", 8).c, // timezone offset without colon separator
  4414. "}",
  4415. "}"
  4416. ].join('\n')}
  4417. ],
  4418. i,
  4419. l;
  4420. for (i = 0, l = arr.length; i < l; ++i) {
  4421. calc.push(arr[i].c);
  4422. }
  4423. return {
  4424. g:1,
  4425. c:calc.join(""),
  4426. s:[
  4427. arr[0].s, // year (required)
  4428. "(?:", "-", arr[1].s, // month (optional)
  4429. "(?:", "-", arr[2].s, // day (optional)
  4430. "(?:",
  4431. "(?:T| )?", // time delimiter -- either a "T" or a single blank space
  4432. arr[3].s, ":", arr[4].s, // hour AND minute, delimited by a single colon (optional). MUST be preceded by either a "T" or a single blank space
  4433. "(?::", arr[5].s, ")?", // seconds (optional)
  4434. "(?:(?:\\.|,)(\\d+))?", // decimal fraction of a second (e.g. ",12345" or ".98765") (optional)
  4435. "(Z|(?:[-+]\\d{2}(?::)?\\d{2}))?", // "Z" (UTC) or "-0530" (UTC offset without colon delimiter) or "+08:00" (UTC offset with colon delimiter) (optional)
  4436. ")?",
  4437. ")?",
  4438. ")?"
  4439. ].join("")
  4440. };
  4441. },
  4442. U: {
  4443. g:1,
  4444. c:"u = parseInt(results[{0}], 10);\n",
  4445. s:"(-?\\d+)" // leading minus sign indicates seconds before UNIX epoch
  4446. }
  4447. },
  4448. //Old Ext.Date prototype methods.
  4449. // private
  4450. dateFormat: function(date, format) {
  4451. return utilDate.format(date, format);
  4452. },
  4453. /**
  4454. * Compares if two dates are equal by comparing their values.
  4455. * @param {Date} date1
  4456. * @param {Date} date2
  4457. * @return {Boolean} True if the date values are equal
  4458. */
  4459. isEqual: function(date1, date2) {
  4460. // check we have 2 date objects
  4461. if (date1 && date2) {
  4462. return (date1.getTime() === date2.getTime());
  4463. }
  4464. // one or both isn't a date, only equal if both are falsey
  4465. return !(date1 || date2);
  4466. },
  4467. /**
  4468. * Formats a date given the supplied format string.
  4469. * @param {Date} date The date to format
  4470. * @param {String} format The format string
  4471. * @return {String} The formatted date or an empty string if date parameter is not a JavaScript Date object
  4472. */
  4473. format: function(date, format) {
  4474. var formatFunctions = utilDate.formatFunctions;
  4475. if (!Ext.isDate(date)) {
  4476. return '';
  4477. }
  4478. if (formatFunctions[format] == null) {
  4479. utilDate.createFormat(format);
  4480. }
  4481. return formatFunctions[format].call(date) + '';
  4482. },
  4483. /**
  4484. * Get the timezone abbreviation of the current date (equivalent to the format specifier 'T').
  4485. *
  4486. * Note: The date string returned by the javascript Date object's toString() method varies
  4487. * between browsers (e.g. FF vs IE) and system region settings (e.g. IE in Asia vs IE in America).
  4488. * For a given date string e.g. "Thu Oct 25 2007 22:55:35 GMT+0800 (Malay Peninsula Standard Time)",
  4489. * getTimezone() first tries to get the timezone abbreviation from between a pair of parentheses
  4490. * (which may or may not be present), failing which it proceeds to get the timezone abbreviation
  4491. * from the GMT offset portion of the date string.
  4492. * @param {Date} date The date
  4493. * @return {String} The abbreviated timezone name (e.g. 'CST', 'PDT', 'EDT', 'MPST' ...).
  4494. */
  4495. getTimezone : function(date) {
  4496. // the following list shows the differences between date strings from different browsers on a WinXP SP2 machine from an Asian locale:
  4497. //
  4498. // Opera : "Thu, 25 Oct 2007 22:53:45 GMT+0800" -- shortest (weirdest) date string of the lot
  4499. // Safari : "Thu Oct 25 2007 22:55:35 GMT+0800 (Malay Peninsula Standard Time)" -- value in parentheses always gives the correct timezone (same as FF)
  4500. // FF : "Thu Oct 25 2007 22:55:35 GMT+0800 (Malay Peninsula Standard Time)" -- value in parentheses always gives the correct timezone
  4501. // IE : "Thu Oct 25 22:54:35 UTC+0800 2007" -- (Asian system setting) look for 3-4 letter timezone abbrev
  4502. // IE : "Thu Oct 25 17:06:37 PDT 2007" -- (American system setting) look for 3-4 letter timezone abbrev
  4503. //
  4504. // this crazy regex attempts to guess the correct timezone abbreviation despite these differences.
  4505. // step 1: (?:\((.*)\) -- find timezone in parentheses
  4506. // step 2: ([A-Z]{1,4})(?:[\-+][0-9]{4})?(?: -?\d+)?) -- if nothing was found in step 1, find timezone from timezone offset portion of date string
  4507. // step 3: remove all non uppercase characters found in step 1 and 2
  4508. return date.toString().replace(/^.* (?:\((.*)\)|([A-Z]{1,4})(?:[\-+][0-9]{4})?(?: -?\d+)?)$/, "$1$2").replace(/[^A-Z]/g, "");
  4509. },
  4510. /**
  4511. * Get the offset from GMT of the current date (equivalent to the format specifier 'O').
  4512. * @param {Date} date The date
  4513. * @param {Boolean} colon (optional) true to separate the hours and minutes with a colon (defaults to false).
  4514. * @return {String} The 4-character offset string prefixed with + or - (e.g. '-0600').
  4515. */
  4516. getGMTOffset : function(date, colon) {
  4517. var offset = date.getTimezoneOffset();
  4518. return (offset > 0 ? "-" : "+")
  4519. + Ext.String.leftPad(Math.floor(Math.abs(offset) / 60), 2, "0")
  4520. + (colon ? ":" : "")
  4521. + Ext.String.leftPad(Math.abs(offset % 60), 2, "0");
  4522. },
  4523. /**
  4524. * Get the numeric day number of the year, adjusted for leap year.
  4525. * @param {Date} date The date
  4526. * @return {Number} 0 to 364 (365 in leap years).
  4527. */
  4528. getDayOfYear: function(date) {
  4529. var num = 0,
  4530. d = Ext.Date.clone(date),
  4531. m = date.getMonth(),
  4532. i;
  4533. for (i = 0, d.setDate(1), d.setMonth(0); i < m; d.setMonth(++i)) {
  4534. num += utilDate.getDaysInMonth(d);
  4535. }
  4536. return num + date.getDate() - 1;
  4537. },
  4538. /**
  4539. * Get the numeric ISO-8601 week number of the year.
  4540. * (equivalent to the format specifier 'W', but without a leading zero).
  4541. * @param {Date} date The date
  4542. * @return {Number} 1 to 53
  4543. * @method
  4544. */
  4545. getWeekOfYear : (function() {
  4546. // adapted from http://www.merlyn.demon.co.uk/weekcalc.htm
  4547. var ms1d = 864e5, // milliseconds in a day
  4548. ms7d = 7 * ms1d; // milliseconds in a week
  4549. return function(date) { // return a closure so constants get calculated only once
  4550. var DC3 = Date.UTC(date.getFullYear(), date.getMonth(), date.getDate() + 3) / ms1d, // an Absolute Day Number
  4551. AWN = Math.floor(DC3 / 7), // an Absolute Week Number
  4552. Wyr = new Date(AWN * ms7d).getUTCFullYear();
  4553. return AWN - Math.floor(Date.UTC(Wyr, 0, 7) / ms7d) + 1;
  4554. };
  4555. }()),
  4556. /**
  4557. * Checks if the current date falls within a leap year.
  4558. * @param {Date} date The date
  4559. * @return {Boolean} True if the current date falls within a leap year, false otherwise.
  4560. */
  4561. isLeapYear : function(date) {
  4562. var year = date.getFullYear();
  4563. return !!((year & 3) == 0 && (year % 100 || (year % 400 == 0 && year)));
  4564. },
  4565. /**
  4566. * Get the first day of the current month, adjusted for leap year. The returned value
  4567. * is the numeric day index within the week (0-6) which can be used in conjunction with
  4568. * the {@link #monthNames} array to retrieve the textual day name.
  4569. * Example:
  4570. * <pre><code>
  4571. var dt = new Date('1/10/2007'),
  4572. firstDay = Ext.Date.getFirstDayOfMonth(dt);
  4573. console.log(Ext.Date.dayNames[firstDay]); //output: 'Monday'
  4574. * </code></pre>
  4575. * @param {Date} date The date
  4576. * @return {Number} The day number (0-6).
  4577. */
  4578. getFirstDayOfMonth : function(date) {
  4579. var day = (date.getDay() - (date.getDate() - 1)) % 7;
  4580. return (day < 0) ? (day + 7) : day;
  4581. },
  4582. /**
  4583. * Get the last day of the current month, adjusted for leap year. The returned value
  4584. * is the numeric day index within the week (0-6) which can be used in conjunction with
  4585. * the {@link #monthNames} array to retrieve the textual day name.
  4586. * Example:
  4587. * <pre><code>
  4588. var dt = new Date('1/10/2007'),
  4589. lastDay = Ext.Date.getLastDayOfMonth(dt);
  4590. console.log(Ext.Date.dayNames[lastDay]); //output: 'Wednesday'
  4591. * </code></pre>
  4592. * @param {Date} date The date
  4593. * @return {Number} The day number (0-6).
  4594. */
  4595. getLastDayOfMonth : function(date) {
  4596. return utilDate.getLastDateOfMonth(date).getDay();
  4597. },
  4598. /**
  4599. * Get the date of the first day of the month in which this date resides.
  4600. * @param {Date} date The date
  4601. * @return {Date}
  4602. */
  4603. getFirstDateOfMonth : function(date) {
  4604. return new Date(date.getFullYear(), date.getMonth(), 1);
  4605. },
  4606. /**
  4607. * Get the date of the last day of the month in which this date resides.
  4608. * @param {Date} date The date
  4609. * @return {Date}
  4610. */
  4611. getLastDateOfMonth : function(date) {
  4612. return new Date(date.getFullYear(), date.getMonth(), utilDate.getDaysInMonth(date));
  4613. },
  4614. /**
  4615. * Get the number of days in the current month, adjusted for leap year.
  4616. * @param {Date} date The date
  4617. * @return {Number} The number of days in the month.
  4618. * @method
  4619. */
  4620. getDaysInMonth: (function() {
  4621. var daysInMonth = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
  4622. return function(date) { // return a closure for efficiency
  4623. var m = date.getMonth();
  4624. return m == 1 && utilDate.isLeapYear(date) ? 29 : daysInMonth[m];
  4625. };
  4626. }()),
  4627. //<locale type="function">
  4628. /**
  4629. * Get the English ordinal suffix of the current day (equivalent to the format specifier 'S').
  4630. * @param {Date} date The date
  4631. * @return {String} 'st, 'nd', 'rd' or 'th'.
  4632. */
  4633. getSuffix : function(date) {
  4634. switch (date.getDate()) {
  4635. case 1:
  4636. case 21:
  4637. case 31:
  4638. return "st";
  4639. case 2:
  4640. case 22:
  4641. return "nd";
  4642. case 3:
  4643. case 23:
  4644. return "rd";
  4645. default:
  4646. return "th";
  4647. }
  4648. },
  4649. //</locale>
  4650. /**
  4651. * Creates and returns a new Date instance with the exact same date value as the called instance.
  4652. * Dates are copied and passed by reference, so if a copied date variable is modified later, the original
  4653. * variable will also be changed. When the intention is to create a new variable that will not
  4654. * modify the original instance, you should create a clone.
  4655. *
  4656. * Example of correctly cloning a date:
  4657. * <pre><code>
  4658. //wrong way:
  4659. var orig = new Date('10/1/2006');
  4660. var copy = orig;
  4661. copy.setDate(5);
  4662. console.log(orig); //returns 'Thu Oct 05 2006'!
  4663. //correct way:
  4664. var orig = new Date('10/1/2006'),
  4665. copy = Ext.Date.clone(orig);
  4666. copy.setDate(5);
  4667. console.log(orig); //returns 'Thu Oct 01 2006'
  4668. * </code></pre>
  4669. * @param {Date} date The date
  4670. * @return {Date} The new Date instance.
  4671. */
  4672. clone : function(date) {
  4673. return new Date(date.getTime());
  4674. },
  4675. /**
  4676. * Checks if the current date is affected by Daylight Saving Time (DST).
  4677. * @param {Date} date The date
  4678. * @return {Boolean} True if the current date is affected by DST.
  4679. */
  4680. isDST : function(date) {
  4681. // adapted from http://sencha.com/forum/showthread.php?p=247172#post247172
  4682. // courtesy of @geoffrey.mcgill
  4683. return new Date(date.getFullYear(), 0, 1).getTimezoneOffset() != date.getTimezoneOffset();
  4684. },
  4685. /**
  4686. * Attempts to clear all time information from this Date by setting the time to midnight of the same day,
  4687. * automatically adjusting for Daylight Saving Time (DST) where applicable.
  4688. * (note: DST timezone information for the browser's host operating system is assumed to be up-to-date)
  4689. * @param {Date} date The date
  4690. * @param {Boolean} clone true to create a clone of this date, clear the time and return it (defaults to false).
  4691. * @return {Date} this or the clone.
  4692. */
  4693. clearTime : function(date, clone) {
  4694. if (clone) {
  4695. return Ext.Date.clearTime(Ext.Date.clone(date));
  4696. }
  4697. // get current date before clearing time
  4698. var d = date.getDate(),
  4699. hr,
  4700. c;
  4701. // clear time
  4702. date.setHours(0);
  4703. date.setMinutes(0);
  4704. date.setSeconds(0);
  4705. date.setMilliseconds(0);
  4706. if (date.getDate() != d) { // account for DST (i.e. day of month changed when setting hour = 0)
  4707. // note: DST adjustments are assumed to occur in multiples of 1 hour (this is almost always the case)
  4708. // refer to http://www.timeanddate.com/time/aboutdst.html for the (rare) exceptions to this rule
  4709. // increment hour until cloned date == current date
  4710. for (hr = 1, c = utilDate.add(date, Ext.Date.HOUR, hr); c.getDate() != d; hr++, c = utilDate.add(date, Ext.Date.HOUR, hr));
  4711. date.setDate(d);
  4712. date.setHours(c.getHours());
  4713. }
  4714. return date;
  4715. },
  4716. /**
  4717. * Provides a convenient method for performing basic date arithmetic. This method
  4718. * does not modify the Date instance being called - it creates and returns
  4719. * a new Date instance containing the resulting date value.
  4720. *
  4721. * Examples:
  4722. * <pre><code>
  4723. // Basic usage:
  4724. var dt = Ext.Date.add(new Date('10/29/2006'), Ext.Date.DAY, 5);
  4725. console.log(dt); //returns 'Fri Nov 03 2006 00:00:00'
  4726. // Negative values will be subtracted:
  4727. var dt2 = Ext.Date.add(new Date('10/1/2006'), Ext.Date.DAY, -5);
  4728. console.log(dt2); //returns 'Tue Sep 26 2006 00:00:00'
  4729. * </code></pre>
  4730. *
  4731. * @param {Date} date The date to modify
  4732. * @param {String} interval A valid date interval enum value.
  4733. * @param {Number} value The amount to add to the current date.
  4734. * @return {Date} The new Date instance.
  4735. */
  4736. add : function(date, interval, value) {
  4737. var d = Ext.Date.clone(date),
  4738. Date = Ext.Date,
  4739. day;
  4740. if (!interval || value === 0) {
  4741. return d;
  4742. }
  4743. switch(interval.toLowerCase()) {
  4744. case Ext.Date.MILLI:
  4745. d.setMilliseconds(d.getMilliseconds() + value);
  4746. break;
  4747. case Ext.Date.SECOND:
  4748. d.setSeconds(d.getSeconds() + value);
  4749. break;
  4750. case Ext.Date.MINUTE:
  4751. d.setMinutes(d.getMinutes() + value);
  4752. break;
  4753. case Ext.Date.HOUR:
  4754. d.setHours(d.getHours() + value);
  4755. break;
  4756. case Ext.Date.DAY:
  4757. d.setDate(d.getDate() + value);
  4758. break;
  4759. case Ext.Date.MONTH:
  4760. day = date.getDate();
  4761. if (day > 28) {
  4762. day = Math.min(day, Ext.Date.getLastDateOfMonth(Ext.Date.add(Ext.Date.getFirstDateOfMonth(date), Ext.Date.MONTH, value)).getDate());
  4763. }
  4764. d.setDate(day);
  4765. d.setMonth(date.getMonth() + value);
  4766. break;
  4767. case Ext.Date.YEAR:
  4768. day = date.getDate();
  4769. if (day > 28) {
  4770. day = Math.min(day, Ext.Date.getLastDateOfMonth(Ext.Date.add(Ext.Date.getFirstDateOfMonth(date), Ext.Date.YEAR, value)).getDate());
  4771. }
  4772. d.setDate(day);
  4773. d.setFullYear(date.getFullYear() + value);
  4774. break;
  4775. }
  4776. return d;
  4777. },
  4778. /**
  4779. * Checks if a date falls on or between the given start and end dates.
  4780. * @param {Date} date The date to check
  4781. * @param {Date} start Start date
  4782. * @param {Date} end End date
  4783. * @return {Boolean} true if this date falls on or between the given start and end dates.
  4784. */
  4785. between : function(date, start, end) {
  4786. var t = date.getTime();
  4787. return start.getTime() <= t && t <= end.getTime();
  4788. },
  4789. //Maintains compatibility with old static and prototype window.Date methods.
  4790. compat: function() {
  4791. var nativeDate = window.Date,
  4792. p, u,
  4793. statics = ['useStrict', 'formatCodeToRegex', 'parseFunctions', 'parseRegexes', 'formatFunctions', 'y2kYear', 'MILLI', 'SECOND', 'MINUTE', 'HOUR', 'DAY', 'MONTH', 'YEAR', 'defaults', 'dayNames', 'monthNames', 'monthNumbers', 'getShortMonthName', 'getShortDayName', 'getMonthNumber', 'formatCodes', 'isValid', 'parseDate', 'getFormatCode', 'createFormat', 'createParser', 'parseCodes'],
  4794. proto = ['dateFormat', 'format', 'getTimezone', 'getGMTOffset', 'getDayOfYear', 'getWeekOfYear', 'isLeapYear', 'getFirstDayOfMonth', 'getLastDayOfMonth', 'getDaysInMonth', 'getSuffix', 'clone', 'isDST', 'clearTime', 'add', 'between'],
  4795. sLen = statics.length,
  4796. pLen = proto.length,
  4797. stat, prot, s;
  4798. //Append statics
  4799. for (s = 0; s < sLen; s++) {
  4800. stat = statics[s];
  4801. nativeDate[stat] = utilDate[stat];
  4802. }
  4803. //Append to prototype
  4804. for (p = 0; p < pLen; p++) {
  4805. prot = proto[p];
  4806. nativeDate.prototype[prot] = function() {
  4807. var args = Array.prototype.slice.call(arguments);
  4808. args.unshift(this);
  4809. return utilDate[prot].apply(utilDate, args);
  4810. };
  4811. }
  4812. }
  4813. };
  4814. var utilDate = Ext.Date;
  4815. }());
  4816. //@tag foundation,core
  4817. //@require ../lang/Date.js
  4818. /**
  4819. * @author Jacky Nguyen <jacky@sencha.com>
  4820. * @docauthor Jacky Nguyen <jacky@sencha.com>
  4821. * @class Ext.Base
  4822. *
  4823. * The root of all classes created with {@link Ext#define}.
  4824. *
  4825. * Ext.Base is the building block of all Ext classes. All classes in Ext inherit from Ext.Base.
  4826. * All prototype and static members of this class are inherited by all other classes.
  4827. */
  4828. (function(flexSetter) {
  4829. var noArgs = [],
  4830. Base = function(){};
  4831. // These static properties will be copied to every newly created class with {@link Ext#define}
  4832. Ext.apply(Base, {
  4833. $className: 'Ext.Base',
  4834. $isClass: true,
  4835. /**
  4836. * Create a new instance of this Class.
  4837. *
  4838. * Ext.define('My.cool.Class', {
  4839. * ...
  4840. * });
  4841. *
  4842. * My.cool.Class.create({
  4843. * someConfig: true
  4844. * });
  4845. *
  4846. * All parameters are passed to the constructor of the class.
  4847. *
  4848. * @return {Object} the created instance.
  4849. * @static
  4850. * @inheritable
  4851. */
  4852. create: function() {
  4853. return Ext.create.apply(Ext, [this].concat(Array.prototype.slice.call(arguments, 0)));
  4854. },
  4855. /**
  4856. * @private
  4857. * @static
  4858. * @inheritable
  4859. * @param config
  4860. */
  4861. extend: function(parent) {
  4862. var parentPrototype = parent.prototype,
  4863. basePrototype, prototype, i, ln, name, statics;
  4864. prototype = this.prototype = Ext.Object.chain(parentPrototype);
  4865. prototype.self = this;
  4866. this.superclass = prototype.superclass = parentPrototype;
  4867. if (!parent.$isClass) {
  4868. basePrototype = Ext.Base.prototype;
  4869. for (i in basePrototype) {
  4870. if (i in prototype) {
  4871. prototype[i] = basePrototype[i];
  4872. }
  4873. }
  4874. }
  4875. // Statics inheritance
  4876. statics = parentPrototype.$inheritableStatics;
  4877. if (statics) {
  4878. for (i = 0,ln = statics.length; i < ln; i++) {
  4879. name = statics[i];
  4880. if (!this.hasOwnProperty(name)) {
  4881. this[name] = parent[name];
  4882. }
  4883. }
  4884. }
  4885. if (parent.$onExtended) {
  4886. this.$onExtended = parent.$onExtended.slice();
  4887. }
  4888. prototype.config = new prototype.configClass();
  4889. prototype.initConfigList = prototype.initConfigList.slice();
  4890. prototype.initConfigMap = Ext.clone(prototype.initConfigMap);
  4891. prototype.configMap = Ext.Object.chain(prototype.configMap);
  4892. },
  4893. /**
  4894. * @private
  4895. * @static
  4896. * @inheritable
  4897. */
  4898. $onExtended: [],
  4899. /**
  4900. * @private
  4901. * @static
  4902. * @inheritable
  4903. */
  4904. triggerExtended: function() {
  4905. var callbacks = this.$onExtended,
  4906. ln = callbacks.length,
  4907. i, callback;
  4908. if (ln > 0) {
  4909. for (i = 0; i < ln; i++) {
  4910. callback = callbacks[i];
  4911. callback.fn.apply(callback.scope || this, arguments);
  4912. }
  4913. }
  4914. },
  4915. /**
  4916. * @private
  4917. * @static
  4918. * @inheritable
  4919. */
  4920. onExtended: function(fn, scope) {
  4921. this.$onExtended.push({
  4922. fn: fn,
  4923. scope: scope
  4924. });
  4925. return this;
  4926. },
  4927. /**
  4928. * @private
  4929. * @static
  4930. * @inheritable
  4931. * @param config
  4932. */
  4933. addConfig: function(config, fullMerge) {
  4934. var prototype = this.prototype,
  4935. configNameCache = Ext.Class.configNameCache,
  4936. hasConfig = prototype.configMap,
  4937. initConfigList = prototype.initConfigList,
  4938. initConfigMap = prototype.initConfigMap,
  4939. defaultConfig = prototype.config,
  4940. initializedName, name, value;
  4941. for (name in config) {
  4942. if (config.hasOwnProperty(name)) {
  4943. if (!hasConfig[name]) {
  4944. hasConfig[name] = true;
  4945. }
  4946. value = config[name];
  4947. initializedName = configNameCache[name].initialized;
  4948. if (!initConfigMap[name] && value !== null && !prototype[initializedName]) {
  4949. initConfigMap[name] = true;
  4950. initConfigList.push(name);
  4951. }
  4952. }
  4953. }
  4954. if (fullMerge) {
  4955. Ext.merge(defaultConfig, config);
  4956. }
  4957. else {
  4958. Ext.mergeIf(defaultConfig, config);
  4959. }
  4960. prototype.configClass = Ext.Object.classify(defaultConfig);
  4961. },
  4962. /**
  4963. * Add / override static properties of this class.
  4964. *
  4965. * Ext.define('My.cool.Class', {
  4966. * ...
  4967. * });
  4968. *
  4969. * My.cool.Class.addStatics({
  4970. * someProperty: 'someValue', // My.cool.Class.someProperty = 'someValue'
  4971. * method1: function() { ... }, // My.cool.Class.method1 = function() { ... };
  4972. * method2: function() { ... } // My.cool.Class.method2 = function() { ... };
  4973. * });
  4974. *
  4975. * @param {Object} members
  4976. * @return {Ext.Base} this
  4977. * @static
  4978. * @inheritable
  4979. */
  4980. addStatics: function(members) {
  4981. var member, name;
  4982. for (name in members) {
  4983. if (members.hasOwnProperty(name)) {
  4984. member = members[name];
  4985. if (typeof member == 'function' && !member.$isClass && member !== Ext.emptyFn && member !== Ext.identityFn) {
  4986. member.$owner = this;
  4987. member.$name = name;
  4988. }
  4989. this[name] = member;
  4990. }
  4991. }
  4992. return this;
  4993. },
  4994. /**
  4995. * @private
  4996. * @static
  4997. * @inheritable
  4998. * @param {Object} members
  4999. */
  5000. addInheritableStatics: function(members) {
  5001. var inheritableStatics,
  5002. hasInheritableStatics,
  5003. prototype = this.prototype,
  5004. name, member;
  5005. inheritableStatics = prototype.$inheritableStatics;
  5006. hasInheritableStatics = prototype.$hasInheritableStatics;
  5007. if (!inheritableStatics) {
  5008. inheritableStatics = prototype.$inheritableStatics = [];
  5009. hasInheritableStatics = prototype.$hasInheritableStatics = {};
  5010. }
  5011. for (name in members) {
  5012. if (members.hasOwnProperty(name)) {
  5013. member = members[name];
  5014. this[name] = member;
  5015. if (!hasInheritableStatics[name]) {
  5016. hasInheritableStatics[name] = true;
  5017. inheritableStatics.push(name);
  5018. }
  5019. }
  5020. }
  5021. return this;
  5022. },
  5023. /**
  5024. * Add methods / properties to the prototype of this class.
  5025. *
  5026. * Ext.define('My.awesome.Cat', {
  5027. * constructor: function() {
  5028. * ...
  5029. * }
  5030. * });
  5031. *
  5032. * My.awesome.Cat.addMembers({
  5033. * meow: function() {
  5034. * alert('Meowww...');
  5035. * }
  5036. * });
  5037. *
  5038. * var kitty = new My.awesome.Cat;
  5039. * kitty.meow();
  5040. *
  5041. * @param {Object} members
  5042. * @static
  5043. * @inheritable
  5044. */
  5045. addMembers: function(members) {
  5046. var prototype = this.prototype,
  5047. enumerables = Ext.enumerables,
  5048. names = [],
  5049. i, ln, name, member;
  5050. for (name in members) {
  5051. names.push(name);
  5052. }
  5053. if (enumerables) {
  5054. names.push.apply(names, enumerables);
  5055. }
  5056. for (i = 0,ln = names.length; i < ln; i++) {
  5057. name = names[i];
  5058. if (members.hasOwnProperty(name)) {
  5059. member = members[name];
  5060. if (typeof member == 'function' && !member.$isClass && member !== Ext.emptyFn) {
  5061. member.$owner = this;
  5062. member.$name = name;
  5063. }
  5064. prototype[name] = member;
  5065. }
  5066. }
  5067. return this;
  5068. },
  5069. /**
  5070. * @private
  5071. * @static
  5072. * @inheritable
  5073. * @param name
  5074. * @param member
  5075. */
  5076. addMember: function(name, member) {
  5077. if (typeof member == 'function' && !member.$isClass && member !== Ext.emptyFn) {
  5078. member.$owner = this;
  5079. member.$name = name;
  5080. }
  5081. this.prototype[name] = member;
  5082. return this;
  5083. },
  5084. /**
  5085. * Adds members to class.
  5086. * @static
  5087. * @inheritable
  5088. * @deprecated 4.1 Use {@link #addMembers} instead.
  5089. */
  5090. implement: function() {
  5091. this.addMembers.apply(this, arguments);
  5092. },
  5093. /**
  5094. * Borrow another class' members to the prototype of this class.
  5095. *
  5096. * Ext.define('Bank', {
  5097. * money: '$$$',
  5098. * printMoney: function() {
  5099. * alert('$$$$$$$');
  5100. * }
  5101. * });
  5102. *
  5103. * Ext.define('Thief', {
  5104. * ...
  5105. * });
  5106. *
  5107. * Thief.borrow(Bank, ['money', 'printMoney']);
  5108. *
  5109. * var steve = new Thief();
  5110. *
  5111. * alert(steve.money); // alerts '$$$'
  5112. * steve.printMoney(); // alerts '$$$$$$$'
  5113. *
  5114. * @param {Ext.Base} fromClass The class to borrow members from
  5115. * @param {Array/String} members The names of the members to borrow
  5116. * @return {Ext.Base} this
  5117. * @static
  5118. * @inheritable
  5119. * @private
  5120. */
  5121. borrow: function(fromClass, members) {
  5122. var prototype = this.prototype,
  5123. fromPrototype = fromClass.prototype,
  5124. i, ln, name, fn, toBorrow;
  5125. members = Ext.Array.from(members);
  5126. for (i = 0,ln = members.length; i < ln; i++) {
  5127. name = members[i];
  5128. toBorrow = fromPrototype[name];
  5129. if (typeof toBorrow == 'function') {
  5130. fn = Ext.Function.clone(toBorrow);
  5131. fn.$owner = this;
  5132. fn.$name = name;
  5133. prototype[name] = fn;
  5134. }
  5135. else {
  5136. prototype[name] = toBorrow;
  5137. }
  5138. }
  5139. return this;
  5140. },
  5141. /**
  5142. * Override members of this class. Overridden methods can be invoked via
  5143. * {@link Ext.Base#callParent}.
  5144. *
  5145. * Ext.define('My.Cat', {
  5146. * constructor: function() {
  5147. * alert("I'm a cat!");
  5148. * }
  5149. * });
  5150. *
  5151. * My.Cat.override({
  5152. * constructor: function() {
  5153. * alert("I'm going to be a cat!");
  5154. *
  5155. * this.callParent(arguments);
  5156. *
  5157. * alert("Meeeeoooowwww");
  5158. * }
  5159. * });
  5160. *
  5161. * var kitty = new My.Cat(); // alerts "I'm going to be a cat!"
  5162. * // alerts "I'm a cat!"
  5163. * // alerts "Meeeeoooowwww"
  5164. *
  5165. * As of 4.1, direct use of this method is deprecated. Use {@link Ext#define Ext.define}
  5166. * instead:
  5167. *
  5168. * Ext.define('My.CatOverride', {
  5169. * override: 'My.Cat',
  5170. * constructor: function() {
  5171. * alert("I'm going to be a cat!");
  5172. *
  5173. * this.callParent(arguments);
  5174. *
  5175. * alert("Meeeeoooowwww");
  5176. * }
  5177. * });
  5178. *
  5179. * The above accomplishes the same result but can be managed by the {@link Ext.Loader}
  5180. * which can properly order the override and its target class and the build process
  5181. * can determine whether the override is needed based on the required state of the
  5182. * target class (My.Cat).
  5183. *
  5184. * @param {Object} members The properties to add to this class. This should be
  5185. * specified as an object literal containing one or more properties.
  5186. * @return {Ext.Base} this class
  5187. * @static
  5188. * @inheritable
  5189. * @markdown
  5190. * @deprecated 4.1.0 Use {@link Ext#define Ext.define} instead
  5191. */
  5192. override: function(members) {
  5193. var me = this,
  5194. enumerables = Ext.enumerables,
  5195. target = me.prototype,
  5196. cloneFunction = Ext.Function.clone,
  5197. name, index, member, statics, names, previous;
  5198. if (arguments.length === 2) {
  5199. name = members;
  5200. members = {};
  5201. members[name] = arguments[1];
  5202. enumerables = null;
  5203. }
  5204. do {
  5205. names = []; // clean slate for prototype (1st pass) and static (2nd pass)
  5206. statics = null; // not needed 1st pass, but needs to be cleared for 2nd pass
  5207. for (name in members) { // hasOwnProperty is checked in the next loop...
  5208. if (name == 'statics') {
  5209. statics = members[name];
  5210. } else if (name == 'config') {
  5211. me.addConfig(members[name], true);
  5212. } else {
  5213. names.push(name);
  5214. }
  5215. }
  5216. if (enumerables) {
  5217. names.push.apply(names, enumerables);
  5218. }
  5219. for (index = names.length; index--; ) {
  5220. name = names[index];
  5221. if (members.hasOwnProperty(name)) {
  5222. member = members[name];
  5223. if (typeof member == 'function' && !member.$className && member !== Ext.emptyFn) {
  5224. if (typeof member.$owner != 'undefined') {
  5225. member = cloneFunction(member);
  5226. }
  5227. member.$owner = me;
  5228. member.$name = name;
  5229. previous = target[name];
  5230. if (previous) {
  5231. member.$previous = previous;
  5232. }
  5233. }
  5234. target[name] = member;
  5235. }
  5236. }
  5237. target = me; // 2nd pass is for statics
  5238. members = statics; // statics will be null on 2nd pass
  5239. } while (members);
  5240. return this;
  5241. },
  5242. // Documented downwards
  5243. callParent: function(args) {
  5244. var method;
  5245. // This code is intentionally inlined for the least number of debugger stepping
  5246. return (method = this.callParent.caller) && (method.$previous ||
  5247. ((method = method.$owner ? method : method.caller) &&
  5248. method.$owner.superclass.self[method.$name])).apply(this, args || noArgs);
  5249. },
  5250. // Documented downwards
  5251. callSuper: function(args) {
  5252. var method;
  5253. // This code is intentionally inlined for the least number of debugger stepping
  5254. return (method = this.callSuper.caller) &&
  5255. ((method = method.$owner ? method : method.caller) &&
  5256. method.$owner.superclass.self[method.$name]).apply(this, args || noArgs);
  5257. },
  5258. /**
  5259. * Used internally by the mixins pre-processor
  5260. * @private
  5261. * @static
  5262. * @inheritable
  5263. */
  5264. mixin: function(name, mixinClass) {
  5265. var mixin = mixinClass.prototype,
  5266. prototype = this.prototype,
  5267. key;
  5268. if (typeof mixin.onClassMixedIn != 'undefined') {
  5269. mixin.onClassMixedIn.call(mixinClass, this);
  5270. }
  5271. if (!prototype.hasOwnProperty('mixins')) {
  5272. if ('mixins' in prototype) {
  5273. prototype.mixins = Ext.Object.chain(prototype.mixins);
  5274. }
  5275. else {
  5276. prototype.mixins = {};
  5277. }
  5278. }
  5279. for (key in mixin) {
  5280. if (key === 'mixins') {
  5281. Ext.merge(prototype.mixins, mixin[key]);
  5282. }
  5283. else if (typeof prototype[key] == 'undefined' && key != 'mixinId' && key != 'config') {
  5284. prototype[key] = mixin[key];
  5285. }
  5286. }
  5287. if ('config' in mixin) {
  5288. this.addConfig(mixin.config, false);
  5289. }
  5290. prototype.mixins[name] = mixin;
  5291. },
  5292. /**
  5293. * Get the current class' name in string format.
  5294. *
  5295. * Ext.define('My.cool.Class', {
  5296. * constructor: function() {
  5297. * alert(this.self.getName()); // alerts 'My.cool.Class'
  5298. * }
  5299. * });
  5300. *
  5301. * My.cool.Class.getName(); // 'My.cool.Class'
  5302. *
  5303. * @return {String} className
  5304. * @static
  5305. * @inheritable
  5306. */
  5307. getName: function() {
  5308. return Ext.getClassName(this);
  5309. },
  5310. /**
  5311. * Create aliases for existing prototype methods. Example:
  5312. *
  5313. * Ext.define('My.cool.Class', {
  5314. * method1: function() { ... },
  5315. * method2: function() { ... }
  5316. * });
  5317. *
  5318. * var test = new My.cool.Class();
  5319. *
  5320. * My.cool.Class.createAlias({
  5321. * method3: 'method1',
  5322. * method4: 'method2'
  5323. * });
  5324. *
  5325. * test.method3(); // test.method1()
  5326. *
  5327. * My.cool.Class.createAlias('method5', 'method3');
  5328. *
  5329. * test.method5(); // test.method3() -> test.method1()
  5330. *
  5331. * @param {String/Object} alias The new method name, or an object to set multiple aliases. See
  5332. * {@link Ext.Function#flexSetter flexSetter}
  5333. * @param {String/Object} origin The original method name
  5334. * @static
  5335. * @inheritable
  5336. * @method
  5337. */
  5338. createAlias: flexSetter(function(alias, origin) {
  5339. this.override(alias, function() {
  5340. return this[origin].apply(this, arguments);
  5341. });
  5342. }),
  5343. /**
  5344. * @private
  5345. * @static
  5346. * @inheritable
  5347. */
  5348. addXtype: function(xtype) {
  5349. var prototype = this.prototype,
  5350. xtypesMap = prototype.xtypesMap,
  5351. xtypes = prototype.xtypes,
  5352. xtypesChain = prototype.xtypesChain;
  5353. if (!prototype.hasOwnProperty('xtypesMap')) {
  5354. xtypesMap = prototype.xtypesMap = Ext.merge({}, prototype.xtypesMap || {});
  5355. xtypes = prototype.xtypes = prototype.xtypes ? [].concat(prototype.xtypes) : [];
  5356. xtypesChain = prototype.xtypesChain = prototype.xtypesChain ? [].concat(prototype.xtypesChain) : [];
  5357. prototype.xtype = xtype;
  5358. }
  5359. if (!xtypesMap[xtype]) {
  5360. xtypesMap[xtype] = true;
  5361. xtypes.push(xtype);
  5362. xtypesChain.push(xtype);
  5363. Ext.ClassManager.setAlias(this, 'widget.' + xtype);
  5364. }
  5365. return this;
  5366. }
  5367. });
  5368. Base.implement({
  5369. /** @private */
  5370. isInstance: true,
  5371. /** @private */
  5372. $className: 'Ext.Base',
  5373. /** @private */
  5374. configClass: Ext.emptyFn,
  5375. /** @private */
  5376. initConfigList: [],
  5377. /** @private */
  5378. configMap: {},
  5379. /** @private */
  5380. initConfigMap: {},
  5381. /**
  5382. * Get the reference to the class from which this object was instantiated. Note that unlike {@link Ext.Base#self},
  5383. * `this.statics()` is scope-independent and it always returns the class from which it was called, regardless of what
  5384. * `this` points to during run-time
  5385. *
  5386. * Ext.define('My.Cat', {
  5387. * statics: {
  5388. * totalCreated: 0,
  5389. * speciesName: 'Cat' // My.Cat.speciesName = 'Cat'
  5390. * },
  5391. *
  5392. * constructor: function() {
  5393. * var statics = this.statics();
  5394. *
  5395. * alert(statics.speciesName); // always equals to 'Cat' no matter what 'this' refers to
  5396. * // equivalent to: My.Cat.speciesName
  5397. *
  5398. * alert(this.self.speciesName); // dependent on 'this'
  5399. *
  5400. * statics.totalCreated++;
  5401. * },
  5402. *
  5403. * clone: function() {
  5404. * var cloned = new this.self; // dependent on 'this'
  5405. *
  5406. * cloned.groupName = this.statics().speciesName; // equivalent to: My.Cat.speciesName
  5407. *
  5408. * return cloned;
  5409. * }
  5410. * });
  5411. *
  5412. *
  5413. * Ext.define('My.SnowLeopard', {
  5414. * extend: 'My.Cat',
  5415. *
  5416. * statics: {
  5417. * speciesName: 'Snow Leopard' // My.SnowLeopard.speciesName = 'Snow Leopard'
  5418. * },
  5419. *
  5420. * constructor: function() {
  5421. * this.callParent();
  5422. * }
  5423. * });
  5424. *
  5425. * var cat = new My.Cat(); // alerts 'Cat', then alerts 'Cat'
  5426. *
  5427. * var snowLeopard = new My.SnowLeopard(); // alerts 'Cat', then alerts 'Snow Leopard'
  5428. *
  5429. * var clone = snowLeopard.clone();
  5430. * alert(Ext.getClassName(clone)); // alerts 'My.SnowLeopard'
  5431. * alert(clone.groupName); // alerts 'Cat'
  5432. *
  5433. * alert(My.Cat.totalCreated); // alerts 3
  5434. *
  5435. * @protected
  5436. * @return {Ext.Class}
  5437. */
  5438. statics: function() {
  5439. var method = this.statics.caller,
  5440. self = this.self;
  5441. if (!method) {
  5442. return self;
  5443. }
  5444. return method.$owner;
  5445. },
  5446. /**
  5447. * Call the "parent" method of the current method. That is the method previously
  5448. * overridden by derivation or by an override (see {@link Ext#define}).
  5449. *
  5450. * Ext.define('My.Base', {
  5451. * constructor: function (x) {
  5452. * this.x = x;
  5453. * },
  5454. *
  5455. * statics: {
  5456. * method: function (x) {
  5457. * return x;
  5458. * }
  5459. * }
  5460. * });
  5461. *
  5462. * Ext.define('My.Derived', {
  5463. * extend: 'My.Base',
  5464. *
  5465. * constructor: function () {
  5466. * this.callParent([21]);
  5467. * }
  5468. * });
  5469. *
  5470. * var obj = new My.Derived();
  5471. *
  5472. * alert(obj.x); // alerts 21
  5473. *
  5474. * This can be used with an override as follows:
  5475. *
  5476. * Ext.define('My.DerivedOverride', {
  5477. * override: 'My.Derived',
  5478. *
  5479. * constructor: function (x) {
  5480. * this.callParent([x*2]); // calls original My.Derived constructor
  5481. * }
  5482. * });
  5483. *
  5484. * var obj = new My.Derived();
  5485. *
  5486. * alert(obj.x); // now alerts 42
  5487. *
  5488. * This also works with static methods.
  5489. *
  5490. * Ext.define('My.Derived2', {
  5491. * extend: 'My.Base',
  5492. *
  5493. * statics: {
  5494. * method: function (x) {
  5495. * return this.callParent([x*2]); // calls My.Base.method
  5496. * }
  5497. * }
  5498. * });
  5499. *
  5500. * alert(My.Base.method(10); // alerts 10
  5501. * alert(My.Derived2.method(10); // alerts 20
  5502. *
  5503. * Lastly, it also works with overridden static methods.
  5504. *
  5505. * Ext.define('My.Derived2Override', {
  5506. * override: 'My.Derived2',
  5507. *
  5508. * statics: {
  5509. * method: function (x) {
  5510. * return this.callParent([x*2]); // calls My.Derived2.method
  5511. * }
  5512. * }
  5513. * });
  5514. *
  5515. * alert(My.Derived2.method(10); // now alerts 40
  5516. *
  5517. * To override a method and replace it and also call the superclass method, use
  5518. * {@link #callSuper}. This is often done to patch a method to fix a bug.
  5519. *
  5520. * @protected
  5521. * @param {Array/Arguments} args The arguments, either an array or the `arguments` object
  5522. * from the current method, for example: `this.callParent(arguments)`
  5523. * @return {Object} Returns the result of calling the parent method
  5524. */
  5525. callParent: function(args) {
  5526. // NOTE: this code is deliberately as few expressions (and no function calls)
  5527. // as possible so that a debugger can skip over this noise with the minimum number
  5528. // of steps. Basically, just hit Step Into until you are where you really wanted
  5529. // to be.
  5530. var method,
  5531. superMethod = (method = this.callParent.caller) && (method.$previous ||
  5532. ((method = method.$owner ? method : method.caller) &&
  5533. method.$owner.superclass[method.$name]));
  5534. return superMethod.apply(this, args || noArgs);
  5535. },
  5536. /**
  5537. * This method is used by an override to call the superclass method but bypass any
  5538. * overridden method. This is often done to "patch" a method that contains a bug
  5539. * but for whatever reason cannot be fixed directly.
  5540. *
  5541. * Consider:
  5542. *
  5543. * Ext.define('Ext.some.Class', {
  5544. * method: function () {
  5545. * console.log('Good');
  5546. * }
  5547. * });
  5548. *
  5549. * Ext.define('Ext.some.DerivedClass', {
  5550. * method: function () {
  5551. * console.log('Bad');
  5552. *
  5553. * // ... logic but with a bug ...
  5554. *
  5555. * this.callParent();
  5556. * }
  5557. * });
  5558. *
  5559. * To patch the bug in `DerivedClass.method`, the typical solution is to create an
  5560. * override:
  5561. *
  5562. * Ext.define('App.paches.DerivedClass', {
  5563. * override: 'Ext.some.DerivedClass',
  5564. *
  5565. * method: function () {
  5566. * console.log('Fixed');
  5567. *
  5568. * // ... logic but with bug fixed ...
  5569. *
  5570. * this.callSuper();
  5571. * }
  5572. * });
  5573. *
  5574. * The patch method cannot use `callParent` to call the superclass `method` since
  5575. * that would call the overridden method containing the bug. In other words, the
  5576. * above patch would only produce "Fixed" then "Good" in the console log, whereas,
  5577. * using `callParent` would produce "Fixed" then "Bad" then "Good".
  5578. *
  5579. * @protected
  5580. * @param {Array/Arguments} args The arguments, either an array or the `arguments` object
  5581. * from the current method, for example: `this.callSuper(arguments)`
  5582. * @return {Object} Returns the result of calling the superclass method
  5583. */
  5584. callSuper: function(args) {
  5585. // NOTE: this code is deliberately as few expressions (and no function calls)
  5586. // as possible so that a debugger can skip over this noise with the minimum number
  5587. // of steps. Basically, just hit Step Into until you are where you really wanted
  5588. // to be.
  5589. var method,
  5590. superMethod = (method = this.callSuper.caller) &&
  5591. ((method = method.$owner ? method : method.caller) &&
  5592. method.$owner.superclass[method.$name]);
  5593. return superMethod.apply(this, args || noArgs);
  5594. },
  5595. /**
  5596. * @property {Ext.Class} self
  5597. *
  5598. * Get the reference to the current class from which this object was instantiated. Unlike {@link Ext.Base#statics},
  5599. * `this.self` is scope-dependent and it's meant to be used for dynamic inheritance. See {@link Ext.Base#statics}
  5600. * for a detailed comparison
  5601. *
  5602. * Ext.define('My.Cat', {
  5603. * statics: {
  5604. * speciesName: 'Cat' // My.Cat.speciesName = 'Cat'
  5605. * },
  5606. *
  5607. * constructor: function() {
  5608. * alert(this.self.speciesName); // dependent on 'this'
  5609. * },
  5610. *
  5611. * clone: function() {
  5612. * return new this.self();
  5613. * }
  5614. * });
  5615. *
  5616. *
  5617. * Ext.define('My.SnowLeopard', {
  5618. * extend: 'My.Cat',
  5619. * statics: {
  5620. * speciesName: 'Snow Leopard' // My.SnowLeopard.speciesName = 'Snow Leopard'
  5621. * }
  5622. * });
  5623. *
  5624. * var cat = new My.Cat(); // alerts 'Cat'
  5625. * var snowLeopard = new My.SnowLeopard(); // alerts 'Snow Leopard'
  5626. *
  5627. * var clone = snowLeopard.clone();
  5628. * alert(Ext.getClassName(clone)); // alerts 'My.SnowLeopard'
  5629. *
  5630. * @protected
  5631. */
  5632. self: Base,
  5633. // Default constructor, simply returns `this`
  5634. constructor: function() {
  5635. return this;
  5636. },
  5637. /**
  5638. * Initialize configuration for this class. a typical example:
  5639. *
  5640. * Ext.define('My.awesome.Class', {
  5641. * // The default config
  5642. * config: {
  5643. * name: 'Awesome',
  5644. * isAwesome: true
  5645. * },
  5646. *
  5647. * constructor: function(config) {
  5648. * this.initConfig(config);
  5649. * }
  5650. * });
  5651. *
  5652. * var awesome = new My.awesome.Class({
  5653. * name: 'Super Awesome'
  5654. * });
  5655. *
  5656. * alert(awesome.getName()); // 'Super Awesome'
  5657. *
  5658. * @protected
  5659. * @param {Object} config
  5660. * @return {Ext.Base} this
  5661. */
  5662. initConfig: function(config) {
  5663. var instanceConfig = config,
  5664. configNameCache = Ext.Class.configNameCache,
  5665. defaultConfig = new this.configClass(),
  5666. defaultConfigList = this.initConfigList,
  5667. hasConfig = this.configMap,
  5668. nameMap, i, ln, name, initializedName;
  5669. this.initConfig = Ext.emptyFn;
  5670. this.initialConfig = instanceConfig || {};
  5671. this.config = config = (instanceConfig) ? Ext.merge(defaultConfig, config) : defaultConfig;
  5672. if (instanceConfig) {
  5673. defaultConfigList = defaultConfigList.slice();
  5674. for (name in instanceConfig) {
  5675. if (hasConfig[name]) {
  5676. if (instanceConfig[name] !== null) {
  5677. defaultConfigList.push(name);
  5678. this[configNameCache[name].initialized] = false;
  5679. }
  5680. }
  5681. }
  5682. }
  5683. for (i = 0,ln = defaultConfigList.length; i < ln; i++) {
  5684. name = defaultConfigList[i];
  5685. nameMap = configNameCache[name];
  5686. initializedName = nameMap.initialized;
  5687. if (!this[initializedName]) {
  5688. this[initializedName] = true;
  5689. this[nameMap.set].call(this, config[name]);
  5690. }
  5691. }
  5692. return this;
  5693. },
  5694. /**
  5695. * @private
  5696. * @param config
  5697. */
  5698. hasConfig: function(name) {
  5699. return Boolean(this.configMap[name]);
  5700. },
  5701. /**
  5702. * @private
  5703. */
  5704. setConfig: function(config, applyIfNotSet) {
  5705. if (!config) {
  5706. return this;
  5707. }
  5708. var configNameCache = Ext.Class.configNameCache,
  5709. currentConfig = this.config,
  5710. hasConfig = this.configMap,
  5711. initialConfig = this.initialConfig,
  5712. name, value;
  5713. applyIfNotSet = Boolean(applyIfNotSet);
  5714. for (name in config) {
  5715. if (applyIfNotSet && initialConfig.hasOwnProperty(name)) {
  5716. continue;
  5717. }
  5718. value = config[name];
  5719. currentConfig[name] = value;
  5720. if (hasConfig[name]) {
  5721. this[configNameCache[name].set](value);
  5722. }
  5723. }
  5724. return this;
  5725. },
  5726. /**
  5727. * @private
  5728. * @param name
  5729. */
  5730. getConfig: function(name) {
  5731. var configNameCache = Ext.Class.configNameCache;
  5732. return this[configNameCache[name].get]();
  5733. },
  5734. /**
  5735. * Returns the initial configuration passed to constructor when instantiating
  5736. * this class.
  5737. * @param {String} [name] Name of the config option to return.
  5738. * @return {Object/Mixed} The full config object or a single config value
  5739. * when `name` parameter specified.
  5740. */
  5741. getInitialConfig: function(name) {
  5742. var config = this.config;
  5743. if (!name) {
  5744. return config;
  5745. }
  5746. else {
  5747. return config[name];
  5748. }
  5749. },
  5750. /**
  5751. * @private
  5752. * @param names
  5753. * @param callback
  5754. * @param scope
  5755. */
  5756. onConfigUpdate: function(names, callback, scope) {
  5757. var self = this.self,
  5758. i, ln, name,
  5759. updaterName, updater, newUpdater;
  5760. names = Ext.Array.from(names);
  5761. scope = scope || this;
  5762. for (i = 0,ln = names.length; i < ln; i++) {
  5763. name = names[i];
  5764. updaterName = 'update' + Ext.String.capitalize(name);
  5765. updater = this[updaterName] || Ext.emptyFn;
  5766. newUpdater = function() {
  5767. updater.apply(this, arguments);
  5768. scope[callback].apply(scope, arguments);
  5769. };
  5770. newUpdater.$name = updaterName;
  5771. newUpdater.$owner = self;
  5772. this[updaterName] = newUpdater;
  5773. }
  5774. },
  5775. /**
  5776. * @private
  5777. */
  5778. destroy: function() {
  5779. this.destroy = Ext.emptyFn;
  5780. }
  5781. });
  5782. /**
  5783. * Call the original method that was previously overridden with {@link Ext.Base#override}
  5784. *
  5785. * Ext.define('My.Cat', {
  5786. * constructor: function() {
  5787. * alert("I'm a cat!");
  5788. * }
  5789. * });
  5790. *
  5791. * My.Cat.override({
  5792. * constructor: function() {
  5793. * alert("I'm going to be a cat!");
  5794. *
  5795. * this.callOverridden();
  5796. *
  5797. * alert("Meeeeoooowwww");
  5798. * }
  5799. * });
  5800. *
  5801. * var kitty = new My.Cat(); // alerts "I'm going to be a cat!"
  5802. * // alerts "I'm a cat!"
  5803. * // alerts "Meeeeoooowwww"
  5804. *
  5805. * @param {Array/Arguments} args The arguments, either an array or the `arguments` object
  5806. * from the current method, for example: `this.callOverridden(arguments)`
  5807. * @return {Object} Returns the result of calling the overridden method
  5808. * @protected
  5809. * @deprecated as of 4.1. Use {@link #callParent} instead.
  5810. */
  5811. Base.prototype.callOverridden = Base.prototype.callParent;
  5812. Ext.Base = Base;
  5813. }(Ext.Function.flexSetter));
  5814. //@tag foundation,core
  5815. //@require Base.js
  5816. /**
  5817. * @author Jacky Nguyen <jacky@sencha.com>
  5818. * @docauthor Jacky Nguyen <jacky@sencha.com>
  5819. * @class Ext.Class
  5820. *
  5821. * Handles class creation throughout the framework. This is a low level factory that is used by Ext.ClassManager and generally
  5822. * should not be used directly. If you choose to use Ext.Class you will lose out on the namespace, aliasing and depency loading
  5823. * features made available by Ext.ClassManager. The only time you would use Ext.Class directly is to create an anonymous class.
  5824. *
  5825. * If you wish to create a class you should use {@link Ext#define Ext.define} which aliases
  5826. * {@link Ext.ClassManager#create Ext.ClassManager.create} to enable namespacing and dynamic dependency resolution.
  5827. *
  5828. * Ext.Class is the factory and **not** the superclass of everything. For the base class that **all** Ext classes inherit
  5829. * from, see {@link Ext.Base}.
  5830. */
  5831. (function() {
  5832. var ExtClass,
  5833. Base = Ext.Base,
  5834. baseStaticMembers = [],
  5835. baseStaticMember, baseStaticMemberLength;
  5836. for (baseStaticMember in Base) {
  5837. if (Base.hasOwnProperty(baseStaticMember)) {
  5838. baseStaticMembers.push(baseStaticMember);
  5839. }
  5840. }
  5841. baseStaticMemberLength = baseStaticMembers.length;
  5842. // Creates a constructor that has nothing extra in its scope chain.
  5843. function makeCtor (className) {
  5844. function constructor () {
  5845. // Opera has some problems returning from a constructor when Dragonfly isn't running. The || null seems to
  5846. // be sufficient to stop it misbehaving. Known to be required against 10.53, 11.51 and 11.61.
  5847. return this.constructor.apply(this, arguments) || null;
  5848. }
  5849. return constructor;
  5850. }
  5851. /**
  5852. * @method constructor
  5853. * Create a new anonymous class.
  5854. *
  5855. * @param {Object} data An object represent the properties of this class
  5856. * @param {Function} onCreated Optional, the callback function to be executed when this class is fully created.
  5857. * Note that the creation process can be asynchronous depending on the pre-processors used.
  5858. *
  5859. * @return {Ext.Base} The newly created class
  5860. */
  5861. Ext.Class = ExtClass = function(Class, data, onCreated) {
  5862. if (typeof Class != 'function') {
  5863. onCreated = data;
  5864. data = Class;
  5865. Class = null;
  5866. }
  5867. if (!data) {
  5868. data = {};
  5869. }
  5870. Class = ExtClass.create(Class, data);
  5871. ExtClass.process(Class, data, onCreated);
  5872. return Class;
  5873. };
  5874. Ext.apply(ExtClass, {
  5875. /**
  5876. * @private
  5877. * @param Class
  5878. * @param data
  5879. * @param hooks
  5880. */
  5881. onBeforeCreated: function(Class, data, hooks) {
  5882. Class.addMembers(data);
  5883. hooks.onCreated.call(Class, Class);
  5884. },
  5885. /**
  5886. * @private
  5887. * @param Class
  5888. * @param classData
  5889. * @param onClassCreated
  5890. */
  5891. create: function(Class, data) {
  5892. var name, i;
  5893. if (!Class) {
  5894. Class = makeCtor(
  5895. );
  5896. }
  5897. for (i = 0; i < baseStaticMemberLength; i++) {
  5898. name = baseStaticMembers[i];
  5899. Class[name] = Base[name];
  5900. }
  5901. return Class;
  5902. },
  5903. /**
  5904. * @private
  5905. * @param Class
  5906. * @param data
  5907. * @param onCreated
  5908. */
  5909. process: function(Class, data, onCreated) {
  5910. var preprocessorStack = data.preprocessors || ExtClass.defaultPreprocessors,
  5911. registeredPreprocessors = this.preprocessors,
  5912. hooks = {
  5913. onBeforeCreated: this.onBeforeCreated
  5914. },
  5915. preprocessors = [],
  5916. preprocessor, preprocessorsProperties,
  5917. i, ln, j, subLn, preprocessorProperty, process;
  5918. delete data.preprocessors;
  5919. for (i = 0,ln = preprocessorStack.length; i < ln; i++) {
  5920. preprocessor = preprocessorStack[i];
  5921. if (typeof preprocessor == 'string') {
  5922. preprocessor = registeredPreprocessors[preprocessor];
  5923. preprocessorsProperties = preprocessor.properties;
  5924. if (preprocessorsProperties === true) {
  5925. preprocessors.push(preprocessor.fn);
  5926. }
  5927. else if (preprocessorsProperties) {
  5928. for (j = 0,subLn = preprocessorsProperties.length; j < subLn; j++) {
  5929. preprocessorProperty = preprocessorsProperties[j];
  5930. if (data.hasOwnProperty(preprocessorProperty)) {
  5931. preprocessors.push(preprocessor.fn);
  5932. break;
  5933. }
  5934. }
  5935. }
  5936. }
  5937. else {
  5938. preprocessors.push(preprocessor);
  5939. }
  5940. }
  5941. hooks.onCreated = onCreated ? onCreated : Ext.emptyFn;
  5942. hooks.preprocessors = preprocessors;
  5943. this.doProcess(Class, data, hooks);
  5944. },
  5945. doProcess: function(Class, data, hooks){
  5946. var me = this,
  5947. preprocessor = hooks.preprocessors.shift();
  5948. if (!preprocessor) {
  5949. hooks.onBeforeCreated.apply(me, arguments);
  5950. return;
  5951. }
  5952. if (preprocessor.call(me, Class, data, hooks, me.doProcess) !== false) {
  5953. me.doProcess(Class, data, hooks);
  5954. }
  5955. },
  5956. /** @private */
  5957. preprocessors: {},
  5958. /**
  5959. * Register a new pre-processor to be used during the class creation process
  5960. *
  5961. * @param {String} name The pre-processor's name
  5962. * @param {Function} fn The callback function to be executed. Typical format:
  5963. *
  5964. * function(cls, data, fn) {
  5965. * // Your code here
  5966. *
  5967. * // Execute this when the processing is finished.
  5968. * // Asynchronous processing is perfectly ok
  5969. * if (fn) {
  5970. * fn.call(this, cls, data);
  5971. * }
  5972. * });
  5973. *
  5974. * @param {Function} fn.cls The created class
  5975. * @param {Object} fn.data The set of properties passed in {@link Ext.Class} constructor
  5976. * @param {Function} fn.fn The callback function that **must** to be executed when this
  5977. * pre-processor finishes, regardless of whether the processing is synchronous or aynchronous.
  5978. * @return {Ext.Class} this
  5979. * @private
  5980. * @static
  5981. */
  5982. registerPreprocessor: function(name, fn, properties, position, relativeTo) {
  5983. if (!position) {
  5984. position = 'last';
  5985. }
  5986. if (!properties) {
  5987. properties = [name];
  5988. }
  5989. this.preprocessors[name] = {
  5990. name: name,
  5991. properties: properties || false,
  5992. fn: fn
  5993. };
  5994. this.setDefaultPreprocessorPosition(name, position, relativeTo);
  5995. return this;
  5996. },
  5997. /**
  5998. * Retrieve a pre-processor callback function by its name, which has been registered before
  5999. *
  6000. * @param {String} name
  6001. * @return {Function} preprocessor
  6002. * @private
  6003. * @static
  6004. */
  6005. getPreprocessor: function(name) {
  6006. return this.preprocessors[name];
  6007. },
  6008. /**
  6009. * @private
  6010. */
  6011. getPreprocessors: function() {
  6012. return this.preprocessors;
  6013. },
  6014. /**
  6015. * @private
  6016. */
  6017. defaultPreprocessors: [],
  6018. /**
  6019. * Retrieve the array stack of default pre-processors
  6020. * @return {Function[]} defaultPreprocessors
  6021. * @private
  6022. * @static
  6023. */
  6024. getDefaultPreprocessors: function() {
  6025. return this.defaultPreprocessors;
  6026. },
  6027. /**
  6028. * Set the default array stack of default pre-processors
  6029. *
  6030. * @private
  6031. * @param {Array} preprocessors
  6032. * @return {Ext.Class} this
  6033. * @static
  6034. */
  6035. setDefaultPreprocessors: function(preprocessors) {
  6036. this.defaultPreprocessors = Ext.Array.from(preprocessors);
  6037. return this;
  6038. },
  6039. /**
  6040. * Insert this pre-processor at a specific position in the stack, optionally relative to
  6041. * any existing pre-processor. For example:
  6042. *
  6043. * Ext.Class.registerPreprocessor('debug', function(cls, data, fn) {
  6044. * // Your code here
  6045. *
  6046. * if (fn) {
  6047. * fn.call(this, cls, data);
  6048. * }
  6049. * }).setDefaultPreprocessorPosition('debug', 'last');
  6050. *
  6051. * @private
  6052. * @param {String} name The pre-processor name. Note that it needs to be registered with
  6053. * {@link Ext.Class#registerPreprocessor registerPreprocessor} before this
  6054. * @param {String} offset The insertion position. Four possible values are:
  6055. * 'first', 'last', or: 'before', 'after' (relative to the name provided in the third argument)
  6056. * @param {String} relativeName
  6057. * @return {Ext.Class} this
  6058. * @static
  6059. */
  6060. setDefaultPreprocessorPosition: function(name, offset, relativeName) {
  6061. var defaultPreprocessors = this.defaultPreprocessors,
  6062. index;
  6063. if (typeof offset == 'string') {
  6064. if (offset === 'first') {
  6065. defaultPreprocessors.unshift(name);
  6066. return this;
  6067. }
  6068. else if (offset === 'last') {
  6069. defaultPreprocessors.push(name);
  6070. return this;
  6071. }
  6072. offset = (offset === 'after') ? 1 : -1;
  6073. }
  6074. index = Ext.Array.indexOf(defaultPreprocessors, relativeName);
  6075. if (index !== -1) {
  6076. Ext.Array.splice(defaultPreprocessors, Math.max(0, index + offset), 0, name);
  6077. }
  6078. return this;
  6079. },
  6080. configNameCache: {},
  6081. getConfigNameMap: function(name) {
  6082. var cache = this.configNameCache,
  6083. map = cache[name],
  6084. capitalizedName;
  6085. if (!map) {
  6086. capitalizedName = name.charAt(0).toUpperCase() + name.substr(1);
  6087. map = cache[name] = {
  6088. internal: name,
  6089. initialized: '_is' + capitalizedName + 'Initialized',
  6090. apply: 'apply' + capitalizedName,
  6091. update: 'update' + capitalizedName,
  6092. 'set': 'set' + capitalizedName,
  6093. 'get': 'get' + capitalizedName,
  6094. doSet : 'doSet' + capitalizedName,
  6095. changeEvent: name.toLowerCase() + 'change'
  6096. };
  6097. }
  6098. return map;
  6099. }
  6100. });
  6101. /**
  6102. * @cfg {String} extend
  6103. * The parent class that this class extends. For example:
  6104. *
  6105. * Ext.define('Person', {
  6106. * say: function(text) { alert(text); }
  6107. * });
  6108. *
  6109. * Ext.define('Developer', {
  6110. * extend: 'Person',
  6111. * say: function(text) { this.callParent(["print "+text]); }
  6112. * });
  6113. */
  6114. ExtClass.registerPreprocessor('extend', function(Class, data) {
  6115. var Base = Ext.Base,
  6116. basePrototype = Base.prototype,
  6117. extend = data.extend,
  6118. Parent, parentPrototype, i;
  6119. delete data.extend;
  6120. if (extend && extend !== Object) {
  6121. Parent = extend;
  6122. }
  6123. else {
  6124. Parent = Base;
  6125. }
  6126. parentPrototype = Parent.prototype;
  6127. if (!Parent.$isClass) {
  6128. for (i in basePrototype) {
  6129. if (!parentPrototype[i]) {
  6130. parentPrototype[i] = basePrototype[i];
  6131. }
  6132. }
  6133. }
  6134. Class.extend(Parent);
  6135. Class.triggerExtended.apply(Class, arguments);
  6136. if (data.onClassExtended) {
  6137. Class.onExtended(data.onClassExtended, Class);
  6138. delete data.onClassExtended;
  6139. }
  6140. }, true);
  6141. /**
  6142. * @cfg {Object} statics
  6143. * List of static methods for this class. For example:
  6144. *
  6145. * Ext.define('Computer', {
  6146. * statics: {
  6147. * factory: function(brand) {
  6148. * // 'this' in static methods refer to the class itself
  6149. * return new this(brand);
  6150. * }
  6151. * },
  6152. *
  6153. * constructor: function() { ... }
  6154. * });
  6155. *
  6156. * var dellComputer = Computer.factory('Dell');
  6157. */
  6158. ExtClass.registerPreprocessor('statics', function(Class, data) {
  6159. Class.addStatics(data.statics);
  6160. delete data.statics;
  6161. });
  6162. /**
  6163. * @cfg {Object} inheritableStatics
  6164. * List of inheritable static methods for this class.
  6165. * Otherwise just like {@link #statics} but subclasses inherit these methods.
  6166. */
  6167. ExtClass.registerPreprocessor('inheritableStatics', function(Class, data) {
  6168. Class.addInheritableStatics(data.inheritableStatics);
  6169. delete data.inheritableStatics;
  6170. });
  6171. /**
  6172. * @cfg {Object} config
  6173. * List of configuration options with their default values, for which automatically
  6174. * accessor methods are generated. For example:
  6175. *
  6176. * Ext.define('SmartPhone', {
  6177. * config: {
  6178. * hasTouchScreen: false,
  6179. * operatingSystem: 'Other',
  6180. * price: 500
  6181. * },
  6182. * constructor: function(cfg) {
  6183. * this.initConfig(cfg);
  6184. * }
  6185. * });
  6186. *
  6187. * var iPhone = new SmartPhone({
  6188. * hasTouchScreen: true,
  6189. * operatingSystem: 'iOS'
  6190. * });
  6191. *
  6192. * iPhone.getPrice(); // 500;
  6193. * iPhone.getOperatingSystem(); // 'iOS'
  6194. * iPhone.getHasTouchScreen(); // true;
  6195. */
  6196. ExtClass.registerPreprocessor('config', function(Class, data) {
  6197. var config = data.config,
  6198. prototype = Class.prototype;
  6199. delete data.config;
  6200. Ext.Object.each(config, function(name, value) {
  6201. var nameMap = ExtClass.getConfigNameMap(name),
  6202. internalName = nameMap.internal,
  6203. initializedName = nameMap.initialized,
  6204. applyName = nameMap.apply,
  6205. updateName = nameMap.update,
  6206. setName = nameMap.set,
  6207. getName = nameMap.get,
  6208. hasOwnSetter = (setName in prototype) || data.hasOwnProperty(setName),
  6209. hasOwnApplier = (applyName in prototype) || data.hasOwnProperty(applyName),
  6210. hasOwnUpdater = (updateName in prototype) || data.hasOwnProperty(updateName),
  6211. optimizedGetter, customGetter;
  6212. if (value === null || (!hasOwnSetter && !hasOwnApplier && !hasOwnUpdater)) {
  6213. prototype[internalName] = value;
  6214. prototype[initializedName] = true;
  6215. }
  6216. else {
  6217. prototype[initializedName] = false;
  6218. }
  6219. if (!hasOwnSetter) {
  6220. data[setName] = function(value) {
  6221. var oldValue = this[internalName],
  6222. applier = this[applyName],
  6223. updater = this[updateName];
  6224. if (!this[initializedName]) {
  6225. this[initializedName] = true;
  6226. }
  6227. if (applier) {
  6228. value = applier.call(this, value, oldValue);
  6229. }
  6230. if (typeof value != 'undefined') {
  6231. this[internalName] = value;
  6232. if (updater && value !== oldValue) {
  6233. updater.call(this, value, oldValue);
  6234. }
  6235. }
  6236. return this;
  6237. };
  6238. }
  6239. if (!(getName in prototype) || data.hasOwnProperty(getName)) {
  6240. customGetter = data[getName] || false;
  6241. if (customGetter) {
  6242. optimizedGetter = function() {
  6243. return customGetter.apply(this, arguments);
  6244. };
  6245. }
  6246. else {
  6247. optimizedGetter = function() {
  6248. return this[internalName];
  6249. };
  6250. }
  6251. data[getName] = function() {
  6252. var currentGetter;
  6253. if (!this[initializedName]) {
  6254. this[initializedName] = true;
  6255. this[setName](this.config[name]);
  6256. }
  6257. currentGetter = this[getName];
  6258. if ('$previous' in currentGetter) {
  6259. currentGetter.$previous = optimizedGetter;
  6260. }
  6261. else {
  6262. this[getName] = optimizedGetter;
  6263. }
  6264. return optimizedGetter.apply(this, arguments);
  6265. };
  6266. }
  6267. });
  6268. Class.addConfig(config, true);
  6269. });
  6270. /**
  6271. * @cfg {String[]/Object} mixins
  6272. * List of classes to mix into this class. For example:
  6273. *
  6274. * Ext.define('CanSing', {
  6275. * sing: function() {
  6276. * alert("I'm on the highway to hell...")
  6277. * }
  6278. * });
  6279. *
  6280. * Ext.define('Musician', {
  6281. * mixins: ['CanSing']
  6282. * })
  6283. *
  6284. * In this case the Musician class will get a `sing` method from CanSing mixin.
  6285. *
  6286. * But what if the Musician already has a `sing` method? Or you want to mix
  6287. * in two classes, both of which define `sing`? In such a cases it's good
  6288. * to define mixins as an object, where you assign a name to each mixin:
  6289. *
  6290. * Ext.define('Musician', {
  6291. * mixins: {
  6292. * canSing: 'CanSing'
  6293. * },
  6294. *
  6295. * sing: function() {
  6296. * // delegate singing operation to mixin
  6297. * this.mixins.canSing.sing.call(this);
  6298. * }
  6299. * })
  6300. *
  6301. * In this case the `sing` method of Musician will overwrite the
  6302. * mixed in `sing` method. But you can access the original mixed in method
  6303. * through special `mixins` property.
  6304. */
  6305. ExtClass.registerPreprocessor('mixins', function(Class, data, hooks) {
  6306. var mixins = data.mixins,
  6307. name, mixin, i, ln;
  6308. delete data.mixins;
  6309. Ext.Function.interceptBefore(hooks, 'onCreated', function() {
  6310. if (mixins instanceof Array) {
  6311. for (i = 0,ln = mixins.length; i < ln; i++) {
  6312. mixin = mixins[i];
  6313. name = mixin.prototype.mixinId || mixin.$className;
  6314. Class.mixin(name, mixin);
  6315. }
  6316. }
  6317. else {
  6318. for (var mixinName in mixins) {
  6319. if (mixins.hasOwnProperty(mixinName)) {
  6320. Class.mixin(mixinName, mixins[mixinName]);
  6321. }
  6322. }
  6323. }
  6324. });
  6325. });
  6326. // Backwards compatible
  6327. Ext.extend = function(Class, Parent, members) {
  6328. if (arguments.length === 2 && Ext.isObject(Parent)) {
  6329. members = Parent;
  6330. Parent = Class;
  6331. Class = null;
  6332. }
  6333. var cls;
  6334. if (!Parent) {
  6335. throw new Error("[Ext.extend] Attempting to extend from a class which has not been loaded on the page.");
  6336. }
  6337. members.extend = Parent;
  6338. members.preprocessors = [
  6339. 'extend'
  6340. ,'statics'
  6341. ,'inheritableStatics'
  6342. ,'mixins'
  6343. ,'config'
  6344. ];
  6345. if (Class) {
  6346. cls = new ExtClass(Class, members);
  6347. // The 'constructor' is given as 'Class' but also needs to be on prototype
  6348. cls.prototype.constructor = Class;
  6349. } else {
  6350. cls = new ExtClass(members);
  6351. }
  6352. cls.prototype.override = function(o) {
  6353. for (var m in o) {
  6354. if (o.hasOwnProperty(m)) {
  6355. this[m] = o[m];
  6356. }
  6357. }
  6358. };
  6359. return cls;
  6360. };
  6361. }());
  6362. //@tag foundation,core
  6363. //@require Class.js
  6364. /**
  6365. * @author Jacky Nguyen <jacky@sencha.com>
  6366. * @docauthor Jacky Nguyen <jacky@sencha.com>
  6367. * @class Ext.ClassManager
  6368. *
  6369. * Ext.ClassManager manages all classes and handles mapping from string class name to
  6370. * actual class objects throughout the whole framework. It is not generally accessed directly, rather through
  6371. * these convenient shorthands:
  6372. *
  6373. * - {@link Ext#define Ext.define}
  6374. * - {@link Ext#create Ext.create}
  6375. * - {@link Ext#widget Ext.widget}
  6376. * - {@link Ext#getClass Ext.getClass}
  6377. * - {@link Ext#getClassName Ext.getClassName}
  6378. *
  6379. * # Basic syntax:
  6380. *
  6381. * Ext.define(className, properties);
  6382. *
  6383. * in which `properties` is an object represent a collection of properties that apply to the class. See
  6384. * {@link Ext.ClassManager#create} for more detailed instructions.
  6385. *
  6386. * Ext.define('Person', {
  6387. * name: 'Unknown',
  6388. *
  6389. * constructor: function(name) {
  6390. * if (name) {
  6391. * this.name = name;
  6392. * }
  6393. * },
  6394. *
  6395. * eat: function(foodType) {
  6396. * alert("I'm eating: " + foodType);
  6397. *
  6398. * return this;
  6399. * }
  6400. * });
  6401. *
  6402. * var aaron = new Person("Aaron");
  6403. * aaron.eat("Sandwich"); // alert("I'm eating: Sandwich");
  6404. *
  6405. * Ext.Class has a powerful set of extensible {@link Ext.Class#registerPreprocessor pre-processors} which takes care of
  6406. * everything related to class creation, including but not limited to inheritance, mixins, configuration, statics, etc.
  6407. *
  6408. * # Inheritance:
  6409. *
  6410. * Ext.define('Developer', {
  6411. * extend: 'Person',
  6412. *
  6413. * constructor: function(name, isGeek) {
  6414. * this.isGeek = isGeek;
  6415. *
  6416. * // Apply a method from the parent class' prototype
  6417. * this.callParent([name]);
  6418. * },
  6419. *
  6420. * code: function(language) {
  6421. * alert("I'm coding in: " + language);
  6422. *
  6423. * this.eat("Bugs");
  6424. *
  6425. * return this;
  6426. * }
  6427. * });
  6428. *
  6429. * var jacky = new Developer("Jacky", true);
  6430. * jacky.code("JavaScript"); // alert("I'm coding in: JavaScript");
  6431. * // alert("I'm eating: Bugs");
  6432. *
  6433. * See {@link Ext.Base#callParent} for more details on calling superclass' methods
  6434. *
  6435. * # Mixins:
  6436. *
  6437. * Ext.define('CanPlayGuitar', {
  6438. * playGuitar: function() {
  6439. * alert("F#...G...D...A");
  6440. * }
  6441. * });
  6442. *
  6443. * Ext.define('CanComposeSongs', {
  6444. * composeSongs: function() { ... }
  6445. * });
  6446. *
  6447. * Ext.define('CanSing', {
  6448. * sing: function() {
  6449. * alert("I'm on the highway to hell...")
  6450. * }
  6451. * });
  6452. *
  6453. * Ext.define('Musician', {
  6454. * extend: 'Person',
  6455. *
  6456. * mixins: {
  6457. * canPlayGuitar: 'CanPlayGuitar',
  6458. * canComposeSongs: 'CanComposeSongs',
  6459. * canSing: 'CanSing'
  6460. * }
  6461. * })
  6462. *
  6463. * Ext.define('CoolPerson', {
  6464. * extend: 'Person',
  6465. *
  6466. * mixins: {
  6467. * canPlayGuitar: 'CanPlayGuitar',
  6468. * canSing: 'CanSing'
  6469. * },
  6470. *
  6471. * sing: function() {
  6472. * alert("Ahem....");
  6473. *
  6474. * this.mixins.canSing.sing.call(this);
  6475. *
  6476. * alert("[Playing guitar at the same time...]");
  6477. *
  6478. * this.playGuitar();
  6479. * }
  6480. * });
  6481. *
  6482. * var me = new CoolPerson("Jacky");
  6483. *
  6484. * me.sing(); // alert("Ahem...");
  6485. * // alert("I'm on the highway to hell...");
  6486. * // alert("[Playing guitar at the same time...]");
  6487. * // alert("F#...G...D...A");
  6488. *
  6489. * # Config:
  6490. *
  6491. * Ext.define('SmartPhone', {
  6492. * config: {
  6493. * hasTouchScreen: false,
  6494. * operatingSystem: 'Other',
  6495. * price: 500
  6496. * },
  6497. *
  6498. * isExpensive: false,
  6499. *
  6500. * constructor: function(config) {
  6501. * this.initConfig(config);
  6502. * },
  6503. *
  6504. * applyPrice: function(price) {
  6505. * this.isExpensive = (price > 500);
  6506. *
  6507. * return price;
  6508. * },
  6509. *
  6510. * applyOperatingSystem: function(operatingSystem) {
  6511. * if (!(/^(iOS|Android|BlackBerry)$/i).test(operatingSystem)) {
  6512. * return 'Other';
  6513. * }
  6514. *
  6515. * return operatingSystem;
  6516. * }
  6517. * });
  6518. *
  6519. * var iPhone = new SmartPhone({
  6520. * hasTouchScreen: true,
  6521. * operatingSystem: 'iOS'
  6522. * });
  6523. *
  6524. * iPhone.getPrice(); // 500;
  6525. * iPhone.getOperatingSystem(); // 'iOS'
  6526. * iPhone.getHasTouchScreen(); // true;
  6527. * iPhone.hasTouchScreen(); // true
  6528. *
  6529. * iPhone.isExpensive; // false;
  6530. * iPhone.setPrice(600);
  6531. * iPhone.getPrice(); // 600
  6532. * iPhone.isExpensive; // true;
  6533. *
  6534. * iPhone.setOperatingSystem('AlienOS');
  6535. * iPhone.getOperatingSystem(); // 'Other'
  6536. *
  6537. * # Statics:
  6538. *
  6539. * Ext.define('Computer', {
  6540. * statics: {
  6541. * factory: function(brand) {
  6542. * // 'this' in static methods refer to the class itself
  6543. * return new this(brand);
  6544. * }
  6545. * },
  6546. *
  6547. * constructor: function() { ... }
  6548. * });
  6549. *
  6550. * var dellComputer = Computer.factory('Dell');
  6551. *
  6552. * Also see {@link Ext.Base#statics} and {@link Ext.Base#self} for more details on accessing
  6553. * static properties within class methods
  6554. *
  6555. * @singleton
  6556. */
  6557. (function(Class, alias, arraySlice, arrayFrom, global) {
  6558. // Creates a constructor that has nothing extra in its scope chain.
  6559. function makeCtor () {
  6560. function constructor () {
  6561. // Opera has some problems returning from a constructor when Dragonfly isn't running. The || null seems to
  6562. // be sufficient to stop it misbehaving. Known to be required against 10.53, 11.51 and 11.61.
  6563. return this.constructor.apply(this, arguments) || null;
  6564. }
  6565. return constructor;
  6566. }
  6567. var Manager = Ext.ClassManager = {
  6568. /**
  6569. * @property {Object} classes
  6570. * All classes which were defined through the ClassManager. Keys are the
  6571. * name of the classes and the values are references to the classes.
  6572. * @private
  6573. */
  6574. classes: {},
  6575. /**
  6576. * @private
  6577. */
  6578. existCache: {},
  6579. /**
  6580. * @private
  6581. */
  6582. namespaceRewrites: [{
  6583. from: 'Ext.',
  6584. to: Ext
  6585. }],
  6586. /**
  6587. * @private
  6588. */
  6589. maps: {
  6590. alternateToName: {},
  6591. aliasToName: {},
  6592. nameToAliases: {},
  6593. nameToAlternates: {}
  6594. },
  6595. /** @private */
  6596. enableNamespaceParseCache: true,
  6597. /** @private */
  6598. namespaceParseCache: {},
  6599. /** @private */
  6600. instantiators: [],
  6601. /**
  6602. * Checks if a class has already been created.
  6603. *
  6604. * @param {String} className
  6605. * @return {Boolean} exist
  6606. */
  6607. isCreated: function(className) {
  6608. var existCache = this.existCache,
  6609. i, ln, part, root, parts;
  6610. if (this.classes[className] || existCache[className]) {
  6611. return true;
  6612. }
  6613. root = global;
  6614. parts = this.parseNamespace(className);
  6615. for (i = 0, ln = parts.length; i < ln; i++) {
  6616. part = parts[i];
  6617. if (typeof part != 'string') {
  6618. root = part;
  6619. } else {
  6620. if (!root || !root[part]) {
  6621. return false;
  6622. }
  6623. root = root[part];
  6624. }
  6625. }
  6626. existCache[className] = true;
  6627. this.triggerCreated(className);
  6628. return true;
  6629. },
  6630. /**
  6631. * @private
  6632. */
  6633. createdListeners: [],
  6634. /**
  6635. * @private
  6636. */
  6637. nameCreatedListeners: {},
  6638. /**
  6639. * @private
  6640. */
  6641. triggerCreated: function(className) {
  6642. var listeners = this.createdListeners,
  6643. nameListeners = this.nameCreatedListeners,
  6644. alternateNames = this.maps.nameToAlternates[className],
  6645. names = [className],
  6646. i, ln, j, subLn, listener, name;
  6647. for (i = 0,ln = listeners.length; i < ln; i++) {
  6648. listener = listeners[i];
  6649. listener.fn.call(listener.scope, className);
  6650. }
  6651. if (alternateNames) {
  6652. names.push.apply(names, alternateNames);
  6653. }
  6654. for (i = 0,ln = names.length; i < ln; i++) {
  6655. name = names[i];
  6656. listeners = nameListeners[name];
  6657. if (listeners) {
  6658. for (j = 0,subLn = listeners.length; j < subLn; j++) {
  6659. listener = listeners[j];
  6660. listener.fn.call(listener.scope, name);
  6661. }
  6662. delete nameListeners[name];
  6663. }
  6664. }
  6665. },
  6666. /**
  6667. * @private
  6668. */
  6669. onCreated: function(fn, scope, className) {
  6670. var listeners = this.createdListeners,
  6671. nameListeners = this.nameCreatedListeners,
  6672. listener = {
  6673. fn: fn,
  6674. scope: scope
  6675. };
  6676. if (className) {
  6677. if (this.isCreated(className)) {
  6678. fn.call(scope, className);
  6679. return;
  6680. }
  6681. if (!nameListeners[className]) {
  6682. nameListeners[className] = [];
  6683. }
  6684. nameListeners[className].push(listener);
  6685. }
  6686. else {
  6687. listeners.push(listener);
  6688. }
  6689. },
  6690. /**
  6691. * Supports namespace rewriting
  6692. * @private
  6693. */
  6694. parseNamespace: function(namespace) {
  6695. var cache = this.namespaceParseCache,
  6696. parts,
  6697. rewrites,
  6698. root,
  6699. name,
  6700. rewrite, from, to, i, ln;
  6701. if (this.enableNamespaceParseCache) {
  6702. if (cache.hasOwnProperty(namespace)) {
  6703. return cache[namespace];
  6704. }
  6705. }
  6706. parts = [];
  6707. rewrites = this.namespaceRewrites;
  6708. root = global;
  6709. name = namespace;
  6710. for (i = 0, ln = rewrites.length; i < ln; i++) {
  6711. rewrite = rewrites[i];
  6712. from = rewrite.from;
  6713. to = rewrite.to;
  6714. if (name === from || name.substring(0, from.length) === from) {
  6715. name = name.substring(from.length);
  6716. if (typeof to != 'string') {
  6717. root = to;
  6718. } else {
  6719. parts = parts.concat(to.split('.'));
  6720. }
  6721. break;
  6722. }
  6723. }
  6724. parts.push(root);
  6725. parts = parts.concat(name.split('.'));
  6726. if (this.enableNamespaceParseCache) {
  6727. cache[namespace] = parts;
  6728. }
  6729. return parts;
  6730. },
  6731. /**
  6732. * Creates a namespace and assign the `value` to the created object
  6733. *
  6734. * Ext.ClassManager.setNamespace('MyCompany.pkg.Example', someObject);
  6735. *
  6736. * alert(MyCompany.pkg.Example === someObject); // alerts true
  6737. *
  6738. * @param {String} name
  6739. * @param {Object} value
  6740. */
  6741. setNamespace: function(name, value) {
  6742. var root = global,
  6743. parts = this.parseNamespace(name),
  6744. ln = parts.length - 1,
  6745. leaf = parts[ln],
  6746. i, part;
  6747. for (i = 0; i < ln; i++) {
  6748. part = parts[i];
  6749. if (typeof part != 'string') {
  6750. root = part;
  6751. } else {
  6752. if (!root[part]) {
  6753. root[part] = {};
  6754. }
  6755. root = root[part];
  6756. }
  6757. }
  6758. root[leaf] = value;
  6759. return root[leaf];
  6760. },
  6761. /**
  6762. * The new Ext.ns, supports namespace rewriting
  6763. * @private
  6764. */
  6765. createNamespaces: function() {
  6766. var root = global,
  6767. parts, part, i, j, ln, subLn;
  6768. for (i = 0, ln = arguments.length; i < ln; i++) {
  6769. parts = this.parseNamespace(arguments[i]);
  6770. for (j = 0, subLn = parts.length; j < subLn; j++) {
  6771. part = parts[j];
  6772. if (typeof part != 'string') {
  6773. root = part;
  6774. } else {
  6775. if (!root[part]) {
  6776. root[part] = {};
  6777. }
  6778. root = root[part];
  6779. }
  6780. }
  6781. }
  6782. return root;
  6783. },
  6784. /**
  6785. * Sets a name reference to a class.
  6786. *
  6787. * @param {String} name
  6788. * @param {Object} value
  6789. * @return {Ext.ClassManager} this
  6790. */
  6791. set: function(name, value) {
  6792. var me = this,
  6793. maps = me.maps,
  6794. nameToAlternates = maps.nameToAlternates,
  6795. targetName = me.getName(value),
  6796. alternates;
  6797. me.classes[name] = me.setNamespace(name, value);
  6798. if (targetName && targetName !== name) {
  6799. maps.alternateToName[name] = targetName;
  6800. alternates = nameToAlternates[targetName] || (nameToAlternates[targetName] = []);
  6801. alternates.push(name);
  6802. }
  6803. return this;
  6804. },
  6805. /**
  6806. * Retrieve a class by its name.
  6807. *
  6808. * @param {String} name
  6809. * @return {Ext.Class} class
  6810. */
  6811. get: function(name) {
  6812. var classes = this.classes,
  6813. root,
  6814. parts,
  6815. part, i, ln;
  6816. if (classes[name]) {
  6817. return classes[name];
  6818. }
  6819. root = global;
  6820. parts = this.parseNamespace(name);
  6821. for (i = 0, ln = parts.length; i < ln; i++) {
  6822. part = parts[i];
  6823. if (typeof part != 'string') {
  6824. root = part;
  6825. } else {
  6826. if (!root || !root[part]) {
  6827. return null;
  6828. }
  6829. root = root[part];
  6830. }
  6831. }
  6832. return root;
  6833. },
  6834. /**
  6835. * Register the alias for a class.
  6836. *
  6837. * @param {Ext.Class/String} cls a reference to a class or a className
  6838. * @param {String} alias Alias to use when referring to this class
  6839. */
  6840. setAlias: function(cls, alias) {
  6841. var aliasToNameMap = this.maps.aliasToName,
  6842. nameToAliasesMap = this.maps.nameToAliases,
  6843. className;
  6844. if (typeof cls == 'string') {
  6845. className = cls;
  6846. } else {
  6847. className = this.getName(cls);
  6848. }
  6849. if (alias && aliasToNameMap[alias] !== className) {
  6850. aliasToNameMap[alias] = className;
  6851. }
  6852. if (!nameToAliasesMap[className]) {
  6853. nameToAliasesMap[className] = [];
  6854. }
  6855. if (alias) {
  6856. Ext.Array.include(nameToAliasesMap[className], alias);
  6857. }
  6858. return this;
  6859. },
  6860. /**
  6861. * Adds a batch of class name to alias mappings
  6862. * @param {Object} aliases The set of mappings of the form
  6863. * className : [values...]
  6864. */
  6865. addNameAliasMappings: function(aliases){
  6866. var aliasToNameMap = this.maps.aliasToName,
  6867. nameToAliasesMap = this.maps.nameToAliases,
  6868. className, aliasList, alias, i;
  6869. for (className in aliases) {
  6870. aliasList = nameToAliasesMap[className] ||
  6871. (nameToAliasesMap[className] = []);
  6872. for (i = 0; i < aliases[className].length; i++) {
  6873. alias = aliases[className][i];
  6874. if (!aliasToNameMap[alias]) {
  6875. aliasToNameMap[alias] = className;
  6876. aliasList.push(alias);
  6877. }
  6878. }
  6879. }
  6880. return this;
  6881. },
  6882. /**
  6883. *
  6884. * @param {Object} alternates The set of mappings of the form
  6885. * className : [values...]
  6886. */
  6887. addNameAlternateMappings: function(alternates) {
  6888. var alternateToName = this.maps.alternateToName,
  6889. nameToAlternates = this.maps.nameToAlternates,
  6890. className, aliasList, alternate, i;
  6891. for (className in alternates) {
  6892. aliasList = nameToAlternates[className] ||
  6893. (nameToAlternates[className] = []);
  6894. for (i = 0; i < alternates[className].length; i++) {
  6895. alternate = alternates[className];
  6896. if (!alternateToName[alternate]) {
  6897. alternateToName[alternate] = className;
  6898. aliasList.push(alternate);
  6899. }
  6900. }
  6901. }
  6902. return this;
  6903. },
  6904. /**
  6905. * Get a reference to the class by its alias.
  6906. *
  6907. * @param {String} alias
  6908. * @return {Ext.Class} class
  6909. */
  6910. getByAlias: function(alias) {
  6911. return this.get(this.getNameByAlias(alias));
  6912. },
  6913. /**
  6914. * Get the name of a class by its alias.
  6915. *
  6916. * @param {String} alias
  6917. * @return {String} className
  6918. */
  6919. getNameByAlias: function(alias) {
  6920. return this.maps.aliasToName[alias] || '';
  6921. },
  6922. /**
  6923. * Get the name of a class by its alternate name.
  6924. *
  6925. * @param {String} alternate
  6926. * @return {String} className
  6927. */
  6928. getNameByAlternate: function(alternate) {
  6929. return this.maps.alternateToName[alternate] || '';
  6930. },
  6931. /**
  6932. * Get the aliases of a class by the class name
  6933. *
  6934. * @param {String} name
  6935. * @return {Array} aliases
  6936. */
  6937. getAliasesByName: function(name) {
  6938. return this.maps.nameToAliases[name] || [];
  6939. },
  6940. /**
  6941. * Get the name of the class by its reference or its instance;
  6942. * usually invoked by the shorthand {@link Ext#getClassName Ext.getClassName}
  6943. *
  6944. * Ext.ClassManager.getName(Ext.Action); // returns "Ext.Action"
  6945. *
  6946. * @param {Ext.Class/Object} object
  6947. * @return {String} className
  6948. */
  6949. getName: function(object) {
  6950. return object && object.$className || '';
  6951. },
  6952. /**
  6953. * Get the class of the provided object; returns null if it's not an instance
  6954. * of any class created with Ext.define. This is usually invoked by the shorthand {@link Ext#getClass Ext.getClass}
  6955. *
  6956. * var component = new Ext.Component();
  6957. *
  6958. * Ext.ClassManager.getClass(component); // returns Ext.Component
  6959. *
  6960. * @param {Object} object
  6961. * @return {Ext.Class} class
  6962. */
  6963. getClass: function(object) {
  6964. return object && object.self || null;
  6965. },
  6966. /**
  6967. * Defines a class.
  6968. * @deprecated 4.1.0 Use {@link Ext#define} instead, as that also supports creating overrides.
  6969. */
  6970. create: function(className, data, createdFn) {
  6971. var ctor = makeCtor();
  6972. if (typeof data == 'function') {
  6973. data = data(ctor);
  6974. }
  6975. data.$className = className;
  6976. return new Class(ctor, data, function() {
  6977. var postprocessorStack = data.postprocessors || Manager.defaultPostprocessors,
  6978. registeredPostprocessors = Manager.postprocessors,
  6979. postprocessors = [],
  6980. postprocessor, i, ln, j, subLn, postprocessorProperties, postprocessorProperty;
  6981. delete data.postprocessors;
  6982. for (i = 0,ln = postprocessorStack.length; i < ln; i++) {
  6983. postprocessor = postprocessorStack[i];
  6984. if (typeof postprocessor == 'string') {
  6985. postprocessor = registeredPostprocessors[postprocessor];
  6986. postprocessorProperties = postprocessor.properties;
  6987. if (postprocessorProperties === true) {
  6988. postprocessors.push(postprocessor.fn);
  6989. }
  6990. else if (postprocessorProperties) {
  6991. for (j = 0,subLn = postprocessorProperties.length; j < subLn; j++) {
  6992. postprocessorProperty = postprocessorProperties[j];
  6993. if (data.hasOwnProperty(postprocessorProperty)) {
  6994. postprocessors.push(postprocessor.fn);
  6995. break;
  6996. }
  6997. }
  6998. }
  6999. }
  7000. else {
  7001. postprocessors.push(postprocessor);
  7002. }
  7003. }
  7004. data.postprocessors = postprocessors;
  7005. data.createdFn = createdFn;
  7006. Manager.processCreate(className, this, data);
  7007. });
  7008. },
  7009. processCreate: function(className, cls, clsData){
  7010. var me = this,
  7011. postprocessor = clsData.postprocessors.shift(),
  7012. createdFn = clsData.createdFn;
  7013. if (!postprocessor) {
  7014. if (className) {
  7015. me.set(className, cls);
  7016. }
  7017. if (createdFn) {
  7018. createdFn.call(cls, cls);
  7019. }
  7020. if (className) {
  7021. me.triggerCreated(className);
  7022. }
  7023. return;
  7024. }
  7025. if (postprocessor.call(me, className, cls, clsData, me.processCreate) !== false) {
  7026. me.processCreate(className, cls, clsData);
  7027. }
  7028. },
  7029. createOverride: function (className, data, createdFn) {
  7030. var me = this,
  7031. overriddenClassName = data.override,
  7032. requires = data.requires,
  7033. uses = data.uses,
  7034. classReady = function () {
  7035. var cls, temp;
  7036. if (requires) {
  7037. temp = requires;
  7038. requires = null; // do the real thing next time (which may be now)
  7039. // Since the override is going to be used (its target class is now
  7040. // created), we need to fetch the required classes for the override
  7041. // and call us back once they are loaded:
  7042. Ext.Loader.require(temp, classReady);
  7043. } else {
  7044. // The target class and the required classes for this override are
  7045. // ready, so we can apply the override now:
  7046. cls = me.get(overriddenClassName);
  7047. // We don't want to apply these:
  7048. delete data.override;
  7049. delete data.requires;
  7050. delete data.uses;
  7051. Ext.override(cls, data);
  7052. // This pushes the overridding file itself into Ext.Loader.history
  7053. // Hence if the target class never exists, the overriding file will
  7054. // never be included in the build.
  7055. me.triggerCreated(className);
  7056. if (uses) {
  7057. Ext.Loader.addUsedClasses(uses); // get these classes too!
  7058. }
  7059. if (createdFn) {
  7060. createdFn.call(cls); // last but not least!
  7061. }
  7062. }
  7063. };
  7064. me.existCache[className] = true;
  7065. // Override the target class right after it's created
  7066. me.onCreated(classReady, me, overriddenClassName);
  7067. return me;
  7068. },
  7069. /**
  7070. * Instantiate a class by its alias; usually invoked by the convenient shorthand {@link Ext#createByAlias Ext.createByAlias}
  7071. * If {@link Ext.Loader} is {@link Ext.Loader#setConfig enabled} and the class has not been defined yet, it will
  7072. * attempt to load the class via synchronous loading.
  7073. *
  7074. * var window = Ext.ClassManager.instantiateByAlias('widget.window', { width: 600, height: 800, ... });
  7075. *
  7076. * @param {String} alias
  7077. * @param {Object...} args Additional arguments after the alias will be passed to the
  7078. * class constructor.
  7079. * @return {Object} instance
  7080. */
  7081. instantiateByAlias: function() {
  7082. var alias = arguments[0],
  7083. args = arraySlice.call(arguments),
  7084. className = this.getNameByAlias(alias);
  7085. if (!className) {
  7086. className = this.maps.aliasToName[alias];
  7087. Ext.syncRequire(className);
  7088. }
  7089. args[0] = className;
  7090. return this.instantiate.apply(this, args);
  7091. },
  7092. /**
  7093. * @private
  7094. */
  7095. instantiate: function() {
  7096. var name = arguments[0],
  7097. nameType = typeof name,
  7098. args = arraySlice.call(arguments, 1),
  7099. alias = name,
  7100. possibleName, cls;
  7101. if (nameType != 'function') {
  7102. if (nameType != 'string' && args.length === 0) {
  7103. args = [name];
  7104. name = name.xclass;
  7105. }
  7106. cls = this.get(name);
  7107. }
  7108. else {
  7109. cls = name;
  7110. }
  7111. // No record of this class name, it's possibly an alias, so look it up
  7112. if (!cls) {
  7113. possibleName = this.getNameByAlias(name);
  7114. if (possibleName) {
  7115. name = possibleName;
  7116. cls = this.get(name);
  7117. }
  7118. }
  7119. // Still no record of this class name, it's possibly an alternate name, so look it up
  7120. if (!cls) {
  7121. possibleName = this.getNameByAlternate(name);
  7122. if (possibleName) {
  7123. name = possibleName;
  7124. cls = this.get(name);
  7125. }
  7126. }
  7127. // Still not existing at this point, try to load it via synchronous mode as the last resort
  7128. if (!cls) {
  7129. Ext.syncRequire(name);
  7130. cls = this.get(name);
  7131. }
  7132. return this.getInstantiator(args.length)(cls, args);
  7133. },
  7134. /**
  7135. * @private
  7136. * @param name
  7137. * @param args
  7138. */
  7139. dynInstantiate: function(name, args) {
  7140. args = arrayFrom(args, true);
  7141. args.unshift(name);
  7142. return this.instantiate.apply(this, args);
  7143. },
  7144. /**
  7145. * @private
  7146. * @param length
  7147. */
  7148. getInstantiator: function(length) {
  7149. var instantiators = this.instantiators,
  7150. instantiator,
  7151. i,
  7152. args;
  7153. instantiator = instantiators[length];
  7154. if (!instantiator) {
  7155. i = length;
  7156. args = [];
  7157. for (i = 0; i < length; i++) {
  7158. args.push('a[' + i + ']');
  7159. }
  7160. instantiator = instantiators[length] = new Function('c', 'a', 'return new c(' + args.join(',') + ')');
  7161. }
  7162. return instantiator;
  7163. },
  7164. /**
  7165. * @private
  7166. */
  7167. postprocessors: {},
  7168. /**
  7169. * @private
  7170. */
  7171. defaultPostprocessors: [],
  7172. /**
  7173. * Register a post-processor function.
  7174. *
  7175. * @private
  7176. * @param {String} name
  7177. * @param {Function} postprocessor
  7178. */
  7179. registerPostprocessor: function(name, fn, properties, position, relativeTo) {
  7180. if (!position) {
  7181. position = 'last';
  7182. }
  7183. if (!properties) {
  7184. properties = [name];
  7185. }
  7186. this.postprocessors[name] = {
  7187. name: name,
  7188. properties: properties || false,
  7189. fn: fn
  7190. };
  7191. this.setDefaultPostprocessorPosition(name, position, relativeTo);
  7192. return this;
  7193. },
  7194. /**
  7195. * Set the default post processors array stack which are applied to every class.
  7196. *
  7197. * @private
  7198. * @param {String/Array} The name of a registered post processor or an array of registered names.
  7199. * @return {Ext.ClassManager} this
  7200. */
  7201. setDefaultPostprocessors: function(postprocessors) {
  7202. this.defaultPostprocessors = arrayFrom(postprocessors);
  7203. return this;
  7204. },
  7205. /**
  7206. * Insert this post-processor at a specific position in the stack, optionally relative to
  7207. * any existing post-processor
  7208. *
  7209. * @private
  7210. * @param {String} name The post-processor name. Note that it needs to be registered with
  7211. * {@link Ext.ClassManager#registerPostprocessor} before this
  7212. * @param {String} offset The insertion position. Four possible values are:
  7213. * 'first', 'last', or: 'before', 'after' (relative to the name provided in the third argument)
  7214. * @param {String} relativeName
  7215. * @return {Ext.ClassManager} this
  7216. */
  7217. setDefaultPostprocessorPosition: function(name, offset, relativeName) {
  7218. var defaultPostprocessors = this.defaultPostprocessors,
  7219. index;
  7220. if (typeof offset == 'string') {
  7221. if (offset === 'first') {
  7222. defaultPostprocessors.unshift(name);
  7223. return this;
  7224. }
  7225. else if (offset === 'last') {
  7226. defaultPostprocessors.push(name);
  7227. return this;
  7228. }
  7229. offset = (offset === 'after') ? 1 : -1;
  7230. }
  7231. index = Ext.Array.indexOf(defaultPostprocessors, relativeName);
  7232. if (index !== -1) {
  7233. Ext.Array.splice(defaultPostprocessors, Math.max(0, index + offset), 0, name);
  7234. }
  7235. return this;
  7236. },
  7237. /**
  7238. * Converts a string expression to an array of matching class names. An expression can either refers to class aliases
  7239. * or class names. Expressions support wildcards:
  7240. *
  7241. * // returns ['Ext.window.Window']
  7242. * var window = Ext.ClassManager.getNamesByExpression('widget.window');
  7243. *
  7244. * // returns ['widget.panel', 'widget.window', ...]
  7245. * var allWidgets = Ext.ClassManager.getNamesByExpression('widget.*');
  7246. *
  7247. * // returns ['Ext.data.Store', 'Ext.data.ArrayProxy', ...]
  7248. * var allData = Ext.ClassManager.getNamesByExpression('Ext.data.*');
  7249. *
  7250. * @param {String} expression
  7251. * @return {String[]} classNames
  7252. */
  7253. getNamesByExpression: function(expression) {
  7254. var nameToAliasesMap = this.maps.nameToAliases,
  7255. names = [],
  7256. name, alias, aliases, possibleName, regex, i, ln;
  7257. if (expression.indexOf('*') !== -1) {
  7258. expression = expression.replace(/\*/g, '(.*?)');
  7259. regex = new RegExp('^' + expression + '$');
  7260. for (name in nameToAliasesMap) {
  7261. if (nameToAliasesMap.hasOwnProperty(name)) {
  7262. aliases = nameToAliasesMap[name];
  7263. if (name.search(regex) !== -1) {
  7264. names.push(name);
  7265. }
  7266. else {
  7267. for (i = 0, ln = aliases.length; i < ln; i++) {
  7268. alias = aliases[i];
  7269. if (alias.search(regex) !== -1) {
  7270. names.push(name);
  7271. break;
  7272. }
  7273. }
  7274. }
  7275. }
  7276. }
  7277. } else {
  7278. possibleName = this.getNameByAlias(expression);
  7279. if (possibleName) {
  7280. names.push(possibleName);
  7281. } else {
  7282. possibleName = this.getNameByAlternate(expression);
  7283. if (possibleName) {
  7284. names.push(possibleName);
  7285. } else {
  7286. names.push(expression);
  7287. }
  7288. }
  7289. }
  7290. return names;
  7291. }
  7292. };
  7293. /**
  7294. * @cfg {String[]} alias
  7295. * @member Ext.Class
  7296. * List of short aliases for class names. Most useful for defining xtypes for widgets:
  7297. *
  7298. * Ext.define('MyApp.CoolPanel', {
  7299. * extend: 'Ext.panel.Panel',
  7300. * alias: ['widget.coolpanel'],
  7301. * title: 'Yeah!'
  7302. * });
  7303. *
  7304. * // Using Ext.create
  7305. * Ext.create('widget.coolpanel');
  7306. *
  7307. * // Using the shorthand for defining widgets by xtype
  7308. * Ext.widget('panel', {
  7309. * items: [
  7310. * {xtype: 'coolpanel', html: 'Foo'},
  7311. * {xtype: 'coolpanel', html: 'Bar'}
  7312. * ]
  7313. * });
  7314. *
  7315. * Besides "widget" for xtype there are alias namespaces like "feature" for ftype and "plugin" for ptype.
  7316. */
  7317. Manager.registerPostprocessor('alias', function(name, cls, data) {
  7318. var aliases = data.alias,
  7319. i, ln;
  7320. for (i = 0,ln = aliases.length; i < ln; i++) {
  7321. alias = aliases[i];
  7322. this.setAlias(cls, alias);
  7323. }
  7324. }, ['xtype', 'alias']);
  7325. /**
  7326. * @cfg {Boolean} singleton
  7327. * @member Ext.Class
  7328. * When set to true, the class will be instantiated as singleton. For example:
  7329. *
  7330. * Ext.define('Logger', {
  7331. * singleton: true,
  7332. * log: function(msg) {
  7333. * console.log(msg);
  7334. * }
  7335. * });
  7336. *
  7337. * Logger.log('Hello');
  7338. */
  7339. Manager.registerPostprocessor('singleton', function(name, cls, data, fn) {
  7340. fn.call(this, name, new cls(), data);
  7341. return false;
  7342. });
  7343. /**
  7344. * @cfg {String/String[]} alternateClassName
  7345. * @member Ext.Class
  7346. * Defines alternate names for this class. For example:
  7347. *
  7348. * Ext.define('Developer', {
  7349. * alternateClassName: ['Coder', 'Hacker'],
  7350. * code: function(msg) {
  7351. * alert('Typing... ' + msg);
  7352. * }
  7353. * });
  7354. *
  7355. * var joe = Ext.create('Developer');
  7356. * joe.code('stackoverflow');
  7357. *
  7358. * var rms = Ext.create('Hacker');
  7359. * rms.code('hack hack');
  7360. */
  7361. Manager.registerPostprocessor('alternateClassName', function(name, cls, data) {
  7362. var alternates = data.alternateClassName,
  7363. i, ln, alternate;
  7364. if (!(alternates instanceof Array)) {
  7365. alternates = [alternates];
  7366. }
  7367. for (i = 0, ln = alternates.length; i < ln; i++) {
  7368. alternate = alternates[i];
  7369. this.set(alternate, cls);
  7370. }
  7371. });
  7372. Ext.apply(Ext, {
  7373. /**
  7374. * Instantiate a class by either full name, alias or alternate name.
  7375. *
  7376. * If {@link Ext.Loader} is {@link Ext.Loader#setConfig enabled} and the class has
  7377. * not been defined yet, it will attempt to load the class via synchronous loading.
  7378. *
  7379. * For example, all these three lines return the same result:
  7380. *
  7381. * // alias
  7382. * var window = Ext.create('widget.window', {
  7383. * width: 600,
  7384. * height: 800,
  7385. * ...
  7386. * });
  7387. *
  7388. * // alternate name
  7389. * var window = Ext.create('Ext.Window', {
  7390. * width: 600,
  7391. * height: 800,
  7392. * ...
  7393. * });
  7394. *
  7395. * // full class name
  7396. * var window = Ext.create('Ext.window.Window', {
  7397. * width: 600,
  7398. * height: 800,
  7399. * ...
  7400. * });
  7401. *
  7402. * // single object with xclass property:
  7403. * var window = Ext.create({
  7404. * xclass: 'Ext.window.Window', // any valid value for 'name' (above)
  7405. * width: 600,
  7406. * height: 800,
  7407. * ...
  7408. * });
  7409. *
  7410. * @param {String} [name] The class name or alias. Can be specified as `xclass`
  7411. * property if only one object parameter is specified.
  7412. * @param {Object...} [args] Additional arguments after the name will be passed to
  7413. * the class' constructor.
  7414. * @return {Object} instance
  7415. * @member Ext
  7416. * @method create
  7417. */
  7418. create: alias(Manager, 'instantiate'),
  7419. /**
  7420. * Convenient shorthand to create a widget by its xtype or a config object.
  7421. * See also {@link Ext.ClassManager#instantiateByAlias}.
  7422. *
  7423. * var button = Ext.widget('button'); // Equivalent to Ext.create('widget.button');
  7424. *
  7425. * var panel = Ext.widget('panel', { // Equivalent to Ext.create('widget.panel')
  7426. * title: 'Panel'
  7427. * });
  7428. *
  7429. * var grid = Ext.widget({
  7430. * xtype: 'grid',
  7431. * ...
  7432. * });
  7433. *
  7434. * If a {@link Ext.Component component} instance is passed, it is simply returned.
  7435. *
  7436. * @member Ext
  7437. * @param {String} [name] The xtype of the widget to create.
  7438. * @param {Object} [config] The configuration object for the widget constructor.
  7439. * @return {Object} The widget instance
  7440. */
  7441. widget: function(name, config) {
  7442. // forms:
  7443. // 1: (xtype)
  7444. // 2: (xtype, config)
  7445. // 3: (config)
  7446. // 4: (xtype, component)
  7447. // 5: (component)
  7448. //
  7449. var xtype = name,
  7450. alias, className, T, load;
  7451. if (typeof xtype != 'string') { // if (form 3 or 5)
  7452. // first arg is config or component
  7453. config = name; // arguments[0]
  7454. xtype = config.xtype;
  7455. } else {
  7456. config = config || {};
  7457. }
  7458. if (config.isComponent) {
  7459. return config;
  7460. }
  7461. alias = 'widget.' + xtype;
  7462. className = Manager.getNameByAlias(alias);
  7463. // this is needed to support demand loading of the class
  7464. if (!className) {
  7465. load = true;
  7466. }
  7467. T = Manager.get(className);
  7468. if (load || !T) {
  7469. return Manager.instantiateByAlias(alias, config);
  7470. }
  7471. return new T(config);
  7472. },
  7473. /**
  7474. * Convenient shorthand, see {@link Ext.ClassManager#instantiateByAlias}
  7475. * @member Ext
  7476. * @method createByAlias
  7477. */
  7478. createByAlias: alias(Manager, 'instantiateByAlias'),
  7479. /**
  7480. * @method
  7481. * Defines a class or override. A basic class is defined like this:
  7482. *
  7483. * Ext.define('My.awesome.Class', {
  7484. * someProperty: 'something',
  7485. *
  7486. * someMethod: function(s) {
  7487. * alert(s + this.someProperty);
  7488. * }
  7489. *
  7490. * ...
  7491. * });
  7492. *
  7493. * var obj = new My.awesome.Class();
  7494. *
  7495. * obj.someMethod('Say '); // alerts 'Say something'
  7496. *
  7497. * To create an anonymous class, pass `null` for the `className`:
  7498. *
  7499. * Ext.define(null, {
  7500. * constructor: function () {
  7501. * // ...
  7502. * }
  7503. * });
  7504. *
  7505. * In some cases, it is helpful to create a nested scope to contain some private
  7506. * properties. The best way to do this is to pass a function instead of an object
  7507. * as the second parameter. This function will be called to produce the class
  7508. * body:
  7509. *
  7510. * Ext.define('MyApp.foo.Bar', function () {
  7511. * var id = 0;
  7512. *
  7513. * return {
  7514. * nextId: function () {
  7515. * return ++id;
  7516. * }
  7517. * };
  7518. * });
  7519. *
  7520. * When using this form of `Ext.define`, the function is passed a reference to its
  7521. * class. This can be used as an efficient way to access any static properties you
  7522. * may have:
  7523. *
  7524. * Ext.define('MyApp.foo.Bar', function (Bar) {
  7525. * return {
  7526. * statics: {
  7527. * staticMethod: function () {
  7528. * // ...
  7529. * }
  7530. * },
  7531. *
  7532. * method: function () {
  7533. * return Bar.staticMethod();
  7534. * }
  7535. * };
  7536. * });
  7537. *
  7538. * To define an override, include the `override` property. The content of an
  7539. * override is aggregated with the specified class in order to extend or modify
  7540. * that class. This can be as simple as setting default property values or it can
  7541. * extend and/or replace methods. This can also extend the statics of the class.
  7542. *
  7543. * One use for an override is to break a large class into manageable pieces.
  7544. *
  7545. * // File: /src/app/Panel.js
  7546. *
  7547. * Ext.define('My.app.Panel', {
  7548. * extend: 'Ext.panel.Panel',
  7549. * requires: [
  7550. * 'My.app.PanelPart2',
  7551. * 'My.app.PanelPart3'
  7552. * ]
  7553. *
  7554. * constructor: function (config) {
  7555. * this.callParent(arguments); // calls Ext.panel.Panel's constructor
  7556. * //...
  7557. * },
  7558. *
  7559. * statics: {
  7560. * method: function () {
  7561. * return 'abc';
  7562. * }
  7563. * }
  7564. * });
  7565. *
  7566. * // File: /src/app/PanelPart2.js
  7567. * Ext.define('My.app.PanelPart2', {
  7568. * override: 'My.app.Panel',
  7569. *
  7570. * constructor: function (config) {
  7571. * this.callParent(arguments); // calls My.app.Panel's constructor
  7572. * //...
  7573. * }
  7574. * });
  7575. *
  7576. * Another use of overrides is to provide optional parts of classes that can be
  7577. * independently required. In this case, the class may even be unaware of the
  7578. * override altogether.
  7579. *
  7580. * Ext.define('My.ux.CoolTip', {
  7581. * override: 'Ext.tip.ToolTip',
  7582. *
  7583. * constructor: function (config) {
  7584. * this.callParent(arguments); // calls Ext.tip.ToolTip's constructor
  7585. * //...
  7586. * }
  7587. * });
  7588. *
  7589. * The above override can now be required as normal.
  7590. *
  7591. * Ext.define('My.app.App', {
  7592. * requires: [
  7593. * 'My.ux.CoolTip'
  7594. * ]
  7595. * });
  7596. *
  7597. * Overrides can also contain statics:
  7598. *
  7599. * Ext.define('My.app.BarMod', {
  7600. * override: 'Ext.foo.Bar',
  7601. *
  7602. * statics: {
  7603. * method: function (x) {
  7604. * return this.callParent([x * 2]); // call Ext.foo.Bar.method
  7605. * }
  7606. * }
  7607. * });
  7608. *
  7609. * IMPORTANT: An override is only included in a build if the class it overrides is
  7610. * required. Otherwise, the override, like the target class, is not included.
  7611. *
  7612. * @param {String} className The class name to create in string dot-namespaced format, for example:
  7613. * 'My.very.awesome.Class', 'FeedViewer.plugin.CoolPager'
  7614. * It is highly recommended to follow this simple convention:
  7615. * - The root and the class name are 'CamelCased'
  7616. * - Everything else is lower-cased
  7617. * Pass `null` to create an anonymous class.
  7618. * @param {Object} data The key - value pairs of properties to apply to this class. Property names can be of any valid
  7619. * strings, except those in the reserved listed below:
  7620. * - `mixins`
  7621. * - `statics`
  7622. * - `config`
  7623. * - `alias`
  7624. * - `self`
  7625. * - `singleton`
  7626. * - `alternateClassName`
  7627. * - `override`
  7628. *
  7629. * @param {Function} createdFn Optional callback to execute after the class is created, the execution scope of which
  7630. * (`this`) will be the newly created class itself.
  7631. * @return {Ext.Base}
  7632. * @markdown
  7633. * @member Ext
  7634. * @method define
  7635. */
  7636. define: function (className, data, createdFn) {
  7637. if (data.override) {
  7638. return Manager.createOverride.apply(Manager, arguments);
  7639. }
  7640. return Manager.create.apply(Manager, arguments);
  7641. },
  7642. /**
  7643. * Convenient shorthand, see {@link Ext.ClassManager#getName}
  7644. * @member Ext
  7645. * @method getClassName
  7646. */
  7647. getClassName: alias(Manager, 'getName'),
  7648. /**
  7649. * Returns the displayName property or className or object. When all else fails, returns "Anonymous".
  7650. * @param {Object} object
  7651. * @return {String}
  7652. */
  7653. getDisplayName: function(object) {
  7654. if (object) {
  7655. if (object.displayName) {
  7656. return object.displayName;
  7657. }
  7658. if (object.$name && object.$class) {
  7659. return Ext.getClassName(object.$class) + '#' + object.$name;
  7660. }
  7661. if (object.$className) {
  7662. return object.$className;
  7663. }
  7664. }
  7665. return 'Anonymous';
  7666. },
  7667. /**
  7668. * Convenient shorthand, see {@link Ext.ClassManager#getClass}
  7669. * @member Ext
  7670. * @method getClass
  7671. */
  7672. getClass: alias(Manager, 'getClass'),
  7673. /**
  7674. * Creates namespaces to be used for scoping variables and classes so that they are not global.
  7675. * Specifying the last node of a namespace implicitly creates all other nodes. Usage:
  7676. *
  7677. * Ext.namespace('Company', 'Company.data');
  7678. *
  7679. * // equivalent and preferable to the above syntax
  7680. * Ext.ns('Company.data');
  7681. *
  7682. * Company.Widget = function() { ... };
  7683. *
  7684. * Company.data.CustomStore = function(config) { ... };
  7685. *
  7686. * @param {String...} namespaces
  7687. * @return {Object} The namespace object.
  7688. * (If multiple arguments are passed, this will be the last namespace created)
  7689. * @member Ext
  7690. * @method namespace
  7691. */
  7692. namespace: alias(Manager, 'createNamespaces')
  7693. });
  7694. /**
  7695. * Old name for {@link Ext#widget}.
  7696. * @deprecated 4.0.0 Use {@link Ext#widget} instead.
  7697. * @method createWidget
  7698. * @member Ext
  7699. */
  7700. Ext.createWidget = Ext.widget;
  7701. /**
  7702. * Convenient alias for {@link Ext#namespace Ext.namespace}.
  7703. * @inheritdoc Ext#namespace
  7704. * @member Ext
  7705. * @method ns
  7706. */
  7707. Ext.ns = Ext.namespace;
  7708. Class.registerPreprocessor('className', function(cls, data) {
  7709. if (data.$className) {
  7710. cls.$className = data.$className;
  7711. }
  7712. }, true, 'first');
  7713. Class.registerPreprocessor('alias', function(cls, data) {
  7714. var prototype = cls.prototype,
  7715. xtypes = arrayFrom(data.xtype),
  7716. aliases = arrayFrom(data.alias),
  7717. widgetPrefix = 'widget.',
  7718. widgetPrefixLength = widgetPrefix.length,
  7719. xtypesChain = Array.prototype.slice.call(prototype.xtypesChain || []),
  7720. xtypesMap = Ext.merge({}, prototype.xtypesMap || {}),
  7721. i, ln, alias, xtype;
  7722. for (i = 0,ln = aliases.length; i < ln; i++) {
  7723. alias = aliases[i];
  7724. if (alias.substring(0, widgetPrefixLength) === widgetPrefix) {
  7725. xtype = alias.substring(widgetPrefixLength);
  7726. Ext.Array.include(xtypes, xtype);
  7727. }
  7728. }
  7729. cls.xtype = data.xtype = xtypes[0];
  7730. data.xtypes = xtypes;
  7731. for (i = 0,ln = xtypes.length; i < ln; i++) {
  7732. xtype = xtypes[i];
  7733. if (!xtypesMap[xtype]) {
  7734. xtypesMap[xtype] = true;
  7735. xtypesChain.push(xtype);
  7736. }
  7737. }
  7738. data.xtypesChain = xtypesChain;
  7739. data.xtypesMap = xtypesMap;
  7740. Ext.Function.interceptAfter(data, 'onClassCreated', function() {
  7741. var mixins = prototype.mixins,
  7742. key, mixin;
  7743. for (key in mixins) {
  7744. if (mixins.hasOwnProperty(key)) {
  7745. mixin = mixins[key];
  7746. xtypes = mixin.xtypes;
  7747. if (xtypes) {
  7748. for (i = 0,ln = xtypes.length; i < ln; i++) {
  7749. xtype = xtypes[i];
  7750. if (!xtypesMap[xtype]) {
  7751. xtypesMap[xtype] = true;
  7752. xtypesChain.push(xtype);
  7753. }
  7754. }
  7755. }
  7756. }
  7757. }
  7758. });
  7759. for (i = 0,ln = xtypes.length; i < ln; i++) {
  7760. xtype = xtypes[i];
  7761. Ext.Array.include(aliases, widgetPrefix + xtype);
  7762. }
  7763. data.alias = aliases;
  7764. }, ['xtype', 'alias']);
  7765. }(Ext.Class, Ext.Function.alias, Array.prototype.slice, Ext.Array.from, Ext.global));
  7766. //@tag foundation,core
  7767. //@require ClassManager.js
  7768. //@define Ext.Loader
  7769. /**
  7770. * @author Jacky Nguyen <jacky@sencha.com>
  7771. * @docauthor Jacky Nguyen <jacky@sencha.com>
  7772. * @class Ext.Loader
  7773. *
  7774. * Ext.Loader is the heart of the new dynamic dependency loading capability in Ext JS 4+. It is most commonly used
  7775. * via the {@link Ext#require} shorthand. Ext.Loader supports both asynchronous and synchronous loading
  7776. * approaches, and leverage their advantages for the best development flow. We'll discuss about the pros and cons of each approach:
  7777. *
  7778. * # Asynchronous Loading #
  7779. *
  7780. * - Advantages:
  7781. * + Cross-domain
  7782. * + No web server needed: you can run the application via the file system protocol (i.e: `file://path/to/your/index
  7783. * .html`)
  7784. * + Best possible debugging experience: error messages come with the exact file name and line number
  7785. *
  7786. * - Disadvantages:
  7787. * + Dependencies need to be specified before-hand
  7788. *
  7789. * ### Method 1: Explicitly include what you need: ###
  7790. *
  7791. * // Syntax
  7792. * Ext.require({String/Array} expressions);
  7793. *
  7794. * // Example: Single alias
  7795. * Ext.require('widget.window');
  7796. *
  7797. * // Example: Single class name
  7798. * Ext.require('Ext.window.Window');
  7799. *
  7800. * // Example: Multiple aliases / class names mix
  7801. * Ext.require(['widget.window', 'layout.border', 'Ext.data.Connection']);
  7802. *
  7803. * // Wildcards
  7804. * Ext.require(['widget.*', 'layout.*', 'Ext.data.*']);
  7805. *
  7806. * ### Method 2: Explicitly exclude what you don't need: ###
  7807. *
  7808. * // Syntax: Note that it must be in this chaining format.
  7809. * Ext.exclude({String/Array} expressions)
  7810. * .require({String/Array} expressions);
  7811. *
  7812. * // Include everything except Ext.data.*
  7813. * Ext.exclude('Ext.data.*').require('*');
  7814. *
  7815. * // Include all widgets except widget.checkbox*,
  7816. * // which will match widget.checkbox, widget.checkboxfield, widget.checkboxgroup, etc.
  7817. * Ext.exclude('widget.checkbox*').require('widget.*');
  7818. *
  7819. * # Synchronous Loading on Demand #
  7820. *
  7821. * - Advantages:
  7822. * + There's no need to specify dependencies before-hand, which is always the convenience of including ext-all.js
  7823. * before
  7824. *
  7825. * - Disadvantages:
  7826. * + Not as good debugging experience since file name won't be shown (except in Firebug at the moment)
  7827. * + Must be from the same domain due to XHR restriction
  7828. * + Need a web server, same reason as above
  7829. *
  7830. * There's one simple rule to follow: Instantiate everything with Ext.create instead of the `new` keyword
  7831. *
  7832. * Ext.create('widget.window', { ... }); // Instead of new Ext.window.Window({...});
  7833. *
  7834. * Ext.create('Ext.window.Window', {}); // Same as above, using full class name instead of alias
  7835. *
  7836. * Ext.widget('window', {}); // Same as above, all you need is the traditional `xtype`
  7837. *
  7838. * Behind the scene, {@link Ext.ClassManager} will automatically check whether the given class name / alias has already
  7839. * existed on the page. If it's not, Ext.Loader will immediately switch itself to synchronous mode and automatic load the given
  7840. * class and all its dependencies.
  7841. *
  7842. * # Hybrid Loading - The Best of Both Worlds #
  7843. *
  7844. * It has all the advantages combined from asynchronous and synchronous loading. The development flow is simple:
  7845. *
  7846. * ### Step 1: Start writing your application using synchronous approach.
  7847. *
  7848. * Ext.Loader will automatically fetch all dependencies on demand as they're needed during run-time. For example:
  7849. *
  7850. * Ext.onReady(function(){
  7851. * var window = Ext.widget('window', {
  7852. * width: 500,
  7853. * height: 300,
  7854. * layout: {
  7855. * type: 'border',
  7856. * padding: 5
  7857. * },
  7858. * title: 'Hello Dialog',
  7859. * items: [{
  7860. * title: 'Navigation',
  7861. * collapsible: true,
  7862. * region: 'west',
  7863. * width: 200,
  7864. * html: 'Hello',
  7865. * split: true
  7866. * }, {
  7867. * title: 'TabPanel',
  7868. * region: 'center'
  7869. * }]
  7870. * });
  7871. *
  7872. * window.show();
  7873. * })
  7874. *
  7875. * ### Step 2: Along the way, when you need better debugging ability, watch the console for warnings like these: ###
  7876. *
  7877. * [Ext.Loader] Synchronously loading 'Ext.window.Window'; consider adding Ext.require('Ext.window.Window') before your application's code
  7878. * ClassManager.js:432
  7879. * [Ext.Loader] Synchronously loading 'Ext.layout.container.Border'; consider adding Ext.require('Ext.layout.container.Border') before your application's code
  7880. *
  7881. * Simply copy and paste the suggested code above `Ext.onReady`, i.e:
  7882. *
  7883. * Ext.require('Ext.window.Window');
  7884. * Ext.require('Ext.layout.container.Border');
  7885. *
  7886. * Ext.onReady(...);
  7887. *
  7888. * Everything should now load via asynchronous mode.
  7889. *
  7890. * # Deployment #
  7891. *
  7892. * It's important to note that dynamic loading should only be used during development on your local machines.
  7893. * During production, all dependencies should be combined into one single JavaScript file. Ext.Loader makes
  7894. * the whole process of transitioning from / to between development / maintenance and production as easy as
  7895. * possible. Internally {@link Ext.Loader#history Ext.Loader.history} maintains the list of all dependencies your application
  7896. * needs in the exact loading sequence. It's as simple as concatenating all files in this array into one,
  7897. * then include it on top of your application.
  7898. *
  7899. * This process will be automated with Sencha Command, to be released and documented towards Ext JS 4 Final.
  7900. *
  7901. * @singleton
  7902. */
  7903. Ext.Loader = new function() {
  7904. var Loader = this,
  7905. Manager = Ext.ClassManager,
  7906. Class = Ext.Class,
  7907. flexSetter = Ext.Function.flexSetter,
  7908. alias = Ext.Function.alias,
  7909. pass = Ext.Function.pass,
  7910. defer = Ext.Function.defer,
  7911. arrayErase = Ext.Array.erase,
  7912. dependencyProperties = ['extend', 'mixins', 'requires'],
  7913. isInHistory = {},
  7914. history = [],
  7915. slashDotSlashRe = /\/\.\//g,
  7916. dotRe = /\./g;
  7917. Ext.apply(Loader, {
  7918. /**
  7919. * @private
  7920. */
  7921. isInHistory: isInHistory,
  7922. /**
  7923. * An array of class names to keep track of the dependency loading order.
  7924. * This is not guaranteed to be the same everytime due to the asynchronous
  7925. * nature of the Loader.
  7926. *
  7927. * @property {Array} history
  7928. */
  7929. history: history,
  7930. /**
  7931. * Configuration
  7932. * @private
  7933. */
  7934. config: {
  7935. /**
  7936. * @cfg {Boolean} enabled
  7937. * Whether or not to enable the dynamic dependency loading feature.
  7938. */
  7939. enabled: false,
  7940. /**
  7941. * @cfg {Boolean} scriptChainDelay
  7942. * millisecond delay between asynchronous script injection (prevents stack overflow on some user agents)
  7943. * 'false' disables delay but potentially increases stack load.
  7944. */
  7945. scriptChainDelay : false,
  7946. /**
  7947. * @cfg {Boolean} disableCaching
  7948. * Appends current timestamp to script files to prevent caching.
  7949. */
  7950. disableCaching: true,
  7951. /**
  7952. * @cfg {String} disableCachingParam
  7953. * The get parameter name for the cache buster's timestamp.
  7954. */
  7955. disableCachingParam: '_dc',
  7956. /**
  7957. * @cfg {Boolean} garbageCollect
  7958. * True to prepare an asynchronous script tag for garbage collection (effective only
  7959. * if {@link #preserveScripts preserveScripts} is false)
  7960. */
  7961. garbageCollect : false,
  7962. /**
  7963. * @cfg {Object} paths
  7964. * The mapping from namespaces to file paths
  7965. *
  7966. * {
  7967. * 'Ext': '.', // This is set by default, Ext.layout.container.Container will be
  7968. * // loaded from ./layout/Container.js
  7969. *
  7970. * 'My': './src/my_own_folder' // My.layout.Container will be loaded from
  7971. * // ./src/my_own_folder/layout/Container.js
  7972. * }
  7973. *
  7974. * Note that all relative paths are relative to the current HTML document.
  7975. * If not being specified, for example, <code>Other.awesome.Class</code>
  7976. * will simply be loaded from <code>./Other/awesome/Class.js</code>
  7977. */
  7978. paths: {
  7979. 'Ext': '.'
  7980. },
  7981. /**
  7982. * @cfg {Boolean} preserveScripts
  7983. * False to remove and optionally {@link #garbageCollect garbage-collect} asynchronously loaded scripts,
  7984. * True to retain script element for browser debugger compatibility and improved load performance.
  7985. */
  7986. preserveScripts : true,
  7987. /**
  7988. * @cfg {String} scriptCharset
  7989. * Optional charset to specify encoding of dynamic script content.
  7990. */
  7991. scriptCharset : undefined
  7992. },
  7993. /**
  7994. * Set the configuration for the loader. This should be called right after ext-(debug).js
  7995. * is included in the page, and before Ext.onReady. i.e:
  7996. *
  7997. * <script type="text/javascript" src="ext-core-debug.js"></script>
  7998. * <script type="text/javascript">
  7999. * Ext.Loader.setConfig({
  8000. * enabled: true,
  8001. * paths: {
  8002. * 'My': 'my_own_path'
  8003. * }
  8004. * });
  8005. * </script>
  8006. * <script type="text/javascript">
  8007. * Ext.require(...);
  8008. *
  8009. * Ext.onReady(function() {
  8010. * // application code here
  8011. * });
  8012. * </script>
  8013. *
  8014. * Refer to config options of {@link Ext.Loader} for the list of possible properties
  8015. *
  8016. * @param {Object} config The config object to override the default values
  8017. * @return {Ext.Loader} this
  8018. */
  8019. setConfig: function(name, value) {
  8020. if (Ext.isObject(name) && arguments.length === 1) {
  8021. Ext.merge(Loader.config, name);
  8022. }
  8023. else {
  8024. Loader.config[name] = (Ext.isObject(value)) ? Ext.merge(Loader.config[name], value) : value;
  8025. }
  8026. return Loader;
  8027. },
  8028. /**
  8029. * Get the config value corresponding to the specified name. If no name is given, will return the config object
  8030. * @param {String} name The config property name
  8031. * @return {Object}
  8032. */
  8033. getConfig: function(name) {
  8034. if (name) {
  8035. return Loader.config[name];
  8036. }
  8037. return Loader.config;
  8038. },
  8039. /**
  8040. * Sets the path of a namespace.
  8041. * For Example:
  8042. *
  8043. * Ext.Loader.setPath('Ext', '.');
  8044. *
  8045. * @param {String/Object} name See {@link Ext.Function#flexSetter flexSetter}
  8046. * @param {String} path See {@link Ext.Function#flexSetter flexSetter}
  8047. * @return {Ext.Loader} this
  8048. * @method
  8049. */
  8050. setPath: flexSetter(function(name, path) {
  8051. Loader.config.paths[name] = path;
  8052. return Loader;
  8053. }),
  8054. /**
  8055. * Sets a batch of path entries
  8056. *
  8057. * @param {Object } paths a set of className: path mappings
  8058. * @return {Ext.Loader} this
  8059. */
  8060. addClassPathMappings: function(paths) {
  8061. var name;
  8062. for(name in paths){
  8063. Loader.config.paths[name] = paths[name];
  8064. }
  8065. return Loader;
  8066. },
  8067. /**
  8068. * Translates a className to a file path by adding the
  8069. * the proper prefix and converting the .'s to /'s. For example:
  8070. *
  8071. * Ext.Loader.setPath('My', '/path/to/My');
  8072. *
  8073. * alert(Ext.Loader.getPath('My.awesome.Class')); // alerts '/path/to/My/awesome/Class.js'
  8074. *
  8075. * Note that the deeper namespace levels, if explicitly set, are always resolved first. For example:
  8076. *
  8077. * Ext.Loader.setPath({
  8078. * 'My': '/path/to/lib',
  8079. * 'My.awesome': '/other/path/for/awesome/stuff',
  8080. * 'My.awesome.more': '/more/awesome/path'
  8081. * });
  8082. *
  8083. * alert(Ext.Loader.getPath('My.awesome.Class')); // alerts '/other/path/for/awesome/stuff/Class.js'
  8084. *
  8085. * alert(Ext.Loader.getPath('My.awesome.more.Class')); // alerts '/more/awesome/path/Class.js'
  8086. *
  8087. * alert(Ext.Loader.getPath('My.cool.Class')); // alerts '/path/to/lib/cool/Class.js'
  8088. *
  8089. * alert(Ext.Loader.getPath('Unknown.strange.Stuff')); // alerts 'Unknown/strange/Stuff.js'
  8090. *
  8091. * @param {String} className
  8092. * @return {String} path
  8093. */
  8094. getPath: function(className) {
  8095. var path = '',
  8096. paths = Loader.config.paths,
  8097. prefix = Loader.getPrefix(className);
  8098. if (prefix.length > 0) {
  8099. if (prefix === className) {
  8100. return paths[prefix];
  8101. }
  8102. path = paths[prefix];
  8103. className = className.substring(prefix.length + 1);
  8104. }
  8105. if (path.length > 0) {
  8106. path += '/';
  8107. }
  8108. return path.replace(slashDotSlashRe, '/') + className.replace(dotRe, "/") + '.js';
  8109. },
  8110. /**
  8111. * @private
  8112. * @param {String} className
  8113. */
  8114. getPrefix: function(className) {
  8115. var paths = Loader.config.paths,
  8116. prefix, deepestPrefix = '';
  8117. if (paths.hasOwnProperty(className)) {
  8118. return className;
  8119. }
  8120. for (prefix in paths) {
  8121. if (paths.hasOwnProperty(prefix) && prefix + '.' === className.substring(0, prefix.length + 1)) {
  8122. if (prefix.length > deepestPrefix.length) {
  8123. deepestPrefix = prefix;
  8124. }
  8125. }
  8126. }
  8127. return deepestPrefix;
  8128. },
  8129. /**
  8130. * @private
  8131. * @param {String} className
  8132. */
  8133. isAClassNameWithAKnownPrefix: function(className) {
  8134. var prefix = Loader.getPrefix(className);
  8135. // we can only say it's really a class if className is not equal to any known namespace
  8136. return prefix !== '' && prefix !== className;
  8137. },
  8138. /**
  8139. * Loads all classes by the given names and all their direct dependencies; optionally executes the given callback function when
  8140. * finishes, within the optional scope. This method is aliased by {@link Ext#require Ext.require} for convenience
  8141. * @param {String/Array} expressions Can either be a string or an array of string
  8142. * @param {Function} fn (Optional) The callback function
  8143. * @param {Object} scope (Optional) The execution scope (`this`) of the callback function
  8144. * @param {String/Array} excludes (Optional) Classes to be excluded, useful when being used with expressions
  8145. */
  8146. require: function(expressions, fn, scope, excludes) {
  8147. if (fn) {
  8148. fn.call(scope);
  8149. }
  8150. },
  8151. /**
  8152. * Synchronously loads all classes by the given names and all their direct dependencies; optionally executes the given callback function when finishes, within the optional scope. This method is aliased by {@link Ext#syncRequire} for convenience
  8153. * @param {String/Array} expressions Can either be a string or an array of string
  8154. * @param {Function} fn (Optional) The callback function
  8155. * @param {Object} scope (Optional) The execution scope (`this`) of the callback function
  8156. * @param {String/Array} excludes (Optional) Classes to be excluded, useful when being used with expressions
  8157. */
  8158. syncRequire: function() {},
  8159. /**
  8160. * Explicitly exclude files from being loaded. Useful when used in conjunction with a broad include expression.
  8161. * Can be chained with more `require` and `exclude` methods, eg:
  8162. *
  8163. * Ext.exclude('Ext.data.*').require('*');
  8164. *
  8165. * Ext.exclude('widget.button*').require('widget.*');
  8166. *
  8167. * @param {Array} excludes
  8168. * @return {Object} object contains `require` method for chaining
  8169. */
  8170. exclude: function(excludes) {
  8171. return {
  8172. require: function(expressions, fn, scope) {
  8173. return Loader.require(expressions, fn, scope, excludes);
  8174. },
  8175. syncRequire: function(expressions, fn, scope) {
  8176. return Loader.syncRequire(expressions, fn, scope, excludes);
  8177. }
  8178. };
  8179. },
  8180. /**
  8181. * Add a new listener to be executed when all required scripts are fully loaded
  8182. *
  8183. * @param {Function} fn The function callback to be executed
  8184. * @param {Object} scope The execution scope (<code>this</code>) of the callback function
  8185. * @param {Boolean} withDomReady Whether or not to wait for document dom ready as well
  8186. */
  8187. onReady: function(fn, scope, withDomReady, options) {
  8188. var oldFn;
  8189. if (withDomReady !== false && Ext.onDocumentReady) {
  8190. oldFn = fn;
  8191. fn = function() {
  8192. Ext.onDocumentReady(oldFn, scope, options);
  8193. };
  8194. }
  8195. fn.call(scope);
  8196. }
  8197. });
  8198. var queue = [],
  8199. isClassFileLoaded = {},
  8200. isFileLoaded = {},
  8201. classNameToFilePathMap = {},
  8202. scriptElements = {},
  8203. readyListeners = [],
  8204. usedClasses = [],
  8205. requiresMap = {};
  8206. Ext.apply(Loader, {
  8207. /**
  8208. * @private
  8209. */
  8210. documentHead: typeof document != 'undefined' && (document.head || document.getElementsByTagName('head')[0]),
  8211. /**
  8212. * Flag indicating whether there are still files being loaded
  8213. * @private
  8214. */
  8215. isLoading: false,
  8216. /**
  8217. * Maintain the queue for all dependencies. Each item in the array is an object of the format:
  8218. *
  8219. * {
  8220. * requires: [...], // The required classes for this queue item
  8221. * callback: function() { ... } // The function to execute when all classes specified in requires exist
  8222. * }
  8223. *
  8224. * @private
  8225. */
  8226. queue: queue,
  8227. /**
  8228. * Maintain the list of files that have already been handled so that they never get double-loaded
  8229. * @private
  8230. */
  8231. isClassFileLoaded: isClassFileLoaded,
  8232. /**
  8233. * @private
  8234. */
  8235. isFileLoaded: isFileLoaded,
  8236. /**
  8237. * Maintain the list of listeners to execute when all required scripts are fully loaded
  8238. * @private
  8239. */
  8240. readyListeners: readyListeners,
  8241. /**
  8242. * Contains classes referenced in `uses` properties.
  8243. * @private
  8244. */
  8245. optionalRequires: usedClasses,
  8246. /**
  8247. * Map of fully qualified class names to an array of dependent classes.
  8248. * @private
  8249. */
  8250. requiresMap: requiresMap,
  8251. /**
  8252. * @private
  8253. */
  8254. numPendingFiles: 0,
  8255. /**
  8256. * @private
  8257. */
  8258. numLoadedFiles: 0,
  8259. /** @private */
  8260. hasFileLoadError: false,
  8261. /**
  8262. * @private
  8263. */
  8264. classNameToFilePathMap: classNameToFilePathMap,
  8265. /**
  8266. * The number of scripts loading via loadScript.
  8267. * @private
  8268. */
  8269. scriptsLoading: 0,
  8270. /**
  8271. * @private
  8272. */
  8273. syncModeEnabled: false,
  8274. scriptElements: scriptElements,
  8275. /**
  8276. * Refresh all items in the queue. If all dependencies for an item exist during looping,
  8277. * it will execute the callback and call refreshQueue again. Triggers onReady when the queue is
  8278. * empty
  8279. * @private
  8280. */
  8281. refreshQueue: function() {
  8282. var ln = queue.length,
  8283. i, item, j, requires;
  8284. // When the queue of loading classes reaches zero, trigger readiness
  8285. if (!ln && !Loader.scriptsLoading) {
  8286. return Loader.triggerReady();
  8287. }
  8288. for (i = 0; i < ln; i++) {
  8289. item = queue[i];
  8290. if (item) {
  8291. requires = item.requires;
  8292. // Don't bother checking when the number of files loaded
  8293. // is still less than the array length
  8294. if (requires.length > Loader.numLoadedFiles) {
  8295. continue;
  8296. }
  8297. // Remove any required classes that are loaded
  8298. for (j = 0; j < requires.length; ) {
  8299. if (Manager.isCreated(requires[j])) {
  8300. // Take out from the queue
  8301. arrayErase(requires, j, 1);
  8302. }
  8303. else {
  8304. j++;
  8305. }
  8306. }
  8307. // If we've ended up with no required classes, call the callback
  8308. if (item.requires.length === 0) {
  8309. arrayErase(queue, i, 1);
  8310. item.callback.call(item.scope);
  8311. Loader.refreshQueue();
  8312. break;
  8313. }
  8314. }
  8315. }
  8316. return Loader;
  8317. },
  8318. /**
  8319. * Inject a script element to document's head, call onLoad and onError accordingly
  8320. * @private
  8321. */
  8322. injectScriptElement: function(url, onLoad, onError, scope, charset) {
  8323. var script = document.createElement('script'),
  8324. dispatched = false,
  8325. config = Loader.config,
  8326. onLoadFn = function() {
  8327. if(!dispatched) {
  8328. dispatched = true;
  8329. script.onload = script.onreadystatechange = script.onerror = null;
  8330. if (typeof config.scriptChainDelay == 'number') {
  8331. //free the stack (and defer the next script)
  8332. defer(onLoad, config.scriptChainDelay, scope);
  8333. } else {
  8334. onLoad.call(scope);
  8335. }
  8336. Loader.cleanupScriptElement(script, config.preserveScripts === false, config.garbageCollect);
  8337. }
  8338. },
  8339. onErrorFn = function(arg) {
  8340. defer(onError, 1, scope); //free the stack
  8341. Loader.cleanupScriptElement(script, config.preserveScripts === false, config.garbageCollect);
  8342. };
  8343. script.type = 'text/javascript';
  8344. script.onerror = onErrorFn;
  8345. charset = charset || config.scriptCharset;
  8346. if (charset) {
  8347. script.charset = charset;
  8348. }
  8349. /*
  8350. * IE9 Standards mode (and others) SHOULD follow the load event only
  8351. * (Note: IE9 supports both onload AND readystatechange events)
  8352. */
  8353. if ('addEventListener' in script ) {
  8354. script.onload = onLoadFn;
  8355. } else if ('readyState' in script) { // for <IE9 Compatability
  8356. script.onreadystatechange = function() {
  8357. if ( this.readyState == 'loaded' || this.readyState == 'complete' ) {
  8358. onLoadFn();
  8359. }
  8360. };
  8361. } else {
  8362. script.onload = onLoadFn;
  8363. }
  8364. script.src = url;
  8365. (Loader.documentHead || document.getElementsByTagName('head')[0]).appendChild(script);
  8366. return script;
  8367. },
  8368. /**
  8369. * @private
  8370. */
  8371. removeScriptElement: function(url) {
  8372. if (scriptElements[url]) {
  8373. Loader.cleanupScriptElement(scriptElements[url], true, !!Loader.getConfig('garbageCollect'));
  8374. delete scriptElements[url];
  8375. }
  8376. return Loader;
  8377. },
  8378. /**
  8379. * @private
  8380. */
  8381. cleanupScriptElement: function(script, remove, collect) {
  8382. var prop;
  8383. script.onload = script.onreadystatechange = script.onerror = null;
  8384. if (remove) {
  8385. Ext.removeNode(script); // Remove, since its useless now
  8386. if (collect) {
  8387. for (prop in script) {
  8388. try {
  8389. script[prop] = null;
  8390. delete script[prop]; // and prepare for GC
  8391. } catch (cleanEx) {
  8392. //ignore
  8393. }
  8394. }
  8395. }
  8396. }
  8397. return Loader;
  8398. },
  8399. /**
  8400. * Loads the specified script URL and calls the supplied callbacks. If this method
  8401. * is called before {@link Ext#isReady}, the script's load will delay the transition
  8402. * to ready. This can be used to load arbitrary scripts that may contain further
  8403. * {@link Ext#require Ext.require} calls.
  8404. *
  8405. * @param {Object/String} options The options object or simply the URL to load.
  8406. * @param {String} options.url The URL from which to load the script.
  8407. * @param {Function} [options.onLoad] The callback to call on successful load.
  8408. * @param {Function} [options.onError] The callback to call on failure to load.
  8409. * @param {Object} [options.scope] The scope (`this`) for the supplied callbacks.
  8410. */
  8411. loadScript: function (options) {
  8412. var config = Loader.getConfig(),
  8413. isString = typeof options == 'string',
  8414. url = isString ? options : options.url,
  8415. onError = !isString && options.onError,
  8416. onLoad = !isString && options.onLoad,
  8417. scope = !isString && options.scope,
  8418. onScriptError = function() {
  8419. Loader.numPendingFiles--;
  8420. Loader.scriptsLoading--;
  8421. if (onError) {
  8422. onError.call(scope, "Failed loading '" + url + "', please verify that the file exists");
  8423. }
  8424. if (Loader.numPendingFiles + Loader.scriptsLoading === 0) {
  8425. Loader.refreshQueue();
  8426. }
  8427. },
  8428. onScriptLoad = function () {
  8429. Loader.numPendingFiles--;
  8430. Loader.scriptsLoading--;
  8431. if (onLoad) {
  8432. onLoad.call(scope);
  8433. }
  8434. if (Loader.numPendingFiles + Loader.scriptsLoading === 0) {
  8435. Loader.refreshQueue();
  8436. }
  8437. },
  8438. src;
  8439. Loader.isLoading = true;
  8440. Loader.numPendingFiles++;
  8441. Loader.scriptsLoading++;
  8442. src = config.disableCaching ?
  8443. (url + '?' + config.disableCachingParam + '=' + Ext.Date.now()) : url;
  8444. scriptElements[url] = Loader.injectScriptElement(src, onScriptLoad, onScriptError);
  8445. },
  8446. /**
  8447. * Load a script file, supports both asynchronous and synchronous approaches
  8448. * @private
  8449. */
  8450. loadScriptFile: function(url, onLoad, onError, scope, synchronous) {
  8451. if (isFileLoaded[url]) {
  8452. return Loader;
  8453. }
  8454. var config = Loader.getConfig(),
  8455. noCacheUrl = url + (config.disableCaching ? ('?' + config.disableCachingParam + '=' + Ext.Date.now()) : ''),
  8456. isCrossOriginRestricted = false,
  8457. xhr, status, onScriptError,
  8458. debugSourceURL = "";
  8459. scope = scope || Loader;
  8460. Loader.isLoading = true;
  8461. if (!synchronous) {
  8462. onScriptError = function() {
  8463. };
  8464. scriptElements[url] = Loader.injectScriptElement(noCacheUrl, onLoad, onScriptError, scope);
  8465. } else {
  8466. if (typeof XMLHttpRequest != 'undefined') {
  8467. xhr = new XMLHttpRequest();
  8468. } else {
  8469. xhr = new ActiveXObject('Microsoft.XMLHTTP');
  8470. }
  8471. try {
  8472. xhr.open('GET', noCacheUrl, false);
  8473. xhr.send(null);
  8474. } catch (e) {
  8475. isCrossOriginRestricted = true;
  8476. }
  8477. status = (xhr.status === 1223) ? 204 :
  8478. (xhr.status === 0 && (self.location || {}).protocol == 'file:') ? 200 : xhr.status;
  8479. isCrossOriginRestricted = isCrossOriginRestricted || (status === 0);
  8480. if (isCrossOriginRestricted
  8481. ) {
  8482. }
  8483. else if ((status >= 200 && status < 300) || (status === 304)
  8484. ) {
  8485. // Debugger friendly, file names are still shown even though they're eval'ed code
  8486. // Breakpoints work on both Firebug and Chrome's Web Inspector
  8487. if (!Ext.isIE) {
  8488. debugSourceURL = "\n//@ sourceURL=" + url;
  8489. }
  8490. Ext.globalEval(xhr.responseText + debugSourceURL);
  8491. onLoad.call(scope);
  8492. }
  8493. else {
  8494. }
  8495. // Prevent potential IE memory leak
  8496. xhr = null;
  8497. }
  8498. },
  8499. // documented above
  8500. syncRequire: function() {
  8501. var syncModeEnabled = Loader.syncModeEnabled;
  8502. if (!syncModeEnabled) {
  8503. Loader.syncModeEnabled = true;
  8504. }
  8505. Loader.require.apply(Loader, arguments);
  8506. if (!syncModeEnabled) {
  8507. Loader.syncModeEnabled = false;
  8508. }
  8509. Loader.refreshQueue();
  8510. },
  8511. // documented above
  8512. require: function(expressions, fn, scope, excludes) {
  8513. var excluded = {},
  8514. included = {},
  8515. excludedClassNames = [],
  8516. possibleClassNames = [],
  8517. classNames = [],
  8518. references = [],
  8519. callback,
  8520. syncModeEnabled,
  8521. filePath, expression, exclude, className,
  8522. possibleClassName, i, j, ln, subLn;
  8523. if (excludes) {
  8524. // Convert possible single string to an array.
  8525. excludes = (typeof excludes === 'string') ? [ excludes ] : excludes;
  8526. for (i = 0,ln = excludes.length; i < ln; i++) {
  8527. exclude = excludes[i];
  8528. if (typeof exclude == 'string' && exclude.length > 0) {
  8529. excludedClassNames = Manager.getNamesByExpression(exclude);
  8530. for (j = 0,subLn = excludedClassNames.length; j < subLn; j++) {
  8531. excluded[excludedClassNames[j]] = true;
  8532. }
  8533. }
  8534. }
  8535. }
  8536. // Convert possible single string to an array.
  8537. expressions = (typeof expressions === 'string') ? [ expressions ] : (expressions ? expressions : []);
  8538. if (fn) {
  8539. if (fn.length > 0) {
  8540. callback = function() {
  8541. var classes = [],
  8542. i, ln;
  8543. for (i = 0,ln = references.length; i < ln; i++) {
  8544. classes.push(Manager.get(references[i]));
  8545. }
  8546. return fn.apply(this, classes);
  8547. };
  8548. }
  8549. else {
  8550. callback = fn;
  8551. }
  8552. }
  8553. else {
  8554. callback = Ext.emptyFn;
  8555. }
  8556. scope = scope || Ext.global;
  8557. for (i = 0,ln = expressions.length; i < ln; i++) {
  8558. expression = expressions[i];
  8559. if (typeof expression == 'string' && expression.length > 0) {
  8560. possibleClassNames = Manager.getNamesByExpression(expression);
  8561. subLn = possibleClassNames.length;
  8562. for (j = 0; j < subLn; j++) {
  8563. possibleClassName = possibleClassNames[j];
  8564. if (excluded[possibleClassName] !== true) {
  8565. references.push(possibleClassName);
  8566. if (!Manager.isCreated(possibleClassName) && !included[possibleClassName]) {
  8567. included[possibleClassName] = true;
  8568. classNames.push(possibleClassName);
  8569. }
  8570. }
  8571. }
  8572. }
  8573. }
  8574. // If the dynamic dependency feature is not being used, throw an error
  8575. // if the dependencies are not defined
  8576. if (classNames.length > 0) {
  8577. if (!Loader.config.enabled) {
  8578. throw new Error("Ext.Loader is not enabled, so dependencies cannot be resolved dynamically. " +
  8579. "Missing required class" + ((classNames.length > 1) ? "es" : "") + ": " + classNames.join(', '));
  8580. }
  8581. }
  8582. else {
  8583. callback.call(scope);
  8584. return Loader;
  8585. }
  8586. syncModeEnabled = Loader.syncModeEnabled;
  8587. if (!syncModeEnabled) {
  8588. queue.push({
  8589. requires: classNames.slice(), // this array will be modified as the queue is processed,
  8590. // so we need a copy of it
  8591. callback: callback,
  8592. scope: scope
  8593. });
  8594. }
  8595. ln = classNames.length;
  8596. for (i = 0; i < ln; i++) {
  8597. className = classNames[i];
  8598. filePath = Loader.getPath(className);
  8599. // If we are synchronously loading a file that has already been asychronously loaded before
  8600. // we need to destroy the script tag and revert the count
  8601. // This file will then be forced loaded in synchronous
  8602. if (syncModeEnabled && isClassFileLoaded.hasOwnProperty(className)) {
  8603. Loader.numPendingFiles--;
  8604. Loader.removeScriptElement(filePath);
  8605. delete isClassFileLoaded[className];
  8606. }
  8607. if (!isClassFileLoaded.hasOwnProperty(className)) {
  8608. isClassFileLoaded[className] = false;
  8609. classNameToFilePathMap[className] = filePath;
  8610. Loader.numPendingFiles++;
  8611. Loader.loadScriptFile(
  8612. filePath,
  8613. pass(Loader.onFileLoaded, [className, filePath], Loader),
  8614. pass(Loader.onFileLoadError, [className, filePath], Loader),
  8615. Loader,
  8616. syncModeEnabled
  8617. );
  8618. }
  8619. }
  8620. if (syncModeEnabled) {
  8621. callback.call(scope);
  8622. if (ln === 1) {
  8623. return Manager.get(className);
  8624. }
  8625. }
  8626. return Loader;
  8627. },
  8628. /**
  8629. * @private
  8630. * @param {String} className
  8631. * @param {String} filePath
  8632. */
  8633. onFileLoaded: function(className, filePath) {
  8634. Loader.numLoadedFiles++;
  8635. isClassFileLoaded[className] = true;
  8636. isFileLoaded[filePath] = true;
  8637. Loader.numPendingFiles--;
  8638. if (Loader.numPendingFiles === 0) {
  8639. Loader.refreshQueue();
  8640. }
  8641. },
  8642. /**
  8643. * @private
  8644. */
  8645. onFileLoadError: function(className, filePath, errorMessage, isSynchronous) {
  8646. Loader.numPendingFiles--;
  8647. Loader.hasFileLoadError = true;
  8648. },
  8649. /**
  8650. * @private
  8651. * Ensure that any classes referenced in the `uses` property are loaded.
  8652. */
  8653. addUsedClasses: function (classes) {
  8654. var cls, i, ln;
  8655. if (classes) {
  8656. classes = (typeof classes == 'string') ? [classes] : classes;
  8657. for (i = 0, ln = classes.length; i < ln; i++) {
  8658. cls = classes[i];
  8659. if (typeof cls == 'string' && !Ext.Array.contains(usedClasses, cls)) {
  8660. usedClasses.push(cls);
  8661. }
  8662. }
  8663. }
  8664. return Loader;
  8665. },
  8666. /**
  8667. * @private
  8668. */
  8669. triggerReady: function() {
  8670. var listener,
  8671. i, refClasses = usedClasses;
  8672. if (Loader.isLoading) {
  8673. Loader.isLoading = false;
  8674. if (refClasses.length !== 0) {
  8675. // Clone then empty the array to eliminate potential recursive loop issue
  8676. refClasses = refClasses.slice();
  8677. usedClasses.length = 0;
  8678. // this may immediately call us back if all 'uses' classes
  8679. // have been loaded
  8680. Loader.require(refClasses, Loader.triggerReady, Loader);
  8681. return Loader;
  8682. }
  8683. }
  8684. // this method can be called with Loader.isLoading either true or false
  8685. // (can be called with false when all 'uses' classes are already loaded)
  8686. // this may bypass the above if condition
  8687. while (readyListeners.length && !Loader.isLoading) {
  8688. // calls to refreshQueue may re-enter triggerReady
  8689. // so we cannot necessarily iterate the readyListeners array
  8690. listener = readyListeners.shift();
  8691. listener.fn.call(listener.scope);
  8692. }
  8693. return Loader;
  8694. },
  8695. // Documented above already
  8696. onReady: function(fn, scope, withDomReady, options) {
  8697. var oldFn;
  8698. if (withDomReady !== false && Ext.onDocumentReady) {
  8699. oldFn = fn;
  8700. fn = function() {
  8701. Ext.onDocumentReady(oldFn, scope, options);
  8702. };
  8703. }
  8704. if (!Loader.isLoading) {
  8705. fn.call(scope);
  8706. }
  8707. else {
  8708. readyListeners.push({
  8709. fn: fn,
  8710. scope: scope
  8711. });
  8712. }
  8713. },
  8714. /**
  8715. * @private
  8716. * @param {String} className
  8717. */
  8718. historyPush: function(className) {
  8719. if (className && isClassFileLoaded.hasOwnProperty(className) && !isInHistory[className]) {
  8720. isInHistory[className] = true;
  8721. history.push(className);
  8722. }
  8723. return Loader;
  8724. }
  8725. });
  8726. /**
  8727. * Turns on or off the "cache buster" applied to dynamically loaded scripts. Normally
  8728. * dynamically loaded scripts have an extra query parameter appended to avoid stale
  8729. * cached scripts. This method can be used to disable this mechanism, and is primarily
  8730. * useful for testing. This is done using a cookie.
  8731. * @param {Boolean} disable True to disable the cache buster.
  8732. * @param {String} [path="/"] An optional path to scope the cookie.
  8733. * @private
  8734. */
  8735. Ext.disableCacheBuster = function (disable, path) {
  8736. var date = new Date();
  8737. date.setTime(date.getTime() + (disable ? 10*365 : -1) * 24*60*60*1000);
  8738. date = date.toGMTString();
  8739. document.cookie = 'ext-cache=1; expires=' + date + '; path='+(path || '/');
  8740. };
  8741. /**
  8742. * Convenient alias of {@link Ext.Loader#require}. Please see the introduction documentation of
  8743. * {@link Ext.Loader} for examples.
  8744. * @member Ext
  8745. * @method require
  8746. */
  8747. Ext.require = alias(Loader, 'require');
  8748. /**
  8749. * Synchronous version of {@link Ext#require}, convenient alias of {@link Ext.Loader#syncRequire}.
  8750. *
  8751. * @member Ext
  8752. * @method syncRequire
  8753. */
  8754. Ext.syncRequire = alias(Loader, 'syncRequire');
  8755. /**
  8756. * Convenient shortcut to {@link Ext.Loader#exclude}
  8757. * @member Ext
  8758. * @method exclude
  8759. */
  8760. Ext.exclude = alias(Loader, 'exclude');
  8761. /**
  8762. * @member Ext
  8763. * @method onReady
  8764. * @ignore
  8765. */
  8766. Ext.onReady = function(fn, scope, options) {
  8767. Loader.onReady(fn, scope, true, options);
  8768. };
  8769. /**
  8770. * @cfg {String[]} requires
  8771. * @member Ext.Class
  8772. * List of classes that have to be loaded before instantiating this class.
  8773. * For example:
  8774. *
  8775. * Ext.define('Mother', {
  8776. * requires: ['Child'],
  8777. * giveBirth: function() {
  8778. * // we can be sure that child class is available.
  8779. * return new Child();
  8780. * }
  8781. * });
  8782. */
  8783. Class.registerPreprocessor('loader', function(cls, data, hooks, continueFn) {
  8784. var me = this,
  8785. dependencies = [],
  8786. dependency,
  8787. className = Manager.getName(cls),
  8788. i, j, ln, subLn, value, propertyName, propertyValue,
  8789. requiredMap, requiredDep;
  8790. /*
  8791. Loop through the dependencyProperties, look for string class names and push
  8792. them into a stack, regardless of whether the property's value is a string, array or object. For example:
  8793. {
  8794. extend: 'Ext.MyClass',
  8795. requires: ['Ext.some.OtherClass'],
  8796. mixins: {
  8797. observable: 'Ext.util.Observable';
  8798. }
  8799. }
  8800. which will later be transformed into:
  8801. {
  8802. extend: Ext.MyClass,
  8803. requires: [Ext.some.OtherClass],
  8804. mixins: {
  8805. observable: Ext.util.Observable;
  8806. }
  8807. }
  8808. */
  8809. for (i = 0,ln = dependencyProperties.length; i < ln; i++) {
  8810. propertyName = dependencyProperties[i];
  8811. if (data.hasOwnProperty(propertyName)) {
  8812. propertyValue = data[propertyName];
  8813. if (typeof propertyValue == 'string') {
  8814. dependencies.push(propertyValue);
  8815. }
  8816. else if (propertyValue instanceof Array) {
  8817. for (j = 0, subLn = propertyValue.length; j < subLn; j++) {
  8818. value = propertyValue[j];
  8819. if (typeof value == 'string') {
  8820. dependencies.push(value);
  8821. }
  8822. }
  8823. }
  8824. else if (typeof propertyValue != 'function') {
  8825. for (j in propertyValue) {
  8826. if (propertyValue.hasOwnProperty(j)) {
  8827. value = propertyValue[j];
  8828. if (typeof value == 'string') {
  8829. dependencies.push(value);
  8830. }
  8831. }
  8832. }
  8833. }
  8834. }
  8835. }
  8836. if (dependencies.length === 0) {
  8837. return;
  8838. }
  8839. Loader.require(dependencies, function() {
  8840. for (i = 0,ln = dependencyProperties.length; i < ln; i++) {
  8841. propertyName = dependencyProperties[i];
  8842. if (data.hasOwnProperty(propertyName)) {
  8843. propertyValue = data[propertyName];
  8844. if (typeof propertyValue == 'string') {
  8845. data[propertyName] = Manager.get(propertyValue);
  8846. }
  8847. else if (propertyValue instanceof Array) {
  8848. for (j = 0, subLn = propertyValue.length; j < subLn; j++) {
  8849. value = propertyValue[j];
  8850. if (typeof value == 'string') {
  8851. data[propertyName][j] = Manager.get(value);
  8852. }
  8853. }
  8854. }
  8855. else if (typeof propertyValue != 'function') {
  8856. for (var k in propertyValue) {
  8857. if (propertyValue.hasOwnProperty(k)) {
  8858. value = propertyValue[k];
  8859. if (typeof value == 'string') {
  8860. data[propertyName][k] = Manager.get(value);
  8861. }
  8862. }
  8863. }
  8864. }
  8865. }
  8866. }
  8867. continueFn.call(me, cls, data, hooks);
  8868. });
  8869. return false;
  8870. }, true, 'after', 'className');
  8871. /**
  8872. * @cfg {String[]} uses
  8873. * @member Ext.Class
  8874. * List of optional classes to load together with this class. These aren't neccessarily loaded before
  8875. * this class is created, but are guaranteed to be available before Ext.onReady listeners are
  8876. * invoked. For example:
  8877. *
  8878. * Ext.define('Mother', {
  8879. * uses: ['Child'],
  8880. * giveBirth: function() {
  8881. * // This code might, or might not work:
  8882. * // return new Child();
  8883. *
  8884. * // Instead use Ext.create() to load the class at the spot if not loaded already:
  8885. * return Ext.create('Child');
  8886. * }
  8887. * });
  8888. */
  8889. Manager.registerPostprocessor('uses', function(name, cls, data) {
  8890. var uses = data.uses;
  8891. if (uses) {
  8892. Loader.addUsedClasses(uses);
  8893. }
  8894. });
  8895. Manager.onCreated(Loader.historyPush);
  8896. };
  8897. // simple mechanism for automated means of injecting large amounts of dependency info
  8898. // at the appropriate time in the load cycle
  8899. if (Ext._classPathMetadata) {
  8900. Ext.Loader.addClassPathMappings(Ext._classPathMetadata);
  8901. Ext._classPathMetadata = null;
  8902. }
  8903. // initalize the default path of the framework
  8904. (function() {
  8905. var scripts = document.getElementsByTagName('script'),
  8906. currentScript = scripts[scripts.length - 1],
  8907. src = currentScript.src,
  8908. path = src.substring(0, src.lastIndexOf('/') + 1),
  8909. Loader = Ext.Loader;
  8910. Loader.setConfig({
  8911. enabled: true,
  8912. disableCaching: true,
  8913. paths: {
  8914. 'Ext': path + 'src'
  8915. }
  8916. });
  8917. })();
  8918. // allows a tools like dynatrace to deterministically detect onReady state by invoking
  8919. // a callback (intended for external consumption)
  8920. Ext._endTime = new Date().getTime();
  8921. if (Ext._beforereadyhandler){
  8922. Ext._beforereadyhandler();
  8923. }
  8924. //@tag foundation,core
  8925. //@require ../class/Loader.js
  8926. /**
  8927. * @author Brian Moeskau <brian@sencha.com>
  8928. * @docauthor Brian Moeskau <brian@sencha.com>
  8929. *
  8930. * A wrapper class for the native JavaScript Error object that adds a few useful capabilities for handling
  8931. * errors in an Ext application. When you use Ext.Error to {@link #raise} an error from within any class that
  8932. * uses the Ext 4 class system, the Error class can automatically add the source class and method from which
  8933. * the error was raised. It also includes logic to automatically log the eroor to the console, if available,
  8934. * with additional metadata about the error. In all cases, the error will always be thrown at the end so that
  8935. * execution will halt.
  8936. *
  8937. * Ext.Error also offers a global error {@link #handle handling} method that can be overridden in order to
  8938. * handle application-wide errors in a single spot. You can optionally {@link #ignore} errors altogether,
  8939. * although in a real application it's usually a better idea to override the handling function and perform
  8940. * logging or some other method of reporting the errors in a way that is meaningful to the application.
  8941. *
  8942. * At its simplest you can simply raise an error as a simple string from within any code:
  8943. *
  8944. * Example usage:
  8945. *
  8946. * Ext.Error.raise('Something bad happened!');
  8947. *
  8948. * If raised from plain JavaScript code, the error will be logged to the console (if available) and the message
  8949. * displayed. In most cases however you'll be raising errors from within a class, and it may often be useful to add
  8950. * additional metadata about the error being raised. The {@link #raise} method can also take a config object.
  8951. * In this form the `msg` attribute becomes the error description, and any other data added to the config gets
  8952. * added to the error object and, if the console is available, logged to the console for inspection.
  8953. *
  8954. * Example usage:
  8955. *
  8956. * Ext.define('Ext.Foo', {
  8957. * doSomething: function(option){
  8958. * if (someCondition === false) {
  8959. * Ext.Error.raise({
  8960. * msg: 'You cannot do that!',
  8961. * option: option, // whatever was passed into the method
  8962. * 'error code': 100 // other arbitrary info
  8963. * });
  8964. * }
  8965. * }
  8966. * });
  8967. *
  8968. * If a console is available (that supports the `console.dir` function) you'll see console output like:
  8969. *
  8970. * An error was raised with the following data:
  8971. * option: Object { foo: "bar"}
  8972. * foo: "bar"
  8973. * error code: 100
  8974. * msg: "You cannot do that!"
  8975. * sourceClass: "Ext.Foo"
  8976. * sourceMethod: "doSomething"
  8977. *
  8978. * uncaught exception: You cannot do that!
  8979. *
  8980. * As you can see, the error will report exactly where it was raised and will include as much information as the
  8981. * raising code can usefully provide.
  8982. *
  8983. * If you want to handle all application errors globally you can simply override the static {@link #handle} method
  8984. * and provide whatever handling logic you need. If the method returns true then the error is considered handled
  8985. * and will not be thrown to the browser. If anything but true is returned then the error will be thrown normally.
  8986. *
  8987. * Example usage:
  8988. *
  8989. * Ext.Error.handle = function(err) {
  8990. * if (err.someProperty == 'NotReallyAnError') {
  8991. * // maybe log something to the application here if applicable
  8992. * return true;
  8993. * }
  8994. * // any non-true return value (including none) will cause the error to be thrown
  8995. * }
  8996. *
  8997. */
  8998. Ext.Error = Ext.extend(Error, {
  8999. statics: {
  9000. /**
  9001. * @property {Boolean} ignore
  9002. * Static flag that can be used to globally disable error reporting to the browser if set to true
  9003. * (defaults to false). Note that if you ignore Ext errors it's likely that some other code may fail
  9004. * and throw a native JavaScript error thereafter, so use with caution. In most cases it will probably
  9005. * be preferable to supply a custom error {@link #handle handling} function instead.
  9006. *
  9007. * Example usage:
  9008. *
  9009. * Ext.Error.ignore = true;
  9010. *
  9011. * @static
  9012. */
  9013. ignore: false,
  9014. /**
  9015. * @property {Boolean} notify
  9016. * Static flag that can be used to globally control error notification to the user. Unlike
  9017. * Ex.Error.ignore, this does not effect exceptions. They are still thrown. This value can be
  9018. * set to false to disable the alert notification (default is true for IE6 and IE7).
  9019. *
  9020. * Only the first error will generate an alert. Internally this flag is set to false when the
  9021. * first error occurs prior to displaying the alert.
  9022. *
  9023. * This flag is not used in a release build.
  9024. *
  9025. * Example usage:
  9026. *
  9027. * Ext.Error.notify = false;
  9028. *
  9029. * @static
  9030. */
  9031. //notify: Ext.isIE6 || Ext.isIE7,
  9032. /**
  9033. * Raise an error that can include additional data and supports automatic console logging if available.
  9034. * You can pass a string error message or an object with the `msg` attribute which will be used as the
  9035. * error message. The object can contain any other name-value attributes (or objects) to be logged
  9036. * along with the error.
  9037. *
  9038. * Note that after displaying the error message a JavaScript error will ultimately be thrown so that
  9039. * execution will halt.
  9040. *
  9041. * Example usage:
  9042. *
  9043. * Ext.Error.raise('A simple string error message');
  9044. *
  9045. * // or...
  9046. *
  9047. * Ext.define('Ext.Foo', {
  9048. * doSomething: function(option){
  9049. * if (someCondition === false) {
  9050. * Ext.Error.raise({
  9051. * msg: 'You cannot do that!',
  9052. * option: option, // whatever was passed into the method
  9053. * 'error code': 100 // other arbitrary info
  9054. * });
  9055. * }
  9056. * }
  9057. * });
  9058. *
  9059. * @param {String/Object} err The error message string, or an object containing the attribute "msg" that will be
  9060. * used as the error message. Any other data included in the object will also be logged to the browser console,
  9061. * if available.
  9062. * @static
  9063. */
  9064. raise: function(err){
  9065. err = err || {};
  9066. if (Ext.isString(err)) {
  9067. err = { msg: err };
  9068. }
  9069. var method = this.raise.caller,
  9070. msg;
  9071. if (method) {
  9072. if (method.$name) {
  9073. err.sourceMethod = method.$name;
  9074. }
  9075. if (method.$owner) {
  9076. err.sourceClass = method.$owner.$className;
  9077. }
  9078. }
  9079. if (Ext.Error.handle(err) !== true) {
  9080. msg = Ext.Error.prototype.toString.call(err);
  9081. Ext.log({
  9082. msg: msg,
  9083. level: 'error',
  9084. dump: err,
  9085. stack: true
  9086. });
  9087. throw new Ext.Error(err);
  9088. }
  9089. },
  9090. /**
  9091. * Globally handle any Ext errors that may be raised, optionally providing custom logic to
  9092. * handle different errors individually. Return true from the function to bypass throwing the
  9093. * error to the browser, otherwise the error will be thrown and execution will halt.
  9094. *
  9095. * Example usage:
  9096. *
  9097. * Ext.Error.handle = function(err) {
  9098. * if (err.someProperty == 'NotReallyAnError') {
  9099. * // maybe log something to the application here if applicable
  9100. * return true;
  9101. * }
  9102. * // any non-true return value (including none) will cause the error to be thrown
  9103. * }
  9104. *
  9105. * @param {Ext.Error} err The Ext.Error object being raised. It will contain any attributes that were originally
  9106. * raised with it, plus properties about the method and class from which the error originated (if raised from a
  9107. * class that uses the Ext 4 class system).
  9108. * @static
  9109. */
  9110. handle: function(){
  9111. return Ext.Error.ignore;
  9112. }
  9113. },
  9114. // This is the standard property that is the name of the constructor.
  9115. name: 'Ext.Error',
  9116. /**
  9117. * Creates new Error object.
  9118. * @param {String/Object} config The error message string, or an object containing the
  9119. * attribute "msg" that will be used as the error message. Any other data included in
  9120. * the object will be applied to the error instance and logged to the browser console, if available.
  9121. */
  9122. constructor: function(config){
  9123. if (Ext.isString(config)) {
  9124. config = { msg: config };
  9125. }
  9126. var me = this;
  9127. Ext.apply(me, config);
  9128. me.message = me.message || me.msg; // 'message' is standard ('msg' is non-standard)
  9129. // note: the above does not work in old WebKit (me.message is readonly) (Safari 4)
  9130. },
  9131. /**
  9132. * Provides a custom string representation of the error object. This is an override of the base JavaScript
  9133. * `Object.toString` method, which is useful so that when logged to the browser console, an error object will
  9134. * be displayed with a useful message instead of `[object Object]`, the default `toString` result.
  9135. *
  9136. * The default implementation will include the error message along with the raising class and method, if available,
  9137. * but this can be overridden with a custom implementation either at the prototype level (for all errors) or on
  9138. * a particular error instance, if you want to provide a custom description that will show up in the console.
  9139. * @return {String} The error message. If raised from within the Ext 4 class system, the error message will also
  9140. * include the raising class and method names, if available.
  9141. */
  9142. toString: function(){
  9143. var me = this,
  9144. className = me.sourceClass ? me.sourceClass : '',
  9145. methodName = me.sourceMethod ? '.' + me.sourceMethod + '(): ' : '',
  9146. msg = me.msg || '(No description provided)';
  9147. return className + methodName + msg;
  9148. }
  9149. });
  9150. /*
  9151. * Create a function that will throw an error if called (in debug mode) with a message that
  9152. * indicates the method has been removed.
  9153. * @param {String} suggestion Optional text to include in the message (a workaround perhaps).
  9154. * @return {Function} The generated function.
  9155. * @private
  9156. */
  9157. Ext.deprecated = function (suggestion) {
  9158. return Ext.emptyFn;
  9159. };
  9160. /*
  9161. * This mechanism is used to notify the user of the first error encountered on the page. This
  9162. * was previously internal to Ext.Error.raise and is a desirable feature since errors often
  9163. * slip silently under the radar. It cannot live in Ext.Error.raise since there are times
  9164. * where exceptions are handled in a try/catch.
  9165. */
  9166. //@tag extras,core
  9167. //@require ../lang/Error.js
  9168. /**
  9169. * Modified version of [Douglas Crockford's JSON.js][dc] that doesn't
  9170. * mess with the Object prototype.
  9171. *
  9172. * [dc]: http://www.json.org/js.html
  9173. *
  9174. * @singleton
  9175. */
  9176. Ext.JSON = (new(function() {
  9177. var me = this,
  9178. encodingFunction,
  9179. decodingFunction,
  9180. useNative = null,
  9181. useHasOwn = !! {}.hasOwnProperty,
  9182. isNative = function() {
  9183. if (useNative === null) {
  9184. useNative = Ext.USE_NATIVE_JSON && window.JSON && JSON.toString() == '[object JSON]';
  9185. }
  9186. return useNative;
  9187. },
  9188. pad = function(n) {
  9189. return n < 10 ? "0" + n : n;
  9190. },
  9191. doDecode = function(json) {
  9192. return eval("(" + json + ')');
  9193. },
  9194. doEncode = function(o, newline) {
  9195. // http://jsperf.com/is-undefined
  9196. if (o === null || o === undefined) {
  9197. return "null";
  9198. } else if (Ext.isDate(o)) {
  9199. return Ext.JSON.encodeDate(o);
  9200. } else if (Ext.isString(o)) {
  9201. return Ext.JSON.encodeString(o);
  9202. } else if (typeof o == "number") {
  9203. //don't use isNumber here, since finite checks happen inside isNumber
  9204. return isFinite(o) ? String(o) : "null";
  9205. } else if (Ext.isBoolean(o)) {
  9206. return String(o);
  9207. }
  9208. // Allow custom zerialization by adding a toJSON method to any object type.
  9209. // Date/String have a toJSON in some environments, so check these first.
  9210. else if (o.toJSON) {
  9211. return o.toJSON();
  9212. } else if (Ext.isArray(o)) {
  9213. return encodeArray(o, newline);
  9214. } else if (Ext.isObject(o)) {
  9215. return encodeObject(o, newline);
  9216. } else if (typeof o === "function") {
  9217. return "null";
  9218. }
  9219. return 'undefined';
  9220. },
  9221. m = {
  9222. "\b": '\\b',
  9223. "\t": '\\t',
  9224. "\n": '\\n',
  9225. "\f": '\\f',
  9226. "\r": '\\r',
  9227. '"': '\\"',
  9228. "\\": '\\\\',
  9229. '\x0b': '\\u000b' //ie doesn't handle \v
  9230. },
  9231. charToReplace = /[\\\"\x00-\x1f\x7f-\uffff]/g,
  9232. encodeString = function(s) {
  9233. return '"' + s.replace(charToReplace, function(a) {
  9234. var c = m[a];
  9235. return typeof c === 'string' ? c : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
  9236. }) + '"';
  9237. },
  9238. encodeArray = function(o, newline) {
  9239. var a = ["[", ""], // Note empty string in case there are no serializable members.
  9240. len = o.length,
  9241. i;
  9242. for (i = 0; i < len; i += 1) {
  9243. a.push(Ext.JSON.encodeValue(o[i]), ',');
  9244. }
  9245. // Overwrite trailing comma (or empty string)
  9246. a[a.length - 1] = ']';
  9247. return a.join("");
  9248. },
  9249. encodeObject = function(o, newline) {
  9250. var a = ["{", ""], // Note empty string in case there are no serializable members.
  9251. i;
  9252. for (i in o) {
  9253. if (!useHasOwn || o.hasOwnProperty(i)) {
  9254. a.push(Ext.JSON.encodeValue(i), ":", Ext.JSON.encodeValue(o[i]), ',');
  9255. }
  9256. }
  9257. // Overwrite trailing comma (or empty string)
  9258. a[a.length - 1] = '}';
  9259. return a.join("");
  9260. };
  9261. /**
  9262. * Encodes a String. This returns the actual string which is inserted into the JSON string as the literal
  9263. * expression. **The returned value includes enclosing double quotation marks.**
  9264. *
  9265. * To override this:
  9266. *
  9267. * Ext.JSON.encodeString = function(s) {
  9268. * return 'Foo' + s;
  9269. * };
  9270. *
  9271. * @param {String} s The String to encode
  9272. * @return {String} The string literal to use in a JSON string.
  9273. * @method
  9274. */
  9275. me.encodeString = encodeString;
  9276. /**
  9277. * The function which {@link #encode} uses to encode all javascript values to their JSON representations
  9278. * when {@link Ext#USE_NATIVE_JSON} is `false`.
  9279. *
  9280. * This is made public so that it can be replaced with a custom implementation.
  9281. *
  9282. * @param {Object} o Any javascript value to be converted to its JSON representation
  9283. * @return {String} The JSON representation of the passed value.
  9284. * @method
  9285. */
  9286. me.encodeValue = doEncode;
  9287. /**
  9288. * Encodes a Date. This returns the actual string which is inserted into the JSON string as the literal
  9289. * expression. **The returned value includes enclosing double quotation marks.**
  9290. *
  9291. * The default return format is `"yyyy-mm-ddThh:mm:ss"`.
  9292. *
  9293. * To override this:
  9294. *
  9295. * Ext.JSON.encodeDate = function(d) {
  9296. * return Ext.Date.format(d, '"Y-m-d"');
  9297. * };
  9298. *
  9299. * @param {Date} d The Date to encode
  9300. * @return {String} The string literal to use in a JSON string.
  9301. */
  9302. me.encodeDate = function(o) {
  9303. return '"' + o.getFullYear() + "-"
  9304. + pad(o.getMonth() + 1) + "-"
  9305. + pad(o.getDate()) + "T"
  9306. + pad(o.getHours()) + ":"
  9307. + pad(o.getMinutes()) + ":"
  9308. + pad(o.getSeconds()) + '"';
  9309. };
  9310. /**
  9311. * Encodes an Object, Array or other value.
  9312. *
  9313. * If the environment's native JSON encoding is not being used ({@link Ext#USE_NATIVE_JSON} is not set,
  9314. * or the environment does not support it), then ExtJS's encoding will be used. This allows the developer
  9315. * to add a `toJSON` method to their classes which need serializing to return a valid JSON representation
  9316. * of the object.
  9317. *
  9318. * @param {Object} o The variable to encode
  9319. * @return {String} The JSON string
  9320. */
  9321. me.encode = function(o) {
  9322. if (!encodingFunction) {
  9323. // setup encoding function on first access
  9324. encodingFunction = isNative() ? JSON.stringify : me.encodeValue;
  9325. }
  9326. return encodingFunction(o);
  9327. };
  9328. /**
  9329. * Decodes (parses) a JSON string to an object. If the JSON is invalid, this function throws
  9330. * a SyntaxError unless the safe option is set.
  9331. *
  9332. * @param {String} json The JSON string
  9333. * @param {Boolean} [safe=false] True to return null, false to throw an exception if the JSON is invalid.
  9334. * @return {Object} The resulting object
  9335. */
  9336. me.decode = function(json, safe) {
  9337. if (!decodingFunction) {
  9338. // setup decoding function on first access
  9339. decodingFunction = isNative() ? JSON.parse : doDecode;
  9340. }
  9341. try {
  9342. return decodingFunction(json);
  9343. } catch (e) {
  9344. if (safe === true) {
  9345. return null;
  9346. }
  9347. Ext.Error.raise({
  9348. sourceClass: "Ext.JSON",
  9349. sourceMethod: "decode",
  9350. msg: "You're trying to decode an invalid JSON String: " + json
  9351. });
  9352. }
  9353. };
  9354. })());
  9355. /**
  9356. * Shorthand for {@link Ext.JSON#encode}
  9357. * @member Ext
  9358. * @method encode
  9359. * @inheritdoc Ext.JSON#encode
  9360. */
  9361. Ext.encode = Ext.JSON.encode;
  9362. /**
  9363. * Shorthand for {@link Ext.JSON#decode}
  9364. * @member Ext
  9365. * @method decode
  9366. * @inheritdoc Ext.JSON#decode
  9367. */
  9368. Ext.decode = Ext.JSON.decode;
  9369. //@tag extras,core
  9370. //@require misc/JSON.js
  9371. /**
  9372. * @class Ext
  9373. *
  9374. * The Ext namespace (global object) encapsulates all classes, singletons, and
  9375. * utility methods provided by Sencha's libraries.
  9376. *
  9377. * Most user interface Components are at a lower level of nesting in the namespace,
  9378. * but many common utility functions are provided as direct properties of the Ext namespace.
  9379. *
  9380. * Also many frequently used methods from other classes are provided as shortcuts
  9381. * within the Ext namespace. For example {@link Ext#getCmp Ext.getCmp} aliases
  9382. * {@link Ext.ComponentManager#get Ext.ComponentManager.get}.
  9383. *
  9384. * Many applications are initiated with {@link Ext#onReady Ext.onReady} which is
  9385. * called once the DOM is ready. This ensures all scripts have been loaded,
  9386. * preventing dependency issues. For example:
  9387. *
  9388. * Ext.onReady(function(){
  9389. * new Ext.Component({
  9390. * renderTo: document.body,
  9391. * html: 'DOM ready!'
  9392. * });
  9393. * });
  9394. *
  9395. * For more information about how to use the Ext classes, see:
  9396. *
  9397. * - <a href="http://www.sencha.com/learn/">The Learning Center</a>
  9398. * - <a href="http://www.sencha.com/learn/Ext_FAQ">The FAQ</a>
  9399. * - <a href="http://www.sencha.com/forum/">The forums</a>
  9400. *
  9401. * @singleton
  9402. */
  9403. Ext.apply(Ext, {
  9404. userAgent: navigator.userAgent.toLowerCase(),
  9405. cache: {},
  9406. idSeed: 1000,
  9407. windowId: 'ext-window',
  9408. documentId: 'ext-document',
  9409. /**
  9410. * True when the document is fully initialized and ready for action
  9411. */
  9412. isReady: false,
  9413. /**
  9414. * True to automatically uncache orphaned Ext.Elements periodically
  9415. */
  9416. enableGarbageCollector: true,
  9417. /**
  9418. * True to automatically purge event listeners during garbageCollection.
  9419. */
  9420. enableListenerCollection: true,
  9421. addCacheEntry: function(id, el, dom) {
  9422. dom = dom || el.dom;
  9423. var key = id || (el && el.id) || dom.id,
  9424. entry = Ext.cache[key] || (Ext.cache[key] = {
  9425. data: {},
  9426. events: {},
  9427. dom: dom,
  9428. // Skip garbage collection for special elements (window, document, iframes)
  9429. skipGarbageCollection: !!(dom.getElementById || dom.navigator)
  9430. });
  9431. if (el) {
  9432. el.$cache = entry;
  9433. // Inject the back link from the cache in case the cache entry
  9434. // had already been created by Ext.fly. Ext.fly creates a cache entry with no el link.
  9435. entry.el = el;
  9436. }
  9437. return entry;
  9438. },
  9439. updateCacheEntry: function(cacheItem, dom){
  9440. cacheItem.dom = dom;
  9441. if (cacheItem.el) {
  9442. cacheItem.el.dom = dom;
  9443. }
  9444. return cacheItem;
  9445. },
  9446. /**
  9447. * Generates unique ids. If the element already has an id, it is unchanged
  9448. * @param {HTMLElement/Ext.Element} [el] The element to generate an id for
  9449. * @param {String} prefix (optional) Id prefix (defaults "ext-gen")
  9450. * @return {String} The generated Id.
  9451. */
  9452. id: function(el, prefix) {
  9453. var me = this,
  9454. sandboxPrefix = '';
  9455. el = Ext.getDom(el, true) || {};
  9456. if (el === document) {
  9457. el.id = me.documentId;
  9458. }
  9459. else if (el === window) {
  9460. el.id = me.windowId;
  9461. }
  9462. if (!el.id) {
  9463. if (me.isSandboxed) {
  9464. sandboxPrefix = Ext.sandboxName.toLowerCase() + '-';
  9465. }
  9466. el.id = sandboxPrefix + (prefix || "ext-gen") + (++Ext.idSeed);
  9467. }
  9468. return el.id;
  9469. },
  9470. escapeId: (function(){
  9471. var validIdRe = /^[a-zA-Z_][a-zA-Z0-9_\-]*$/i,
  9472. escapeRx = /([\W]{1})/g,
  9473. leadingNumRx = /^(\d)/g,
  9474. escapeFn = function(match, capture){
  9475. return "\\" + capture;
  9476. },
  9477. numEscapeFn = function(match, capture){
  9478. return '\\00' + capture.charCodeAt(0).toString(16) + ' ';
  9479. };
  9480. return function(id) {
  9481. return validIdRe.test(id)
  9482. ? id
  9483. // replace the number portion last to keep the trailing ' '
  9484. // from being escaped
  9485. : id.replace(escapeRx, escapeFn)
  9486. .replace(leadingNumRx, numEscapeFn);
  9487. };
  9488. }()),
  9489. /**
  9490. * Returns the current document body as an {@link Ext.Element}.
  9491. * @return Ext.Element The document body
  9492. */
  9493. getBody: (function() {
  9494. var body;
  9495. return function() {
  9496. return body || (body = Ext.get(document.body));
  9497. };
  9498. }()),
  9499. /**
  9500. * Returns the current document head as an {@link Ext.Element}.
  9501. * @return Ext.Element The document head
  9502. * @method
  9503. */
  9504. getHead: (function() {
  9505. var head;
  9506. return function() {
  9507. return head || (head = Ext.get(document.getElementsByTagName("head")[0]));
  9508. };
  9509. }()),
  9510. /**
  9511. * Returns the current HTML document object as an {@link Ext.Element}.
  9512. * @return Ext.Element The document
  9513. */
  9514. getDoc: (function() {
  9515. var doc;
  9516. return function() {
  9517. return doc || (doc = Ext.get(document));
  9518. };
  9519. }()),
  9520. /**
  9521. * This is shorthand reference to {@link Ext.ComponentManager#get}.
  9522. * Looks up an existing {@link Ext.Component Component} by {@link Ext.Component#id id}
  9523. *
  9524. * @param {String} id The component {@link Ext.Component#id id}
  9525. * @return Ext.Component The Component, `undefined` if not found, or `null` if a
  9526. * Class was found.
  9527. */
  9528. getCmp: function(id) {
  9529. return Ext.ComponentManager.get(id);
  9530. },
  9531. /**
  9532. * Returns the current orientation of the mobile device
  9533. * @return {String} Either 'portrait' or 'landscape'
  9534. */
  9535. getOrientation: function() {
  9536. return window.innerHeight > window.innerWidth ? 'portrait' : 'landscape';
  9537. },
  9538. /**
  9539. * Attempts to destroy any objects passed to it by removing all event listeners, removing them from the
  9540. * DOM (if applicable) and calling their destroy functions (if available). This method is primarily
  9541. * intended for arguments of type {@link Ext.Element} and {@link Ext.Component}, but any subclass of
  9542. * {@link Ext.util.Observable} can be passed in. Any number of elements and/or components can be
  9543. * passed into this function in a single call as separate arguments.
  9544. *
  9545. * @param {Ext.Element/Ext.Component/Ext.Element[]/Ext.Component[]...} args
  9546. * An {@link Ext.Element}, {@link Ext.Component}, or an Array of either of these to destroy
  9547. */
  9548. destroy: function() {
  9549. var ln = arguments.length,
  9550. i, arg;
  9551. for (i = 0; i < ln; i++) {
  9552. arg = arguments[i];
  9553. if (arg) {
  9554. if (Ext.isArray(arg)) {
  9555. this.destroy.apply(this, arg);
  9556. }
  9557. else if (Ext.isFunction(arg.destroy)) {
  9558. arg.destroy();
  9559. }
  9560. else if (arg.dom) {
  9561. arg.remove();
  9562. }
  9563. }
  9564. }
  9565. },
  9566. /**
  9567. * Execute a callback function in a particular scope. If no function is passed the call is ignored.
  9568. *
  9569. * For example, these lines are equivalent:
  9570. *
  9571. * Ext.callback(myFunc, this, [arg1, arg2]);
  9572. * Ext.isFunction(myFunc) && myFunc.apply(this, [arg1, arg2]);
  9573. *
  9574. * @param {Function} callback The callback to execute
  9575. * @param {Object} [scope] The scope to execute in
  9576. * @param {Array} [args] The arguments to pass to the function
  9577. * @param {Number} [delay] Pass a number to delay the call by a number of milliseconds.
  9578. */
  9579. callback: function(callback, scope, args, delay){
  9580. if(Ext.isFunction(callback)){
  9581. args = args || [];
  9582. scope = scope || window;
  9583. if (delay) {
  9584. Ext.defer(callback, delay, scope, args);
  9585. } else {
  9586. callback.apply(scope, args);
  9587. }
  9588. }
  9589. },
  9590. /**
  9591. * Alias for {@link Ext.String#htmlEncode}.
  9592. * @inheritdoc Ext.String#htmlEncode
  9593. * @ignore
  9594. */
  9595. htmlEncode : function(value) {
  9596. return Ext.String.htmlEncode(value);
  9597. },
  9598. /**
  9599. * Alias for {@link Ext.String#htmlDecode}.
  9600. * @inheritdoc Ext.String#htmlDecode
  9601. * @ignore
  9602. */
  9603. htmlDecode : function(value) {
  9604. return Ext.String.htmlDecode(value);
  9605. },
  9606. /**
  9607. * Alias for {@link Ext.String#urlAppend}.
  9608. * @inheritdoc Ext.String#urlAppend
  9609. * @ignore
  9610. */
  9611. urlAppend : function(url, s) {
  9612. return Ext.String.urlAppend(url, s);
  9613. }
  9614. });
  9615. Ext.ns = Ext.namespace;
  9616. // for old browsers
  9617. window.undefined = window.undefined;
  9618. /**
  9619. * @class Ext
  9620. */
  9621. (function(){
  9622. /*
  9623. FF 3.6 - Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.17) Gecko/20110420 Firefox/3.6.17
  9624. FF 4.0.1 - Mozilla/5.0 (Windows NT 5.1; rv:2.0.1) Gecko/20100101 Firefox/4.0.1
  9625. FF 5.0 - Mozilla/5.0 (Windows NT 6.1; WOW64; rv:5.0) Gecko/20100101 Firefox/5.0
  9626. IE6 - Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1;)
  9627. IE7 - Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; SV1;)
  9628. IE8 - Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0)
  9629. IE9 - Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E)
  9630. Chrome 11 - Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.60 Safari/534.24
  9631. Safari 5 - Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5 Safari/533.21.1
  9632. Opera 11.11 - Opera/9.80 (Windows NT 6.1; U; en) Presto/2.8.131 Version/11.11
  9633. */
  9634. var check = function(regex){
  9635. return regex.test(Ext.userAgent);
  9636. },
  9637. isStrict = document.compatMode == "CSS1Compat",
  9638. version = function (is, regex) {
  9639. var m;
  9640. return (is && (m = regex.exec(Ext.userAgent))) ? parseFloat(m[1]) : 0;
  9641. },
  9642. docMode = document.documentMode,
  9643. isOpera = check(/opera/),
  9644. isOpera10_5 = isOpera && check(/version\/10\.5/),
  9645. isChrome = check(/\bchrome\b/),
  9646. isWebKit = check(/webkit/),
  9647. isSafari = !isChrome && check(/safari/),
  9648. isSafari2 = isSafari && check(/applewebkit\/4/), // unique to Safari 2
  9649. isSafari3 = isSafari && check(/version\/3/),
  9650. isSafari4 = isSafari && check(/version\/4/),
  9651. isSafari5_0 = isSafari && check(/version\/5\.0/),
  9652. isSafari5 = isSafari && check(/version\/5/),
  9653. isIE = !isOpera && check(/msie/),
  9654. isIE7 = isIE && ((check(/msie 7/) && docMode != 8 && docMode != 9) || docMode == 7),
  9655. isIE8 = isIE && ((check(/msie 8/) && docMode != 7 && docMode != 9) || docMode == 8),
  9656. isIE9 = isIE && ((check(/msie 9/) && docMode != 7 && docMode != 8) || docMode == 9),
  9657. isIE6 = isIE && check(/msie 6/),
  9658. isGecko = !isWebKit && check(/gecko/),
  9659. isGecko3 = isGecko && check(/rv:1\.9/),
  9660. isGecko4 = isGecko && check(/rv:2\.0/),
  9661. isGecko5 = isGecko && check(/rv:5\./),
  9662. isGecko10 = isGecko && check(/rv:10\./),
  9663. isFF3_0 = isGecko3 && check(/rv:1\.9\.0/),
  9664. isFF3_5 = isGecko3 && check(/rv:1\.9\.1/),
  9665. isFF3_6 = isGecko3 && check(/rv:1\.9\.2/),
  9666. isWindows = check(/windows|win32/),
  9667. isMac = check(/macintosh|mac os x/),
  9668. isLinux = check(/linux/),
  9669. scrollbarSize = null,
  9670. chromeVersion = version(true, /\bchrome\/(\d+\.\d+)/),
  9671. firefoxVersion = version(true, /\bfirefox\/(\d+\.\d+)/),
  9672. ieVersion = version(isIE, /msie (\d+\.\d+)/),
  9673. operaVersion = version(isOpera, /version\/(\d+\.\d+)/),
  9674. safariVersion = version(isSafari, /version\/(\d+\.\d+)/),
  9675. webKitVersion = version(isWebKit, /webkit\/(\d+\.\d+)/),
  9676. isSecure = /^https/i.test(window.location.protocol),
  9677. nullLog;
  9678. // remove css image flicker
  9679. try {
  9680. document.execCommand("BackgroundImageCache", false, true);
  9681. } catch(e) {}
  9682. nullLog = function () {};
  9683. nullLog.info = nullLog.warn = nullLog.error = Ext.emptyFn;
  9684. Ext.setVersion('extjs', '4.1.1.1');
  9685. Ext.apply(Ext, {
  9686. /**
  9687. * @property {String} SSL_SECURE_URL
  9688. * URL to a blank file used by Ext when in secure mode for iframe src and onReady src
  9689. * to prevent the IE insecure content warning (`'about:blank'`, except for IE
  9690. * in secure mode, which is `'javascript:""'`).
  9691. */
  9692. SSL_SECURE_URL : isSecure && isIE ? 'javascript:\'\'' : 'about:blank',
  9693. /**
  9694. * @property {Boolean} enableFx
  9695. * True if the {@link Ext.fx.Anim} Class is available.
  9696. */
  9697. /**
  9698. * @property {Boolean} scopeResetCSS
  9699. * True to scope the reset CSS to be just applied to Ext components. Note that this
  9700. * wraps root containers with an additional element. Also remember that when you turn
  9701. * on this option, you have to use ext-all-scoped (unless you use the bootstrap.js to
  9702. * load your javascript, in which case it will be handled for you).
  9703. */
  9704. scopeResetCSS : Ext.buildSettings.scopeResetCSS,
  9705. /**
  9706. * @property {String} resetCls
  9707. * The css class used to wrap Ext components when the {@link #scopeResetCSS} option
  9708. * is used.
  9709. */
  9710. resetCls: Ext.buildSettings.baseCSSPrefix + 'reset',
  9711. /**
  9712. * @property {Boolean} enableNestedListenerRemoval
  9713. * **Experimental.** True to cascade listener removal to child elements when an element
  9714. * is removed. Currently not optimized for performance.
  9715. */
  9716. enableNestedListenerRemoval : false,
  9717. /**
  9718. * @property {Boolean} USE_NATIVE_JSON
  9719. * Indicates whether to use native browser parsing for JSON methods.
  9720. * This option is ignored if the browser does not support native JSON methods.
  9721. *
  9722. * **Note:** Native JSON methods will not work with objects that have functions.
  9723. * Also, property names must be quoted, otherwise the data will not parse.
  9724. */
  9725. USE_NATIVE_JSON : false,
  9726. /**
  9727. * Returns the dom node for the passed String (id), dom node, or Ext.Element.
  9728. * Optional 'strict' flag is needed for IE since it can return 'name' and
  9729. * 'id' elements by using getElementById.
  9730. *
  9731. * Here are some examples:
  9732. *
  9733. * // gets dom node based on id
  9734. * var elDom = Ext.getDom('elId');
  9735. * // gets dom node based on the dom node
  9736. * var elDom1 = Ext.getDom(elDom);
  9737. *
  9738. * // If we don&#39;t know if we are working with an
  9739. * // Ext.Element or a dom node use Ext.getDom
  9740. * function(el){
  9741. * var dom = Ext.getDom(el);
  9742. * // do something with the dom node
  9743. * }
  9744. *
  9745. * **Note:** the dom node to be found actually needs to exist (be rendered, etc)
  9746. * when this method is called to be successful.
  9747. *
  9748. * @param {String/HTMLElement/Ext.Element} el
  9749. * @return HTMLElement
  9750. */
  9751. getDom : function(el, strict) {
  9752. if (!el || !document) {
  9753. return null;
  9754. }
  9755. if (el.dom) {
  9756. return el.dom;
  9757. } else {
  9758. if (typeof el == 'string') {
  9759. var e = Ext.getElementById(el);
  9760. // IE returns elements with the 'name' and 'id' attribute.
  9761. // we do a strict check to return the element with only the id attribute
  9762. if (e && isIE && strict) {
  9763. if (el == e.getAttribute('id')) {
  9764. return e;
  9765. } else {
  9766. return null;
  9767. }
  9768. }
  9769. return e;
  9770. } else {
  9771. return el;
  9772. }
  9773. }
  9774. },
  9775. /**
  9776. * Removes a DOM node from the document.
  9777. *
  9778. * Removes this element from the document, removes all DOM event listeners, and
  9779. * deletes the cache reference. All DOM event listeners are removed from this element.
  9780. * If {@link Ext#enableNestedListenerRemoval Ext.enableNestedListenerRemoval} is
  9781. * `true`, then DOM event listeners are also removed from all child nodes.
  9782. * The body node will be ignored if passed in.
  9783. *
  9784. * @param {HTMLElement} node The node to remove
  9785. * @method
  9786. */
  9787. removeNode : isIE6 || isIE7 || isIE8
  9788. ? (function() {
  9789. var d;
  9790. return function(n){
  9791. if(n && n.tagName.toUpperCase() != 'BODY'){
  9792. (Ext.enableNestedListenerRemoval) ? Ext.EventManager.purgeElement(n) : Ext.EventManager.removeAll(n);
  9793. var cache = Ext.cache,
  9794. id = n.id;
  9795. if (cache[id]) {
  9796. delete cache[id].dom;
  9797. delete cache[id];
  9798. }
  9799. if (isIE8 && n.parentNode) {
  9800. n.parentNode.removeChild(n);
  9801. }
  9802. d = d || document.createElement('div');
  9803. d.appendChild(n);
  9804. d.innerHTML = '';
  9805. }
  9806. };
  9807. }())
  9808. : function(n) {
  9809. if (n && n.parentNode && n.tagName.toUpperCase() != 'BODY') {
  9810. (Ext.enableNestedListenerRemoval) ? Ext.EventManager.purgeElement(n) : Ext.EventManager.removeAll(n);
  9811. var cache = Ext.cache,
  9812. id = n.id;
  9813. if (cache[id]) {
  9814. delete cache[id].dom;
  9815. delete cache[id];
  9816. }
  9817. n.parentNode.removeChild(n);
  9818. }
  9819. },
  9820. isStrict: isStrict,
  9821. isIEQuirks: isIE && !isStrict,
  9822. /**
  9823. * True if the detected browser is Opera.
  9824. * @type Boolean
  9825. */
  9826. isOpera : isOpera,
  9827. /**
  9828. * True if the detected browser is Opera 10.5x.
  9829. * @type Boolean
  9830. */
  9831. isOpera10_5 : isOpera10_5,
  9832. /**
  9833. * True if the detected browser uses WebKit.
  9834. * @type Boolean
  9835. */
  9836. isWebKit : isWebKit,
  9837. /**
  9838. * True if the detected browser is Chrome.
  9839. * @type Boolean
  9840. */
  9841. isChrome : isChrome,
  9842. /**
  9843. * True if the detected browser is Safari.
  9844. * @type Boolean
  9845. */
  9846. isSafari : isSafari,
  9847. /**
  9848. * True if the detected browser is Safari 3.x.
  9849. * @type Boolean
  9850. */
  9851. isSafari3 : isSafari3,
  9852. /**
  9853. * True if the detected browser is Safari 4.x.
  9854. * @type Boolean
  9855. */
  9856. isSafari4 : isSafari4,
  9857. /**
  9858. * True if the detected browser is Safari 5.x.
  9859. * @type Boolean
  9860. */
  9861. isSafari5 : isSafari5,
  9862. /**
  9863. * True if the detected browser is Safari 5.0.x.
  9864. * @type Boolean
  9865. */
  9866. isSafari5_0 : isSafari5_0,
  9867. /**
  9868. * True if the detected browser is Safari 2.x.
  9869. * @type Boolean
  9870. */
  9871. isSafari2 : isSafari2,
  9872. /**
  9873. * True if the detected browser is Internet Explorer.
  9874. * @type Boolean
  9875. */
  9876. isIE : isIE,
  9877. /**
  9878. * True if the detected browser is Internet Explorer 6.x.
  9879. * @type Boolean
  9880. */
  9881. isIE6 : isIE6,
  9882. /**
  9883. * True if the detected browser is Internet Explorer 7.x.
  9884. * @type Boolean
  9885. */
  9886. isIE7 : isIE7,
  9887. /**
  9888. * True if the detected browser is Internet Explorer 8.x.
  9889. * @type Boolean
  9890. */
  9891. isIE8 : isIE8,
  9892. /**
  9893. * True if the detected browser is Internet Explorer 9.x.
  9894. * @type Boolean
  9895. */
  9896. isIE9 : isIE9,
  9897. /**
  9898. * True if the detected browser uses the Gecko layout engine (e.g. Mozilla, Firefox).
  9899. * @type Boolean
  9900. */
  9901. isGecko : isGecko,
  9902. /**
  9903. * True if the detected browser uses a Gecko 1.9+ layout engine (e.g. Firefox 3.x).
  9904. * @type Boolean
  9905. */
  9906. isGecko3 : isGecko3,
  9907. /**
  9908. * True if the detected browser uses a Gecko 2.0+ layout engine (e.g. Firefox 4.x).
  9909. * @type Boolean
  9910. */
  9911. isGecko4 : isGecko4,
  9912. /**
  9913. * True if the detected browser uses a Gecko 5.0+ layout engine (e.g. Firefox 5.x).
  9914. * @type Boolean
  9915. */
  9916. isGecko5 : isGecko5,
  9917. /**
  9918. * True if the detected browser uses a Gecko 5.0+ layout engine (e.g. Firefox 5.x).
  9919. * @type Boolean
  9920. */
  9921. isGecko10 : isGecko10,
  9922. /**
  9923. * True if the detected browser uses FireFox 3.0
  9924. * @type Boolean
  9925. */
  9926. isFF3_0 : isFF3_0,
  9927. /**
  9928. * True if the detected browser uses FireFox 3.5
  9929. * @type Boolean
  9930. */
  9931. isFF3_5 : isFF3_5,
  9932. /**
  9933. * True if the detected browser uses FireFox 3.6
  9934. * @type Boolean
  9935. */
  9936. isFF3_6 : isFF3_6,
  9937. /**
  9938. * True if the detected browser uses FireFox 4
  9939. * @type Boolean
  9940. */
  9941. isFF4 : 4 <= firefoxVersion && firefoxVersion < 5,
  9942. /**
  9943. * True if the detected browser uses FireFox 5
  9944. * @type Boolean
  9945. */
  9946. isFF5 : 5 <= firefoxVersion && firefoxVersion < 6,
  9947. /**
  9948. * True if the detected browser uses FireFox 10
  9949. * @type Boolean
  9950. */
  9951. isFF10 : 10 <= firefoxVersion && firefoxVersion < 11,
  9952. /**
  9953. * True if the detected platform is Linux.
  9954. * @type Boolean
  9955. */
  9956. isLinux : isLinux,
  9957. /**
  9958. * True if the detected platform is Windows.
  9959. * @type Boolean
  9960. */
  9961. isWindows : isWindows,
  9962. /**
  9963. * True if the detected platform is Mac OS.
  9964. * @type Boolean
  9965. */
  9966. isMac : isMac,
  9967. /**
  9968. * The current version of Chrome (0 if the browser is not Chrome).
  9969. * @type Number
  9970. */
  9971. chromeVersion: chromeVersion,
  9972. /**
  9973. * The current version of Firefox (0 if the browser is not Firefox).
  9974. * @type Number
  9975. */
  9976. firefoxVersion: firefoxVersion,
  9977. /**
  9978. * The current version of IE (0 if the browser is not IE). This does not account
  9979. * for the documentMode of the current page, which is factored into {@link #isIE7},
  9980. * {@link #isIE8} and {@link #isIE9}. Thus this is not always true:
  9981. *
  9982. * Ext.isIE8 == (Ext.ieVersion == 8)
  9983. *
  9984. * @type Number
  9985. */
  9986. ieVersion: ieVersion,
  9987. /**
  9988. * The current version of Opera (0 if the browser is not Opera).
  9989. * @type Number
  9990. */
  9991. operaVersion: operaVersion,
  9992. /**
  9993. * The current version of Safari (0 if the browser is not Safari).
  9994. * @type Number
  9995. */
  9996. safariVersion: safariVersion,
  9997. /**
  9998. * The current version of WebKit (0 if the browser does not use WebKit).
  9999. * @type Number
  10000. */
  10001. webKitVersion: webKitVersion,
  10002. /**
  10003. * True if the page is running over SSL
  10004. * @type Boolean
  10005. */
  10006. isSecure: isSecure,
  10007. /**
  10008. * URL to a 1x1 transparent gif image used by Ext to create inline icons with
  10009. * CSS background images. In older versions of IE, this defaults to
  10010. * "http://sencha.com/s.gif" and you should change this to a URL on your server.
  10011. * For other browsers it uses an inline data URL.
  10012. * @type String
  10013. */
  10014. BLANK_IMAGE_URL : (isIE6 || isIE7) ? '/' + '/www.sencha.com/s.gif' : 'data:image/gif;base64,R0lGODlhAQABAID/AMDAwAAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==',
  10015. /**
  10016. * Utility method for returning a default value if the passed value is empty.
  10017. *
  10018. * The value is deemed to be empty if it is:
  10019. *
  10020. * - null
  10021. * - undefined
  10022. * - an empty array
  10023. * - a zero length string (Unless the `allowBlank` parameter is `true`)
  10024. *
  10025. * @param {Object} value The value to test
  10026. * @param {Object} defaultValue The value to return if the original value is empty
  10027. * @param {Boolean} [allowBlank=false] true to allow zero length strings to qualify as non-empty.
  10028. * @return {Object} value, if non-empty, else defaultValue
  10029. * @deprecated 4.0.0 Use {@link Ext#valueFrom} instead
  10030. */
  10031. value : function(v, defaultValue, allowBlank){
  10032. return Ext.isEmpty(v, allowBlank) ? defaultValue : v;
  10033. },
  10034. /**
  10035. * Escapes the passed string for use in a regular expression.
  10036. * @param {String} str
  10037. * @return {String}
  10038. * @deprecated 4.0.0 Use {@link Ext.String#escapeRegex} instead
  10039. */
  10040. escapeRe : function(s) {
  10041. return s.replace(/([-.*+?\^${}()|\[\]\/\\])/g, "\\$1");
  10042. },
  10043. /**
  10044. * Applies event listeners to elements by selectors when the document is ready.
  10045. * The event name is specified with an `@` suffix.
  10046. *
  10047. * Ext.addBehaviors({
  10048. * // add a listener for click on all anchors in element with id foo
  10049. * '#foo a@click' : function(e, t){
  10050. * // do something
  10051. * },
  10052. *
  10053. * // add the same listener to multiple selectors (separated by comma BEFORE the @)
  10054. * '#foo a, #bar span.some-class@mouseover' : function(){
  10055. * // do something
  10056. * }
  10057. * });
  10058. *
  10059. * @param {Object} obj The list of behaviors to apply
  10060. */
  10061. addBehaviors : function(o){
  10062. if(!Ext.isReady){
  10063. Ext.onReady(function(){
  10064. Ext.addBehaviors(o);
  10065. });
  10066. } else {
  10067. var cache = {}, // simple cache for applying multiple behaviors to same selector does query multiple times
  10068. parts,
  10069. b,
  10070. s;
  10071. for (b in o) {
  10072. if ((parts = b.split('@'))[1]) { // for Object prototype breakers
  10073. s = parts[0];
  10074. if(!cache[s]){
  10075. cache[s] = Ext.select(s);
  10076. }
  10077. cache[s].on(parts[1], o[b]);
  10078. }
  10079. }
  10080. cache = null;
  10081. }
  10082. },
  10083. /**
  10084. * Returns the size of the browser scrollbars. This can differ depending on
  10085. * operating system settings, such as the theme or font size.
  10086. * @param {Boolean} [force] true to force a recalculation of the value.
  10087. * @return {Object} An object containing scrollbar sizes.
  10088. * @return.width {Number} The width of the vertical scrollbar.
  10089. * @return.height {Number} The height of the horizontal scrollbar.
  10090. */
  10091. getScrollbarSize: function (force) {
  10092. if (!Ext.isReady) {
  10093. return {};
  10094. }
  10095. if (force || !scrollbarSize) {
  10096. var db = document.body,
  10097. div = document.createElement('div');
  10098. div.style.width = div.style.height = '100px';
  10099. div.style.overflow = 'scroll';
  10100. div.style.position = 'absolute';
  10101. db.appendChild(div); // now we can measure the div...
  10102. // at least in iE9 the div is not 100px - the scrollbar size is removed!
  10103. scrollbarSize = {
  10104. width: div.offsetWidth - div.clientWidth,
  10105. height: div.offsetHeight - div.clientHeight
  10106. };
  10107. db.removeChild(div);
  10108. }
  10109. return scrollbarSize;
  10110. },
  10111. /**
  10112. * Utility method for getting the width of the browser's vertical scrollbar. This
  10113. * can differ depending on operating system settings, such as the theme or font size.
  10114. *
  10115. * This method is deprected in favor of {@link #getScrollbarSize}.
  10116. *
  10117. * @param {Boolean} [force] true to force a recalculation of the value.
  10118. * @return {Number} The width of a vertical scrollbar.
  10119. * @deprecated
  10120. */
  10121. getScrollBarWidth: function(force){
  10122. var size = Ext.getScrollbarSize(force);
  10123. return size.width + 2; // legacy fudge factor
  10124. },
  10125. /**
  10126. * Copies a set of named properties fom the source object to the destination object.
  10127. *
  10128. * Example:
  10129. *
  10130. * ImageComponent = Ext.extend(Ext.Component, {
  10131. * initComponent: function() {
  10132. * this.autoEl = { tag: 'img' };
  10133. * MyComponent.superclass.initComponent.apply(this, arguments);
  10134. * this.initialBox = Ext.copyTo({}, this.initialConfig, 'x,y,width,height');
  10135. * }
  10136. * });
  10137. *
  10138. * Important note: To borrow class prototype methods, use {@link Ext.Base#borrow} instead.
  10139. *
  10140. * @param {Object} dest The destination object.
  10141. * @param {Object} source The source object.
  10142. * @param {String/String[]} names Either an Array of property names, or a comma-delimited list
  10143. * of property names to copy.
  10144. * @param {Boolean} [usePrototypeKeys] Defaults to false. Pass true to copy keys off of the
  10145. * prototype as well as the instance.
  10146. * @return {Object} The modified object.
  10147. */
  10148. copyTo : function(dest, source, names, usePrototypeKeys){
  10149. if(typeof names == 'string'){
  10150. names = names.split(/[,;\s]/);
  10151. }
  10152. var n,
  10153. nLen = names.length,
  10154. name;
  10155. for(n = 0; n < nLen; n++) {
  10156. name = names[n];
  10157. if(usePrototypeKeys || source.hasOwnProperty(name)){
  10158. dest[name] = source[name];
  10159. }
  10160. }
  10161. return dest;
  10162. },
  10163. /**
  10164. * Attempts to destroy and then remove a set of named properties of the passed object.
  10165. * @param {Object} o The object (most likely a Component) who's properties you wish to destroy.
  10166. * @param {String...} args One or more names of the properties to destroy and remove from the object.
  10167. */
  10168. destroyMembers : function(o){
  10169. for (var i = 1, a = arguments, len = a.length; i < len; i++) {
  10170. Ext.destroy(o[a[i]]);
  10171. delete o[a[i]];
  10172. }
  10173. },
  10174. /**
  10175. * Logs a message. If a console is present it will be used. On Opera, the method
  10176. * "opera.postError" is called. In other cases, the message is logged to an array
  10177. * "Ext.log.out". An attached debugger can watch this array and view the log. The
  10178. * log buffer is limited to a maximum of "Ext.log.max" entries (defaults to 250).
  10179. * The `Ext.log.out` array can also be written to a popup window by entering the
  10180. * following in the URL bar (a "bookmarklet"):
  10181. *
  10182. * javascript:void(Ext.log.show());
  10183. *
  10184. * If additional parameters are passed, they are joined and appended to the message.
  10185. * A technique for tracing entry and exit of a function is this:
  10186. *
  10187. * function foo () {
  10188. * Ext.log({ indent: 1 }, '>> foo');
  10189. *
  10190. * // log statements in here or methods called from here will be indented
  10191. * // by one step
  10192. *
  10193. * Ext.log({ outdent: 1 }, '<< foo');
  10194. * }
  10195. *
  10196. * This method does nothing in a release build.
  10197. *
  10198. * @param {String/Object} [options] The message to log or an options object with any
  10199. * of the following properties:
  10200. *
  10201. * - `msg`: The message to log (required).
  10202. * - `level`: One of: "error", "warn", "info" or "log" (the default is "log").
  10203. * - `dump`: An object to dump to the log as part of the message.
  10204. * - `stack`: True to include a stack trace in the log.
  10205. * - `indent`: Cause subsequent log statements to be indented one step.
  10206. * - `outdent`: Cause this and following statements to be one step less indented.
  10207. *
  10208. * @param {String...} [message] The message to log (required unless specified in
  10209. * options object).
  10210. *
  10211. * @method
  10212. */
  10213. log :
  10214. nullLog,
  10215. /**
  10216. * Partitions the set into two sets: a true set and a false set.
  10217. *
  10218. * Example 1:
  10219. *
  10220. * Ext.partition([true, false, true, true, false]);
  10221. * // returns [[true, true, true], [false, false]]
  10222. *
  10223. * Example 2:
  10224. *
  10225. * Ext.partition(
  10226. * Ext.query("p"),
  10227. * function(val){
  10228. * return val.className == "class1"
  10229. * }
  10230. * );
  10231. * // true are those paragraph elements with a className of "class1",
  10232. * // false set are those that do not have that className.
  10233. *
  10234. * @param {Array/NodeList} arr The array to partition
  10235. * @param {Function} truth (optional) a function to determine truth.
  10236. * If this is omitted the element itself must be able to be evaluated for its truthfulness.
  10237. * @return {Array} [array of truish values, array of falsy values]
  10238. * @deprecated 4.0.0 Will be removed in the next major version
  10239. */
  10240. partition : function(arr, truth){
  10241. var ret = [[],[]],
  10242. a, v,
  10243. aLen = arr.length;
  10244. for (a = 0; a < aLen; a++) {
  10245. v = arr[a];
  10246. ret[ (truth && truth(v, a, arr)) || (!truth && v) ? 0 : 1].push(v);
  10247. }
  10248. return ret;
  10249. },
  10250. /**
  10251. * Invokes a method on each item in an Array.
  10252. *
  10253. * Example:
  10254. *
  10255. * Ext.invoke(Ext.query("p"), "getAttribute", "id");
  10256. * // [el1.getAttribute("id"), el2.getAttribute("id"), ..., elN.getAttribute("id")]
  10257. *
  10258. * @param {Array/NodeList} arr The Array of items to invoke the method on.
  10259. * @param {String} methodName The method name to invoke.
  10260. * @param {Object...} args Arguments to send into the method invocation.
  10261. * @return {Array} The results of invoking the method on each item in the array.
  10262. * @deprecated 4.0.0 Will be removed in the next major version
  10263. */
  10264. invoke : function(arr, methodName){
  10265. var ret = [],
  10266. args = Array.prototype.slice.call(arguments, 2),
  10267. a, v,
  10268. aLen = arr.length;
  10269. for (a = 0; a < aLen; a++) {
  10270. v = arr[a];
  10271. if (v && typeof v[methodName] == 'function') {
  10272. ret.push(v[methodName].apply(v, args));
  10273. } else {
  10274. ret.push(undefined);
  10275. }
  10276. }
  10277. return ret;
  10278. },
  10279. /**
  10280. * Zips N sets together.
  10281. *
  10282. * Example 1:
  10283. *
  10284. * Ext.zip([1,2,3],[4,5,6]); // [[1,4],[2,5],[3,6]]
  10285. *
  10286. * Example 2:
  10287. *
  10288. * Ext.zip(
  10289. * [ "+", "-", "+"],
  10290. * [ 12, 10, 22],
  10291. * [ 43, 15, 96],
  10292. * function(a, b, c){
  10293. * return "$" + a + "" + b + "." + c
  10294. * }
  10295. * ); // ["$+12.43", "$-10.15", "$+22.96"]
  10296. *
  10297. * @param {Array/NodeList...} arr This argument may be repeated. Array(s)
  10298. * to contribute values.
  10299. * @param {Function} zipper (optional) The last item in the argument list.
  10300. * This will drive how the items are zipped together.
  10301. * @return {Array} The zipped set.
  10302. * @deprecated 4.0.0 Will be removed in the next major version
  10303. */
  10304. zip : function(){
  10305. var parts = Ext.partition(arguments, function( val ){ return typeof val != 'function'; }),
  10306. arrs = parts[0],
  10307. fn = parts[1][0],
  10308. len = Ext.max(Ext.pluck(arrs, "length")),
  10309. ret = [],
  10310. i,
  10311. j,
  10312. aLen;
  10313. for (i = 0; i < len; i++) {
  10314. ret[i] = [];
  10315. if(fn){
  10316. ret[i] = fn.apply(fn, Ext.pluck(arrs, i));
  10317. }else{
  10318. for (j = 0, aLen = arrs.length; j < aLen; j++){
  10319. ret[i].push( arrs[j][i] );
  10320. }
  10321. }
  10322. }
  10323. return ret;
  10324. },
  10325. /**
  10326. * Turns an array into a sentence, joined by a specified connector - e.g.:
  10327. *
  10328. * Ext.toSentence(['Adama', 'Tigh', 'Roslin']); //'Adama, Tigh and Roslin'
  10329. * Ext.toSentence(['Adama', 'Tigh', 'Roslin'], 'or'); //'Adama, Tigh or Roslin'
  10330. *
  10331. * @param {String[]} items The array to create a sentence from
  10332. * @param {String} connector The string to use to connect the last two words.
  10333. * Usually 'and' or 'or' - defaults to 'and'.
  10334. * @return {String} The sentence string
  10335. * @deprecated 4.0.0 Will be removed in the next major version
  10336. */
  10337. toSentence: function(items, connector) {
  10338. var length = items.length,
  10339. head,
  10340. tail;
  10341. if (length <= 1) {
  10342. return items[0];
  10343. } else {
  10344. head = items.slice(0, length - 1);
  10345. tail = items[length - 1];
  10346. return Ext.util.Format.format("{0} {1} {2}", head.join(", "), connector || 'and', tail);
  10347. }
  10348. },
  10349. /**
  10350. * @property {Boolean} useShims
  10351. * By default, Ext intelligently decides whether floating elements should be shimmed.
  10352. * If you are using flash, you may want to set this to true.
  10353. */
  10354. useShims: isIE6
  10355. });
  10356. }());
  10357. /**
  10358. * Loads Ext.app.Application class and starts it up with given configuration after the page is ready.
  10359. *
  10360. * See Ext.app.Application for details.
  10361. *
  10362. * @param {Object} config
  10363. */
  10364. Ext.application = function(config) {
  10365. Ext.require('Ext.app.Application');
  10366. Ext.onReady(function() {
  10367. new Ext.app.Application(config);
  10368. });
  10369. };
  10370. //@tag extras,core
  10371. //@require ../Ext-more.js
  10372. //@define Ext.util.Format
  10373. /**
  10374. * @class Ext.util.Format
  10375. *
  10376. * This class is a centralized place for formatting functions. It includes
  10377. * functions to format various different types of data, such as text, dates and numeric values.
  10378. *
  10379. * ## Localization
  10380. *
  10381. * This class contains several options for localization. These can be set once the library has loaded,
  10382. * all calls to the functions from that point will use the locale settings that were specified.
  10383. *
  10384. * Options include:
  10385. *
  10386. * - thousandSeparator
  10387. * - decimalSeparator
  10388. * - currenyPrecision
  10389. * - currencySign
  10390. * - currencyAtEnd
  10391. *
  10392. * This class also uses the default date format defined here: {@link Ext.Date#defaultFormat}.
  10393. *
  10394. * ## Using with renderers
  10395. *
  10396. * There are two helper functions that return a new function that can be used in conjunction with
  10397. * grid renderers:
  10398. *
  10399. * columns: [{
  10400. * dataIndex: 'date',
  10401. * renderer: Ext.util.Format.dateRenderer('Y-m-d')
  10402. * }, {
  10403. * dataIndex: 'time',
  10404. * renderer: Ext.util.Format.numberRenderer('0.000')
  10405. * }]
  10406. *
  10407. * Functions that only take a single argument can also be passed directly:
  10408. *
  10409. * columns: [{
  10410. * dataIndex: 'cost',
  10411. * renderer: Ext.util.Format.usMoney
  10412. * }, {
  10413. * dataIndex: 'productCode',
  10414. * renderer: Ext.util.Format.uppercase
  10415. * }]
  10416. *
  10417. * ## Using with XTemplates
  10418. *
  10419. * XTemplates can also directly use Ext.util.Format functions:
  10420. *
  10421. * new Ext.XTemplate([
  10422. * 'Date: {startDate:date("Y-m-d")}',
  10423. * 'Cost: {cost:usMoney}'
  10424. * ]);
  10425. *
  10426. * @singleton
  10427. */
  10428. (function() {
  10429. Ext.ns('Ext.util');
  10430. Ext.util.Format = {};
  10431. var UtilFormat = Ext.util.Format,
  10432. stripTagsRE = /<\/?[^>]+>/gi,
  10433. stripScriptsRe = /(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)/ig,
  10434. nl2brRe = /\r?\n/g,
  10435. // A RegExp to remove from a number format string, all characters except digits and '.'
  10436. formatCleanRe = /[^\d\.]/g,
  10437. // A RegExp to remove from a number format string, all characters except digits and the local decimal separator.
  10438. // Created on first use. The local decimal separator character must be initialized for this to be created.
  10439. I18NFormatCleanRe;
  10440. Ext.apply(UtilFormat, {
  10441. //<locale>
  10442. /**
  10443. * @property {String} thousandSeparator
  10444. * The character that the {@link #number} function uses as a thousand separator.
  10445. *
  10446. * This may be overridden in a locale file.
  10447. */
  10448. thousandSeparator: ',',
  10449. //</locale>
  10450. //<locale>
  10451. /**
  10452. * @property {String} decimalSeparator
  10453. * The character that the {@link #number} function uses as a decimal point.
  10454. *
  10455. * This may be overridden in a locale file.
  10456. */
  10457. decimalSeparator: '.',
  10458. //</locale>
  10459. //<locale>
  10460. /**
  10461. * @property {Number} currencyPrecision
  10462. * The number of decimal places that the {@link #currency} function displays.
  10463. *
  10464. * This may be overridden in a locale file.
  10465. */
  10466. currencyPrecision: 2,
  10467. //</locale>
  10468. //<locale>
  10469. /**
  10470. * @property {String} currencySign
  10471. * The currency sign that the {@link #currency} function displays.
  10472. *
  10473. * This may be overridden in a locale file.
  10474. */
  10475. currencySign: '$',
  10476. //</locale>
  10477. //<locale>
  10478. /**
  10479. * @property {Boolean} currencyAtEnd
  10480. * This may be set to <code>true</code> to make the {@link #currency} function
  10481. * append the currency sign to the formatted value.
  10482. *
  10483. * This may be overridden in a locale file.
  10484. */
  10485. currencyAtEnd: false,
  10486. //</locale>
  10487. /**
  10488. * Checks a reference and converts it to empty string if it is undefined.
  10489. * @param {Object} value Reference to check
  10490. * @return {Object} Empty string if converted, otherwise the original value
  10491. */
  10492. undef : function(value) {
  10493. return value !== undefined ? value : "";
  10494. },
  10495. /**
  10496. * Checks a reference and converts it to the default value if it's empty.
  10497. * @param {Object} value Reference to check
  10498. * @param {String} [defaultValue=""] The value to insert of it's undefined.
  10499. * @return {String}
  10500. */
  10501. defaultValue : function(value, defaultValue) {
  10502. return value !== undefined && value !== '' ? value : defaultValue;
  10503. },
  10504. /**
  10505. * Returns a substring from within an original string.
  10506. * @param {String} value The original text
  10507. * @param {Number} start The start index of the substring
  10508. * @param {Number} length The length of the substring
  10509. * @return {String} The substring
  10510. * @method
  10511. */
  10512. substr : 'ab'.substr(-1) != 'b'
  10513. ? function (value, start, length) {
  10514. var str = String(value);
  10515. return (start < 0)
  10516. ? str.substr(Math.max(str.length + start, 0), length)
  10517. : str.substr(start, length);
  10518. }
  10519. : function(value, start, length) {
  10520. return String(value).substr(start, length);
  10521. },
  10522. /**
  10523. * Converts a string to all lower case letters.
  10524. * @param {String} value The text to convert
  10525. * @return {String} The converted text
  10526. */
  10527. lowercase : function(value) {
  10528. return String(value).toLowerCase();
  10529. },
  10530. /**
  10531. * Converts a string to all upper case letters.
  10532. * @param {String} value The text to convert
  10533. * @return {String} The converted text
  10534. */
  10535. uppercase : function(value) {
  10536. return String(value).toUpperCase();
  10537. },
  10538. /**
  10539. * Format a number as US currency.
  10540. * @param {Number/String} value The numeric value to format
  10541. * @return {String} The formatted currency string
  10542. */
  10543. usMoney : function(v) {
  10544. return UtilFormat.currency(v, '$', 2);
  10545. },
  10546. /**
  10547. * Format a number as a currency.
  10548. * @param {Number/String} value The numeric value to format
  10549. * @param {String} [sign] The currency sign to use (defaults to {@link #currencySign})
  10550. * @param {Number} [decimals] The number of decimals to use for the currency
  10551. * (defaults to {@link #currencyPrecision})
  10552. * @param {Boolean} [end] True if the currency sign should be at the end of the string
  10553. * (defaults to {@link #currencyAtEnd})
  10554. * @return {String} The formatted currency string
  10555. */
  10556. currency: function(v, currencySign, decimals, end) {
  10557. var negativeSign = '',
  10558. format = ",0",
  10559. i = 0;
  10560. v = v - 0;
  10561. if (v < 0) {
  10562. v = -v;
  10563. negativeSign = '-';
  10564. }
  10565. decimals = Ext.isDefined(decimals) ? decimals : UtilFormat.currencyPrecision;
  10566. format += format + (decimals > 0 ? '.' : '');
  10567. for (; i < decimals; i++) {
  10568. format += '0';
  10569. }
  10570. v = UtilFormat.number(v, format);
  10571. if ((end || UtilFormat.currencyAtEnd) === true) {
  10572. return Ext.String.format("{0}{1}{2}", negativeSign, v, currencySign || UtilFormat.currencySign);
  10573. } else {
  10574. return Ext.String.format("{0}{1}{2}", negativeSign, currencySign || UtilFormat.currencySign, v);
  10575. }
  10576. },
  10577. /**
  10578. * Formats the passed date using the specified format pattern.
  10579. * @param {String/Date} value The value to format. If a string is passed, it is converted to a Date
  10580. * by the Javascript's built-in Date#parse method.
  10581. * @param {String} [format] Any valid date format string. Defaults to {@link Ext.Date#defaultFormat}.
  10582. * @return {String} The formatted date string.
  10583. */
  10584. date: function(v, format) {
  10585. if (!v) {
  10586. return "";
  10587. }
  10588. if (!Ext.isDate(v)) {
  10589. v = new Date(Date.parse(v));
  10590. }
  10591. return Ext.Date.dateFormat(v, format || Ext.Date.defaultFormat);
  10592. },
  10593. /**
  10594. * Returns a date rendering function that can be reused to apply a date format multiple times efficiently.
  10595. * @param {String} format Any valid date format string. Defaults to {@link Ext.Date#defaultFormat}.
  10596. * @return {Function} The date formatting function
  10597. */
  10598. dateRenderer : function(format) {
  10599. return function(v) {
  10600. return UtilFormat.date(v, format);
  10601. };
  10602. },
  10603. /**
  10604. * Strips all HTML tags.
  10605. * @param {Object} value The text from which to strip tags
  10606. * @return {String} The stripped text
  10607. */
  10608. stripTags : function(v) {
  10609. return !v ? v : String(v).replace(stripTagsRE, "");
  10610. },
  10611. /**
  10612. * Strips all script tags.
  10613. * @param {Object} value The text from which to strip script tags
  10614. * @return {String} The stripped text
  10615. */
  10616. stripScripts : function(v) {
  10617. return !v ? v : String(v).replace(stripScriptsRe, "");
  10618. },
  10619. /**
  10620. * Simple format for a file size (xxx bytes, xxx KB, xxx MB).
  10621. * @param {Number/String} size The numeric value to format
  10622. * @return {String} The formatted file size
  10623. */
  10624. fileSize : function(size) {
  10625. if (size < 1024) {
  10626. return size + " bytes";
  10627. } else if (size < 1048576) {
  10628. return (Math.round(((size*10) / 1024))/10) + " KB";
  10629. } else {
  10630. return (Math.round(((size*10) / 1048576))/10) + " MB";
  10631. }
  10632. },
  10633. /**
  10634. * It does simple math for use in a template, for example:
  10635. *
  10636. * var tpl = new Ext.Template('{value} * 10 = {value:math("* 10")}');
  10637. *
  10638. * @return {Function} A function that operates on the passed value.
  10639. * @method
  10640. */
  10641. math : (function(){
  10642. var fns = {};
  10643. return function(v, a){
  10644. if (!fns[a]) {
  10645. fns[a] = Ext.functionFactory('v', 'return v ' + a + ';');
  10646. }
  10647. return fns[a](v);
  10648. };
  10649. }()),
  10650. /**
  10651. * Rounds the passed number to the required decimal precision.
  10652. * @param {Number/String} value The numeric value to round.
  10653. * @param {Number} precision The number of decimal places to which to round the first parameter's value.
  10654. * @return {Number} The rounded value.
  10655. */
  10656. round : function(value, precision) {
  10657. var result = Number(value);
  10658. if (typeof precision == 'number') {
  10659. precision = Math.pow(10, precision);
  10660. result = Math.round(value * precision) / precision;
  10661. }
  10662. return result;
  10663. },
  10664. /**
  10665. * Formats the passed number according to the passed format string.
  10666. *
  10667. * The number of digits after the decimal separator character specifies the number of
  10668. * decimal places in the resulting string. The *local-specific* decimal character is
  10669. * used in the result.
  10670. *
  10671. * The *presence* of a thousand separator character in the format string specifies that
  10672. * the *locale-specific* thousand separator (if any) is inserted separating thousand groups.
  10673. *
  10674. * By default, "," is expected as the thousand separator, and "." is expected as the decimal separator.
  10675. *
  10676. * ## New to Ext JS 4
  10677. *
  10678. * Locale-specific characters are always used in the formatted output when inserting
  10679. * thousand and decimal separators.
  10680. *
  10681. * The format string must specify separator characters according to US/UK conventions ("," as the
  10682. * thousand separator, and "." as the decimal separator)
  10683. *
  10684. * To allow specification of format strings according to local conventions for separator characters, add
  10685. * the string `/i` to the end of the format string.
  10686. *
  10687. * examples (123456.789):
  10688. *
  10689. * - `0` - (123456) show only digits, no precision
  10690. * - `0.00` - (123456.78) show only digits, 2 precision
  10691. * - `0.0000` - (123456.7890) show only digits, 4 precision
  10692. * - `0,000` - (123,456) show comma and digits, no precision
  10693. * - `0,000.00` - (123,456.78) show comma and digits, 2 precision
  10694. * - `0,0.00` - (123,456.78) shortcut method, show comma and digits, 2 precision
  10695. *
  10696. * To allow specification of the formatting string using UK/US grouping characters (,) and
  10697. * decimal (.) for international numbers, add /i to the end. For example: 0.000,00/i
  10698. *
  10699. * @param {Number} v The number to format.
  10700. * @param {String} format The way you would like to format this text.
  10701. * @return {String} The formatted number.
  10702. */
  10703. number : function(v, formatString) {
  10704. if (!formatString) {
  10705. return v;
  10706. }
  10707. v = Ext.Number.from(v, NaN);
  10708. if (isNaN(v)) {
  10709. return '';
  10710. }
  10711. var comma = UtilFormat.thousandSeparator,
  10712. dec = UtilFormat.decimalSeparator,
  10713. i18n = false,
  10714. neg = v < 0,
  10715. hasComma,
  10716. psplit,
  10717. fnum,
  10718. cnum,
  10719. parr,
  10720. j,
  10721. m,
  10722. n,
  10723. i;
  10724. v = Math.abs(v);
  10725. // The "/i" suffix allows caller to use a locale-specific formatting string.
  10726. // Clean the format string by removing all but numerals and the decimal separator.
  10727. // Then split the format string into pre and post decimal segments according to *what* the
  10728. // decimal separator is. If they are specifying "/i", they are using the local convention in the format string.
  10729. if (formatString.substr(formatString.length - 2) == '/i') {
  10730. if (!I18NFormatCleanRe) {
  10731. I18NFormatCleanRe = new RegExp('[^\\d\\' + UtilFormat.decimalSeparator + ']','g');
  10732. }
  10733. formatString = formatString.substr(0, formatString.length - 2);
  10734. i18n = true;
  10735. hasComma = formatString.indexOf(comma) != -1;
  10736. psplit = formatString.replace(I18NFormatCleanRe, '').split(dec);
  10737. } else {
  10738. hasComma = formatString.indexOf(',') != -1;
  10739. psplit = formatString.replace(formatCleanRe, '').split('.');
  10740. }
  10741. if (psplit.length > 2) {
  10742. } else if (psplit.length > 1) {
  10743. v = Ext.Number.toFixed(v, psplit[1].length);
  10744. } else {
  10745. v = Ext.Number.toFixed(v, 0);
  10746. }
  10747. fnum = v.toString();
  10748. psplit = fnum.split('.');
  10749. if (hasComma) {
  10750. cnum = psplit[0];
  10751. parr = [];
  10752. j = cnum.length;
  10753. m = Math.floor(j / 3);
  10754. n = cnum.length % 3 || 3;
  10755. for (i = 0; i < j; i += n) {
  10756. if (i !== 0) {
  10757. n = 3;
  10758. }
  10759. parr[parr.length] = cnum.substr(i, n);
  10760. m -= 1;
  10761. }
  10762. fnum = parr.join(comma);
  10763. if (psplit[1]) {
  10764. fnum += dec + psplit[1];
  10765. }
  10766. } else {
  10767. if (psplit[1]) {
  10768. fnum = psplit[0] + dec + psplit[1];
  10769. }
  10770. }
  10771. if (neg) {
  10772. /*
  10773. * Edge case. If we have a very small negative number it will get rounded to 0,
  10774. * however the initial check at the top will still report as negative. Replace
  10775. * everything but 1-9 and check if the string is empty to determine a 0 value.
  10776. */
  10777. neg = fnum.replace(/[^1-9]/g, '') !== '';
  10778. }
  10779. return (neg ? '-' : '') + formatString.replace(/[\d,?\.?]+/, fnum);
  10780. },
  10781. /**
  10782. * Returns a number rendering function that can be reused to apply a number format multiple
  10783. * times efficiently.
  10784. *
  10785. * @param {String} format Any valid number format string for {@link #number}
  10786. * @return {Function} The number formatting function
  10787. */
  10788. numberRenderer : function(format) {
  10789. return function(v) {
  10790. return UtilFormat.number(v, format);
  10791. };
  10792. },
  10793. /**
  10794. * Selectively do a plural form of a word based on a numeric value. For example, in a template,
  10795. * `{commentCount:plural("Comment")}` would result in `"1 Comment"` if commentCount was 1 or
  10796. * would be `"x Comments"` if the value is 0 or greater than 1.
  10797. *
  10798. * @param {Number} value The value to compare against
  10799. * @param {String} singular The singular form of the word
  10800. * @param {String} [plural] The plural form of the word (defaults to the singular with an "s")
  10801. */
  10802. plural : function(v, s, p) {
  10803. return v +' ' + (v == 1 ? s : (p ? p : s+'s'));
  10804. },
  10805. /**
  10806. * Converts newline characters to the HTML tag `<br/>`
  10807. *
  10808. * @param {String} The string value to format.
  10809. * @return {String} The string with embedded `<br/>` tags in place of newlines.
  10810. */
  10811. nl2br : function(v) {
  10812. return Ext.isEmpty(v) ? '' : v.replace(nl2brRe, '<br/>');
  10813. },
  10814. /**
  10815. * Alias for {@link Ext.String#capitalize}.
  10816. * @method
  10817. * @inheritdoc Ext.String#capitalize
  10818. */
  10819. capitalize: Ext.String.capitalize,
  10820. /**
  10821. * Alias for {@link Ext.String#ellipsis}.
  10822. * @method
  10823. * @inheritdoc Ext.String#ellipsis
  10824. */
  10825. ellipsis: Ext.String.ellipsis,
  10826. /**
  10827. * Alias for {@link Ext.String#format}.
  10828. * @method
  10829. * @inheritdoc Ext.String#format
  10830. */
  10831. format: Ext.String.format,
  10832. /**
  10833. * Alias for {@link Ext.String#htmlDecode}.
  10834. * @method
  10835. * @inheritdoc Ext.String#htmlDecode
  10836. */
  10837. htmlDecode: Ext.String.htmlDecode,
  10838. /**
  10839. * Alias for {@link Ext.String#htmlEncode}.
  10840. * @method
  10841. * @inheritdoc Ext.String#htmlEncode
  10842. */
  10843. htmlEncode: Ext.String.htmlEncode,
  10844. /**
  10845. * Alias for {@link Ext.String#leftPad}.
  10846. * @method
  10847. * @inheritdoc Ext.String#leftPad
  10848. */
  10849. leftPad: Ext.String.leftPad,
  10850. /**
  10851. * Alias for {@link Ext.String#trim}.
  10852. * @method
  10853. * @inheritdoc Ext.String#trim
  10854. */
  10855. trim : Ext.String.trim,
  10856. /**
  10857. * Parses a number or string representing margin sizes into an object.
  10858. * Supports CSS-style margin declarations (e.g. 10, "10", "10 10", "10 10 10" and
  10859. * "10 10 10 10" are all valid options and would return the same result).
  10860. *
  10861. * @param {Number/String} v The encoded margins
  10862. * @return {Object} An object with margin sizes for top, right, bottom and left
  10863. */
  10864. parseBox : function(box) {
  10865. box = Ext.isEmpty(box) ? '' : box;
  10866. if (Ext.isNumber(box)) {
  10867. box = box.toString();
  10868. }
  10869. var parts = box.split(' '),
  10870. ln = parts.length;
  10871. if (ln == 1) {
  10872. parts[1] = parts[2] = parts[3] = parts[0];
  10873. }
  10874. else if (ln == 2) {
  10875. parts[2] = parts[0];
  10876. parts[3] = parts[1];
  10877. }
  10878. else if (ln == 3) {
  10879. parts[3] = parts[1];
  10880. }
  10881. return {
  10882. top :parseInt(parts[0], 10) || 0,
  10883. right :parseInt(parts[1], 10) || 0,
  10884. bottom:parseInt(parts[2], 10) || 0,
  10885. left :parseInt(parts[3], 10) || 0
  10886. };
  10887. },
  10888. /**
  10889. * Escapes the passed string for use in a regular expression.
  10890. * @param {String} str
  10891. * @return {String}
  10892. */
  10893. escapeRegex : function(s) {
  10894. return s.replace(/([\-.*+?\^${}()|\[\]\/\\])/g, "\\$1");
  10895. }
  10896. });
  10897. }());
  10898. //@tag extras,core
  10899. //@require Format.js
  10900. //@define Ext.util.TaskManager
  10901. //@define Ext.TaskManager
  10902. /**
  10903. * Provides the ability to execute one or more arbitrary tasks in a asynchronous manner.
  10904. * Generally, you can use the singleton {@link Ext.TaskManager} instead, but if needed,
  10905. * you can create separate instances of TaskRunner. Any number of separate tasks can be
  10906. * started at any time and will run independently of each other.
  10907. *
  10908. * Example usage:
  10909. *
  10910. * // Start a simple clock task that updates a div once per second
  10911. * var updateClock = function () {
  10912. * Ext.fly('clock').update(new Date().format('g:i:s A'));
  10913. * }
  10914. *
  10915. * var runner = new Ext.util.TaskRunner();
  10916. * var task = runner.start({
  10917. * run: updateClock,
  10918. * interval: 1000
  10919. * }
  10920. *
  10921. * The equivalent using TaskManager:
  10922. *
  10923. * var task = Ext.TaskManager.start({
  10924. * run: updateClock,
  10925. * interval: 1000
  10926. * });
  10927. *
  10928. * To end a running task:
  10929. *
  10930. * Ext.TaskManager.stop(task);
  10931. *
  10932. * If a task needs to be started and stopped repeated over time, you can create a
  10933. * {@link Ext.util.TaskRunner.Task Task} instance.
  10934. *
  10935. * var task = runner.newTask({
  10936. * run: function () {
  10937. * // useful code
  10938. * },
  10939. * interval: 1000
  10940. * });
  10941. *
  10942. * task.start();
  10943. *
  10944. * // ...
  10945. *
  10946. * task.stop();
  10947. *
  10948. * // ...
  10949. *
  10950. * task.start();
  10951. *
  10952. * A re-usable, one-shot task can be managed similar to the above:
  10953. *
  10954. * var task = runner.newTask({
  10955. * run: function () {
  10956. * // useful code to run once
  10957. * },
  10958. * repeat: 1
  10959. * });
  10960. *
  10961. * task.start();
  10962. *
  10963. * // ...
  10964. *
  10965. * task.start();
  10966. *
  10967. * See the {@link #start} method for details about how to configure a task object.
  10968. *
  10969. * Also see {@link Ext.util.DelayedTask}.
  10970. *
  10971. * @constructor
  10972. * @param {Number/Object} [interval=10] The minimum precision in milliseconds supported by this
  10973. * TaskRunner instance. Alternatively, a config object to apply to the new instance.
  10974. */
  10975. Ext.define('Ext.util.TaskRunner', {
  10976. /**
  10977. * @cfg interval
  10978. * The timer resolution.
  10979. */
  10980. interval: 10,
  10981. /**
  10982. * @property timerId
  10983. * The id of the current timer.
  10984. * @private
  10985. */
  10986. timerId: null,
  10987. constructor: function (interval) {
  10988. var me = this;
  10989. if (typeof interval == 'number') {
  10990. me.interval = interval;
  10991. } else if (interval) {
  10992. Ext.apply(me, interval);
  10993. }
  10994. me.tasks = [];
  10995. me.timerFn = Ext.Function.bind(me.onTick, me);
  10996. },
  10997. /**
  10998. * Creates a new {@link Ext.util.TaskRunner.Task Task} instance. These instances can
  10999. * be easily started and stopped.
  11000. * @param {Object} config The config object. For details on the supported properties,
  11001. * see {@link #start}.
  11002. */
  11003. newTask: function (config) {
  11004. var task = new Ext.util.TaskRunner.Task(config);
  11005. task.manager = this;
  11006. return task;
  11007. },
  11008. /**
  11009. * Starts a new task.
  11010. *
  11011. * Before each invocation, Ext injects the property `taskRunCount` into the task object
  11012. * so that calculations based on the repeat count can be performed.
  11013. *
  11014. * The returned task will contain a `destroy` method that can be used to destroy the
  11015. * task and cancel further calls. This is equivalent to the {@link #stop} method.
  11016. *
  11017. * @param {Object} task A config object that supports the following properties:
  11018. * @param {Function} task.run The function to execute each time the task is invoked. The
  11019. * function will be called at each interval and passed the `args` argument if specified,
  11020. * and the current invocation count if not.
  11021. *
  11022. * If a particular scope (`this` reference) is required, be sure to specify it using
  11023. * the `scope` argument.
  11024. *
  11025. * @param {Function} task.onError The function to execute in case of unhandled
  11026. * error on task.run.
  11027. *
  11028. * @param {Boolean} task.run.return `false` from this function to terminate the task.
  11029. *
  11030. * @param {Number} task.interval The frequency in milliseconds with which the task
  11031. * should be invoked.
  11032. *
  11033. * @param {Object[]} task.args An array of arguments to be passed to the function
  11034. * specified by `run`. If not specified, the current invocation count is passed.
  11035. *
  11036. * @param {Object} task.scope The scope (`this` reference) in which to execute the
  11037. * `run` function. Defaults to the task config object.
  11038. *
  11039. * @param {Number} task.duration The length of time in milliseconds to invoke the task
  11040. * before stopping automatically (defaults to indefinite).
  11041. *
  11042. * @param {Number} task.repeat The number of times to invoke the task before stopping
  11043. * automatically (defaults to indefinite).
  11044. * @return {Object} The task
  11045. */
  11046. start: function(task) {
  11047. var me = this,
  11048. now = new Date().getTime();
  11049. if (!task.pending) {
  11050. me.tasks.push(task);
  11051. task.pending = true; // don't allow the task to be added to me.tasks again
  11052. }
  11053. task.stopped = false; // might have been previously stopped...
  11054. task.taskStartTime = now;
  11055. task.taskRunTime = task.fireOnStart !== false ? 0 : task.taskStartTime;
  11056. task.taskRunCount = 0;
  11057. if (!me.firing) {
  11058. if (task.fireOnStart !== false) {
  11059. me.startTimer(0, now);
  11060. } else {
  11061. me.startTimer(task.interval, now);
  11062. }
  11063. }
  11064. return task;
  11065. },
  11066. /**
  11067. * Stops an existing running task.
  11068. * @param {Object} task The task to stop
  11069. * @return {Object} The task
  11070. */
  11071. stop: function(task) {
  11072. // NOTE: we don't attempt to remove the task from me.tasks at this point because
  11073. // this could be called from inside a task which would then corrupt the state of
  11074. // the loop in onTick
  11075. if (!task.stopped) {
  11076. task.stopped = true;
  11077. if (task.onStop) {
  11078. task.onStop.call(task.scope || task, task);
  11079. }
  11080. }
  11081. return task;
  11082. },
  11083. /**
  11084. * Stops all tasks that are currently running.
  11085. */
  11086. stopAll: function() {
  11087. // onTick will take care of cleaning up the mess after this point...
  11088. Ext.each(this.tasks, this.stop, this);
  11089. },
  11090. //-------------------------------------------------------------------------
  11091. firing: false,
  11092. nextExpires: 1e99,
  11093. // private
  11094. onTick: function () {
  11095. var me = this,
  11096. tasks = me.tasks,
  11097. now = new Date().getTime(),
  11098. nextExpires = 1e99,
  11099. len = tasks.length,
  11100. expires, newTasks, i, task, rt, remove;
  11101. me.timerId = null;
  11102. me.firing = true; // ensure we don't startTimer during this loop...
  11103. // tasks.length can be > len if start is called during a task.run call... so we
  11104. // first check len to avoid tasks.length reference but eventually we need to also
  11105. // check tasks.length. we avoid repeating use of tasks.length by setting len at
  11106. // that time (to help the next loop)
  11107. for (i = 0; i < len || i < (len = tasks.length); ++i) {
  11108. task = tasks[i];
  11109. if (!(remove = task.stopped)) {
  11110. expires = task.taskRunTime + task.interval;
  11111. if (expires <= now) {
  11112. rt = 1; // otherwise we have a stale "rt"
  11113. try {
  11114. rt = task.run.apply(task.scope || task, task.args || [++task.taskRunCount]);
  11115. } catch (taskError) {
  11116. try {
  11117. if (task.onError) {
  11118. rt = task.onError.call(task.scope || task, task, taskError);
  11119. }
  11120. } catch (ignore) { }
  11121. }
  11122. task.taskRunTime = now;
  11123. if (rt === false || task.taskRunCount === task.repeat) {
  11124. me.stop(task);
  11125. remove = true;
  11126. } else {
  11127. remove = task.stopped; // in case stop was called by run
  11128. expires = now + task.interval;
  11129. }
  11130. }
  11131. if (!remove && task.duration && task.duration <= (now - task.taskStartTime)) {
  11132. me.stop(task);
  11133. remove = true;
  11134. }
  11135. }
  11136. if (remove) {
  11137. task.pending = false; // allow the task to be added to me.tasks again
  11138. // once we detect that a task needs to be removed, we copy the tasks that
  11139. // will carry forward into newTasks... this way we avoid O(N*N) to remove
  11140. // each task from the tasks array (and ripple the array down) and also the
  11141. // potentially wasted effort of making a new tasks[] even if all tasks are
  11142. // going into the next wave.
  11143. if (!newTasks) {
  11144. newTasks = tasks.slice(0, i);
  11145. // we don't set me.tasks here because callbacks can also start tasks,
  11146. // which get added to me.tasks... so we will visit them in this loop
  11147. // and account for their expirations in nextExpires...
  11148. }
  11149. } else {
  11150. if (newTasks) {
  11151. newTasks.push(task); // we've cloned the tasks[], so keep this one...
  11152. }
  11153. if (nextExpires > expires) {
  11154. nextExpires = expires; // track the nearest expiration time
  11155. }
  11156. }
  11157. }
  11158. if (newTasks) {
  11159. // only now can we copy the newTasks to me.tasks since no user callbacks can
  11160. // take place
  11161. me.tasks = newTasks;
  11162. }
  11163. me.firing = false; // we're done, so allow startTimer afterwards
  11164. if (me.tasks.length) {
  11165. // we create a new Date here because all the callbacks could have taken a long
  11166. // time... we want to base the next timeout on the current time (after the
  11167. // callback storm):
  11168. me.startTimer(nextExpires - now, new Date().getTime());
  11169. }
  11170. },
  11171. // private
  11172. startTimer: function (timeout, now) {
  11173. var me = this,
  11174. expires = now + timeout,
  11175. timerId = me.timerId;
  11176. // Check to see if this request is enough in advance of the current timer. If so,
  11177. // we reschedule the timer based on this new expiration.
  11178. if (timerId && me.nextExpires - expires > me.interval) {
  11179. clearTimeout(timerId);
  11180. timerId = null;
  11181. }
  11182. if (!timerId) {
  11183. if (timeout < me.interval) {
  11184. timeout = me.interval;
  11185. }
  11186. me.timerId = setTimeout(me.timerFn, timeout);
  11187. me.nextExpires = expires;
  11188. }
  11189. }
  11190. },
  11191. function () {
  11192. var me = this,
  11193. proto = me.prototype;
  11194. /**
  11195. * Destroys this instance, stopping all tasks that are currently running.
  11196. * @method destroy
  11197. */
  11198. proto.destroy = proto.stopAll;
  11199. /**
  11200. * @class Ext.TaskManager
  11201. * @extends Ext.util.TaskRunner
  11202. * @singleton
  11203. *
  11204. * A static {@link Ext.util.TaskRunner} instance that can be used to start and stop
  11205. * arbitrary tasks. See {@link Ext.util.TaskRunner} for supported methods and task
  11206. * config properties.
  11207. *
  11208. * // Start a simple clock task that updates a div once per second
  11209. * var task = {
  11210. * run: function(){
  11211. * Ext.fly('clock').update(new Date().format('g:i:s A'));
  11212. * },
  11213. * interval: 1000 //1 second
  11214. * }
  11215. *
  11216. * Ext.TaskManager.start(task);
  11217. *
  11218. * See the {@link #start} method for details about how to configure a task object.
  11219. */
  11220. Ext.util.TaskManager = Ext.TaskManager = new me();
  11221. /**
  11222. * Instances of this class are created by {@link Ext.util.TaskRunner#newTask} method.
  11223. *
  11224. * For details on config properties, see {@link Ext.util.TaskRunner#start}.
  11225. * @class Ext.util.TaskRunner.Task
  11226. */
  11227. me.Task = new Ext.Class({
  11228. isTask: true,
  11229. /**
  11230. * This flag is set to `true` by {@link #stop}.
  11231. * @private
  11232. */
  11233. stopped: true, // this avoids the odd combination of !stopped && !pending
  11234. /**
  11235. * Override default behavior
  11236. */
  11237. fireOnStart: false,
  11238. constructor: function (config) {
  11239. Ext.apply(this, config);
  11240. },
  11241. /**
  11242. * Restarts this task, clearing it duration, expiration and run count.
  11243. * @param {Number} [interval] Optionally reset this task's interval.
  11244. */
  11245. restart: function (interval) {
  11246. if (interval !== undefined) {
  11247. this.interval = interval;
  11248. }
  11249. this.manager.start(this);
  11250. },
  11251. /**
  11252. * Starts this task if it is not already started.
  11253. * @param {Number} [interval] Optionally reset this task's interval.
  11254. */
  11255. start: function (interval) {
  11256. if (this.stopped) {
  11257. this.restart(interval);
  11258. }
  11259. },
  11260. /**
  11261. * Stops this task.
  11262. */
  11263. stop: function () {
  11264. this.manager.stop(this);
  11265. }
  11266. });
  11267. proto = me.Task.prototype;
  11268. /**
  11269. * Destroys this instance, stopping this task's execution.
  11270. * @method destroy
  11271. */
  11272. proto.destroy = proto.stop;
  11273. });
  11274. //@tag extras,core
  11275. //@require ../util/TaskManager.js
  11276. /**
  11277. * @class Ext.perf.Accumulator
  11278. * @private
  11279. */
  11280. Ext.define('Ext.perf.Accumulator', (function () {
  11281. var currentFrame = null,
  11282. khrome = Ext.global['chrome'],
  11283. formatTpl,
  11284. // lazy init on first request for timestamp (avoids infobar in IE until needed)
  11285. // Also avoids kicking off Chrome's microsecond timer until first needed
  11286. getTimestamp = function () {
  11287. getTimestamp = function () {
  11288. return new Date().getTime();
  11289. };
  11290. var interval, toolbox;
  11291. // If Chrome is started with the --enable-benchmarking switch
  11292. if (Ext.isChrome && khrome && khrome.Interval) {
  11293. interval = new khrome.Interval();
  11294. interval.start();
  11295. getTimestamp = function () {
  11296. return interval.microseconds() / 1000;
  11297. };
  11298. } else if (window.ActiveXObject) {
  11299. try {
  11300. // the above technique is not very accurate for small intervals...
  11301. toolbox = new ActiveXObject('SenchaToolbox.Toolbox');
  11302. Ext.senchaToolbox = toolbox; // export for other uses
  11303. getTimestamp = function () {
  11304. return toolbox.milliseconds;
  11305. };
  11306. } catch (e) {
  11307. // ignore
  11308. }
  11309. } else if (Date.now) {
  11310. getTimestamp = Date.now;
  11311. }
  11312. Ext.perf.getTimestamp = Ext.perf.Accumulator.getTimestamp = getTimestamp;
  11313. return getTimestamp();
  11314. };
  11315. function adjustSet (set, time) {
  11316. set.sum += time;
  11317. set.min = Math.min(set.min, time);
  11318. set.max = Math.max(set.max, time);
  11319. }
  11320. function leaveFrame (time) {
  11321. var totalTime = time ? time : (getTimestamp() - this.time), // do this first
  11322. me = this, // me = frame
  11323. accum = me.accum;
  11324. ++accum.count;
  11325. if (! --accum.depth) {
  11326. adjustSet(accum.total, totalTime);
  11327. }
  11328. adjustSet(accum.pure, totalTime - me.childTime);
  11329. currentFrame = me.parent;
  11330. if (currentFrame) {
  11331. ++currentFrame.accum.childCount;
  11332. currentFrame.childTime += totalTime;
  11333. }
  11334. }
  11335. function makeSet () {
  11336. return {
  11337. min: Number.MAX_VALUE,
  11338. max: 0,
  11339. sum: 0
  11340. };
  11341. }
  11342. function makeTap (me, fn) {
  11343. return function () {
  11344. var frame = me.enter(),
  11345. ret = fn.apply(this, arguments);
  11346. frame.leave();
  11347. return ret;
  11348. };
  11349. }
  11350. function round (x) {
  11351. return Math.round(x * 100) / 100;
  11352. }
  11353. function setToJSON (count, childCount, calibration, set) {
  11354. var data = {
  11355. avg: 0,
  11356. min: set.min,
  11357. max: set.max,
  11358. sum: 0
  11359. };
  11360. if (count) {
  11361. calibration = calibration || 0;
  11362. data.sum = set.sum - childCount * calibration;
  11363. data.avg = data.sum / count;
  11364. // min and max cannot be easily corrected since we don't know the number of
  11365. // child calls for them.
  11366. }
  11367. return data;
  11368. }
  11369. return {
  11370. constructor: function (name) {
  11371. var me = this;
  11372. me.count = me.childCount = me.depth = me.maxDepth = 0;
  11373. me.pure = makeSet();
  11374. me.total = makeSet();
  11375. me.name = name;
  11376. },
  11377. statics: {
  11378. getTimestamp: getTimestamp
  11379. },
  11380. format: function (calibration) {
  11381. if (!formatTpl) {
  11382. formatTpl = new Ext.XTemplate([
  11383. '{name} - {count} call(s)',
  11384. '<tpl if="count">',
  11385. '<tpl if="childCount">',
  11386. ' ({childCount} children)',
  11387. '</tpl>',
  11388. '<tpl if="depth - 1">',
  11389. ' ({depth} deep)',
  11390. '</tpl>',
  11391. '<tpl for="times">',
  11392. ', {type}: {[this.time(values.sum)]} msec (',
  11393. //'min={[this.time(values.min)]}, ',
  11394. 'avg={[this.time(values.sum / parent.count)]}',
  11395. //', max={[this.time(values.max)]}',
  11396. ')',
  11397. '</tpl>',
  11398. '</tpl>'
  11399. ].join(''), {
  11400. time: function (t) {
  11401. return Math.round(t * 100) / 100;
  11402. }
  11403. });
  11404. }
  11405. var data = this.getData(calibration);
  11406. data.name = this.name;
  11407. data.pure.type = 'Pure';
  11408. data.total.type = 'Total';
  11409. data.times = [data.pure, data.total];
  11410. return formatTpl.apply(data);
  11411. },
  11412. getData: function (calibration) {
  11413. var me = this;
  11414. return {
  11415. count: me.count,
  11416. childCount: me.childCount,
  11417. depth: me.maxDepth,
  11418. pure: setToJSON(me.count, me.childCount, calibration, me.pure),
  11419. total: setToJSON(me.count, me.childCount, calibration, me.total)
  11420. };
  11421. },
  11422. enter: function () {
  11423. var me = this,
  11424. frame = {
  11425. accum: me,
  11426. leave: leaveFrame,
  11427. childTime: 0,
  11428. parent: currentFrame
  11429. };
  11430. ++me.depth;
  11431. if (me.maxDepth < me.depth) {
  11432. me.maxDepth = me.depth;
  11433. }
  11434. currentFrame = frame;
  11435. frame.time = getTimestamp(); // do this last
  11436. return frame;
  11437. },
  11438. monitor: function (fn, scope, args) {
  11439. var frame = this.enter();
  11440. if (args) {
  11441. fn.apply(scope, args);
  11442. } else {
  11443. fn.call(scope);
  11444. }
  11445. frame.leave();
  11446. },
  11447. report: function () {
  11448. Ext.log(this.format());
  11449. },
  11450. tap: function (className, methodName) {
  11451. var me = this,
  11452. methods = typeof methodName == 'string' ? [methodName] : methodName,
  11453. klass, statik, i, parts, length, name, src,
  11454. tapFunc;
  11455. tapFunc = function(){
  11456. if (typeof className == 'string') {
  11457. klass = Ext.global;
  11458. parts = className.split('.');
  11459. for (i = 0, length = parts.length; i < length; ++i) {
  11460. klass = klass[parts[i]];
  11461. }
  11462. } else {
  11463. klass = className;
  11464. }
  11465. for (i = 0, length = methods.length; i < length; ++i) {
  11466. name = methods[i];
  11467. statik = name.charAt(0) == '!';
  11468. if (statik) {
  11469. name = name.substring(1);
  11470. } else {
  11471. statik = !(name in klass.prototype);
  11472. }
  11473. src = statik ? klass : klass.prototype;
  11474. src[name] = makeTap(me, src[name]);
  11475. }
  11476. };
  11477. Ext.ClassManager.onCreated(tapFunc, me, className);
  11478. return me;
  11479. }
  11480. };
  11481. }()),
  11482. function () {
  11483. Ext.perf.getTimestamp = this.getTimestamp;
  11484. });
  11485. //@tag extras,core
  11486. //@require Accumulator.js
  11487. /**
  11488. * @class Ext.perf.Monitor
  11489. * @singleton
  11490. * @private
  11491. */
  11492. Ext.define('Ext.perf.Monitor', {
  11493. singleton: true,
  11494. alternateClassName: 'Ext.Perf',
  11495. requires: [
  11496. 'Ext.perf.Accumulator'
  11497. ],
  11498. constructor: function () {
  11499. this.accumulators = [];
  11500. this.accumulatorsByName = {};
  11501. },
  11502. calibrate: function () {
  11503. var accum = new Ext.perf.Accumulator('$'),
  11504. total = accum.total,
  11505. getTimestamp = Ext.perf.Accumulator.getTimestamp,
  11506. count = 0,
  11507. frame,
  11508. endTime,
  11509. startTime;
  11510. startTime = getTimestamp();
  11511. do {
  11512. frame = accum.enter();
  11513. frame.leave();
  11514. ++count;
  11515. } while (total.sum < 100);
  11516. endTime = getTimestamp();
  11517. return (endTime - startTime) / count;
  11518. },
  11519. get: function (name) {
  11520. var me = this,
  11521. accum = me.accumulatorsByName[name];
  11522. if (!accum) {
  11523. me.accumulatorsByName[name] = accum = new Ext.perf.Accumulator(name);
  11524. me.accumulators.push(accum);
  11525. }
  11526. return accum;
  11527. },
  11528. enter: function (name) {
  11529. return this.get(name).enter();
  11530. },
  11531. monitor: function (name, fn, scope) {
  11532. this.get(name).monitor(fn, scope);
  11533. },
  11534. report: function () {
  11535. var me = this,
  11536. accumulators = me.accumulators,
  11537. calibration = me.calibrate();
  11538. accumulators.sort(function (a, b) {
  11539. return (a.name < b.name) ? -1 : ((b.name < a.name) ? 1 : 0);
  11540. });
  11541. me.updateGC();
  11542. Ext.log('Calibration: ' + Math.round(calibration * 100) / 100 + ' msec/sample');
  11543. Ext.each(accumulators, function (accum) {
  11544. Ext.log(accum.format(calibration));
  11545. });
  11546. },
  11547. getData: function (all) {
  11548. var ret = {},
  11549. accumulators = this.accumulators;
  11550. Ext.each(accumulators, function (accum) {
  11551. if (all || accum.count) {
  11552. ret[accum.name] = accum.getData();
  11553. }
  11554. });
  11555. return ret;
  11556. },
  11557. reset: function(){
  11558. Ext.each(this.accumulators, function(accum){
  11559. var me = accum;
  11560. me.count = me.childCount = me.depth = me.maxDepth = 0;
  11561. me.pure = {
  11562. min: Number.MAX_VALUE,
  11563. max: 0,
  11564. sum: 0
  11565. };
  11566. me.total = {
  11567. min: Number.MAX_VALUE,
  11568. max: 0,
  11569. sum: 0
  11570. };
  11571. });
  11572. },
  11573. updateGC: function () {
  11574. var accumGC = this.accumulatorsByName.GC,
  11575. toolbox = Ext.senchaToolbox,
  11576. bucket;
  11577. if (accumGC) {
  11578. accumGC.count = toolbox.garbageCollectionCounter || 0;
  11579. if (accumGC.count) {
  11580. bucket = accumGC.pure;
  11581. accumGC.total.sum = bucket.sum = toolbox.garbageCollectionMilliseconds;
  11582. bucket.min = bucket.max = bucket.sum / accumGC.count;
  11583. bucket = accumGC.total;
  11584. bucket.min = bucket.max = bucket.sum / accumGC.count;
  11585. }
  11586. }
  11587. },
  11588. watchGC: function () {
  11589. Ext.perf.getTimestamp(); // initializes SenchaToolbox (if available)
  11590. var toolbox = Ext.senchaToolbox;
  11591. if (toolbox) {
  11592. this.get("GC");
  11593. toolbox.watchGarbageCollector(false); // no logging, just totals
  11594. }
  11595. },
  11596. setup: function (config) {
  11597. if (!config) {
  11598. config = {
  11599. /*insertHtml: {
  11600. 'Ext.dom.Helper': 'insertHtml'
  11601. },*/
  11602. /*xtplCompile: {
  11603. 'Ext.XTemplateCompiler': 'compile'
  11604. },*/
  11605. // doInsert: {
  11606. // 'Ext.Template': 'doInsert'
  11607. // },
  11608. // applyOut: {
  11609. // 'Ext.XTemplate': 'applyOut'
  11610. // },
  11611. render: {
  11612. 'Ext.AbstractComponent': 'render'
  11613. },
  11614. // fnishRender: {
  11615. // 'Ext.AbstractComponent': 'finishRender'
  11616. // },
  11617. // renderSelectors: {
  11618. // 'Ext.AbstractComponent': 'applyRenderSelectors'
  11619. // },
  11620. // compAddCls: {
  11621. // 'Ext.AbstractComponent': 'addCls'
  11622. // },
  11623. // compRemoveCls: {
  11624. // 'Ext.AbstractComponent': 'removeCls'
  11625. // },
  11626. // getStyle: {
  11627. // 'Ext.core.Element': 'getStyle'
  11628. // },
  11629. // setStyle: {
  11630. // 'Ext.core.Element': 'setStyle'
  11631. // },
  11632. // addCls: {
  11633. // 'Ext.core.Element': 'addCls'
  11634. // },
  11635. // removeCls: {
  11636. // 'Ext.core.Element': 'removeCls'
  11637. // },
  11638. // measure: {
  11639. // 'Ext.layout.component.Component': 'measureAutoDimensions'
  11640. // },
  11641. // moveItem: {
  11642. // 'Ext.layout.Layout': 'moveItem'
  11643. // },
  11644. // layoutFlush: {
  11645. // 'Ext.layout.Context': 'flush'
  11646. // },
  11647. layout: {
  11648. 'Ext.layout.Context': 'run'
  11649. }
  11650. };
  11651. }
  11652. this.currentConfig = config;
  11653. var key, prop,
  11654. accum, className, methods;
  11655. for (key in config) {
  11656. if (config.hasOwnProperty(key)) {
  11657. prop = config[key];
  11658. accum = Ext.Perf.get(key);
  11659. for (className in prop) {
  11660. if (prop.hasOwnProperty(className)) {
  11661. methods = prop[className];
  11662. accum.tap(className, methods);
  11663. }
  11664. }
  11665. }
  11666. }
  11667. this.watchGC();
  11668. }
  11669. });
  11670. //@tag extras,core
  11671. //@require perf/Monitor.js
  11672. //@define Ext.Supports
  11673. /**
  11674. * @class Ext.is
  11675. *
  11676. * Determines information about the current platform the application is running on.
  11677. *
  11678. * @singleton
  11679. */
  11680. Ext.is = {
  11681. init : function(navigator) {
  11682. var platforms = this.platforms,
  11683. ln = platforms.length,
  11684. i, platform;
  11685. navigator = navigator || window.navigator;
  11686. for (i = 0; i < ln; i++) {
  11687. platform = platforms[i];
  11688. this[platform.identity] = platform.regex.test(navigator[platform.property]);
  11689. }
  11690. /**
  11691. * @property Desktop True if the browser is running on a desktop machine
  11692. * @type {Boolean}
  11693. */
  11694. this.Desktop = this.Mac || this.Windows || (this.Linux && !this.Android);
  11695. /**
  11696. * @property Tablet True if the browser is running on a tablet (iPad)
  11697. */
  11698. this.Tablet = this.iPad;
  11699. /**
  11700. * @property Phone True if the browser is running on a phone.
  11701. * @type {Boolean}
  11702. */
  11703. this.Phone = !this.Desktop && !this.Tablet;
  11704. /**
  11705. * @property iOS True if the browser is running on iOS
  11706. * @type {Boolean}
  11707. */
  11708. this.iOS = this.iPhone || this.iPad || this.iPod;
  11709. /**
  11710. * @property Standalone Detects when application has been saved to homescreen.
  11711. * @type {Boolean}
  11712. */
  11713. this.Standalone = !!window.navigator.standalone;
  11714. },
  11715. /**
  11716. * @property iPhone True when the browser is running on a iPhone
  11717. * @type {Boolean}
  11718. */
  11719. platforms: [{
  11720. property: 'platform',
  11721. regex: /iPhone/i,
  11722. identity: 'iPhone'
  11723. },
  11724. /**
  11725. * @property iPod True when the browser is running on a iPod
  11726. * @type {Boolean}
  11727. */
  11728. {
  11729. property: 'platform',
  11730. regex: /iPod/i,
  11731. identity: 'iPod'
  11732. },
  11733. /**
  11734. * @property iPad True when the browser is running on a iPad
  11735. * @type {Boolean}
  11736. */
  11737. {
  11738. property: 'userAgent',
  11739. regex: /iPad/i,
  11740. identity: 'iPad'
  11741. },
  11742. /**
  11743. * @property Blackberry True when the browser is running on a Blackberry
  11744. * @type {Boolean}
  11745. */
  11746. {
  11747. property: 'userAgent',
  11748. regex: /Blackberry/i,
  11749. identity: 'Blackberry'
  11750. },
  11751. /**
  11752. * @property Android True when the browser is running on an Android device
  11753. * @type {Boolean}
  11754. */
  11755. {
  11756. property: 'userAgent',
  11757. regex: /Android/i,
  11758. identity: 'Android'
  11759. },
  11760. /**
  11761. * @property Mac True when the browser is running on a Mac
  11762. * @type {Boolean}
  11763. */
  11764. {
  11765. property: 'platform',
  11766. regex: /Mac/i,
  11767. identity: 'Mac'
  11768. },
  11769. /**
  11770. * @property Windows True when the browser is running on Windows
  11771. * @type {Boolean}
  11772. */
  11773. {
  11774. property: 'platform',
  11775. regex: /Win/i,
  11776. identity: 'Windows'
  11777. },
  11778. /**
  11779. * @property Linux True when the browser is running on Linux
  11780. * @type {Boolean}
  11781. */
  11782. {
  11783. property: 'platform',
  11784. regex: /Linux/i,
  11785. identity: 'Linux'
  11786. }]
  11787. };
  11788. Ext.is.init();
  11789. /**
  11790. * @class Ext.supports
  11791. *
  11792. * Determines information about features are supported in the current environment
  11793. *
  11794. * @singleton
  11795. */
  11796. (function(){
  11797. // this is a local copy of certain logic from (Abstract)Element.getStyle
  11798. // to break a dependancy between the supports mechanism and Element
  11799. // use this instead of element references to check for styling info
  11800. var getStyle = function(element, styleName){
  11801. var view = element.ownerDocument.defaultView,
  11802. style = (view ? view.getComputedStyle(element, null) : element.currentStyle) || element.style;
  11803. return style[styleName];
  11804. };
  11805. Ext.supports = {
  11806. /**
  11807. * Runs feature detection routines and sets the various flags. This is called when
  11808. * the scripts loads (very early) and again at {@link Ext#onReady}. Some detections
  11809. * are flagged as `early` and run immediately. Others that require the document body
  11810. * will not run until ready.
  11811. *
  11812. * Each test is run only once, so calling this method from an onReady function is safe
  11813. * and ensures that all flags have been set.
  11814. * @markdown
  11815. * @private
  11816. */
  11817. init : function() {
  11818. var me = this,
  11819. doc = document,
  11820. tests = me.tests,
  11821. n = tests.length,
  11822. div = n && Ext.isReady && doc.createElement('div'),
  11823. test, notRun = [];
  11824. if (div) {
  11825. div.innerHTML = [
  11826. '<div style="height:30px;width:50px;">',
  11827. '<div style="height:20px;width:20px;"></div>',
  11828. '</div>',
  11829. '<div style="width: 200px; height: 200px; position: relative; padding: 5px;">',
  11830. '<div style="position: absolute; top: 0; left: 0; width: 100%; height: 100%;"></div>',
  11831. '</div>',
  11832. '<div style="position: absolute; left: 10%; top: 10%;"></div>',
  11833. '<div style="float:left; background-color:transparent;"></div>'
  11834. ].join('');
  11835. doc.body.appendChild(div);
  11836. }
  11837. while (n--) {
  11838. test = tests[n];
  11839. if (div || test.early) {
  11840. me[test.identity] = test.fn.call(me, doc, div);
  11841. } else {
  11842. notRun.push(test);
  11843. }
  11844. }
  11845. if (div) {
  11846. doc.body.removeChild(div);
  11847. }
  11848. me.tests = notRun;
  11849. },
  11850. /**
  11851. * @property PointerEvents True if document environment supports the CSS3 pointer-events style.
  11852. * @type {Boolean}
  11853. */
  11854. PointerEvents: 'pointerEvents' in document.documentElement.style,
  11855. /**
  11856. * @property CSS3BoxShadow True if document environment supports the CSS3 box-shadow style.
  11857. * @type {Boolean}
  11858. */
  11859. CSS3BoxShadow: 'boxShadow' in document.documentElement.style || 'WebkitBoxShadow' in document.documentElement.style || 'MozBoxShadow' in document.documentElement.style,
  11860. /**
  11861. * @property ClassList True if document environment supports the HTML5 classList API.
  11862. * @type {Boolean}
  11863. */
  11864. ClassList: !!document.documentElement.classList,
  11865. /**
  11866. * @property OrientationChange True if the device supports orientation change
  11867. * @type {Boolean}
  11868. */
  11869. OrientationChange: ((typeof window.orientation != 'undefined') && ('onorientationchange' in window)),
  11870. /**
  11871. * @property DeviceMotion True if the device supports device motion (acceleration and rotation rate)
  11872. * @type {Boolean}
  11873. */
  11874. DeviceMotion: ('ondevicemotion' in window),
  11875. /**
  11876. * @property Touch True if the device supports touch
  11877. * @type {Boolean}
  11878. */
  11879. // is.Desktop is needed due to the bug in Chrome 5.0.375, Safari 3.1.2
  11880. // and Safari 4.0 (they all have 'ontouchstart' in the window object).
  11881. Touch: ('ontouchstart' in window) && (!Ext.is.Desktop),
  11882. /**
  11883. * @property TimeoutActualLateness True if the browser passes the "actualLateness" parameter to
  11884. * setTimeout. See: https://developer.mozilla.org/en/DOM/window.setTimeout
  11885. * @type {Boolean}
  11886. */
  11887. TimeoutActualLateness: (function(){
  11888. setTimeout(function(){
  11889. Ext.supports.TimeoutActualLateness = arguments.length !== 0;
  11890. }, 0);
  11891. }()),
  11892. tests: [
  11893. /**
  11894. * @property Transitions True if the device supports CSS3 Transitions
  11895. * @type {Boolean}
  11896. */
  11897. {
  11898. identity: 'Transitions',
  11899. fn: function(doc, div) {
  11900. var prefix = [
  11901. 'webkit',
  11902. 'Moz',
  11903. 'o',
  11904. 'ms',
  11905. 'khtml'
  11906. ],
  11907. TE = 'TransitionEnd',
  11908. transitionEndName = [
  11909. prefix[0] + TE,
  11910. 'transitionend', //Moz bucks the prefixing convention
  11911. prefix[2] + TE,
  11912. prefix[3] + TE,
  11913. prefix[4] + TE
  11914. ],
  11915. ln = prefix.length,
  11916. i = 0,
  11917. out = false;
  11918. for (; i < ln; i++) {
  11919. if (getStyle(div, prefix[i] + "TransitionProperty")) {
  11920. Ext.supports.CSS3Prefix = prefix[i];
  11921. Ext.supports.CSS3TransitionEnd = transitionEndName[i];
  11922. out = true;
  11923. break;
  11924. }
  11925. }
  11926. return out;
  11927. }
  11928. },
  11929. /**
  11930. * @property RightMargin True if the device supports right margin.
  11931. * See https://bugs.webkit.org/show_bug.cgi?id=13343 for why this is needed.
  11932. * @type {Boolean}
  11933. */
  11934. {
  11935. identity: 'RightMargin',
  11936. fn: function(doc, div) {
  11937. var view = doc.defaultView;
  11938. return !(view && view.getComputedStyle(div.firstChild.firstChild, null).marginRight != '0px');
  11939. }
  11940. },
  11941. /**
  11942. * @property DisplayChangeInputSelectionBug True if INPUT elements lose their
  11943. * selection when their display style is changed. Essentially, if a text input
  11944. * has focus and its display style is changed, the I-beam disappears.
  11945. *
  11946. * This bug is encountered due to the work around in place for the {@link #RightMargin}
  11947. * bug. This has been observed in Safari 4.0.4 and older, and appears to be fixed
  11948. * in Safari 5. It's not clear if Safari 4.1 has the bug, but it has the same WebKit
  11949. * version number as Safari 5 (according to http://unixpapa.com/js/gecko.html).
  11950. */
  11951. {
  11952. identity: 'DisplayChangeInputSelectionBug',
  11953. early: true,
  11954. fn: function() {
  11955. var webKitVersion = Ext.webKitVersion;
  11956. // WebKit but older than Safari 5 or Chrome 6:
  11957. return 0 < webKitVersion && webKitVersion < 533;
  11958. }
  11959. },
  11960. /**
  11961. * @property DisplayChangeTextAreaSelectionBug True if TEXTAREA elements lose their
  11962. * selection when their display style is changed. Essentially, if a text area has
  11963. * focus and its display style is changed, the I-beam disappears.
  11964. *
  11965. * This bug is encountered due to the work around in place for the {@link #RightMargin}
  11966. * bug. This has been observed in Chrome 10 and Safari 5 and older, and appears to
  11967. * be fixed in Chrome 11.
  11968. */
  11969. {
  11970. identity: 'DisplayChangeTextAreaSelectionBug',
  11971. early: true,
  11972. fn: function() {
  11973. var webKitVersion = Ext.webKitVersion;
  11974. /*
  11975. Has bug w/textarea:
  11976. (Chrome) Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-US)
  11977. AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.127
  11978. Safari/534.16
  11979. (Safari) Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-us)
  11980. AppleWebKit/533.21.1 (KHTML, like Gecko) Version/5.0.5
  11981. Safari/533.21.1
  11982. No bug:
  11983. (Chrome) Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_7)
  11984. AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.57
  11985. Safari/534.24
  11986. */
  11987. return 0 < webKitVersion && webKitVersion < 534.24;
  11988. }
  11989. },
  11990. /**
  11991. * @property TransparentColor True if the device supports transparent color
  11992. * @type {Boolean}
  11993. */
  11994. {
  11995. identity: 'TransparentColor',
  11996. fn: function(doc, div, view) {
  11997. view = doc.defaultView;
  11998. return !(view && view.getComputedStyle(div.lastChild, null).backgroundColor != 'transparent');
  11999. }
  12000. },
  12001. /**
  12002. * @property ComputedStyle True if the browser supports document.defaultView.getComputedStyle()
  12003. * @type {Boolean}
  12004. */
  12005. {
  12006. identity: 'ComputedStyle',
  12007. fn: function(doc, div, view) {
  12008. view = doc.defaultView;
  12009. return view && view.getComputedStyle;
  12010. }
  12011. },
  12012. /**
  12013. * @property Svg True if the device supports SVG
  12014. * @type {Boolean}
  12015. */
  12016. {
  12017. identity: 'Svg',
  12018. fn: function(doc) {
  12019. return !!doc.createElementNS && !!doc.createElementNS( "http:/" + "/www.w3.org/2000/svg", "svg").createSVGRect;
  12020. }
  12021. },
  12022. /**
  12023. * @property Canvas True if the device supports Canvas
  12024. * @type {Boolean}
  12025. */
  12026. {
  12027. identity: 'Canvas',
  12028. fn: function(doc) {
  12029. return !!doc.createElement('canvas').getContext;
  12030. }
  12031. },
  12032. /**
  12033. * @property Vml True if the device supports VML
  12034. * @type {Boolean}
  12035. */
  12036. {
  12037. identity: 'Vml',
  12038. fn: function(doc) {
  12039. var d = doc.createElement("div");
  12040. d.innerHTML = "<!--[if vml]><br/><br/><![endif]-->";
  12041. return (d.childNodes.length == 2);
  12042. }
  12043. },
  12044. /**
  12045. * @property Float True if the device supports CSS float
  12046. * @type {Boolean}
  12047. */
  12048. {
  12049. identity: 'Float',
  12050. fn: function(doc, div) {
  12051. return !!div.lastChild.style.cssFloat;
  12052. }
  12053. },
  12054. /**
  12055. * @property AudioTag True if the device supports the HTML5 audio tag
  12056. * @type {Boolean}
  12057. */
  12058. {
  12059. identity: 'AudioTag',
  12060. fn: function(doc) {
  12061. return !!doc.createElement('audio').canPlayType;
  12062. }
  12063. },
  12064. /**
  12065. * @property History True if the device supports HTML5 history
  12066. * @type {Boolean}
  12067. */
  12068. {
  12069. identity: 'History',
  12070. fn: function() {
  12071. var history = window.history;
  12072. return !!(history && history.pushState);
  12073. }
  12074. },
  12075. /**
  12076. * @property CSS3DTransform True if the device supports CSS3DTransform
  12077. * @type {Boolean}
  12078. */
  12079. {
  12080. identity: 'CSS3DTransform',
  12081. fn: function() {
  12082. return (typeof WebKitCSSMatrix != 'undefined' && new WebKitCSSMatrix().hasOwnProperty('m41'));
  12083. }
  12084. },
  12085. /**
  12086. * @property CSS3LinearGradient True if the device supports CSS3 linear gradients
  12087. * @type {Boolean}
  12088. */
  12089. {
  12090. identity: 'CSS3LinearGradient',
  12091. fn: function(doc, div) {
  12092. var property = 'background-image:',
  12093. webkit = '-webkit-gradient(linear, left top, right bottom, from(black), to(white))',
  12094. w3c = 'linear-gradient(left top, black, white)',
  12095. moz = '-moz-' + w3c,
  12096. opera = '-o-' + w3c,
  12097. options = [property + webkit, property + w3c, property + moz, property + opera];
  12098. div.style.cssText = options.join(';');
  12099. return ("" + div.style.backgroundImage).indexOf('gradient') !== -1;
  12100. }
  12101. },
  12102. /**
  12103. * @property CSS3BorderRadius True if the device supports CSS3 border radius
  12104. * @type {Boolean}
  12105. */
  12106. {
  12107. identity: 'CSS3BorderRadius',
  12108. fn: function(doc, div) {
  12109. var domPrefixes = ['borderRadius', 'BorderRadius', 'MozBorderRadius', 'WebkitBorderRadius', 'OBorderRadius', 'KhtmlBorderRadius'],
  12110. pass = false,
  12111. i;
  12112. for (i = 0; i < domPrefixes.length; i++) {
  12113. if (document.body.style[domPrefixes[i]] !== undefined) {
  12114. return true;
  12115. }
  12116. }
  12117. return pass;
  12118. }
  12119. },
  12120. /**
  12121. * @property GeoLocation True if the device supports GeoLocation
  12122. * @type {Boolean}
  12123. */
  12124. {
  12125. identity: 'GeoLocation',
  12126. fn: function() {
  12127. return (typeof navigator != 'undefined' && typeof navigator.geolocation != 'undefined') || (typeof google != 'undefined' && typeof google.gears != 'undefined');
  12128. }
  12129. },
  12130. /**
  12131. * @property MouseEnterLeave True if the browser supports mouseenter and mouseleave events
  12132. * @type {Boolean}
  12133. */
  12134. {
  12135. identity: 'MouseEnterLeave',
  12136. fn: function(doc, div){
  12137. return ('onmouseenter' in div && 'onmouseleave' in div);
  12138. }
  12139. },
  12140. /**
  12141. * @property MouseWheel True if the browser supports the mousewheel event
  12142. * @type {Boolean}
  12143. */
  12144. {
  12145. identity: 'MouseWheel',
  12146. fn: function(doc, div) {
  12147. return ('onmousewheel' in div);
  12148. }
  12149. },
  12150. /**
  12151. * @property Opacity True if the browser supports normal css opacity
  12152. * @type {Boolean}
  12153. */
  12154. {
  12155. identity: 'Opacity',
  12156. fn: function(doc, div){
  12157. // Not a strict equal comparison in case opacity can be converted to a number.
  12158. if (Ext.isIE6 || Ext.isIE7 || Ext.isIE8) {
  12159. return false;
  12160. }
  12161. div.firstChild.style.cssText = 'opacity:0.73';
  12162. return div.firstChild.style.opacity == '0.73';
  12163. }
  12164. },
  12165. /**
  12166. * @property Placeholder True if the browser supports the HTML5 placeholder attribute on inputs
  12167. * @type {Boolean}
  12168. */
  12169. {
  12170. identity: 'Placeholder',
  12171. fn: function(doc) {
  12172. return 'placeholder' in doc.createElement('input');
  12173. }
  12174. },
  12175. /**
  12176. * @property Direct2DBug True if when asking for an element's dimension via offsetWidth or offsetHeight,
  12177. * getBoundingClientRect, etc. the browser returns the subpixel width rounded to the nearest pixel.
  12178. * @type {Boolean}
  12179. */
  12180. {
  12181. identity: 'Direct2DBug',
  12182. fn: function() {
  12183. return Ext.isString(document.body.style.msTransformOrigin);
  12184. }
  12185. },
  12186. /**
  12187. * @property BoundingClientRect True if the browser supports the getBoundingClientRect method on elements
  12188. * @type {Boolean}
  12189. */
  12190. {
  12191. identity: 'BoundingClientRect',
  12192. fn: function(doc, div) {
  12193. return Ext.isFunction(div.getBoundingClientRect);
  12194. }
  12195. },
  12196. {
  12197. identity: 'IncludePaddingInWidthCalculation',
  12198. fn: function(doc, div){
  12199. return div.childNodes[1].firstChild.offsetWidth == 210;
  12200. }
  12201. },
  12202. {
  12203. identity: 'IncludePaddingInHeightCalculation',
  12204. fn: function(doc, div){
  12205. return div.childNodes[1].firstChild.offsetHeight == 210;
  12206. }
  12207. },
  12208. /**
  12209. * @property ArraySort True if the Array sort native method isn't bugged.
  12210. * @type {Boolean}
  12211. */
  12212. {
  12213. identity: 'ArraySort',
  12214. fn: function() {
  12215. var a = [1,2,3,4,5].sort(function(){ return 0; });
  12216. return a[0] === 1 && a[1] === 2 && a[2] === 3 && a[3] === 4 && a[4] === 5;
  12217. }
  12218. },
  12219. /**
  12220. * @property Range True if browser support document.createRange native method.
  12221. * @type {Boolean}
  12222. */
  12223. {
  12224. identity: 'Range',
  12225. fn: function() {
  12226. return !!document.createRange;
  12227. }
  12228. },
  12229. /**
  12230. * @property CreateContextualFragment True if browser support CreateContextualFragment range native methods.
  12231. * @type {Boolean}
  12232. */
  12233. {
  12234. identity: 'CreateContextualFragment',
  12235. fn: function() {
  12236. var range = Ext.supports.Range ? document.createRange() : false;
  12237. return range && !!range.createContextualFragment;
  12238. }
  12239. },
  12240. /**
  12241. * @property WindowOnError True if browser supports window.onerror.
  12242. * @type {Boolean}
  12243. */
  12244. {
  12245. identity: 'WindowOnError',
  12246. fn: function () {
  12247. // sadly, we cannot feature detect this...
  12248. return Ext.isIE || Ext.isGecko || Ext.webKitVersion >= 534.16; // Chrome 10+
  12249. }
  12250. },
  12251. /**
  12252. * @property TextAreaMaxLength True if the browser supports maxlength on textareas.
  12253. * @type {Boolean}
  12254. */
  12255. {
  12256. identity: 'TextAreaMaxLength',
  12257. fn: function(){
  12258. var el = document.createElement('textarea');
  12259. return ('maxlength' in el);
  12260. }
  12261. },
  12262. /**
  12263. * @property GetPositionPercentage True if the browser will return the left/top/right/bottom
  12264. * position as a percentage when explicitly set as a percentage value.
  12265. * @type {Boolean}
  12266. */
  12267. // Related bug: https://bugzilla.mozilla.org/show_bug.cgi?id=707691#c7
  12268. {
  12269. identity: 'GetPositionPercentage',
  12270. fn: function(doc, div){
  12271. return getStyle(div.childNodes[2], 'left') == '10%';
  12272. }
  12273. }
  12274. ]
  12275. };
  12276. }());
  12277. Ext.supports.init(); // run the "early" detections now
  12278. //@tag dom,core
  12279. //@require ../Support.js
  12280. //@define Ext.util.DelayedTask
  12281. /**
  12282. * @class Ext.util.DelayedTask
  12283. *
  12284. * The DelayedTask class provides a convenient way to "buffer" the execution of a method,
  12285. * performing setTimeout where a new timeout cancels the old timeout. When called, the
  12286. * task will wait the specified time period before executing. If durng that time period,
  12287. * the task is called again, the original call will be cancelled. This continues so that
  12288. * the function is only called a single time for each iteration.
  12289. *
  12290. * This method is especially useful for things like detecting whether a user has finished
  12291. * typing in a text field. An example would be performing validation on a keypress. You can
  12292. * use this class to buffer the keypress events for a certain number of milliseconds, and
  12293. * perform only if they stop for that amount of time.
  12294. *
  12295. * ## Usage
  12296. *
  12297. * var task = new Ext.util.DelayedTask(function(){
  12298. * alert(Ext.getDom('myInputField').value.length);
  12299. * });
  12300. *
  12301. * // Wait 500ms before calling our function. If the user presses another key
  12302. * // during that 500ms, it will be cancelled and we'll wait another 500ms.
  12303. * Ext.get('myInputField').on('keypress', function(){
  12304. * task.{@link #delay}(500);
  12305. * });
  12306. *
  12307. * Note that we are using a DelayedTask here to illustrate a point. The configuration
  12308. * option `buffer` for {@link Ext.util.Observable#addListener addListener/on} will
  12309. * also setup a delayed task for you to buffer events.
  12310. *
  12311. * @constructor The parameters to this constructor serve as defaults and are not required.
  12312. * @param {Function} fn (optional) The default function to call. If not specified here, it must be specified during the {@link #delay} call.
  12313. * @param {Object} scope (optional) The default scope (The <code><b>this</b></code> reference) in which the
  12314. * function is called. If not specified, <code>this</code> will refer to the browser window.
  12315. * @param {Array} args (optional) The default Array of arguments.
  12316. */
  12317. Ext.util.DelayedTask = function(fn, scope, args) {
  12318. var me = this,
  12319. id,
  12320. call = function() {
  12321. clearInterval(id);
  12322. id = null;
  12323. fn.apply(scope, args || []);
  12324. };
  12325. /**
  12326. * Cancels any pending timeout and queues a new one
  12327. * @param {Number} delay The milliseconds to delay
  12328. * @param {Function} newFn (optional) Overrides function passed to constructor
  12329. * @param {Object} newScope (optional) Overrides scope passed to constructor. Remember that if no scope
  12330. * is specified, <code>this</code> will refer to the browser window.
  12331. * @param {Array} newArgs (optional) Overrides args passed to constructor
  12332. */
  12333. this.delay = function(delay, newFn, newScope, newArgs) {
  12334. me.cancel();
  12335. fn = newFn || fn;
  12336. scope = newScope || scope;
  12337. args = newArgs || args;
  12338. id = setInterval(call, delay);
  12339. };
  12340. /**
  12341. * Cancel the last queued timeout
  12342. */
  12343. this.cancel = function(){
  12344. if (id) {
  12345. clearInterval(id);
  12346. id = null;
  12347. }
  12348. };
  12349. };
  12350. //@tag dom,core
  12351. //@define Ext.util.Event
  12352. //@require Ext.util.DelayedTask
  12353. Ext.require('Ext.util.DelayedTask', function() {
  12354. /**
  12355. * Represents single event type that an Observable object listens to.
  12356. * All actual listeners are tracked inside here. When the event fires,
  12357. * it calls all the registered listener functions.
  12358. *
  12359. * @private
  12360. */
  12361. Ext.util.Event = Ext.extend(Object, (function() {
  12362. var noOptions = {};
  12363. function createTargeted(handler, listener, o, scope){
  12364. return function(){
  12365. if (o.target === arguments[0]){
  12366. handler.apply(scope, arguments);
  12367. }
  12368. };
  12369. }
  12370. function createBuffered(handler, listener, o, scope) {
  12371. listener.task = new Ext.util.DelayedTask();
  12372. return function() {
  12373. listener.task.delay(o.buffer, handler, scope, Ext.Array.toArray(arguments));
  12374. };
  12375. }
  12376. function createDelayed(handler, listener, o, scope) {
  12377. return function() {
  12378. var task = new Ext.util.DelayedTask();
  12379. if (!listener.tasks) {
  12380. listener.tasks = [];
  12381. }
  12382. listener.tasks.push(task);
  12383. task.delay(o.delay || 10, handler, scope, Ext.Array.toArray(arguments));
  12384. };
  12385. }
  12386. function createSingle(handler, listener, o, scope) {
  12387. return function() {
  12388. var event = listener.ev;
  12389. if (event.removeListener(listener.fn, scope) && event.observable) {
  12390. // Removing from a regular Observable-owned, named event (not an anonymous
  12391. // event such as Ext's readyEvent): Decrement the listeners count
  12392. event.observable.hasListeners[event.name]--;
  12393. }
  12394. return handler.apply(scope, arguments);
  12395. };
  12396. }
  12397. return {
  12398. /**
  12399. * @property {Boolean} isEvent
  12400. * `true` in this class to identify an object as an instantiated Event, or subclass thereof.
  12401. */
  12402. isEvent: true,
  12403. constructor: function(observable, name) {
  12404. this.name = name;
  12405. this.observable = observable;
  12406. this.listeners = [];
  12407. },
  12408. addListener: function(fn, scope, options) {
  12409. var me = this,
  12410. listener;
  12411. scope = scope || me.observable;
  12412. if (!me.isListening(fn, scope)) {
  12413. listener = me.createListener(fn, scope, options);
  12414. if (me.firing) {
  12415. // if we are currently firing this event, don't disturb the listener loop
  12416. me.listeners = me.listeners.slice(0);
  12417. }
  12418. me.listeners.push(listener);
  12419. }
  12420. },
  12421. createListener: function(fn, scope, options) {
  12422. options = options || noOptions;
  12423. scope = scope || this.observable;
  12424. var listener = {
  12425. fn: fn,
  12426. scope: scope,
  12427. o: options,
  12428. ev: this
  12429. },
  12430. handler = fn;
  12431. // The order is important. The 'single' wrapper must be wrapped by the 'buffer' and 'delayed' wrapper
  12432. // because the event removal that the single listener does destroys the listener's DelayedTask(s)
  12433. if (options.single) {
  12434. handler = createSingle(handler, listener, options, scope);
  12435. }
  12436. if (options.target) {
  12437. handler = createTargeted(handler, listener, options, scope);
  12438. }
  12439. if (options.delay) {
  12440. handler = createDelayed(handler, listener, options, scope);
  12441. }
  12442. if (options.buffer) {
  12443. handler = createBuffered(handler, listener, options, scope);
  12444. }
  12445. listener.fireFn = handler;
  12446. return listener;
  12447. },
  12448. findListener: function(fn, scope) {
  12449. var listeners = this.listeners,
  12450. i = listeners.length,
  12451. listener,
  12452. s;
  12453. while (i--) {
  12454. listener = listeners[i];
  12455. if (listener) {
  12456. s = listener.scope;
  12457. // Compare the listener's scope with *JUST THE PASSED SCOPE* if one is passed, and only fall back to the owning Observable if none is passed.
  12458. // We cannot use the test (s == scope || s == this.observable)
  12459. // Otherwise, if the Observable itself adds Ext.emptyFn as a listener, and then Ext.emptyFn is added under another scope, there will be a false match.
  12460. if (listener.fn == fn && (s == (scope || this.observable))) {
  12461. return i;
  12462. }
  12463. }
  12464. }
  12465. return - 1;
  12466. },
  12467. isListening: function(fn, scope) {
  12468. return this.findListener(fn, scope) !== -1;
  12469. },
  12470. removeListener: function(fn, scope) {
  12471. var me = this,
  12472. index,
  12473. listener,
  12474. k;
  12475. index = me.findListener(fn, scope);
  12476. if (index != -1) {
  12477. listener = me.listeners[index];
  12478. if (me.firing) {
  12479. me.listeners = me.listeners.slice(0);
  12480. }
  12481. // cancel and remove a buffered handler that hasn't fired yet
  12482. if (listener.task) {
  12483. listener.task.cancel();
  12484. delete listener.task;
  12485. }
  12486. // cancel and remove all delayed handlers that haven't fired yet
  12487. k = listener.tasks && listener.tasks.length;
  12488. if (k) {
  12489. while (k--) {
  12490. listener.tasks[k].cancel();
  12491. }
  12492. delete listener.tasks;
  12493. }
  12494. // remove this listener from the listeners array
  12495. Ext.Array.erase(me.listeners, index, 1);
  12496. return true;
  12497. }
  12498. return false;
  12499. },
  12500. // Iterate to stop any buffered/delayed events
  12501. clearListeners: function() {
  12502. var listeners = this.listeners,
  12503. i = listeners.length;
  12504. while (i--) {
  12505. this.removeListener(listeners[i].fn, listeners[i].scope);
  12506. }
  12507. },
  12508. fire: function() {
  12509. var me = this,
  12510. listeners = me.listeners,
  12511. count = listeners.length,
  12512. i,
  12513. args,
  12514. listener;
  12515. if (count > 0) {
  12516. me.firing = true;
  12517. for (i = 0; i < count; i++) {
  12518. listener = listeners[i];
  12519. args = arguments.length ? Array.prototype.slice.call(arguments, 0) : [];
  12520. if (listener.o) {
  12521. args.push(listener.o);
  12522. }
  12523. if (listener && listener.fireFn.apply(listener.scope || me.observable, args) === false) {
  12524. return (me.firing = false);
  12525. }
  12526. }
  12527. }
  12528. me.firing = false;
  12529. return true;
  12530. }
  12531. };
  12532. }()));
  12533. });
  12534. //@tag dom,core
  12535. //@require util/Event.js
  12536. //@define Ext.EventManager
  12537. /**
  12538. * @class Ext.EventManager
  12539. * Registers event handlers that want to receive a normalized EventObject instead of the standard browser event and provides
  12540. * several useful events directly.
  12541. * See {@link Ext.EventObject} for more details on normalized event objects.
  12542. * @singleton
  12543. */
  12544. Ext.EventManager = new function() {
  12545. var EventManager = this,
  12546. doc = document,
  12547. win = window,
  12548. initExtCss = function() {
  12549. // find the body element
  12550. var bd = doc.body || doc.getElementsByTagName('body')[0],
  12551. baseCSSPrefix = Ext.baseCSSPrefix,
  12552. cls = [baseCSSPrefix + 'body'],
  12553. htmlCls = [],
  12554. supportsLG = Ext.supports.CSS3LinearGradient,
  12555. supportsBR = Ext.supports.CSS3BorderRadius,
  12556. resetCls = [],
  12557. html,
  12558. resetElementSpec;
  12559. if (!bd) {
  12560. return false;
  12561. }
  12562. html = bd.parentNode;
  12563. function add (c) {
  12564. cls.push(baseCSSPrefix + c);
  12565. }
  12566. //Let's keep this human readable!
  12567. if (Ext.isIE) {
  12568. add('ie');
  12569. // very often CSS needs to do checks like "IE7+" or "IE6 or 7". To help
  12570. // reduce the clutter (since CSS/SCSS cannot do these tests), we add some
  12571. // additional classes:
  12572. //
  12573. // x-ie7p : IE7+ : 7 <= ieVer
  12574. // x-ie7m : IE7- : ieVer <= 7
  12575. // x-ie8p : IE8+ : 8 <= ieVer
  12576. // x-ie8m : IE8- : ieVer <= 8
  12577. // x-ie9p : IE9+ : 9 <= ieVer
  12578. // x-ie78 : IE7 or 8 : 7 <= ieVer <= 8
  12579. //
  12580. if (Ext.isIE6) {
  12581. add('ie6');
  12582. } else { // ignore pre-IE6 :)
  12583. add('ie7p');
  12584. if (Ext.isIE7) {
  12585. add('ie7');
  12586. } else {
  12587. add('ie8p');
  12588. if (Ext.isIE8) {
  12589. add('ie8');
  12590. } else {
  12591. add('ie9p');
  12592. if (Ext.isIE9) {
  12593. add('ie9');
  12594. }
  12595. }
  12596. }
  12597. }
  12598. if (Ext.isIE6 || Ext.isIE7) {
  12599. add('ie7m');
  12600. }
  12601. if (Ext.isIE6 || Ext.isIE7 || Ext.isIE8) {
  12602. add('ie8m');
  12603. }
  12604. if (Ext.isIE7 || Ext.isIE8) {
  12605. add('ie78');
  12606. }
  12607. }
  12608. if (Ext.isGecko) {
  12609. add('gecko');
  12610. if (Ext.isGecko3) {
  12611. add('gecko3');
  12612. }
  12613. if (Ext.isGecko4) {
  12614. add('gecko4');
  12615. }
  12616. if (Ext.isGecko5) {
  12617. add('gecko5');
  12618. }
  12619. }
  12620. if (Ext.isOpera) {
  12621. add('opera');
  12622. }
  12623. if (Ext.isWebKit) {
  12624. add('webkit');
  12625. }
  12626. if (Ext.isSafari) {
  12627. add('safari');
  12628. if (Ext.isSafari2) {
  12629. add('safari2');
  12630. }
  12631. if (Ext.isSafari3) {
  12632. add('safari3');
  12633. }
  12634. if (Ext.isSafari4) {
  12635. add('safari4');
  12636. }
  12637. if (Ext.isSafari5) {
  12638. add('safari5');
  12639. }
  12640. if (Ext.isSafari5_0) {
  12641. add('safari5_0')
  12642. }
  12643. }
  12644. if (Ext.isChrome) {
  12645. add('chrome');
  12646. }
  12647. if (Ext.isMac) {
  12648. add('mac');
  12649. }
  12650. if (Ext.isLinux) {
  12651. add('linux');
  12652. }
  12653. if (!supportsBR) {
  12654. add('nbr');
  12655. }
  12656. if (!supportsLG) {
  12657. add('nlg');
  12658. }
  12659. // If we are not globally resetting scope, but just resetting it in a wrapper around
  12660. // serarately rendered widgets, then create a common reset element for use when creating
  12661. // measurable elements. Using a common DomHelper spec.
  12662. if (Ext.scopeResetCSS) {
  12663. // Create Ext.resetElementSpec for use in Renderable when wrapping top level Components.
  12664. resetElementSpec = Ext.resetElementSpec = {
  12665. cls: baseCSSPrefix + 'reset'
  12666. };
  12667. if (!supportsLG) {
  12668. resetCls.push(baseCSSPrefix + 'nlg');
  12669. }
  12670. if (!supportsBR) {
  12671. resetCls.push(baseCSSPrefix + 'nbr');
  12672. }
  12673. if (resetCls.length) {
  12674. resetElementSpec.cn = {
  12675. cls: resetCls.join(' ')
  12676. };
  12677. }
  12678. Ext.resetElement = Ext.getBody().createChild(resetElementSpec);
  12679. if (resetCls.length) {
  12680. Ext.resetElement = Ext.get(Ext.resetElement.dom.firstChild);
  12681. }
  12682. }
  12683. // Otherwise, the common reset element is the document body
  12684. else {
  12685. Ext.resetElement = Ext.getBody();
  12686. add('reset');
  12687. }
  12688. // add to the parent to allow for selectors x-strict x-border-box, also set the isBorderBox property correctly
  12689. if (html) {
  12690. if (Ext.isStrict && (Ext.isIE6 || Ext.isIE7)) {
  12691. Ext.isBorderBox = false;
  12692. }
  12693. else {
  12694. Ext.isBorderBox = true;
  12695. }
  12696. if(Ext.isBorderBox) {
  12697. htmlCls.push(baseCSSPrefix + 'border-box');
  12698. }
  12699. if (Ext.isStrict) {
  12700. htmlCls.push(baseCSSPrefix + 'strict');
  12701. } else {
  12702. htmlCls.push(baseCSSPrefix + 'quirks');
  12703. }
  12704. Ext.fly(html, '_internal').addCls(htmlCls);
  12705. }
  12706. Ext.fly(bd, '_internal').addCls(cls);
  12707. return true;
  12708. };
  12709. Ext.apply(EventManager, {
  12710. /**
  12711. * Check if we have bound our global onReady listener
  12712. * @private
  12713. */
  12714. hasBoundOnReady: false,
  12715. /**
  12716. * Check if fireDocReady has been called
  12717. * @private
  12718. */
  12719. hasFiredReady: false,
  12720. /**
  12721. * Additionally, allow the 'DOM' listener thread to complete (usually desirable with mobWebkit, Gecko)
  12722. * before firing the entire onReady chain (high stack load on Loader) by specifying a delay value
  12723. * @default 1ms
  12724. * @private
  12725. */
  12726. deferReadyEvent : 1,
  12727. /*
  12728. * diags: a list of event names passed to onReadyEvent (in chron order)
  12729. * @private
  12730. */
  12731. onReadyChain : [],
  12732. /**
  12733. * Holds references to any onReady functions
  12734. * @private
  12735. */
  12736. readyEvent:
  12737. (function () {
  12738. var event = new Ext.util.Event();
  12739. event.fire = function () {
  12740. Ext._beforeReadyTime = Ext._beforeReadyTime || new Date().getTime();
  12741. event.self.prototype.fire.apply(event, arguments);
  12742. Ext._afterReadytime = new Date().getTime();
  12743. };
  12744. return event;
  12745. }()),
  12746. /**
  12747. * Fires when a DOM event handler finishes its run, just before returning to browser control.
  12748. * This can be useful for performing cleanup, or upfdate tasks which need to happen only
  12749. * after all code in an event handler has been run, but which should not be executed in a timer
  12750. * due to the intervening browser reflow/repaint which would take place.
  12751. *
  12752. */
  12753. idleEvent: new Ext.util.Event(),
  12754. /**
  12755. * detects whether the EventManager has been placed in a paused state for synchronization
  12756. * with external debugging / perf tools (PageAnalyzer)
  12757. * @private
  12758. */
  12759. isReadyPaused: function(){
  12760. return (/[?&]ext-pauseReadyFire\b/i.test(location.search) && !Ext._continueFireReady);
  12761. },
  12762. /**
  12763. * Binds the appropriate browser event for checking if the DOM has loaded.
  12764. * @private
  12765. */
  12766. bindReadyEvent: function() {
  12767. if (EventManager.hasBoundOnReady) {
  12768. return;
  12769. }
  12770. // Test scenario where Core is dynamically loaded AFTER window.load
  12771. if ( doc.readyState == 'complete' ) { // Firefox4+ got support for this state, others already do.
  12772. EventManager.onReadyEvent({
  12773. type: doc.readyState || 'body'
  12774. });
  12775. } else {
  12776. document.addEventListener('DOMContentLoaded', EventManager.onReadyEvent, false);
  12777. window.addEventListener('load', EventManager.onReadyEvent, false);
  12778. EventManager.hasBoundOnReady = true;
  12779. }
  12780. },
  12781. onReadyEvent : function(e) {
  12782. if (e && e.type) {
  12783. EventManager.onReadyChain.push(e.type);
  12784. }
  12785. if (EventManager.hasBoundOnReady) {
  12786. document.removeEventListener('DOMContentLoaded', EventManager.onReadyEvent, false);
  12787. window.removeEventListener('load', EventManager.onReadyEvent, false);
  12788. }
  12789. if (!Ext.isReady) {
  12790. EventManager.fireDocReady();
  12791. }
  12792. },
  12793. /**
  12794. * We know the document is loaded, so trigger any onReady events.
  12795. * @private
  12796. */
  12797. fireDocReady: function() {
  12798. if (!Ext.isReady) {
  12799. Ext._readyTime = new Date().getTime();
  12800. Ext.isReady = true;
  12801. Ext.supports.init();
  12802. EventManager.onWindowUnload();
  12803. EventManager.readyEvent.onReadyChain = EventManager.onReadyChain; //diags report
  12804. if (Ext.isNumber(EventManager.deferReadyEvent)) {
  12805. Ext.Function.defer(EventManager.fireReadyEvent, EventManager.deferReadyEvent);
  12806. EventManager.hasDocReadyTimer = true;
  12807. } else {
  12808. EventManager.fireReadyEvent();
  12809. }
  12810. }
  12811. },
  12812. /**
  12813. * Fires the ready event
  12814. * @private
  12815. */
  12816. fireReadyEvent: function(){
  12817. var readyEvent = EventManager.readyEvent;
  12818. // Unset the timer flag here since other onReady events may be
  12819. // added during the fire() call and we don't want to block them
  12820. EventManager.hasDocReadyTimer = false;
  12821. EventManager.isFiring = true;
  12822. // Ready events are all single: true, if we get to the end
  12823. // & there are more listeners, it means they were added
  12824. // inside some other ready event
  12825. while (readyEvent.listeners.length && !EventManager.isReadyPaused()) {
  12826. readyEvent.fire();
  12827. }
  12828. EventManager.isFiring = false;
  12829. EventManager.hasFiredReady = true;
  12830. },
  12831. /**
  12832. * Adds a listener to be notified when the document is ready (before onload and before images are loaded).
  12833. *
  12834. * @param {Function} fn The method the event invokes.
  12835. * @param {Object} [scope] The scope (`this` reference) in which the handler function executes.
  12836. * Defaults to the browser window.
  12837. * @param {Object} [options] Options object as passed to {@link Ext.Element#addListener}.
  12838. */
  12839. onDocumentReady: function(fn, scope, options) {
  12840. options = options || {};
  12841. // force single, only ever fire it once
  12842. options.single = true;
  12843. EventManager.readyEvent.addListener(fn, scope, options);
  12844. // If we're in the middle of firing, or we have a deferred timer
  12845. // pending, drop out since the event will be fired later
  12846. if (!(EventManager.isFiring || EventManager.hasDocReadyTimer)) {
  12847. if (Ext.isReady) {
  12848. EventManager.fireReadyEvent();
  12849. } else {
  12850. EventManager.bindReadyEvent();
  12851. }
  12852. }
  12853. },
  12854. // --------------------- event binding ---------------------
  12855. /**
  12856. * Contains a list of all document mouse downs, so we can ensure they fire even when stopEvent is called.
  12857. * @private
  12858. */
  12859. stoppedMouseDownEvent: new Ext.util.Event(),
  12860. /**
  12861. * Options to parse for the 4th argument to addListener.
  12862. * @private
  12863. */
  12864. propRe: /^(?:scope|delay|buffer|single|stopEvent|preventDefault|stopPropagation|normalized|args|delegate|freezeEvent)$/,
  12865. /**
  12866. * Get the id of the element. If one has not been assigned, automatically assign it.
  12867. * @param {HTMLElement/Ext.Element} element The element to get the id for.
  12868. * @return {String} id
  12869. */
  12870. getId : function(element) {
  12871. var id;
  12872. element = Ext.getDom(element);
  12873. if (element === doc || element === win) {
  12874. id = element === doc ? Ext.documentId : Ext.windowId;
  12875. }
  12876. else {
  12877. id = Ext.id(element);
  12878. }
  12879. if (!Ext.cache[id]) {
  12880. Ext.addCacheEntry(id, null, element);
  12881. }
  12882. return id;
  12883. },
  12884. /**
  12885. * Convert a "config style" listener into a set of flat arguments so they can be passed to addListener
  12886. * @private
  12887. * @param {Object} element The element the event is for
  12888. * @param {Object} event The event configuration
  12889. * @param {Object} isRemove True if a removal should be performed, otherwise an add will be done.
  12890. */
  12891. prepareListenerConfig: function(element, config, isRemove) {
  12892. var propRe = EventManager.propRe,
  12893. key, value, args;
  12894. // loop over all the keys in the object
  12895. for (key in config) {
  12896. if (config.hasOwnProperty(key)) {
  12897. // if the key is something else then an event option
  12898. if (!propRe.test(key)) {
  12899. value = config[key];
  12900. // if the value is a function it must be something like click: function() {}, scope: this
  12901. // which means that there might be multiple event listeners with shared options
  12902. if (typeof value == 'function') {
  12903. // shared options
  12904. args = [element, key, value, config.scope, config];
  12905. } else {
  12906. // if its not a function, it must be an object like click: {fn: function() {}, scope: this}
  12907. args = [element, key, value.fn, value.scope, value];
  12908. }
  12909. if (isRemove) {
  12910. EventManager.removeListener.apply(EventManager, args);
  12911. } else {
  12912. EventManager.addListener.apply(EventManager, args);
  12913. }
  12914. }
  12915. }
  12916. }
  12917. },
  12918. mouseEnterLeaveRe: /mouseenter|mouseleave/,
  12919. /**
  12920. * Normalize cross browser event differences
  12921. * @private
  12922. * @param {Object} eventName The event name
  12923. * @param {Object} fn The function to execute
  12924. * @return {Object} The new event name/function
  12925. */
  12926. normalizeEvent: function(eventName, fn) {
  12927. if (EventManager.mouseEnterLeaveRe.test(eventName) && !Ext.supports.MouseEnterLeave) {
  12928. if (fn) {
  12929. fn = Ext.Function.createInterceptor(fn, EventManager.contains);
  12930. }
  12931. eventName = eventName == 'mouseenter' ? 'mouseover' : 'mouseout';
  12932. } else if (eventName == 'mousewheel' && !Ext.supports.MouseWheel && !Ext.isOpera) {
  12933. eventName = 'DOMMouseScroll';
  12934. }
  12935. return {
  12936. eventName: eventName,
  12937. fn: fn
  12938. };
  12939. },
  12940. /**
  12941. * Checks whether the event's relatedTarget is contained inside (or <b>is</b>) the element.
  12942. * @private
  12943. * @param {Object} event
  12944. */
  12945. contains: function(event) {
  12946. var parent = event.browserEvent.currentTarget,
  12947. child = EventManager.getRelatedTarget(event);
  12948. if (parent && parent.firstChild) {
  12949. while (child) {
  12950. if (child === parent) {
  12951. return false;
  12952. }
  12953. child = child.parentNode;
  12954. if (child && (child.nodeType != 1)) {
  12955. child = null;
  12956. }
  12957. }
  12958. }
  12959. return true;
  12960. },
  12961. /**
  12962. * Appends an event handler to an element. The shorthand version {@link #on} is equivalent. Typically you will
  12963. * use {@link Ext.Element#addListener} directly on an Element in favor of calling this version.
  12964. * @param {String/HTMLElement} el The html element or id to assign the event handler to.
  12965. * @param {String} eventName The name of the event to listen for.
  12966. * @param {Function} handler The handler function the event invokes. This function is passed
  12967. * the following parameters:<ul>
  12968. * <li>evt : EventObject<div class="sub-desc">The {@link Ext.EventObject EventObject} describing the event.</div></li>
  12969. * <li>t : Element<div class="sub-desc">The {@link Ext.Element Element} which was the target of the event.
  12970. * Note that this may be filtered by using the <tt>delegate</tt> option.</div></li>
  12971. * <li>o : Object<div class="sub-desc">The options object from the addListener call.</div></li>
  12972. * </ul>
  12973. * @param {Object} scope (optional) The scope (<b><code>this</code></b> reference) in which the handler function is executed. <b>Defaults to the Element</b>.
  12974. * @param {Object} options (optional) An object containing handler configuration properties.
  12975. * This may contain any of the following properties:<ul>
  12976. * <li>scope : Object<div class="sub-desc">The scope (<b><code>this</code></b> reference) in which the handler function is executed. <b>Defaults to the Element</b>.</div></li>
  12977. * <li>delegate : String<div class="sub-desc">A simple selector to filter the target or look for a descendant of the target</div></li>
  12978. * <li>stopEvent : Boolean<div class="sub-desc">True to stop the event. That is stop propagation, and prevent the default action.</div></li>
  12979. * <li>preventDefault : Boolean<div class="sub-desc">True to prevent the default action</div></li>
  12980. * <li>stopPropagation : Boolean<div class="sub-desc">True to prevent event propagation</div></li>
  12981. * <li>normalized : Boolean<div class="sub-desc">False to pass a browser event to the handler function instead of an Ext.EventObject</div></li>
  12982. * <li>delay : Number<div class="sub-desc">The number of milliseconds to delay the invocation of the handler after te event fires.</div></li>
  12983. * <li>single : Boolean<div class="sub-desc">True to add a handler to handle just the next firing of the event, and then remove itself.</div></li>
  12984. * <li>buffer : Number<div class="sub-desc">Causes the handler to be scheduled to run in an {@link Ext.util.DelayedTask} delayed
  12985. * by the specified number of milliseconds. If the event fires again within that time, the original
  12986. * handler is <em>not</em> invoked, but the new handler is scheduled in its place.</div></li>
  12987. * <li>target : Element<div class="sub-desc">Only call the handler if the event was fired on the target Element, <i>not</i> if the event was bubbled up from a child node.</div></li>
  12988. * </ul><br>
  12989. * <p>See {@link Ext.Element#addListener} for examples of how to use these options.</p>
  12990. */
  12991. addListener: function(element, eventName, fn, scope, options) {
  12992. // Check if we've been passed a "config style" event.
  12993. if (typeof eventName !== 'string') {
  12994. EventManager.prepareListenerConfig(element, eventName);
  12995. return;
  12996. }
  12997. var dom = element.dom || Ext.getDom(element),
  12998. bind, wrap;
  12999. // create the wrapper function
  13000. options = options || {};
  13001. bind = EventManager.normalizeEvent(eventName, fn);
  13002. wrap = EventManager.createListenerWrap(dom, eventName, bind.fn, scope, options);
  13003. if (dom.attachEvent) {
  13004. dom.attachEvent('on' + bind.eventName, wrap);
  13005. } else {
  13006. dom.addEventListener(bind.eventName, wrap, options.capture || false);
  13007. }
  13008. if (dom == doc && eventName == 'mousedown') {
  13009. EventManager.stoppedMouseDownEvent.addListener(wrap);
  13010. }
  13011. // add all required data into the event cache
  13012. EventManager.getEventListenerCache(element.dom ? element : dom, eventName).push({
  13013. fn: fn,
  13014. wrap: wrap,
  13015. scope: scope
  13016. });
  13017. },
  13018. /**
  13019. * Removes an event handler from an element. The shorthand version {@link #un} is equivalent. Typically
  13020. * you will use {@link Ext.Element#removeListener} directly on an Element in favor of calling this version.
  13021. * @param {String/HTMLElement} el The id or html element from which to remove the listener.
  13022. * @param {String} eventName The name of the event.
  13023. * @param {Function} fn The handler function to remove. <b>This must be a reference to the function passed into the {@link #addListener} call.</b>
  13024. * @param {Object} scope If a scope (<b><code>this</code></b> reference) was specified when the listener was added,
  13025. * then this must refer to the same object.
  13026. */
  13027. removeListener : function(element, eventName, fn, scope) {
  13028. // handle our listener config object syntax
  13029. if (typeof eventName !== 'string') {
  13030. EventManager.prepareListenerConfig(element, eventName, true);
  13031. return;
  13032. }
  13033. var dom = Ext.getDom(element),
  13034. el = element.dom ? element : Ext.get(dom),
  13035. cache = EventManager.getEventListenerCache(el, eventName),
  13036. bindName = EventManager.normalizeEvent(eventName).eventName,
  13037. i = cache.length, j,
  13038. listener, wrap, tasks;
  13039. while (i--) {
  13040. listener = cache[i];
  13041. if (listener && (!fn || listener.fn == fn) && (!scope || listener.scope === scope)) {
  13042. wrap = listener.wrap;
  13043. // clear buffered calls
  13044. if (wrap.task) {
  13045. clearTimeout(wrap.task);
  13046. delete wrap.task;
  13047. }
  13048. // clear delayed calls
  13049. j = wrap.tasks && wrap.tasks.length;
  13050. if (j) {
  13051. while (j--) {
  13052. clearTimeout(wrap.tasks[j]);
  13053. }
  13054. delete wrap.tasks;
  13055. }
  13056. if (dom.detachEvent) {
  13057. dom.detachEvent('on' + bindName, wrap);
  13058. } else {
  13059. dom.removeEventListener(bindName, wrap, false);
  13060. }
  13061. if (wrap && dom == doc && eventName == 'mousedown') {
  13062. EventManager.stoppedMouseDownEvent.removeListener(wrap);
  13063. }
  13064. // remove listener from cache
  13065. Ext.Array.erase(cache, i, 1);
  13066. }
  13067. }
  13068. },
  13069. /**
  13070. * Removes all event handers from an element. Typically you will use {@link Ext.Element#removeAllListeners}
  13071. * directly on an Element in favor of calling this version.
  13072. * @param {String/HTMLElement} el The id or html element from which to remove all event handlers.
  13073. */
  13074. removeAll : function(element) {
  13075. var el = element.dom ? element : Ext.get(element),
  13076. cache, events, eventName;
  13077. if (!el) {
  13078. return;
  13079. }
  13080. cache = (el.$cache || el.getCache());
  13081. events = cache.events;
  13082. for (eventName in events) {
  13083. if (events.hasOwnProperty(eventName)) {
  13084. EventManager.removeListener(el, eventName);
  13085. }
  13086. }
  13087. cache.events = {};
  13088. },
  13089. /**
  13090. * Recursively removes all previous added listeners from an element and its children. Typically you will use {@link Ext.Element#purgeAllListeners}
  13091. * directly on an Element in favor of calling this version.
  13092. * @param {String/HTMLElement} el The id or html element from which to remove all event handlers.
  13093. * @param {String} eventName (optional) The name of the event.
  13094. */
  13095. purgeElement : function(element, eventName) {
  13096. var dom = Ext.getDom(element),
  13097. i = 0, len;
  13098. if (eventName) {
  13099. EventManager.removeListener(element, eventName);
  13100. }
  13101. else {
  13102. EventManager.removeAll(element);
  13103. }
  13104. if (dom && dom.childNodes) {
  13105. for (len = element.childNodes.length; i < len; i++) {
  13106. EventManager.purgeElement(element.childNodes[i], eventName);
  13107. }
  13108. }
  13109. },
  13110. /**
  13111. * Create the wrapper function for the event
  13112. * @private
  13113. * @param {HTMLElement} dom The dom element
  13114. * @param {String} ename The event name
  13115. * @param {Function} fn The function to execute
  13116. * @param {Object} scope The scope to execute callback in
  13117. * @param {Object} options The options
  13118. * @return {Function} the wrapper function
  13119. */
  13120. createListenerWrap : function(dom, ename, fn, scope, options) {
  13121. options = options || {};
  13122. var f, gen, escapeRx = /\\/g, wrap = function(e, args) {
  13123. // Compile the implementation upon first firing
  13124. if (!gen) {
  13125. f = ['if(!' + Ext.name + ') {return;}'];
  13126. if(options.buffer || options.delay || options.freezeEvent) {
  13127. f.push('e = new X.EventObjectImpl(e, ' + (options.freezeEvent ? 'true' : 'false' ) + ');');
  13128. } else {
  13129. f.push('e = X.EventObject.setEvent(e);');
  13130. }
  13131. if (options.delegate) {
  13132. // double up '\' characters so escape sequences survive the
  13133. // string-literal translation
  13134. f.push('var result, t = e.getTarget("' + (options.delegate + '').replace(escapeRx, '\\\\') + '", this);');
  13135. f.push('if(!t) {return;}');
  13136. } else {
  13137. f.push('var t = e.target, result;');
  13138. }
  13139. if (options.target) {
  13140. f.push('if(e.target !== options.target) {return;}');
  13141. }
  13142. if(options.stopEvent) {
  13143. f.push('e.stopEvent();');
  13144. } else {
  13145. if(options.preventDefault) {
  13146. f.push('e.preventDefault();');
  13147. }
  13148. if(options.stopPropagation) {
  13149. f.push('e.stopPropagation();');
  13150. }
  13151. }
  13152. if(options.normalized === false) {
  13153. f.push('e = e.browserEvent;');
  13154. }
  13155. if(options.buffer) {
  13156. f.push('(wrap.task && clearTimeout(wrap.task));');
  13157. f.push('wrap.task = setTimeout(function() {');
  13158. }
  13159. if(options.delay) {
  13160. f.push('wrap.tasks = wrap.tasks || [];');
  13161. f.push('wrap.tasks.push(setTimeout(function() {');
  13162. }
  13163. // finally call the actual handler fn
  13164. f.push('result = fn.call(scope || dom, e, t, options);');
  13165. if(options.single) {
  13166. f.push('evtMgr.removeListener(dom, ename, fn, scope);');
  13167. }
  13168. // Fire the global idle event for all events except mousemove which is too common, and
  13169. // fires too frequently and fast to be use in tiggering onIdle processing.
  13170. if (ename !== 'mousemove') {
  13171. f.push('if (evtMgr.idleEvent.listeners.length) {');
  13172. f.push('evtMgr.idleEvent.fire();');
  13173. f.push('}');
  13174. }
  13175. if(options.delay) {
  13176. f.push('}, ' + options.delay + '));');
  13177. }
  13178. if(options.buffer) {
  13179. f.push('}, ' + options.buffer + ');');
  13180. }
  13181. f.push('return result;')
  13182. gen = Ext.cacheableFunctionFactory('e', 'options', 'fn', 'scope', 'ename', 'dom', 'wrap', 'args', 'X', 'evtMgr', f.join('\n'));
  13183. }
  13184. return gen.call(dom, e, options, fn, scope, ename, dom, wrap, args, Ext, EventManager);
  13185. };
  13186. return wrap;
  13187. },
  13188. /**
  13189. * Get the event cache for a particular element for a particular event
  13190. * @private
  13191. * @param {HTMLElement} element The element
  13192. * @param {Object} eventName The event name
  13193. * @return {Array} The events for the element
  13194. */
  13195. getEventListenerCache : function(element, eventName) {
  13196. var elementCache, eventCache;
  13197. if (!element) {
  13198. return [];
  13199. }
  13200. if (element.$cache) {
  13201. elementCache = element.$cache;
  13202. } else {
  13203. // getId will populate the cache for this element if it isn't already present
  13204. elementCache = Ext.cache[EventManager.getId(element)];
  13205. }
  13206. eventCache = elementCache.events || (elementCache.events = {});
  13207. return eventCache[eventName] || (eventCache[eventName] = []);
  13208. },
  13209. // --------------------- utility methods ---------------------
  13210. mouseLeaveRe: /(mouseout|mouseleave)/,
  13211. mouseEnterRe: /(mouseover|mouseenter)/,
  13212. /**
  13213. * Stop the event (preventDefault and stopPropagation)
  13214. * @param {Event} The event to stop
  13215. */
  13216. stopEvent: function(event) {
  13217. EventManager.stopPropagation(event);
  13218. EventManager.preventDefault(event);
  13219. },
  13220. /**
  13221. * Cancels bubbling of the event.
  13222. * @param {Event} The event to stop bubbling.
  13223. */
  13224. stopPropagation: function(event) {
  13225. event = event.browserEvent || event;
  13226. if (event.stopPropagation) {
  13227. event.stopPropagation();
  13228. } else {
  13229. event.cancelBubble = true;
  13230. }
  13231. },
  13232. /**
  13233. * Prevents the browsers default handling of the event.
  13234. * @param {Event} The event to prevent the default
  13235. */
  13236. preventDefault: function(event) {
  13237. event = event.browserEvent || event;
  13238. if (event.preventDefault) {
  13239. event.preventDefault();
  13240. } else {
  13241. event.returnValue = false;
  13242. // Some keys events require setting the keyCode to -1 to be prevented
  13243. try {
  13244. // all ctrl + X and F1 -> F12
  13245. if (event.ctrlKey || event.keyCode > 111 && event.keyCode < 124) {
  13246. event.keyCode = -1;
  13247. }
  13248. } catch (e) {
  13249. // see this outdated document http://support.microsoft.com/kb/934364/en-us for more info
  13250. }
  13251. }
  13252. },
  13253. /**
  13254. * Gets the related target from the event.
  13255. * @param {Object} event The event
  13256. * @return {HTMLElement} The related target.
  13257. */
  13258. getRelatedTarget: function(event) {
  13259. event = event.browserEvent || event;
  13260. var target = event.relatedTarget;
  13261. if (!target) {
  13262. if (EventManager.mouseLeaveRe.test(event.type)) {
  13263. target = event.toElement;
  13264. } else if (EventManager.mouseEnterRe.test(event.type)) {
  13265. target = event.fromElement;
  13266. }
  13267. }
  13268. return EventManager.resolveTextNode(target);
  13269. },
  13270. /**
  13271. * Gets the x coordinate from the event
  13272. * @param {Object} event The event
  13273. * @return {Number} The x coordinate
  13274. */
  13275. getPageX: function(event) {
  13276. return EventManager.getPageXY(event)[0];
  13277. },
  13278. /**
  13279. * Gets the y coordinate from the event
  13280. * @param {Object} event The event
  13281. * @return {Number} The y coordinate
  13282. */
  13283. getPageY: function(event) {
  13284. return EventManager.getPageXY(event)[1];
  13285. },
  13286. /**
  13287. * Gets the x & y coordinate from the event
  13288. * @param {Object} event The event
  13289. * @return {Number[]} The x/y coordinate
  13290. */
  13291. getPageXY: function(event) {
  13292. event = event.browserEvent || event;
  13293. var x = event.pageX,
  13294. y = event.pageY,
  13295. docEl = doc.documentElement,
  13296. body = doc.body;
  13297. // pageX/pageY not available (undefined, not null), use clientX/clientY instead
  13298. if (!x && x !== 0) {
  13299. x = event.clientX + (docEl && docEl.scrollLeft || body && body.scrollLeft || 0) - (docEl && docEl.clientLeft || body && body.clientLeft || 0);
  13300. y = event.clientY + (docEl && docEl.scrollTop || body && body.scrollTop || 0) - (docEl && docEl.clientTop || body && body.clientTop || 0);
  13301. }
  13302. return [x, y];
  13303. },
  13304. /**
  13305. * Gets the target of the event.
  13306. * @param {Object} event The event
  13307. * @return {HTMLElement} target
  13308. */
  13309. getTarget: function(event) {
  13310. event = event.browserEvent || event;
  13311. return EventManager.resolveTextNode(event.target || event.srcElement);
  13312. },
  13313. // technically no need to browser sniff this, however it makes
  13314. // no sense to check this every time, for every event, whether
  13315. // the string is equal.
  13316. /**
  13317. * Resolve any text nodes accounting for browser differences.
  13318. * @private
  13319. * @param {HTMLElement} node The node
  13320. * @return {HTMLElement} The resolved node
  13321. */
  13322. resolveTextNode: Ext.isGecko ?
  13323. function(node) {
  13324. if (!node) {
  13325. return;
  13326. }
  13327. // work around firefox bug, https://bugzilla.mozilla.org/show_bug.cgi?id=101197
  13328. var s = HTMLElement.prototype.toString.call(node);
  13329. if (s == '[xpconnect wrapped native prototype]' || s == '[object XULElement]') {
  13330. return;
  13331. }
  13332. return node.nodeType == 3 ? node.parentNode: node;
  13333. }: function(node) {
  13334. return node && node.nodeType == 3 ? node.parentNode: node;
  13335. },
  13336. // --------------------- custom event binding ---------------------
  13337. // Keep track of the current width/height
  13338. curWidth: 0,
  13339. curHeight: 0,
  13340. /**
  13341. * Adds a listener to be notified when the browser window is resized and provides resize event buffering (100 milliseconds),
  13342. * passes new viewport width and height to handlers.
  13343. * @param {Function} fn The handler function the window resize event invokes.
  13344. * @param {Object} scope The scope (<code>this</code> reference) in which the handler function executes. Defaults to the browser window.
  13345. * @param {Boolean} options Options object as passed to {@link Ext.Element#addListener}
  13346. */
  13347. onWindowResize: function(fn, scope, options) {
  13348. var resize = EventManager.resizeEvent;
  13349. if (!resize) {
  13350. EventManager.resizeEvent = resize = new Ext.util.Event();
  13351. EventManager.on(win, 'resize', EventManager.fireResize, null, {buffer: 100});
  13352. }
  13353. resize.addListener(fn, scope, options);
  13354. },
  13355. /**
  13356. * Fire the resize event.
  13357. * @private
  13358. */
  13359. fireResize: function() {
  13360. var w = Ext.Element.getViewWidth(),
  13361. h = Ext.Element.getViewHeight();
  13362. //whacky problem in IE where the resize event will sometimes fire even though the w/h are the same.
  13363. if (EventManager.curHeight != h || EventManager.curWidth != w) {
  13364. EventManager.curHeight = h;
  13365. EventManager.curWidth = w;
  13366. EventManager.resizeEvent.fire(w, h);
  13367. }
  13368. },
  13369. /**
  13370. * Removes the passed window resize listener.
  13371. * @param {Function} fn The method the event invokes
  13372. * @param {Object} scope The scope of handler
  13373. */
  13374. removeResizeListener: function(fn, scope) {
  13375. var resize = EventManager.resizeEvent;
  13376. if (resize) {
  13377. resize.removeListener(fn, scope);
  13378. }
  13379. },
  13380. /**
  13381. * Adds a listener to be notified when the browser window is unloaded.
  13382. * @param {Function} fn The handler function the window unload event invokes.
  13383. * @param {Object} scope The scope (<code>this</code> reference) in which the handler function executes. Defaults to the browser window.
  13384. * @param {Boolean} options Options object as passed to {@link Ext.Element#addListener}
  13385. */
  13386. onWindowUnload: function(fn, scope, options) {
  13387. var unload = EventManager.unloadEvent;
  13388. if (!unload) {
  13389. EventManager.unloadEvent = unload = new Ext.util.Event();
  13390. EventManager.addListener(win, 'unload', EventManager.fireUnload);
  13391. }
  13392. if (fn) {
  13393. unload.addListener(fn, scope, options);
  13394. }
  13395. },
  13396. /**
  13397. * Fires the unload event for items bound with onWindowUnload
  13398. * @private
  13399. */
  13400. fireUnload: function() {
  13401. // wrap in a try catch, could have some problems during unload
  13402. try {
  13403. // relinquish references.
  13404. doc = win = undefined;
  13405. var gridviews, i, ln,
  13406. el, cache;
  13407. EventManager.unloadEvent.fire();
  13408. // Work around FF3 remembering the last scroll position when refreshing the grid and then losing grid view
  13409. if (Ext.isGecko3) {
  13410. gridviews = Ext.ComponentQuery.query('gridview');
  13411. i = 0;
  13412. ln = gridviews.length;
  13413. for (; i < ln; i++) {
  13414. gridviews[i].scrollToTop();
  13415. }
  13416. }
  13417. // Purge all elements in the cache
  13418. cache = Ext.cache;
  13419. for (el in cache) {
  13420. if (cache.hasOwnProperty(el)) {
  13421. EventManager.removeAll(el);
  13422. }
  13423. }
  13424. } catch(e) {
  13425. }
  13426. },
  13427. /**
  13428. * Removes the passed window unload listener.
  13429. * @param {Function} fn The method the event invokes
  13430. * @param {Object} scope The scope of handler
  13431. */
  13432. removeUnloadListener: function(fn, scope) {
  13433. var unload = EventManager.unloadEvent;
  13434. if (unload) {
  13435. unload.removeListener(fn, scope);
  13436. }
  13437. },
  13438. /**
  13439. * note 1: IE fires ONLY the keydown event on specialkey autorepeat
  13440. * note 2: Safari < 3.1, Gecko (Mac/Linux) & Opera fire only the keypress event on specialkey autorepeat
  13441. * (research done by Jan Wolter at http://unixpapa.com/js/key.html)
  13442. * @private
  13443. */
  13444. useKeyDown: Ext.isWebKit ?
  13445. parseInt(navigator.userAgent.match(/AppleWebKit\/(\d+)/)[1], 10) >= 525 :
  13446. !((Ext.isGecko && !Ext.isWindows) || Ext.isOpera),
  13447. /**
  13448. * Indicates which event to use for getting key presses.
  13449. * @return {String} The appropriate event name.
  13450. */
  13451. getKeyEvent: function() {
  13452. return EventManager.useKeyDown ? 'keydown' : 'keypress';
  13453. }
  13454. });
  13455. // route "< ie9-Standards" to a legacy IE onReady implementation
  13456. if(!('addEventListener' in document) && document.attachEvent) {
  13457. Ext.apply( EventManager, {
  13458. /* Customized implementation for Legacy IE. The default implementation is configured for use
  13459. * with all other 'standards compliant' agents.
  13460. * References: http://javascript.nwbox.com/IEContentLoaded/
  13461. * licensed courtesy of http://developer.yahoo.com/yui/license.html
  13462. */
  13463. /**
  13464. * This strategy has minimal benefits for Sencha solutions that build themselves (ie. minimal initial page markup).
  13465. * However, progressively-enhanced pages (with image content and/or embedded frames) will benefit the most from it.
  13466. * Browser timer resolution is too poor to ensure a doScroll check more than once on a page loaded with minimal
  13467. * assets (the readystatechange event 'complete' usually beats the doScroll timer on a 'lightly-loaded' initial document).
  13468. */
  13469. pollScroll : function() {
  13470. var scrollable = true;
  13471. try {
  13472. document.documentElement.doScroll('left');
  13473. } catch(e) {
  13474. scrollable = false;
  13475. }
  13476. // on IE8, when running within an iFrame, document.body is not immediately available
  13477. if (scrollable && document.body) {
  13478. EventManager.onReadyEvent({
  13479. type:'doScroll'
  13480. });
  13481. } else {
  13482. /*
  13483. * minimize thrashing --
  13484. * adjusted for setTimeout's close-to-minimums (not too low),
  13485. * as this method SHOULD always be called once initially
  13486. */
  13487. EventManager.scrollTimeout = setTimeout(EventManager.pollScroll, 20);
  13488. }
  13489. return scrollable;
  13490. },
  13491. /**
  13492. * Timer for doScroll polling
  13493. * @private
  13494. */
  13495. scrollTimeout: null,
  13496. /* @private
  13497. */
  13498. readyStatesRe : /complete/i,
  13499. /* @private
  13500. */
  13501. checkReadyState: function() {
  13502. var state = document.readyState;
  13503. if (EventManager.readyStatesRe.test(state)) {
  13504. EventManager.onReadyEvent({
  13505. type: state
  13506. });
  13507. }
  13508. },
  13509. bindReadyEvent: function() {
  13510. var topContext = true;
  13511. if (EventManager.hasBoundOnReady) {
  13512. return;
  13513. }
  13514. //are we in an IFRAME? (doScroll ineffective here)
  13515. try {
  13516. topContext = window.frameElement === undefined;
  13517. } catch(e) {
  13518. // If we throw an exception, it means we're probably getting access denied,
  13519. // which means we're in an iframe cross domain.
  13520. topContext = false;
  13521. }
  13522. if (!topContext || !doc.documentElement.doScroll) {
  13523. EventManager.pollScroll = Ext.emptyFn; //then noop this test altogether
  13524. }
  13525. // starts doScroll polling if necessary
  13526. if (EventManager.pollScroll() === true) {
  13527. return;
  13528. }
  13529. // Core is loaded AFTER initial document write/load ?
  13530. if (doc.readyState == 'complete' ) {
  13531. EventManager.onReadyEvent({type: 'already ' + (doc.readyState || 'body') });
  13532. } else {
  13533. doc.attachEvent('onreadystatechange', EventManager.checkReadyState);
  13534. window.attachEvent('onload', EventManager.onReadyEvent);
  13535. EventManager.hasBoundOnReady = true;
  13536. }
  13537. },
  13538. onReadyEvent : function(e) {
  13539. if (e && e.type) {
  13540. EventManager.onReadyChain.push(e.type);
  13541. }
  13542. if (EventManager.hasBoundOnReady) {
  13543. document.detachEvent('onreadystatechange', EventManager.checkReadyState);
  13544. window.detachEvent('onload', EventManager.onReadyEvent);
  13545. }
  13546. if (Ext.isNumber(EventManager.scrollTimeout)) {
  13547. clearTimeout(EventManager.scrollTimeout);
  13548. delete EventManager.scrollTimeout;
  13549. }
  13550. if (!Ext.isReady) {
  13551. EventManager.fireDocReady();
  13552. }
  13553. },
  13554. //diags: a list of event types passed to onReadyEvent (in chron order)
  13555. onReadyChain : []
  13556. });
  13557. }
  13558. /**
  13559. * Alias for {@link Ext.Loader#onReady Ext.Loader.onReady} with withDomReady set to true
  13560. * @member Ext
  13561. * @method onReady
  13562. */
  13563. Ext.onReady = function(fn, scope, options) {
  13564. Ext.Loader.onReady(fn, scope, true, options);
  13565. };
  13566. /**
  13567. * Alias for {@link Ext.EventManager#onDocumentReady Ext.EventManager.onDocumentReady}
  13568. * @member Ext
  13569. * @method onDocumentReady
  13570. */
  13571. Ext.onDocumentReady = EventManager.onDocumentReady;
  13572. /**
  13573. * Alias for {@link Ext.EventManager#addListener Ext.EventManager.addListener}
  13574. * @member Ext.EventManager
  13575. * @method on
  13576. */
  13577. EventManager.on = EventManager.addListener;
  13578. /**
  13579. * Alias for {@link Ext.EventManager#removeListener Ext.EventManager.removeListener}
  13580. * @member Ext.EventManager
  13581. * @method un
  13582. */
  13583. EventManager.un = EventManager.removeListener;
  13584. Ext.onReady(initExtCss);
  13585. };
  13586. //@tag dom,core
  13587. //@require EventManager.js
  13588. //@define Ext.EventObject
  13589. /**
  13590. * @class Ext.EventObject
  13591. Just as {@link Ext.Element} wraps around a native DOM node, Ext.EventObject
  13592. wraps the browser's native event-object normalizing cross-browser differences,
  13593. such as which mouse button is clicked, keys pressed, mechanisms to stop
  13594. event-propagation along with a method to prevent default actions from taking place.
  13595. For example:
  13596. function handleClick(e, t){ // e is not a standard event object, it is a Ext.EventObject
  13597. e.preventDefault();
  13598. var target = e.getTarget(); // same as t (the target HTMLElement)
  13599. ...
  13600. }
  13601. var myDiv = {@link Ext#get Ext.get}("myDiv"); // get reference to an {@link Ext.Element}
  13602. myDiv.on( // 'on' is shorthand for addListener
  13603. "click", // perform an action on click of myDiv
  13604. handleClick // reference to the action handler
  13605. );
  13606. // other methods to do the same:
  13607. Ext.EventManager.on("myDiv", 'click', handleClick);
  13608. Ext.EventManager.addListener("myDiv", 'click', handleClick);
  13609. * @singleton
  13610. * @markdown
  13611. */
  13612. Ext.define('Ext.EventObjectImpl', {
  13613. uses: ['Ext.util.Point'],
  13614. /** Key constant @type Number */
  13615. BACKSPACE: 8,
  13616. /** Key constant @type Number */
  13617. TAB: 9,
  13618. /** Key constant @type Number */
  13619. NUM_CENTER: 12,
  13620. /** Key constant @type Number */
  13621. ENTER: 13,
  13622. /** Key constant @type Number */
  13623. RETURN: 13,
  13624. /** Key constant @type Number */
  13625. SHIFT: 16,
  13626. /** Key constant @type Number */
  13627. CTRL: 17,
  13628. /** Key constant @type Number */
  13629. ALT: 18,
  13630. /** Key constant @type Number */
  13631. PAUSE: 19,
  13632. /** Key constant @type Number */
  13633. CAPS_LOCK: 20,
  13634. /** Key constant @type Number */
  13635. ESC: 27,
  13636. /** Key constant @type Number */
  13637. SPACE: 32,
  13638. /** Key constant @type Number */
  13639. PAGE_UP: 33,
  13640. /** Key constant @type Number */
  13641. PAGE_DOWN: 34,
  13642. /** Key constant @type Number */
  13643. END: 35,
  13644. /** Key constant @type Number */
  13645. HOME: 36,
  13646. /** Key constant @type Number */
  13647. LEFT: 37,
  13648. /** Key constant @type Number */
  13649. UP: 38,
  13650. /** Key constant @type Number */
  13651. RIGHT: 39,
  13652. /** Key constant @type Number */
  13653. DOWN: 40,
  13654. /** Key constant @type Number */
  13655. PRINT_SCREEN: 44,
  13656. /** Key constant @type Number */
  13657. INSERT: 45,
  13658. /** Key constant @type Number */
  13659. DELETE: 46,
  13660. /** Key constant @type Number */
  13661. ZERO: 48,
  13662. /** Key constant @type Number */
  13663. ONE: 49,
  13664. /** Key constant @type Number */
  13665. TWO: 50,
  13666. /** Key constant @type Number */
  13667. THREE: 51,
  13668. /** Key constant @type Number */
  13669. FOUR: 52,
  13670. /** Key constant @type Number */
  13671. FIVE: 53,
  13672. /** Key constant @type Number */
  13673. SIX: 54,
  13674. /** Key constant @type Number */
  13675. SEVEN: 55,
  13676. /** Key constant @type Number */
  13677. EIGHT: 56,
  13678. /** Key constant @type Number */
  13679. NINE: 57,
  13680. /** Key constant @type Number */
  13681. A: 65,
  13682. /** Key constant @type Number */
  13683. B: 66,
  13684. /** Key constant @type Number */
  13685. C: 67,
  13686. /** Key constant @type Number */
  13687. D: 68,
  13688. /** Key constant @type Number */
  13689. E: 69,
  13690. /** Key constant @type Number */
  13691. F: 70,
  13692. /** Key constant @type Number */
  13693. G: 71,
  13694. /** Key constant @type Number */
  13695. H: 72,
  13696. /** Key constant @type Number */
  13697. I: 73,
  13698. /** Key constant @type Number */
  13699. J: 74,
  13700. /** Key constant @type Number */
  13701. K: 75,
  13702. /** Key constant @type Number */
  13703. L: 76,
  13704. /** Key constant @type Number */
  13705. M: 77,
  13706. /** Key constant @type Number */
  13707. N: 78,
  13708. /** Key constant @type Number */
  13709. O: 79,
  13710. /** Key constant @type Number */
  13711. P: 80,
  13712. /** Key constant @type Number */
  13713. Q: 81,
  13714. /** Key constant @type Number */
  13715. R: 82,
  13716. /** Key constant @type Number */
  13717. S: 83,
  13718. /** Key constant @type Number */
  13719. T: 84,
  13720. /** Key constant @type Number */
  13721. U: 85,
  13722. /** Key constant @type Number */
  13723. V: 86,
  13724. /** Key constant @type Number */
  13725. W: 87,
  13726. /** Key constant @type Number */
  13727. X: 88,
  13728. /** Key constant @type Number */
  13729. Y: 89,
  13730. /** Key constant @type Number */
  13731. Z: 90,
  13732. /** Key constant @type Number */
  13733. CONTEXT_MENU: 93,
  13734. /** Key constant @type Number */
  13735. NUM_ZERO: 96,
  13736. /** Key constant @type Number */
  13737. NUM_ONE: 97,
  13738. /** Key constant @type Number */
  13739. NUM_TWO: 98,
  13740. /** Key constant @type Number */
  13741. NUM_THREE: 99,
  13742. /** Key constant @type Number */
  13743. NUM_FOUR: 100,
  13744. /** Key constant @type Number */
  13745. NUM_FIVE: 101,
  13746. /** Key constant @type Number */
  13747. NUM_SIX: 102,
  13748. /** Key constant @type Number */
  13749. NUM_SEVEN: 103,
  13750. /** Key constant @type Number */
  13751. NUM_EIGHT: 104,
  13752. /** Key constant @type Number */
  13753. NUM_NINE: 105,
  13754. /** Key constant @type Number */
  13755. NUM_MULTIPLY: 106,
  13756. /** Key constant @type Number */
  13757. NUM_PLUS: 107,
  13758. /** Key constant @type Number */
  13759. NUM_MINUS: 109,
  13760. /** Key constant @type Number */
  13761. NUM_PERIOD: 110,
  13762. /** Key constant @type Number */
  13763. NUM_DIVISION: 111,
  13764. /** Key constant @type Number */
  13765. F1: 112,
  13766. /** Key constant @type Number */
  13767. F2: 113,
  13768. /** Key constant @type Number */
  13769. F3: 114,
  13770. /** Key constant @type Number */
  13771. F4: 115,
  13772. /** Key constant @type Number */
  13773. F5: 116,
  13774. /** Key constant @type Number */
  13775. F6: 117,
  13776. /** Key constant @type Number */
  13777. F7: 118,
  13778. /** Key constant @type Number */
  13779. F8: 119,
  13780. /** Key constant @type Number */
  13781. F9: 120,
  13782. /** Key constant @type Number */
  13783. F10: 121,
  13784. /** Key constant @type Number */
  13785. F11: 122,
  13786. /** Key constant @type Number */
  13787. F12: 123,
  13788. /**
  13789. * The mouse wheel delta scaling factor. This value depends on browser version and OS and
  13790. * attempts to produce a similar scrolling experience across all platforms and browsers.
  13791. *
  13792. * To change this value:
  13793. *
  13794. * Ext.EventObjectImpl.prototype.WHEEL_SCALE = 72;
  13795. *
  13796. * @type Number
  13797. * @markdown
  13798. */
  13799. WHEEL_SCALE: (function () {
  13800. var scale;
  13801. if (Ext.isGecko) {
  13802. // Firefox uses 3 on all platforms
  13803. scale = 3;
  13804. } else if (Ext.isMac) {
  13805. // Continuous scrolling devices have momentum and produce much more scroll than
  13806. // discrete devices on the same OS and browser. To make things exciting, Safari
  13807. // (and not Chrome) changed from small values to 120 (like IE).
  13808. if (Ext.isSafari && Ext.webKitVersion >= 532.0) {
  13809. // Safari changed the scrolling factor to match IE (for details see
  13810. // https://bugs.webkit.org/show_bug.cgi?id=24368). The WebKit version where this
  13811. // change was introduced was 532.0
  13812. // Detailed discussion:
  13813. // https://bugs.webkit.org/show_bug.cgi?id=29601
  13814. // http://trac.webkit.org/browser/trunk/WebKit/chromium/src/mac/WebInputEventFactory.mm#L1063
  13815. scale = 120;
  13816. } else {
  13817. // MS optical wheel mouse produces multiples of 12 which is close enough
  13818. // to help tame the speed of the continuous mice...
  13819. scale = 12;
  13820. }
  13821. // Momentum scrolling produces very fast scrolling, so increase the scale factor
  13822. // to help produce similar results cross platform. This could be even larger and
  13823. // it would help those mice, but other mice would become almost unusable as a
  13824. // result (since we cannot tell which device type is in use).
  13825. scale *= 3;
  13826. } else {
  13827. // IE, Opera and other Windows browsers use 120.
  13828. scale = 120;
  13829. }
  13830. return scale;
  13831. }()),
  13832. /**
  13833. * Simple click regex
  13834. * @private
  13835. */
  13836. clickRe: /(dbl)?click/,
  13837. // safari keypress events for special keys return bad keycodes
  13838. safariKeys: {
  13839. 3: 13, // enter
  13840. 63234: 37, // left
  13841. 63235: 39, // right
  13842. 63232: 38, // up
  13843. 63233: 40, // down
  13844. 63276: 33, // page up
  13845. 63277: 34, // page down
  13846. 63272: 46, // delete
  13847. 63273: 36, // home
  13848. 63275: 35 // end
  13849. },
  13850. // normalize button clicks, don't see any way to feature detect this.
  13851. btnMap: Ext.isIE ? {
  13852. 1: 0,
  13853. 4: 1,
  13854. 2: 2
  13855. } : {
  13856. 0: 0,
  13857. 1: 1,
  13858. 2: 2
  13859. },
  13860. /**
  13861. * @property {Boolean} ctrlKey
  13862. * True if the control key was down during the event.
  13863. * In Mac this will also be true when meta key was down.
  13864. */
  13865. /**
  13866. * @property {Boolean} altKey
  13867. * True if the alt key was down during the event.
  13868. */
  13869. /**
  13870. * @property {Boolean} shiftKey
  13871. * True if the shift key was down during the event.
  13872. */
  13873. constructor: function(event, freezeEvent){
  13874. if (event) {
  13875. this.setEvent(event.browserEvent || event, freezeEvent);
  13876. }
  13877. },
  13878. setEvent: function(event, freezeEvent){
  13879. var me = this, button, options;
  13880. if (event == me || (event && event.browserEvent)) { // already wrapped
  13881. return event;
  13882. }
  13883. me.browserEvent = event;
  13884. if (event) {
  13885. // normalize buttons
  13886. button = event.button ? me.btnMap[event.button] : (event.which ? event.which - 1 : -1);
  13887. if (me.clickRe.test(event.type) && button == -1) {
  13888. button = 0;
  13889. }
  13890. options = {
  13891. type: event.type,
  13892. button: button,
  13893. shiftKey: event.shiftKey,
  13894. // mac metaKey behaves like ctrlKey
  13895. ctrlKey: event.ctrlKey || event.metaKey || false,
  13896. altKey: event.altKey,
  13897. // in getKey these will be normalized for the mac
  13898. keyCode: event.keyCode,
  13899. charCode: event.charCode,
  13900. // cache the targets for the delayed and or buffered events
  13901. target: Ext.EventManager.getTarget(event),
  13902. relatedTarget: Ext.EventManager.getRelatedTarget(event),
  13903. currentTarget: event.currentTarget,
  13904. xy: (freezeEvent ? me.getXY() : null)
  13905. };
  13906. } else {
  13907. options = {
  13908. button: -1,
  13909. shiftKey: false,
  13910. ctrlKey: false,
  13911. altKey: false,
  13912. keyCode: 0,
  13913. charCode: 0,
  13914. target: null,
  13915. xy: [0, 0]
  13916. };
  13917. }
  13918. Ext.apply(me, options);
  13919. return me;
  13920. },
  13921. /**
  13922. * Stop the event (preventDefault and stopPropagation)
  13923. */
  13924. stopEvent: function(){
  13925. this.stopPropagation();
  13926. this.preventDefault();
  13927. },
  13928. /**
  13929. * Prevents the browsers default handling of the event.
  13930. */
  13931. preventDefault: function(){
  13932. if (this.browserEvent) {
  13933. Ext.EventManager.preventDefault(this.browserEvent);
  13934. }
  13935. },
  13936. /**
  13937. * Cancels bubbling of the event.
  13938. */
  13939. stopPropagation: function(){
  13940. var browserEvent = this.browserEvent;
  13941. if (browserEvent) {
  13942. if (browserEvent.type == 'mousedown') {
  13943. Ext.EventManager.stoppedMouseDownEvent.fire(this);
  13944. }
  13945. Ext.EventManager.stopPropagation(browserEvent);
  13946. }
  13947. },
  13948. /**
  13949. * Gets the character code for the event.
  13950. * @return {Number}
  13951. */
  13952. getCharCode: function(){
  13953. return this.charCode || this.keyCode;
  13954. },
  13955. /**
  13956. * Returns a normalized keyCode for the event.
  13957. * @return {Number} The key code
  13958. */
  13959. getKey: function(){
  13960. return this.normalizeKey(this.keyCode || this.charCode);
  13961. },
  13962. /**
  13963. * Normalize key codes across browsers
  13964. * @private
  13965. * @param {Number} key The key code
  13966. * @return {Number} The normalized code
  13967. */
  13968. normalizeKey: function(key){
  13969. // can't feature detect this
  13970. return Ext.isWebKit ? (this.safariKeys[key] || key) : key;
  13971. },
  13972. /**
  13973. * Gets the x coordinate of the event.
  13974. * @return {Number}
  13975. * @deprecated 4.0 Replaced by {@link #getX}
  13976. */
  13977. getPageX: function(){
  13978. return this.getX();
  13979. },
  13980. /**
  13981. * Gets the y coordinate of the event.
  13982. * @return {Number}
  13983. * @deprecated 4.0 Replaced by {@link #getY}
  13984. */
  13985. getPageY: function(){
  13986. return this.getY();
  13987. },
  13988. /**
  13989. * Gets the x coordinate of the event.
  13990. * @return {Number}
  13991. */
  13992. getX: function() {
  13993. return this.getXY()[0];
  13994. },
  13995. /**
  13996. * Gets the y coordinate of the event.
  13997. * @return {Number}
  13998. */
  13999. getY: function() {
  14000. return this.getXY()[1];
  14001. },
  14002. /**
  14003. * Gets the page coordinates of the event.
  14004. * @return {Number[]} The xy values like [x, y]
  14005. */
  14006. getXY: function() {
  14007. if (!this.xy) {
  14008. // same for XY
  14009. this.xy = Ext.EventManager.getPageXY(this.browserEvent);
  14010. }
  14011. return this.xy;
  14012. },
  14013. /**
  14014. * Gets the target for the event.
  14015. * @param {String} selector (optional) A simple selector to filter the target or look for an ancestor of the target
  14016. * @param {Number/HTMLElement} maxDepth (optional) The max depth to search as a number or element (defaults to 10 || document.body)
  14017. * @param {Boolean} returnEl (optional) True to return a Ext.Element object instead of DOM node
  14018. * @return {HTMLElement}
  14019. */
  14020. getTarget : function(selector, maxDepth, returnEl){
  14021. if (selector) {
  14022. return Ext.fly(this.target).findParent(selector, maxDepth, returnEl);
  14023. }
  14024. return returnEl ? Ext.get(this.target) : this.target;
  14025. },
  14026. /**
  14027. * Gets the related target.
  14028. * @param {String} selector (optional) A simple selector to filter the target or look for an ancestor of the target
  14029. * @param {Number/HTMLElement} maxDepth (optional) The max depth to search as a number or element (defaults to 10 || document.body)
  14030. * @param {Boolean} returnEl (optional) True to return a Ext.Element object instead of DOM node
  14031. * @return {HTMLElement}
  14032. */
  14033. getRelatedTarget : function(selector, maxDepth, returnEl){
  14034. if (selector) {
  14035. return Ext.fly(this.relatedTarget).findParent(selector, maxDepth, returnEl);
  14036. }
  14037. return returnEl ? Ext.get(this.relatedTarget) : this.relatedTarget;
  14038. },
  14039. /**
  14040. * Correctly scales a given wheel delta.
  14041. * @param {Number} delta The delta value.
  14042. */
  14043. correctWheelDelta : function (delta) {
  14044. var scale = this.WHEEL_SCALE,
  14045. ret = Math.round(delta / scale);
  14046. if (!ret && delta) {
  14047. ret = (delta < 0) ? -1 : 1; // don't allow non-zero deltas to go to zero!
  14048. }
  14049. return ret;
  14050. },
  14051. /**
  14052. * Returns the mouse wheel deltas for this event.
  14053. * @return {Object} An object with "x" and "y" properties holding the mouse wheel deltas.
  14054. */
  14055. getWheelDeltas : function () {
  14056. var me = this,
  14057. event = me.browserEvent,
  14058. dx = 0, dy = 0; // the deltas
  14059. if (Ext.isDefined(event.wheelDeltaX)) { // WebKit has both dimensions
  14060. dx = event.wheelDeltaX;
  14061. dy = event.wheelDeltaY;
  14062. } else if (event.wheelDelta) { // old WebKit and IE
  14063. dy = event.wheelDelta;
  14064. } else if (event.detail) { // Gecko
  14065. dy = -event.detail; // gecko is backwards
  14066. // Gecko sometimes returns really big values if the user changes settings to
  14067. // scroll a whole page per scroll
  14068. if (dy > 100) {
  14069. dy = 3;
  14070. } else if (dy < -100) {
  14071. dy = -3;
  14072. }
  14073. // Firefox 3.1 adds an axis field to the event to indicate direction of
  14074. // scroll. See https://developer.mozilla.org/en/Gecko-Specific_DOM_Events
  14075. if (Ext.isDefined(event.axis) && event.axis === event.HORIZONTAL_AXIS) {
  14076. dx = dy;
  14077. dy = 0;
  14078. }
  14079. }
  14080. return {
  14081. x: me.correctWheelDelta(dx),
  14082. y: me.correctWheelDelta(dy)
  14083. };
  14084. },
  14085. /**
  14086. * Normalizes mouse wheel y-delta across browsers. To get x-delta information, use
  14087. * {@link #getWheelDeltas} instead.
  14088. * @return {Number} The mouse wheel y-delta
  14089. */
  14090. getWheelDelta : function(){
  14091. var deltas = this.getWheelDeltas();
  14092. return deltas.y;
  14093. },
  14094. /**
  14095. * Returns true if the target of this event is a child of el. Unless the allowEl parameter is set, it will return false if if the target is el.
  14096. * Example usage:<pre><code>
  14097. // Handle click on any child of an element
  14098. Ext.getBody().on('click', function(e){
  14099. if(e.within('some-el')){
  14100. alert('Clicked on a child of some-el!');
  14101. }
  14102. });
  14103. // Handle click directly on an element, ignoring clicks on child nodes
  14104. Ext.getBody().on('click', function(e,t){
  14105. if((t.id == 'some-el') && !e.within(t, true)){
  14106. alert('Clicked directly on some-el!');
  14107. }
  14108. });
  14109. </code></pre>
  14110. * @param {String/HTMLElement/Ext.Element} el The id, DOM element or Ext.Element to check
  14111. * @param {Boolean} related (optional) true to test if the related target is within el instead of the target
  14112. * @param {Boolean} allowEl (optional) true to also check if the passed element is the target or related target
  14113. * @return {Boolean}
  14114. */
  14115. within : function(el, related, allowEl){
  14116. if(el){
  14117. var t = related ? this.getRelatedTarget() : this.getTarget(),
  14118. result;
  14119. if (t) {
  14120. result = Ext.fly(el).contains(t);
  14121. if (!result && allowEl) {
  14122. result = t == Ext.getDom(el);
  14123. }
  14124. return result;
  14125. }
  14126. }
  14127. return false;
  14128. },
  14129. /**
  14130. * Checks if the key pressed was a "navigation" key
  14131. * @return {Boolean} True if the press is a navigation keypress
  14132. */
  14133. isNavKeyPress : function(){
  14134. var me = this,
  14135. k = this.normalizeKey(me.keyCode);
  14136. return (k >= 33 && k <= 40) || // Page Up/Down, End, Home, Left, Up, Right, Down
  14137. k == me.RETURN ||
  14138. k == me.TAB ||
  14139. k == me.ESC;
  14140. },
  14141. /**
  14142. * Checks if the key pressed was a "special" key
  14143. * @return {Boolean} True if the press is a special keypress
  14144. */
  14145. isSpecialKey : function(){
  14146. var k = this.normalizeKey(this.keyCode);
  14147. return (this.type == 'keypress' && this.ctrlKey) ||
  14148. this.isNavKeyPress() ||
  14149. (k == this.BACKSPACE) || // Backspace
  14150. (k >= 16 && k <= 20) || // Shift, Ctrl, Alt, Pause, Caps Lock
  14151. (k >= 44 && k <= 46); // Print Screen, Insert, Delete
  14152. },
  14153. /**
  14154. * Returns a point object that consists of the object coordinates.
  14155. * @return {Ext.util.Point} point
  14156. */
  14157. getPoint : function(){
  14158. var xy = this.getXY();
  14159. return new Ext.util.Point(xy[0], xy[1]);
  14160. },
  14161. /**
  14162. * Returns true if the control, meta, shift or alt key was pressed during this event.
  14163. * @return {Boolean}
  14164. */
  14165. hasModifier : function(){
  14166. return this.ctrlKey || this.altKey || this.shiftKey || this.metaKey;
  14167. },
  14168. /**
  14169. * Injects a DOM event using the data in this object and (optionally) a new target.
  14170. * This is a low-level technique and not likely to be used by application code. The
  14171. * currently supported event types are:
  14172. * <p><b>HTMLEvents</b></p>
  14173. * <ul>
  14174. * <li>load</li>
  14175. * <li>unload</li>
  14176. * <li>select</li>
  14177. * <li>change</li>
  14178. * <li>submit</li>
  14179. * <li>reset</li>
  14180. * <li>resize</li>
  14181. * <li>scroll</li>
  14182. * </ul>
  14183. * <p><b>MouseEvents</b></p>
  14184. * <ul>
  14185. * <li>click</li>
  14186. * <li>dblclick</li>
  14187. * <li>mousedown</li>
  14188. * <li>mouseup</li>
  14189. * <li>mouseover</li>
  14190. * <li>mousemove</li>
  14191. * <li>mouseout</li>
  14192. * </ul>
  14193. * <p><b>UIEvents</b></p>
  14194. * <ul>
  14195. * <li>focusin</li>
  14196. * <li>focusout</li>
  14197. * <li>activate</li>
  14198. * <li>focus</li>
  14199. * <li>blur</li>
  14200. * </ul>
  14201. * @param {Ext.Element/HTMLElement} target (optional) If specified, the target for the event. This
  14202. * is likely to be used when relaying a DOM event. If not specified, {@link #getTarget}
  14203. * is used to determine the target.
  14204. */
  14205. injectEvent: (function () {
  14206. var API,
  14207. dispatchers = {}, // keyed by event type (e.g., 'mousedown')
  14208. crazyIEButtons;
  14209. // Good reference: http://developer.yahoo.com/yui/docs/UserAction.js.html
  14210. // IE9 has createEvent, but this code causes major problems with htmleditor (it
  14211. // blocks all mouse events and maybe more). TODO
  14212. if (!Ext.isIE && document.createEvent) { // if (DOM compliant)
  14213. API = {
  14214. createHtmlEvent: function (doc, type, bubbles, cancelable) {
  14215. var event = doc.createEvent('HTMLEvents');
  14216. event.initEvent(type, bubbles, cancelable);
  14217. return event;
  14218. },
  14219. createMouseEvent: function (doc, type, bubbles, cancelable, detail,
  14220. clientX, clientY, ctrlKey, altKey, shiftKey, metaKey,
  14221. button, relatedTarget) {
  14222. var event = doc.createEvent('MouseEvents'),
  14223. view = doc.defaultView || window;
  14224. if (event.initMouseEvent) {
  14225. event.initMouseEvent(type, bubbles, cancelable, view, detail,
  14226. clientX, clientY, clientX, clientY, ctrlKey, altKey,
  14227. shiftKey, metaKey, button, relatedTarget);
  14228. } else { // old Safari
  14229. event = doc.createEvent('UIEvents');
  14230. event.initEvent(type, bubbles, cancelable);
  14231. event.view = view;
  14232. event.detail = detail;
  14233. event.screenX = clientX;
  14234. event.screenY = clientY;
  14235. event.clientX = clientX;
  14236. event.clientY = clientY;
  14237. event.ctrlKey = ctrlKey;
  14238. event.altKey = altKey;
  14239. event.metaKey = metaKey;
  14240. event.shiftKey = shiftKey;
  14241. event.button = button;
  14242. event.relatedTarget = relatedTarget;
  14243. }
  14244. return event;
  14245. },
  14246. createUIEvent: function (doc, type, bubbles, cancelable, detail) {
  14247. var event = doc.createEvent('UIEvents'),
  14248. view = doc.defaultView || window;
  14249. event.initUIEvent(type, bubbles, cancelable, view, detail);
  14250. return event;
  14251. },
  14252. fireEvent: function (target, type, event) {
  14253. target.dispatchEvent(event);
  14254. },
  14255. fixTarget: function (target) {
  14256. // Safari3 doesn't have window.dispatchEvent()
  14257. if (target == window && !target.dispatchEvent) {
  14258. return document;
  14259. }
  14260. return target;
  14261. }
  14262. };
  14263. } else if (document.createEventObject) { // else if (IE)
  14264. crazyIEButtons = { 0: 1, 1: 4, 2: 2 };
  14265. API = {
  14266. createHtmlEvent: function (doc, type, bubbles, cancelable) {
  14267. var event = doc.createEventObject();
  14268. event.bubbles = bubbles;
  14269. event.cancelable = cancelable;
  14270. return event;
  14271. },
  14272. createMouseEvent: function (doc, type, bubbles, cancelable, detail,
  14273. clientX, clientY, ctrlKey, altKey, shiftKey, metaKey,
  14274. button, relatedTarget) {
  14275. var event = doc.createEventObject();
  14276. event.bubbles = bubbles;
  14277. event.cancelable = cancelable;
  14278. event.detail = detail;
  14279. event.screenX = clientX;
  14280. event.screenY = clientY;
  14281. event.clientX = clientX;
  14282. event.clientY = clientY;
  14283. event.ctrlKey = ctrlKey;
  14284. event.altKey = altKey;
  14285. event.shiftKey = shiftKey;
  14286. event.metaKey = metaKey;
  14287. event.button = crazyIEButtons[button] || button;
  14288. event.relatedTarget = relatedTarget; // cannot assign to/fromElement
  14289. return event;
  14290. },
  14291. createUIEvent: function (doc, type, bubbles, cancelable, detail) {
  14292. var event = doc.createEventObject();
  14293. event.bubbles = bubbles;
  14294. event.cancelable = cancelable;
  14295. return event;
  14296. },
  14297. fireEvent: function (target, type, event) {
  14298. target.fireEvent('on' + type, event);
  14299. },
  14300. fixTarget: function (target) {
  14301. if (target == document) {
  14302. // IE6,IE7 thinks window==document and doesn't have window.fireEvent()
  14303. // IE6,IE7 cannot properly call document.fireEvent()
  14304. return document.documentElement;
  14305. }
  14306. return target;
  14307. }
  14308. };
  14309. }
  14310. //----------------
  14311. // HTMLEvents
  14312. Ext.Object.each({
  14313. load: [false, false],
  14314. unload: [false, false],
  14315. select: [true, false],
  14316. change: [true, false],
  14317. submit: [true, true],
  14318. reset: [true, false],
  14319. resize: [true, false],
  14320. scroll: [true, false]
  14321. },
  14322. function (name, value) {
  14323. var bubbles = value[0], cancelable = value[1];
  14324. dispatchers[name] = function (targetEl, srcEvent) {
  14325. var e = API.createHtmlEvent(name, bubbles, cancelable);
  14326. API.fireEvent(targetEl, name, e);
  14327. };
  14328. });
  14329. //----------------
  14330. // MouseEvents
  14331. function createMouseEventDispatcher (type, detail) {
  14332. var cancelable = (type != 'mousemove');
  14333. return function (targetEl, srcEvent) {
  14334. var xy = srcEvent.getXY(),
  14335. e = API.createMouseEvent(targetEl.ownerDocument, type, true, cancelable,
  14336. detail, xy[0], xy[1], srcEvent.ctrlKey, srcEvent.altKey,
  14337. srcEvent.shiftKey, srcEvent.metaKey, srcEvent.button,
  14338. srcEvent.relatedTarget);
  14339. API.fireEvent(targetEl, type, e);
  14340. };
  14341. }
  14342. Ext.each(['click', 'dblclick', 'mousedown', 'mouseup', 'mouseover', 'mousemove', 'mouseout'],
  14343. function (eventName) {
  14344. dispatchers[eventName] = createMouseEventDispatcher(eventName, 1);
  14345. });
  14346. //----------------
  14347. // UIEvents
  14348. Ext.Object.each({
  14349. focusin: [true, false],
  14350. focusout: [true, false],
  14351. activate: [true, true],
  14352. focus: [false, false],
  14353. blur: [false, false]
  14354. },
  14355. function (name, value) {
  14356. var bubbles = value[0], cancelable = value[1];
  14357. dispatchers[name] = function (targetEl, srcEvent) {
  14358. var e = API.createUIEvent(targetEl.ownerDocument, name, bubbles, cancelable, 1);
  14359. API.fireEvent(targetEl, name, e);
  14360. };
  14361. });
  14362. //---------
  14363. if (!API) {
  14364. // not even sure what ancient browsers fall into this category...
  14365. dispatchers = {}; // never mind all those we just built :P
  14366. API = {
  14367. fixTarget: function (t) {
  14368. return t;
  14369. }
  14370. };
  14371. }
  14372. function cannotInject (target, srcEvent) {
  14373. }
  14374. return function (target) {
  14375. var me = this,
  14376. dispatcher = dispatchers[me.type] || cannotInject,
  14377. t = target ? (target.dom || target) : me.getTarget();
  14378. t = API.fixTarget(t);
  14379. dispatcher(t, me);
  14380. };
  14381. }()) // call to produce method
  14382. }, function() {
  14383. Ext.EventObject = new Ext.EventObjectImpl();
  14384. });
  14385. //@tag dom,core
  14386. //@require ../EventObject.js
  14387. /**
  14388. * @class Ext.dom.AbstractQuery
  14389. * @private
  14390. */
  14391. Ext.define('Ext.dom.AbstractQuery', {
  14392. /**
  14393. * Selects a group of elements.
  14394. * @param {String} selector The selector/xpath query (can be a comma separated list of selectors)
  14395. * @param {HTMLElement/String} [root] The start of the query (defaults to document).
  14396. * @return {HTMLElement[]} An Array of DOM elements which match the selector. If there are
  14397. * no matches, and empty Array is returned.
  14398. */
  14399. select: function(q, root) {
  14400. var results = [],
  14401. nodes,
  14402. i,
  14403. j,
  14404. qlen,
  14405. nlen;
  14406. root = root || document;
  14407. if (typeof root == 'string') {
  14408. root = document.getElementById(root);
  14409. }
  14410. q = q.split(",");
  14411. for (i = 0,qlen = q.length; i < qlen; i++) {
  14412. if (typeof q[i] == 'string') {
  14413. //support for node attribute selection
  14414. if (typeof q[i][0] == '@') {
  14415. nodes = root.getAttributeNode(q[i].substring(1));
  14416. results.push(nodes);
  14417. } else {
  14418. nodes = root.querySelectorAll(q[i]);
  14419. for (j = 0,nlen = nodes.length; j < nlen; j++) {
  14420. results.push(nodes[j]);
  14421. }
  14422. }
  14423. }
  14424. }
  14425. return results;
  14426. },
  14427. /**
  14428. * Selects a single element.
  14429. * @param {String} selector The selector/xpath query
  14430. * @param {HTMLElement/String} [root] The start of the query (defaults to document).
  14431. * @return {HTMLElement} The DOM element which matched the selector.
  14432. */
  14433. selectNode: function(q, root) {
  14434. return this.select(q, root)[0];
  14435. },
  14436. /**
  14437. * Returns true if the passed element(s) match the passed simple selector (e.g. div.some-class or span:first-child)
  14438. * @param {String/HTMLElement/Array} el An element id, element or array of elements
  14439. * @param {String} selector The simple selector to test
  14440. * @return {Boolean}
  14441. */
  14442. is: function(el, q) {
  14443. if (typeof el == "string") {
  14444. el = document.getElementById(el);
  14445. }
  14446. return this.select(q).indexOf(el) !== -1;
  14447. }
  14448. });
  14449. //@tag dom,core
  14450. //@require AbstractQuery.js
  14451. /**
  14452. * Abstract base class for {@link Ext.dom.Helper}.
  14453. * @private
  14454. */
  14455. Ext.define('Ext.dom.AbstractHelper', {
  14456. emptyTags : /^(?:br|frame|hr|img|input|link|meta|range|spacer|wbr|area|param|col)$/i,
  14457. confRe : /(?:tag|children|cn|html|tpl|tplData)$/i,
  14458. endRe : /end/i,
  14459. // Since cls & for are reserved words, we need to transform them
  14460. attributeTransform: { cls : 'class', htmlFor : 'for' },
  14461. closeTags: {},
  14462. decamelizeName : (function () {
  14463. var camelCaseRe = /([a-z])([A-Z])/g,
  14464. cache = {};
  14465. function decamel (match, p1, p2) {
  14466. return p1 + '-' + p2.toLowerCase();
  14467. }
  14468. return function (s) {
  14469. return cache[s] || (cache[s] = s.replace(camelCaseRe, decamel));
  14470. };
  14471. }()),
  14472. generateMarkup: function(spec, buffer) {
  14473. var me = this,
  14474. attr, val, tag, i, closeTags;
  14475. if (typeof spec == "string") {
  14476. buffer.push(spec);
  14477. } else if (Ext.isArray(spec)) {
  14478. for (i = 0; i < spec.length; i++) {
  14479. if (spec[i]) {
  14480. me.generateMarkup(spec[i], buffer);
  14481. }
  14482. }
  14483. } else {
  14484. tag = spec.tag || 'div';
  14485. buffer.push('<', tag);
  14486. for (attr in spec) {
  14487. if (spec.hasOwnProperty(attr)) {
  14488. val = spec[attr];
  14489. if (!me.confRe.test(attr)) {
  14490. if (typeof val == "object") {
  14491. buffer.push(' ', attr, '="');
  14492. me.generateStyles(val, buffer).push('"');
  14493. } else {
  14494. buffer.push(' ', me.attributeTransform[attr] || attr, '="', val, '"');
  14495. }
  14496. }
  14497. }
  14498. }
  14499. // Now either just close the tag or try to add children and close the tag.
  14500. if (me.emptyTags.test(tag)) {
  14501. buffer.push('/>');
  14502. } else {
  14503. buffer.push('>');
  14504. // Apply the tpl html, and cn specifications
  14505. if ((val = spec.tpl)) {
  14506. val.applyOut(spec.tplData, buffer);
  14507. }
  14508. if ((val = spec.html)) {
  14509. buffer.push(val);
  14510. }
  14511. if ((val = spec.cn || spec.children)) {
  14512. me.generateMarkup(val, buffer);
  14513. }
  14514. // we generate a lot of close tags, so cache them rather than push 3 parts
  14515. closeTags = me.closeTags;
  14516. buffer.push(closeTags[tag] || (closeTags[tag] = '</' + tag + '>'));
  14517. }
  14518. }
  14519. return buffer;
  14520. },
  14521. /**
  14522. * Converts the styles from the given object to text. The styles are CSS style names
  14523. * with their associated value.
  14524. *
  14525. * The basic form of this method returns a string:
  14526. *
  14527. * var s = Ext.DomHelper.generateStyles({
  14528. * backgroundColor: 'red'
  14529. * });
  14530. *
  14531. * // s = 'background-color:red;'
  14532. *
  14533. * Alternatively, this method can append to an output array.
  14534. *
  14535. * var buf = [];
  14536. *
  14537. * ...
  14538. *
  14539. * Ext.DomHelper.generateStyles({
  14540. * backgroundColor: 'red'
  14541. * }, buf);
  14542. *
  14543. * In this case, the style text is pushed on to the array and the array is returned.
  14544. *
  14545. * @param {Object} styles The object describing the styles.
  14546. * @param {String[]} [buffer] The output buffer.
  14547. * @return {String/String[]} If buffer is passed, it is returned. Otherwise the style
  14548. * string is returned.
  14549. */
  14550. generateStyles: function (styles, buffer) {
  14551. var a = buffer || [],
  14552. name;
  14553. for (name in styles) {
  14554. if (styles.hasOwnProperty(name)) {
  14555. a.push(this.decamelizeName(name), ':', styles[name], ';');
  14556. }
  14557. }
  14558. return buffer || a.join('');
  14559. },
  14560. /**
  14561. * Returns the markup for the passed Element(s) config.
  14562. * @param {Object} spec The DOM object spec (and children)
  14563. * @return {String}
  14564. */
  14565. markup: function(spec) {
  14566. if (typeof spec == "string") {
  14567. return spec;
  14568. }
  14569. var buf = this.generateMarkup(spec, []);
  14570. return buf.join('');
  14571. },
  14572. /**
  14573. * Applies a style specification to an element.
  14574. * @param {String/HTMLElement} el The element to apply styles to
  14575. * @param {String/Object/Function} styles A style specification string e.g. 'width:100px', or object in the form {width:'100px'}, or
  14576. * a function which returns such a specification.
  14577. */
  14578. applyStyles: function(el, styles) {
  14579. if (styles) {
  14580. var i = 0,
  14581. len,
  14582. style;
  14583. el = Ext.fly(el);
  14584. if (typeof styles == 'function') {
  14585. styles = styles.call();
  14586. }
  14587. if (typeof styles == 'string'){
  14588. styles = Ext.util.Format.trim(styles).split(/\s*(?::|;)\s*/);
  14589. for(len = styles.length; i < len;){
  14590. el.setStyle(styles[i++], styles[i++]);
  14591. }
  14592. } else if (Ext.isObject(styles)) {
  14593. el.setStyle(styles);
  14594. }
  14595. }
  14596. },
  14597. /**
  14598. * Inserts an HTML fragment into the DOM.
  14599. * @param {String} where Where to insert the html in relation to el - beforeBegin, afterBegin, beforeEnd, afterEnd.
  14600. *
  14601. * For example take the following HTML: `<div>Contents</div>`
  14602. *
  14603. * Using different `where` values inserts element to the following places:
  14604. *
  14605. * - beforeBegin: `<HERE><div>Contents</div>`
  14606. * - afterBegin: `<div><HERE>Contents</div>`
  14607. * - beforeEnd: `<div>Contents<HERE></div>`
  14608. * - afterEnd: `<div>Contents</div><HERE>`
  14609. *
  14610. * @param {HTMLElement/TextNode} el The context element
  14611. * @param {String} html The HTML fragment
  14612. * @return {HTMLElement} The new node
  14613. */
  14614. insertHtml: function(where, el, html) {
  14615. var hash = {},
  14616. hashVal,
  14617. setStart,
  14618. range,
  14619. frag,
  14620. rangeEl,
  14621. rs;
  14622. where = where.toLowerCase();
  14623. // add these here because they are used in both branches of the condition.
  14624. hash['beforebegin'] = ['BeforeBegin', 'previousSibling'];
  14625. hash['afterend'] = ['AfterEnd', 'nextSibling'];
  14626. range = el.ownerDocument.createRange();
  14627. setStart = 'setStart' + (this.endRe.test(where) ? 'After' : 'Before');
  14628. if (hash[where]) {
  14629. range[setStart](el);
  14630. frag = range.createContextualFragment(html);
  14631. el.parentNode.insertBefore(frag, where == 'beforebegin' ? el : el.nextSibling);
  14632. return el[(where == 'beforebegin' ? 'previous' : 'next') + 'Sibling'];
  14633. }
  14634. else {
  14635. rangeEl = (where == 'afterbegin' ? 'first' : 'last') + 'Child';
  14636. if (el.firstChild) {
  14637. range[setStart](el[rangeEl]);
  14638. frag = range.createContextualFragment(html);
  14639. if (where == 'afterbegin') {
  14640. el.insertBefore(frag, el.firstChild);
  14641. }
  14642. else {
  14643. el.appendChild(frag);
  14644. }
  14645. }
  14646. else {
  14647. el.innerHTML = html;
  14648. }
  14649. return el[rangeEl];
  14650. }
  14651. throw 'Illegal insertion point -> "' + where + '"';
  14652. },
  14653. /**
  14654. * Creates new DOM element(s) and inserts them before el.
  14655. * @param {String/HTMLElement/Ext.Element} el The context element
  14656. * @param {Object/String} o The DOM object spec (and children) or raw HTML blob
  14657. * @param {Boolean} [returnElement] true to return a Ext.Element
  14658. * @return {HTMLElement/Ext.Element} The new node
  14659. */
  14660. insertBefore: function(el, o, returnElement) {
  14661. return this.doInsert(el, o, returnElement, 'beforebegin');
  14662. },
  14663. /**
  14664. * Creates new DOM element(s) and inserts them after el.
  14665. * @param {String/HTMLElement/Ext.Element} el The context element
  14666. * @param {Object} o The DOM object spec (and children)
  14667. * @param {Boolean} [returnElement] true to return a Ext.Element
  14668. * @return {HTMLElement/Ext.Element} The new node
  14669. */
  14670. insertAfter: function(el, o, returnElement) {
  14671. return this.doInsert(el, o, returnElement, 'afterend', 'nextSibling');
  14672. },
  14673. /**
  14674. * Creates new DOM element(s) and inserts them as the first child of el.
  14675. * @param {String/HTMLElement/Ext.Element} el The context element
  14676. * @param {Object/String} o The DOM object spec (and children) or raw HTML blob
  14677. * @param {Boolean} [returnElement] true to return a Ext.Element
  14678. * @return {HTMLElement/Ext.Element} The new node
  14679. */
  14680. insertFirst: function(el, o, returnElement) {
  14681. return this.doInsert(el, o, returnElement, 'afterbegin', 'firstChild');
  14682. },
  14683. /**
  14684. * Creates new DOM element(s) and appends them to el.
  14685. * @param {String/HTMLElement/Ext.Element} el The context element
  14686. * @param {Object/String} o The DOM object spec (and children) or raw HTML blob
  14687. * @param {Boolean} [returnElement] true to return a Ext.Element
  14688. * @return {HTMLElement/Ext.Element} The new node
  14689. */
  14690. append: function(el, o, returnElement) {
  14691. return this.doInsert(el, o, returnElement, 'beforeend', '', true);
  14692. },
  14693. /**
  14694. * Creates new DOM element(s) and overwrites the contents of el with them.
  14695. * @param {String/HTMLElement/Ext.Element} el The context element
  14696. * @param {Object/String} o The DOM object spec (and children) or raw HTML blob
  14697. * @param {Boolean} [returnElement] true to return a Ext.Element
  14698. * @return {HTMLElement/Ext.Element} The new node
  14699. */
  14700. overwrite: function(el, o, returnElement) {
  14701. el = Ext.getDom(el);
  14702. el.innerHTML = this.markup(o);
  14703. return returnElement ? Ext.get(el.firstChild) : el.firstChild;
  14704. },
  14705. doInsert: function(el, o, returnElement, pos, sibling, append) {
  14706. var newNode = this.insertHtml(pos, Ext.getDom(el), this.markup(o));
  14707. return returnElement ? Ext.get(newNode, true) : newNode;
  14708. }
  14709. });
  14710. //@tag dom,core
  14711. //@require AbstractHelper.js
  14712. //@require Ext.Supports
  14713. //@require Ext.EventManager
  14714. //@define Ext.dom.AbstractElement
  14715. /**
  14716. * @class Ext.dom.AbstractElement
  14717. * @extend Ext.Base
  14718. * @private
  14719. */
  14720. (function() {
  14721. var document = window.document,
  14722. trimRe = /^\s+|\s+$/g,
  14723. whitespaceRe = /\s/;
  14724. if (!Ext.cache){
  14725. Ext.cache = {};
  14726. }
  14727. Ext.define('Ext.dom.AbstractElement', {
  14728. inheritableStatics: {
  14729. /**
  14730. * Retrieves Ext.dom.Element objects. {@link Ext#get} is alias for {@link Ext.dom.Element#get}.
  14731. *
  14732. * **This method does not retrieve {@link Ext.Component Component}s.** This method retrieves Ext.dom.Element
  14733. * objects which encapsulate DOM elements. To retrieve a Component by its ID, use {@link Ext.ComponentManager#get}.
  14734. *
  14735. * Uses simple caching to consistently return the same object. Automatically fixes if an object was recreated with
  14736. * the same id via AJAX or DOM.
  14737. *
  14738. * @param {String/HTMLElement/Ext.Element} el The id of the node, a DOM Node or an existing Element.
  14739. * @return {Ext.dom.Element} The Element object (or null if no matching element was found)
  14740. * @static
  14741. * @inheritable
  14742. */
  14743. get: function(el) {
  14744. var me = this,
  14745. El = Ext.dom.Element,
  14746. cacheItem,
  14747. extEl,
  14748. dom,
  14749. id;
  14750. if (!el) {
  14751. return null;
  14752. }
  14753. if (typeof el == "string") { // element id
  14754. if (el == Ext.windowId) {
  14755. return El.get(window);
  14756. } else if (el == Ext.documentId) {
  14757. return El.get(document);
  14758. }
  14759. cacheItem = Ext.cache[el];
  14760. // This code is here to catch the case where we've got a reference to a document of an iframe
  14761. // It getElementById will fail because it's not part of the document, so if we're skipping
  14762. // GC it means it's a window/document object that isn't the default window/document, which we have
  14763. // already handled above
  14764. if (cacheItem && cacheItem.skipGarbageCollection) {
  14765. extEl = cacheItem.el;
  14766. return extEl;
  14767. }
  14768. if (!(dom = document.getElementById(el))) {
  14769. return null;
  14770. }
  14771. if (cacheItem && cacheItem.el) {
  14772. extEl = Ext.updateCacheEntry(cacheItem, dom).el;
  14773. } else {
  14774. // Force new element if there's a cache but no el attached
  14775. extEl = new El(dom, !!cacheItem);
  14776. }
  14777. return extEl;
  14778. } else if (el.tagName) { // dom element
  14779. if (!(id = el.id)) {
  14780. id = Ext.id(el);
  14781. }
  14782. cacheItem = Ext.cache[id];
  14783. if (cacheItem && cacheItem.el) {
  14784. extEl = Ext.updateCacheEntry(cacheItem, el).el;
  14785. } else {
  14786. // Force new element if there's a cache but no el attached
  14787. extEl = new El(el, !!cacheItem);
  14788. }
  14789. return extEl;
  14790. } else if (el instanceof me) {
  14791. if (el != me.docEl && el != me.winEl) {
  14792. id = el.id;
  14793. // refresh dom element in case no longer valid,
  14794. // catch case where it hasn't been appended
  14795. cacheItem = Ext.cache[id];
  14796. if (cacheItem) {
  14797. Ext.updateCacheEntry(cacheItem, document.getElementById(id) || el.dom);
  14798. }
  14799. }
  14800. return el;
  14801. } else if (el.isComposite) {
  14802. return el;
  14803. } else if (Ext.isArray(el)) {
  14804. return me.select(el);
  14805. } else if (el === document) {
  14806. // create a bogus element object representing the document object
  14807. if (!me.docEl) {
  14808. me.docEl = Ext.Object.chain(El.prototype);
  14809. me.docEl.dom = document;
  14810. me.docEl.id = Ext.id(document);
  14811. me.addToCache(me.docEl);
  14812. }
  14813. return me.docEl;
  14814. } else if (el === window) {
  14815. if (!me.winEl) {
  14816. me.winEl = Ext.Object.chain(El.prototype);
  14817. me.winEl.dom = window;
  14818. me.winEl.id = Ext.id(window);
  14819. me.addToCache(me.winEl);
  14820. }
  14821. return me.winEl;
  14822. }
  14823. return null;
  14824. },
  14825. addToCache: function(el, id) {
  14826. if (el) {
  14827. Ext.addCacheEntry(id, el);
  14828. }
  14829. return el;
  14830. },
  14831. addMethods: function() {
  14832. this.override.apply(this, arguments);
  14833. },
  14834. /**
  14835. * <p>Returns an array of unique class names based upon the input strings, or string arrays.</p>
  14836. * <p>The number of parameters is unlimited.</p>
  14837. * <p>Example</p><code><pre>
  14838. // Add x-invalid and x-mandatory classes, do not duplicate
  14839. myElement.dom.className = Ext.core.Element.mergeClsList(this.initialClasses, 'x-invalid x-mandatory');
  14840. </pre></code>
  14841. * @param {Mixed} clsList1 A string of class names, or an array of class names.
  14842. * @param {Mixed} clsList2 A string of class names, or an array of class names.
  14843. * @return {Array} An array of strings representing remaining unique, merged class names. If class names were added to the first list, the <code>changed</code> property will be <code>true</code>.
  14844. * @static
  14845. * @inheritable
  14846. */
  14847. mergeClsList: function() {
  14848. var clsList, clsHash = {},
  14849. i, length, j, listLength, clsName, result = [],
  14850. changed = false;
  14851. for (i = 0, length = arguments.length; i < length; i++) {
  14852. clsList = arguments[i];
  14853. if (Ext.isString(clsList)) {
  14854. clsList = clsList.replace(trimRe, '').split(whitespaceRe);
  14855. }
  14856. if (clsList) {
  14857. for (j = 0, listLength = clsList.length; j < listLength; j++) {
  14858. clsName = clsList[j];
  14859. if (!clsHash[clsName]) {
  14860. if (i) {
  14861. changed = true;
  14862. }
  14863. clsHash[clsName] = true;
  14864. }
  14865. }
  14866. }
  14867. }
  14868. for (clsName in clsHash) {
  14869. result.push(clsName);
  14870. }
  14871. result.changed = changed;
  14872. return result;
  14873. },
  14874. /**
  14875. * <p>Returns an array of unique class names deom the first parameter with all class names
  14876. * from the second parameter removed.</p>
  14877. * <p>Example</p><code><pre>
  14878. // Remove x-invalid and x-mandatory classes if present.
  14879. myElement.dom.className = Ext.core.Element.removeCls(this.initialClasses, 'x-invalid x-mandatory');
  14880. </pre></code>
  14881. * @param {Mixed} existingClsList A string of class names, or an array of class names.
  14882. * @param {Mixed} removeClsList A string of class names, or an array of class names to remove from <code>existingClsList</code>.
  14883. * @return {Array} An array of strings representing remaining class names. If class names were removed, the <code>changed</code> property will be <code>true</code>.
  14884. * @static
  14885. * @inheritable
  14886. */
  14887. removeCls: function(existingClsList, removeClsList) {
  14888. var clsHash = {},
  14889. i, length, clsName, result = [],
  14890. changed = false;
  14891. if (existingClsList) {
  14892. if (Ext.isString(existingClsList)) {
  14893. existingClsList = existingClsList.replace(trimRe, '').split(whitespaceRe);
  14894. }
  14895. for (i = 0, length = existingClsList.length; i < length; i++) {
  14896. clsHash[existingClsList[i]] = true;
  14897. }
  14898. }
  14899. if (removeClsList) {
  14900. if (Ext.isString(removeClsList)) {
  14901. removeClsList = removeClsList.split(whitespaceRe);
  14902. }
  14903. for (i = 0, length = removeClsList.length; i < length; i++) {
  14904. clsName = removeClsList[i];
  14905. if (clsHash[clsName]) {
  14906. changed = true;
  14907. delete clsHash[clsName];
  14908. }
  14909. }
  14910. }
  14911. for (clsName in clsHash) {
  14912. result.push(clsName);
  14913. }
  14914. result.changed = changed;
  14915. return result;
  14916. },
  14917. /**
  14918. * @property
  14919. * Visibility mode constant for use with {@link Ext.dom.Element#setVisibilityMode}.
  14920. * Use the CSS 'visibility' property to hide the element.
  14921. *
  14922. * Note that in this mode, {@link Ext.dom.Element#isVisible isVisible} may return true
  14923. * for an element even though it actually has a parent element that is hidden. For this
  14924. * reason, and in most cases, using the {@link #OFFSETS} mode is a better choice.
  14925. * @static
  14926. * @inheritable
  14927. */
  14928. VISIBILITY: 1,
  14929. /**
  14930. * @property
  14931. * Visibility mode constant for use with {@link Ext.dom.Element#setVisibilityMode}.
  14932. * Use the CSS 'display' property to hide the element.
  14933. * @static
  14934. * @inheritable
  14935. */
  14936. DISPLAY: 2,
  14937. /**
  14938. * @property
  14939. * Visibility mode constant for use with {@link Ext.dom.Element#setVisibilityMode}.
  14940. * Use CSS absolute positioning and top/left offsets to hide the element.
  14941. * @static
  14942. * @inheritable
  14943. */
  14944. OFFSETS: 3,
  14945. /**
  14946. * @property
  14947. * Visibility mode constant for use with {@link Ext.dom.Element#setVisibilityMode}.
  14948. * Add or remove the {@link Ext.Layer#visibilityCls} class to hide the element.
  14949. * @static
  14950. * @inheritable
  14951. */
  14952. ASCLASS: 4
  14953. },
  14954. constructor: function(element, forceNew) {
  14955. var me = this,
  14956. dom = typeof element == 'string'
  14957. ? document.getElementById(element)
  14958. : element,
  14959. id;
  14960. if (!dom) {
  14961. return null;
  14962. }
  14963. id = dom.id;
  14964. if (!forceNew && id && Ext.cache[id]) {
  14965. // element object already exists
  14966. return Ext.cache[id].el;
  14967. }
  14968. /**
  14969. * @property {HTMLElement} dom
  14970. * The DOM element
  14971. */
  14972. me.dom = dom;
  14973. /**
  14974. * @property {String} id
  14975. * The DOM element ID
  14976. */
  14977. me.id = id || Ext.id(dom);
  14978. me.self.addToCache(me);
  14979. },
  14980. /**
  14981. * Sets the passed attributes as attributes of this element (a style attribute can be a string, object or function)
  14982. * @param {Object} o The object with the attributes
  14983. * @param {Boolean} [useSet=true] false to override the default setAttribute to use expandos.
  14984. * @return {Ext.dom.Element} this
  14985. */
  14986. set: function(o, useSet) {
  14987. var el = this.dom,
  14988. attr,
  14989. value;
  14990. for (attr in o) {
  14991. if (o.hasOwnProperty(attr)) {
  14992. value = o[attr];
  14993. if (attr == 'style') {
  14994. this.applyStyles(value);
  14995. }
  14996. else if (attr == 'cls') {
  14997. el.className = value;
  14998. }
  14999. else if (useSet !== false) {
  15000. if (value === undefined) {
  15001. el.removeAttribute(attr);
  15002. } else {
  15003. el.setAttribute(attr, value);
  15004. }
  15005. }
  15006. else {
  15007. el[attr] = value;
  15008. }
  15009. }
  15010. }
  15011. return this;
  15012. },
  15013. /**
  15014. * @property {String} defaultUnit
  15015. * The default unit to append to CSS values where a unit isn't provided.
  15016. */
  15017. defaultUnit: "px",
  15018. /**
  15019. * Returns true if this element matches the passed simple selector (e.g. div.some-class or span:first-child)
  15020. * @param {String} selector The simple selector to test
  15021. * @return {Boolean} True if this element matches the selector, else false
  15022. */
  15023. is: function(simpleSelector) {
  15024. return Ext.DomQuery.is(this.dom, simpleSelector);
  15025. },
  15026. /**
  15027. * Returns the value of the "value" attribute
  15028. * @param {Boolean} asNumber true to parse the value as a number
  15029. * @return {String/Number}
  15030. */
  15031. getValue: function(asNumber) {
  15032. var val = this.dom.value;
  15033. return asNumber ? parseInt(val, 10) : val;
  15034. },
  15035. /**
  15036. * Removes this element's dom reference. Note that event and cache removal is handled at {@link Ext#removeNode
  15037. * Ext.removeNode}
  15038. */
  15039. remove: function() {
  15040. var me = this,
  15041. dom = me.dom;
  15042. if (dom) {
  15043. Ext.removeNode(dom);
  15044. delete me.dom;
  15045. }
  15046. },
  15047. /**
  15048. * Returns true if this element is an ancestor of the passed element
  15049. * @param {HTMLElement/String} el The element to check
  15050. * @return {Boolean} True if this element is an ancestor of el, else false
  15051. */
  15052. contains: function(el) {
  15053. if (!el) {
  15054. return false;
  15055. }
  15056. var me = this,
  15057. dom = el.dom || el;
  15058. // we need el-contains-itself logic here because isAncestor does not do that:
  15059. return (dom === me.dom) || Ext.dom.AbstractElement.isAncestor(me.dom, dom);
  15060. },
  15061. /**
  15062. * Returns the value of an attribute from the element's underlying DOM node.
  15063. * @param {String} name The attribute name
  15064. * @param {String} [namespace] The namespace in which to look for the attribute
  15065. * @return {String} The attribute value
  15066. */
  15067. getAttribute: function(name, ns) {
  15068. var dom = this.dom;
  15069. return dom.getAttributeNS(ns, name) || dom.getAttribute(ns + ":" + name) || dom.getAttribute(name) || dom[name];
  15070. },
  15071. /**
  15072. * Update the innerHTML of this element
  15073. * @param {String} html The new HTML
  15074. * @return {Ext.dom.Element} this
  15075. */
  15076. update: function(html) {
  15077. if (this.dom) {
  15078. this.dom.innerHTML = html;
  15079. }
  15080. return this;
  15081. },
  15082. /**
  15083. * Set the innerHTML of this element
  15084. * @param {String} html The new HTML
  15085. * @return {Ext.Element} this
  15086. */
  15087. setHTML: function(html) {
  15088. if(this.dom) {
  15089. this.dom.innerHTML = html;
  15090. }
  15091. return this;
  15092. },
  15093. /**
  15094. * Returns the innerHTML of an Element or an empty string if the element's
  15095. * dom no longer exists.
  15096. */
  15097. getHTML: function() {
  15098. return this.dom ? this.dom.innerHTML : '';
  15099. },
  15100. /**
  15101. * Hide this element - Uses display mode to determine whether to use "display" or "visibility". See {@link #setVisible}.
  15102. * @param {Boolean/Object} animate (optional) true for the default animation or a standard Element animation config object
  15103. * @return {Ext.Element} this
  15104. */
  15105. hide: function() {
  15106. this.setVisible(false);
  15107. return this;
  15108. },
  15109. /**
  15110. * Show this element - Uses display mode to determine whether to use "display" or "visibility". See {@link #setVisible}.
  15111. * @param {Boolean/Object} animate (optional) true for the default animation or a standard Element animation config object
  15112. * @return {Ext.Element} this
  15113. */
  15114. show: function() {
  15115. this.setVisible(true);
  15116. return this;
  15117. },
  15118. /**
  15119. * Sets the visibility of the element (see details). If the visibilityMode is set to Element.DISPLAY, it will use
  15120. * the display property to hide the element, otherwise it uses visibility. The default is to hide and show using the visibility property.
  15121. * @param {Boolean} visible Whether the element is visible
  15122. * @param {Boolean/Object} animate (optional) True for the default animation, or a standard Element animation config object
  15123. * @return {Ext.Element} this
  15124. */
  15125. setVisible: function(visible, animate) {
  15126. var me = this,
  15127. statics = me.self,
  15128. mode = me.getVisibilityMode(),
  15129. prefix = Ext.baseCSSPrefix;
  15130. switch (mode) {
  15131. case statics.VISIBILITY:
  15132. me.removeCls([prefix + 'hidden-display', prefix + 'hidden-offsets']);
  15133. me[visible ? 'removeCls' : 'addCls'](prefix + 'hidden-visibility');
  15134. break;
  15135. case statics.DISPLAY:
  15136. me.removeCls([prefix + 'hidden-visibility', prefix + 'hidden-offsets']);
  15137. me[visible ? 'removeCls' : 'addCls'](prefix + 'hidden-display');
  15138. break;
  15139. case statics.OFFSETS:
  15140. me.removeCls([prefix + 'hidden-visibility', prefix + 'hidden-display']);
  15141. me[visible ? 'removeCls' : 'addCls'](prefix + 'hidden-offsets');
  15142. break;
  15143. }
  15144. return me;
  15145. },
  15146. getVisibilityMode: function() {
  15147. // Only flyweights won't have a $cache object, by calling getCache the cache
  15148. // will be created for future accesses. As such, we're eliminating the method
  15149. // call since it's mostly redundant
  15150. var data = (this.$cache || this.getCache()).data,
  15151. visMode = data.visibilityMode;
  15152. if (visMode === undefined) {
  15153. data.visibilityMode = visMode = this.self.DISPLAY;
  15154. }
  15155. return visMode;
  15156. },
  15157. /**
  15158. * Use this to change the visibility mode between {@link #VISIBILITY}, {@link #DISPLAY}, {@link #OFFSETS} or {@link #ASCLASS}.
  15159. */
  15160. setVisibilityMode: function(mode) {
  15161. (this.$cache || this.getCache()).data.visibilityMode = mode;
  15162. return this;
  15163. },
  15164. getCache: function() {
  15165. var me = this,
  15166. id = me.dom.id || Ext.id(me.dom);
  15167. // Note that we do not assign an ID to the calling object here.
  15168. // An Ext.dom.Element will have one assigned at construction, and an Ext.dom.AbstractElement.Fly must not have one.
  15169. // We assign an ID to the DOM element if it does not have one.
  15170. me.$cache = Ext.cache[id] || Ext.addCacheEntry(id, null, me.dom);
  15171. return me.$cache;
  15172. }
  15173. }, function() {
  15174. var AbstractElement = this;
  15175. /**
  15176. * @private
  15177. * @member Ext
  15178. */
  15179. Ext.getDetachedBody = function () {
  15180. var detachedEl = AbstractElement.detachedBodyEl;
  15181. if (!detachedEl) {
  15182. detachedEl = document.createElement('div');
  15183. AbstractElement.detachedBodyEl = detachedEl = new AbstractElement.Fly(detachedEl);
  15184. detachedEl.isDetachedBody = true;
  15185. }
  15186. return detachedEl;
  15187. };
  15188. /**
  15189. * @private
  15190. * @member Ext
  15191. */
  15192. Ext.getElementById = function (id) {
  15193. var el = document.getElementById(id),
  15194. detachedBodyEl;
  15195. if (!el && (detachedBodyEl = AbstractElement.detachedBodyEl)) {
  15196. el = detachedBodyEl.dom.querySelector('#' + Ext.escapeId(id));
  15197. }
  15198. return el;
  15199. };
  15200. /**
  15201. * @member Ext
  15202. * @method get
  15203. * @inheritdoc Ext.dom.Element#get
  15204. */
  15205. Ext.get = function(el) {
  15206. return Ext.dom.Element.get(el);
  15207. };
  15208. this.addStatics({
  15209. /**
  15210. * @class Ext.dom.AbstractElement.Fly
  15211. * @extends Ext.dom.AbstractElement
  15212. *
  15213. * A non-persistent wrapper for a DOM element which may be used to execute methods of {@link Ext.dom.Element}
  15214. * upon a DOM element without creating an instance of {@link Ext.dom.Element}.
  15215. *
  15216. * A **singleton** instance of this class is returned when you use {@link Ext#fly}
  15217. *
  15218. * Because it is a singleton, this Flyweight does not have an ID, and must be used and discarded in a single line.
  15219. * You should not keep and use the reference to this singleton over multiple lines because methods that you call
  15220. * may themselves make use of {@link Ext#fly} and may change the DOM element to which the instance refers.
  15221. */
  15222. Fly: new Ext.Class({
  15223. extend: AbstractElement,
  15224. /**
  15225. * @property {Boolean} isFly
  15226. * This is `true` to identify Element flyweights
  15227. */
  15228. isFly: true,
  15229. constructor: function(dom) {
  15230. this.dom = dom;
  15231. },
  15232. /**
  15233. * @private
  15234. * Attach this fliyweight instance to the passed DOM element.
  15235. *
  15236. * Note that a flightweight does **not** have an ID, and does not acquire the ID of the DOM element.
  15237. */
  15238. attach: function (dom) {
  15239. // Attach to the passed DOM element. The same code as in Ext.Fly
  15240. this.dom = dom;
  15241. // Use cached data if there is existing cached data for the referenced DOM element,
  15242. // otherwise it will be created when needed by getCache.
  15243. this.$cache = dom.id ? Ext.cache[dom.id] : null;
  15244. return this;
  15245. }
  15246. }),
  15247. _flyweights: {},
  15248. /**
  15249. * Gets the singleton {@link Ext.dom.AbstractElement.Fly flyweight} element, with the passed node as the active element.
  15250. *
  15251. * Because it is a singleton, this Flyweight does not have an ID, and must be used and discarded in a single line.
  15252. * You may not keep and use the reference to this singleton over multiple lines because methods that you call
  15253. * may themselves make use of {@link Ext#fly} and may change the DOM element to which the instance refers.
  15254. *
  15255. * {@link Ext#fly} is alias for {@link Ext.dom.AbstractElement#fly}.
  15256. *
  15257. * Use this to make one-time references to DOM elements which are not going to be accessed again either by
  15258. * application code, or by Ext's classes. If accessing an element which will be processed regularly, then {@link
  15259. * Ext#get Ext.get} will be more appropriate to take advantage of the caching provided by the Ext.dom.Element
  15260. * class.
  15261. *
  15262. * @param {String/HTMLElement} dom The dom node or id
  15263. * @param {String} [named] Allows for creation of named reusable flyweights to prevent conflicts (e.g.
  15264. * internally Ext uses "_global")
  15265. * @return {Ext.dom.AbstractElement.Fly} The singleton flyweight object (or null if no matching element was found)
  15266. * @static
  15267. * @member Ext.dom.AbstractElement
  15268. */
  15269. fly: function(dom, named) {
  15270. var fly = null,
  15271. _flyweights = AbstractElement._flyweights;
  15272. named = named || '_global';
  15273. dom = Ext.getDom(dom);
  15274. if (dom) {
  15275. fly = _flyweights[named] || (_flyweights[named] = new AbstractElement.Fly());
  15276. // Attach to the passed DOM element.
  15277. // This code performs the same function as Fly.attach, but inline it for efficiency
  15278. fly.dom = dom;
  15279. // Use cached data if there is existing cached data for the referenced DOM element,
  15280. // otherwise it will be created when needed by getCache.
  15281. fly.$cache = dom.id ? Ext.cache[dom.id] : null;
  15282. }
  15283. return fly;
  15284. }
  15285. });
  15286. /**
  15287. * @member Ext
  15288. * @method fly
  15289. * @inheritdoc Ext.dom.AbstractElement#fly
  15290. */
  15291. Ext.fly = function() {
  15292. return AbstractElement.fly.apply(AbstractElement, arguments);
  15293. };
  15294. (function (proto) {
  15295. /**
  15296. * @method destroy
  15297. * @member Ext.dom.AbstractElement
  15298. * @inheritdoc Ext.dom.AbstractElement#remove
  15299. * Alias to {@link #remove}.
  15300. */
  15301. proto.destroy = proto.remove;
  15302. /**
  15303. * Returns a child element of this element given its `id`.
  15304. * @method getById
  15305. * @member Ext.dom.AbstractElement
  15306. * @param {String} id The id of the desired child element.
  15307. * @param {Boolean} [asDom=false] True to return the DOM element, false to return a
  15308. * wrapped Element object.
  15309. */
  15310. if (document.querySelector) {
  15311. proto.getById = function (id, asDom) {
  15312. // for normal elements getElementById is the best solution, but if the el is
  15313. // not part of the document.body, we have to resort to querySelector
  15314. var dom = document.getElementById(id) ||
  15315. this.dom.querySelector('#'+Ext.escapeId(id));
  15316. return asDom ? dom : (dom ? Ext.get(dom) : null);
  15317. };
  15318. } else {
  15319. proto.getById = function (id, asDom) {
  15320. var dom = document.getElementById(id);
  15321. return asDom ? dom : (dom ? Ext.get(dom) : null);
  15322. };
  15323. }
  15324. }(this.prototype));
  15325. });
  15326. }());
  15327. //@tag dom,core
  15328. //@require AbstractElement.js
  15329. //@define Ext.dom.AbstractElement-static
  15330. //@define Ext.dom.AbstractElement
  15331. /**
  15332. * @class Ext.dom.AbstractElement
  15333. */
  15334. Ext.dom.AbstractElement.addInheritableStatics({
  15335. unitRe: /\d+(px|em|%|en|ex|pt|in|cm|mm|pc)$/i,
  15336. camelRe: /(-[a-z])/gi,
  15337. cssRe: /([a-z0-9\-]+)\s*:\s*([^;\s]+(?:\s*[^;\s]+)*);?/gi,
  15338. opacityRe: /alpha\(opacity=(.*)\)/i,
  15339. propertyCache: {},
  15340. defaultUnit : "px",
  15341. borders: {l: 'border-left-width', r: 'border-right-width', t: 'border-top-width', b: 'border-bottom-width'},
  15342. paddings: {l: 'padding-left', r: 'padding-right', t: 'padding-top', b: 'padding-bottom'},
  15343. margins: {l: 'margin-left', r: 'margin-right', t: 'margin-top', b: 'margin-bottom'},
  15344. /**
  15345. * Test if size has a unit, otherwise appends the passed unit string, or the default for this Element.
  15346. * @param size {Object} The size to set
  15347. * @param units {String} The units to append to a numeric size value
  15348. * @private
  15349. * @static
  15350. */
  15351. addUnits: function(size, units) {
  15352. // Most common case first: Size is set to a number
  15353. if (typeof size == 'number') {
  15354. return size + (units || this.defaultUnit || 'px');
  15355. }
  15356. // Size set to a value which means "auto"
  15357. if (size === "" || size == "auto" || size === undefined || size === null) {
  15358. return size || '';
  15359. }
  15360. // Otherwise, warn if it's not a valid CSS measurement
  15361. if (!this.unitRe.test(size)) {
  15362. return size || '';
  15363. }
  15364. return size;
  15365. },
  15366. /**
  15367. * @static
  15368. * @private
  15369. */
  15370. isAncestor: function(p, c) {
  15371. var ret = false;
  15372. p = Ext.getDom(p);
  15373. c = Ext.getDom(c);
  15374. if (p && c) {
  15375. if (p.contains) {
  15376. return p.contains(c);
  15377. } else if (p.compareDocumentPosition) {
  15378. return !!(p.compareDocumentPosition(c) & 16);
  15379. } else {
  15380. while ((c = c.parentNode)) {
  15381. ret = c == p || ret;
  15382. }
  15383. }
  15384. }
  15385. return ret;
  15386. },
  15387. /**
  15388. * Parses a number or string representing margin sizes into an object. Supports CSS-style margin declarations
  15389. * (e.g. 10, "10", "10 10", "10 10 10" and "10 10 10 10" are all valid options and would return the same result)
  15390. * @static
  15391. * @param {Number/String} box The encoded margins
  15392. * @return {Object} An object with margin sizes for top, right, bottom and left
  15393. */
  15394. parseBox: function(box) {
  15395. if (typeof box != 'string') {
  15396. box = box.toString();
  15397. }
  15398. var parts = box.split(' '),
  15399. ln = parts.length;
  15400. if (ln == 1) {
  15401. parts[1] = parts[2] = parts[3] = parts[0];
  15402. }
  15403. else if (ln == 2) {
  15404. parts[2] = parts[0];
  15405. parts[3] = parts[1];
  15406. }
  15407. else if (ln == 3) {
  15408. parts[3] = parts[1];
  15409. }
  15410. return {
  15411. top :parseFloat(parts[0]) || 0,
  15412. right :parseFloat(parts[1]) || 0,
  15413. bottom:parseFloat(parts[2]) || 0,
  15414. left :parseFloat(parts[3]) || 0
  15415. };
  15416. },
  15417. /**
  15418. * Parses a number or string representing margin sizes into an object. Supports CSS-style margin declarations
  15419. * (e.g. 10, "10", "10 10", "10 10 10" and "10 10 10 10" are all valid options and would return the same result)
  15420. * @static
  15421. * @param {Number/String} box The encoded margins
  15422. * @param {String} units The type of units to add
  15423. * @return {String} An string with unitized (px if units is not specified) metrics for top, right, bottom and left
  15424. */
  15425. unitizeBox: function(box, units) {
  15426. var a = this.addUnits,
  15427. b = this.parseBox(box);
  15428. return a(b.top, units) + ' ' +
  15429. a(b.right, units) + ' ' +
  15430. a(b.bottom, units) + ' ' +
  15431. a(b.left, units);
  15432. },
  15433. // private
  15434. camelReplaceFn: function(m, a) {
  15435. return a.charAt(1).toUpperCase();
  15436. },
  15437. /**
  15438. * Normalizes CSS property keys from dash delimited to camel case JavaScript Syntax.
  15439. * For example:
  15440. *
  15441. * - border-width -> borderWidth
  15442. * - padding-top -> paddingTop
  15443. *
  15444. * @static
  15445. * @param {String} prop The property to normalize
  15446. * @return {String} The normalized string
  15447. */
  15448. normalize: function(prop) {
  15449. // TODO: Mobile optimization?
  15450. if (prop == 'float') {
  15451. prop = Ext.supports.Float ? 'cssFloat' : 'styleFloat';
  15452. }
  15453. return this.propertyCache[prop] || (this.propertyCache[prop] = prop.replace(this.camelRe, this.camelReplaceFn));
  15454. },
  15455. /**
  15456. * Retrieves the document height
  15457. * @static
  15458. * @return {Number} documentHeight
  15459. */
  15460. getDocumentHeight: function() {
  15461. return Math.max(!Ext.isStrict ? document.body.scrollHeight : document.documentElement.scrollHeight, this.getViewportHeight());
  15462. },
  15463. /**
  15464. * Retrieves the document width
  15465. * @static
  15466. * @return {Number} documentWidth
  15467. */
  15468. getDocumentWidth: function() {
  15469. return Math.max(!Ext.isStrict ? document.body.scrollWidth : document.documentElement.scrollWidth, this.getViewportWidth());
  15470. },
  15471. /**
  15472. * Retrieves the viewport height of the window.
  15473. * @static
  15474. * @return {Number} viewportHeight
  15475. */
  15476. getViewportHeight: function(){
  15477. return window.innerHeight;
  15478. },
  15479. /**
  15480. * Retrieves the viewport width of the window.
  15481. * @static
  15482. * @return {Number} viewportWidth
  15483. */
  15484. getViewportWidth: function() {
  15485. return window.innerWidth;
  15486. },
  15487. /**
  15488. * Retrieves the viewport size of the window.
  15489. * @static
  15490. * @return {Object} object containing width and height properties
  15491. */
  15492. getViewSize: function() {
  15493. return {
  15494. width: window.innerWidth,
  15495. height: window.innerHeight
  15496. };
  15497. },
  15498. /**
  15499. * Retrieves the current orientation of the window. This is calculated by
  15500. * determing if the height is greater than the width.
  15501. * @static
  15502. * @return {String} Orientation of window: 'portrait' or 'landscape'
  15503. */
  15504. getOrientation: function() {
  15505. if (Ext.supports.OrientationChange) {
  15506. return (window.orientation == 0) ? 'portrait' : 'landscape';
  15507. }
  15508. return (window.innerHeight > window.innerWidth) ? 'portrait' : 'landscape';
  15509. },
  15510. /**
  15511. * Returns the top Element that is located at the passed coordinates
  15512. * @static
  15513. * @param {Number} x The x coordinate
  15514. * @param {Number} y The y coordinate
  15515. * @return {String} The found Element
  15516. */
  15517. fromPoint: function(x, y) {
  15518. return Ext.get(document.elementFromPoint(x, y));
  15519. },
  15520. /**
  15521. * Converts a CSS string into an object with a property for each style.
  15522. *
  15523. * The sample code below would return an object with 2 properties, one
  15524. * for background-color and one for color.
  15525. *
  15526. * var css = 'background-color: red;color: blue; ';
  15527. * console.log(Ext.dom.Element.parseStyles(css));
  15528. *
  15529. * @static
  15530. * @param {String} styles A CSS string
  15531. * @return {Object} styles
  15532. */
  15533. parseStyles: function(styles){
  15534. var out = {},
  15535. cssRe = this.cssRe,
  15536. matches;
  15537. if (styles) {
  15538. // Since we're using the g flag on the regex, we need to set the lastIndex.
  15539. // This automatically happens on some implementations, but not others, see:
  15540. // http://stackoverflow.com/questions/2645273/javascript-regular-expression-literal-persists-between-function-calls
  15541. // http://blog.stevenlevithan.com/archives/fixing-javascript-regexp
  15542. cssRe.lastIndex = 0;
  15543. while ((matches = cssRe.exec(styles))) {
  15544. out[matches[1]] = matches[2];
  15545. }
  15546. }
  15547. return out;
  15548. }
  15549. });
  15550. //TODO Need serious cleanups
  15551. (function(){
  15552. var doc = document,
  15553. AbstractElement = Ext.dom.AbstractElement,
  15554. activeElement = null,
  15555. isCSS1 = doc.compatMode == "CSS1Compat",
  15556. flyInstance,
  15557. fly = function (el) {
  15558. if (!flyInstance) {
  15559. flyInstance = new AbstractElement.Fly();
  15560. }
  15561. flyInstance.attach(el);
  15562. return flyInstance;
  15563. };
  15564. // If the browser does not support document.activeElement we need some assistance.
  15565. // This covers old Safari 3.2 (4.0 added activeElement along with just about all
  15566. // other browsers). We need this support to handle issues with old Safari.
  15567. if (!('activeElement' in doc) && doc.addEventListener) {
  15568. doc.addEventListener('focus',
  15569. function (ev) {
  15570. if (ev && ev.target) {
  15571. activeElement = (ev.target == doc) ? null : ev.target;
  15572. }
  15573. }, true);
  15574. }
  15575. /*
  15576. * Helper function to create the function that will restore the selection.
  15577. */
  15578. function makeSelectionRestoreFn (activeEl, start, end) {
  15579. return function () {
  15580. activeEl.selectionStart = start;
  15581. activeEl.selectionEnd = end;
  15582. };
  15583. }
  15584. AbstractElement.addInheritableStatics({
  15585. /**
  15586. * Returns the active element in the DOM. If the browser supports activeElement
  15587. * on the document, this is returned. If not, the focus is tracked and the active
  15588. * element is maintained internally.
  15589. * @return {HTMLElement} The active (focused) element in the document.
  15590. */
  15591. getActiveElement: function () {
  15592. return doc.activeElement || activeElement;
  15593. },
  15594. /**
  15595. * Creates a function to call to clean up problems with the work-around for the
  15596. * WebKit RightMargin bug. The work-around is to add "display: 'inline-block'" to
  15597. * the element before calling getComputedStyle and then to restore its original
  15598. * display value. The problem with this is that it corrupts the selection of an
  15599. * INPUT or TEXTAREA element (as in the "I-beam" goes away but ths focus remains).
  15600. * To cleanup after this, we need to capture the selection of any such element and
  15601. * then restore it after we have restored the display style.
  15602. *
  15603. * @param {Ext.dom.Element} target The top-most element being adjusted.
  15604. * @private
  15605. */
  15606. getRightMarginFixCleaner: function (target) {
  15607. var supports = Ext.supports,
  15608. hasInputBug = supports.DisplayChangeInputSelectionBug,
  15609. hasTextAreaBug = supports.DisplayChangeTextAreaSelectionBug,
  15610. activeEl,
  15611. tag,
  15612. start,
  15613. end;
  15614. if (hasInputBug || hasTextAreaBug) {
  15615. activeEl = doc.activeElement || activeElement; // save a call
  15616. tag = activeEl && activeEl.tagName;
  15617. if ((hasTextAreaBug && tag == 'TEXTAREA') ||
  15618. (hasInputBug && tag == 'INPUT' && activeEl.type == 'text')) {
  15619. if (Ext.dom.Element.isAncestor(target, activeEl)) {
  15620. start = activeEl.selectionStart;
  15621. end = activeEl.selectionEnd;
  15622. if (Ext.isNumber(start) && Ext.isNumber(end)) { // to be safe...
  15623. // We don't create the raw closure here inline because that
  15624. // will be costly even if we don't want to return it (nested
  15625. // function decls and exprs are often instantiated on entry
  15626. // regardless of whether execution ever reaches them):
  15627. return makeSelectionRestoreFn(activeEl, start, end);
  15628. }
  15629. }
  15630. }
  15631. }
  15632. return Ext.emptyFn; // avoid special cases, just return a nop
  15633. },
  15634. getViewWidth: function(full) {
  15635. return full ? Ext.dom.Element.getDocumentWidth() : Ext.dom.Element.getViewportWidth();
  15636. },
  15637. getViewHeight: function(full) {
  15638. return full ? Ext.dom.Element.getDocumentHeight() : Ext.dom.Element.getViewportHeight();
  15639. },
  15640. getDocumentHeight: function() {
  15641. return Math.max(!isCSS1 ? doc.body.scrollHeight : doc.documentElement.scrollHeight, Ext.dom.Element.getViewportHeight());
  15642. },
  15643. getDocumentWidth: function() {
  15644. return Math.max(!isCSS1 ? doc.body.scrollWidth : doc.documentElement.scrollWidth, Ext.dom.Element.getViewportWidth());
  15645. },
  15646. getViewportHeight: function(){
  15647. return Ext.isIE ?
  15648. (Ext.isStrict ? doc.documentElement.clientHeight : doc.body.clientHeight) :
  15649. self.innerHeight;
  15650. },
  15651. getViewportWidth: function() {
  15652. return (!Ext.isStrict && !Ext.isOpera) ? doc.body.clientWidth :
  15653. Ext.isIE ? doc.documentElement.clientWidth : self.innerWidth;
  15654. },
  15655. getY: function(el) {
  15656. return Ext.dom.Element.getXY(el)[1];
  15657. },
  15658. getX: function(el) {
  15659. return Ext.dom.Element.getXY(el)[0];
  15660. },
  15661. getXY: function(el) {
  15662. var bd = doc.body,
  15663. docEl = doc.documentElement,
  15664. leftBorder = 0,
  15665. topBorder = 0,
  15666. ret = [0,0],
  15667. round = Math.round,
  15668. box,
  15669. scroll;
  15670. el = Ext.getDom(el);
  15671. if(el != doc && el != bd){
  15672. // IE has the potential to throw when getBoundingClientRect called
  15673. // on element not attached to dom
  15674. if (Ext.isIE) {
  15675. try {
  15676. box = el.getBoundingClientRect();
  15677. // In some versions of IE, the documentElement (HTML element) will have a 2px border that gets included, so subtract it off
  15678. topBorder = docEl.clientTop || bd.clientTop;
  15679. leftBorder = docEl.clientLeft || bd.clientLeft;
  15680. } catch (ex) {
  15681. box = { left: 0, top: 0 };
  15682. }
  15683. } else {
  15684. box = el.getBoundingClientRect();
  15685. }
  15686. scroll = fly(document).getScroll();
  15687. ret = [round(box.left + scroll.left - leftBorder), round(box.top + scroll.top - topBorder)];
  15688. }
  15689. return ret;
  15690. },
  15691. setXY: function(el, xy) {
  15692. (el = Ext.fly(el, '_setXY')).position();
  15693. var pts = el.translatePoints(xy),
  15694. style = el.dom.style,
  15695. pos;
  15696. for (pos in pts) {
  15697. if (!isNaN(pts[pos])) {
  15698. style[pos] = pts[pos] + "px";
  15699. }
  15700. }
  15701. },
  15702. setX: function(el, x) {
  15703. Ext.dom.Element.setXY(el, [x, false]);
  15704. },
  15705. setY: function(el, y) {
  15706. Ext.dom.Element.setXY(el, [false, y]);
  15707. },
  15708. /**
  15709. * Serializes a DOM form into a url encoded string
  15710. * @param {Object} form The form
  15711. * @return {String} The url encoded form
  15712. */
  15713. serializeForm: function(form) {
  15714. var fElements = form.elements || (document.forms[form] || Ext.getDom(form)).elements,
  15715. hasSubmit = false,
  15716. encoder = encodeURIComponent,
  15717. data = '',
  15718. eLen = fElements.length,
  15719. element, name, type, options, hasValue, e,
  15720. o, oLen, opt;
  15721. for (e = 0; e < eLen; e++) {
  15722. element = fElements[e];
  15723. name = element.name;
  15724. type = element.type;
  15725. options = element.options;
  15726. if (!element.disabled && name) {
  15727. if (/select-(one|multiple)/i.test(type)) {
  15728. oLen = options.length;
  15729. for (o = 0; o < oLen; o++) {
  15730. opt = options[o];
  15731. if (opt.selected) {
  15732. hasValue = opt.hasAttribute ? opt.hasAttribute('value') : opt.getAttributeNode('value').specified;
  15733. data += Ext.String.format("{0}={1}&", encoder(name), encoder(hasValue ? opt.value : opt.text));
  15734. }
  15735. }
  15736. } else if (!(/file|undefined|reset|button/i.test(type))) {
  15737. if (!(/radio|checkbox/i.test(type) && !element.checked) && !(type == 'submit' && hasSubmit)) {
  15738. data += encoder(name) + '=' + encoder(element.value) + '&';
  15739. hasSubmit = /submit/i.test(type);
  15740. }
  15741. }
  15742. }
  15743. }
  15744. return data.substr(0, data.length - 1);
  15745. }
  15746. });
  15747. }());
  15748. //@tag dom,core
  15749. //@require Ext.dom.AbstractElement-static
  15750. //@define Ext.dom.AbstractElement-alignment
  15751. /**
  15752. * @class Ext.dom.AbstractElement
  15753. */
  15754. Ext.dom.AbstractElement.override({
  15755. /**
  15756. * Gets the x,y coordinates specified by the anchor position on the element.
  15757. * @param {String} [anchor] The specified anchor position (defaults to "c"). See {@link Ext.dom.Element#alignTo}
  15758. * for details on supported anchor positions.
  15759. * @param {Boolean} [local] True to get the local (element top/left-relative) anchor position instead
  15760. * of page coordinates
  15761. * @param {Object} [size] An object containing the size to use for calculating anchor position
  15762. * {width: (target width), height: (target height)} (defaults to the element's current size)
  15763. * @return {Array} [x, y] An array containing the element's x and y coordinates
  15764. */
  15765. getAnchorXY: function(anchor, local, size) {
  15766. //Passing a different size is useful for pre-calculating anchors,
  15767. //especially for anchored animations that change the el size.
  15768. anchor = (anchor || "tl").toLowerCase();
  15769. size = size || {};
  15770. var me = this,
  15771. vp = me.dom == document.body || me.dom == document,
  15772. width = size.width || vp ? window.innerWidth: me.getWidth(),
  15773. height = size.height || vp ? window.innerHeight: me.getHeight(),
  15774. xy,
  15775. rnd = Math.round,
  15776. myXY = me.getXY(),
  15777. extraX = vp ? 0: !local ? myXY[0] : 0,
  15778. extraY = vp ? 0: !local ? myXY[1] : 0,
  15779. hash = {
  15780. c: [rnd(width * 0.5), rnd(height * 0.5)],
  15781. t: [rnd(width * 0.5), 0],
  15782. l: [0, rnd(height * 0.5)],
  15783. r: [width, rnd(height * 0.5)],
  15784. b: [rnd(width * 0.5), height],
  15785. tl: [0, 0],
  15786. bl: [0, height],
  15787. br: [width, height],
  15788. tr: [width, 0]
  15789. };
  15790. xy = hash[anchor];
  15791. return [xy[0] + extraX, xy[1] + extraY];
  15792. },
  15793. alignToRe: /^([a-z]+)-([a-z]+)(\?)?$/,
  15794. /**
  15795. * Gets the x,y coordinates to align this element with another element. See {@link Ext.dom.Element#alignTo} for more info on the
  15796. * supported position values.
  15797. * @param {Ext.Element/HTMLElement/String} element The element to align to.
  15798. * @param {String} [position="tl-bl?"] The position to align to.
  15799. * @param {Array} [offsets=[0,0]] Offset the positioning by [x, y]
  15800. * @return {Array} [x, y]
  15801. */
  15802. getAlignToXY: function(el, position, offsets, local) {
  15803. local = !!local;
  15804. el = Ext.get(el);
  15805. offsets = offsets || [0, 0];
  15806. if (!position || position == '?') {
  15807. position = 'tl-bl?';
  15808. }
  15809. else if (! (/-/).test(position) && position !== "") {
  15810. position = 'tl-' + position;
  15811. }
  15812. position = position.toLowerCase();
  15813. var me = this,
  15814. matches = position.match(this.alignToRe),
  15815. dw = window.innerWidth,
  15816. dh = window.innerHeight,
  15817. p1 = "",
  15818. p2 = "",
  15819. a1,
  15820. a2,
  15821. x,
  15822. y,
  15823. swapX,
  15824. swapY,
  15825. p1x,
  15826. p1y,
  15827. p2x,
  15828. p2y,
  15829. width,
  15830. height,
  15831. region,
  15832. constrain;
  15833. if (!matches) {
  15834. throw "Element.alignTo with an invalid alignment " + position;
  15835. }
  15836. p1 = matches[1];
  15837. p2 = matches[2];
  15838. constrain = !!matches[3];
  15839. //Subtract the aligned el's internal xy from the target's offset xy
  15840. //plus custom offset to get the aligned el's new offset xy
  15841. a1 = me.getAnchorXY(p1, true);
  15842. a2 = el.getAnchorXY(p2, local);
  15843. x = a2[0] - a1[0] + offsets[0];
  15844. y = a2[1] - a1[1] + offsets[1];
  15845. if (constrain) {
  15846. width = me.getWidth();
  15847. height = me.getHeight();
  15848. region = el.getPageBox();
  15849. //If we are at a viewport boundary and the aligned el is anchored on a target border that is
  15850. //perpendicular to the vp border, allow the aligned el to slide on that border,
  15851. //otherwise swap the aligned el to the opposite border of the target.
  15852. p1y = p1.charAt(0);
  15853. p1x = p1.charAt(p1.length - 1);
  15854. p2y = p2.charAt(0);
  15855. p2x = p2.charAt(p2.length - 1);
  15856. swapY = ((p1y == "t" && p2y == "b") || (p1y == "b" && p2y == "t"));
  15857. swapX = ((p1x == "r" && p2x == "l") || (p1x == "l" && p2x == "r"));
  15858. if (x + width > dw) {
  15859. x = swapX ? region.left - width: dw - width;
  15860. }
  15861. if (x < 0) {
  15862. x = swapX ? region.right: 0;
  15863. }
  15864. if (y + height > dh) {
  15865. y = swapY ? region.top - height: dh - height;
  15866. }
  15867. if (y < 0) {
  15868. y = swapY ? region.bottom: 0;
  15869. }
  15870. }
  15871. return [x, y];
  15872. },
  15873. // private
  15874. getAnchor: function(){
  15875. var data = (this.$cache || this.getCache()).data,
  15876. anchor;
  15877. if (!this.dom) {
  15878. return;
  15879. }
  15880. anchor = data._anchor;
  15881. if(!anchor){
  15882. anchor = data._anchor = {};
  15883. }
  15884. return anchor;
  15885. },
  15886. // private ==> used outside of core
  15887. adjustForConstraints: function(xy, parent) {
  15888. var vector = this.getConstrainVector(parent, xy);
  15889. if (vector) {
  15890. xy[0] += vector[0];
  15891. xy[1] += vector[1];
  15892. }
  15893. return xy;
  15894. }
  15895. });
  15896. //@tag dom,core
  15897. //@require Ext.dom.AbstractElement-alignment
  15898. //@define Ext.dom.AbstractElement-insertion
  15899. //@define Ext.dom.AbstractElement
  15900. /**
  15901. * @class Ext.dom.AbstractElement
  15902. */
  15903. Ext.dom.AbstractElement.addMethods({
  15904. /**
  15905. * Appends the passed element(s) to this element
  15906. * @param {String/HTMLElement/Ext.dom.AbstractElement} el
  15907. * The id of the node, a DOM Node or an existing Element.
  15908. * @return {Ext.dom.AbstractElement} This element
  15909. */
  15910. appendChild: function(el) {
  15911. return Ext.get(el).appendTo(this);
  15912. },
  15913. /**
  15914. * Appends this element to the passed element
  15915. * @param {String/HTMLElement/Ext.dom.AbstractElement} el The new parent element.
  15916. * The id of the node, a DOM Node or an existing Element.
  15917. * @return {Ext.dom.AbstractElement} This element
  15918. */
  15919. appendTo: function(el) {
  15920. Ext.getDom(el).appendChild(this.dom);
  15921. return this;
  15922. },
  15923. /**
  15924. * Inserts this element before the passed element in the DOM
  15925. * @param {String/HTMLElement/Ext.dom.AbstractElement} el The element before which this element will be inserted.
  15926. * The id of the node, a DOM Node or an existing Element.
  15927. * @return {Ext.dom.AbstractElement} This element
  15928. */
  15929. insertBefore: function(el) {
  15930. el = Ext.getDom(el);
  15931. el.parentNode.insertBefore(this.dom, el);
  15932. return this;
  15933. },
  15934. /**
  15935. * Inserts this element after the passed element in the DOM
  15936. * @param {String/HTMLElement/Ext.dom.AbstractElement} el The element to insert after.
  15937. * The id of the node, a DOM Node or an existing Element.
  15938. * @return {Ext.dom.AbstractElement} This element
  15939. */
  15940. insertAfter: function(el) {
  15941. el = Ext.getDom(el);
  15942. el.parentNode.insertBefore(this.dom, el.nextSibling);
  15943. return this;
  15944. },
  15945. /**
  15946. * Inserts (or creates) an element (or DomHelper config) as the first child of this element
  15947. * @param {String/HTMLElement/Ext.dom.AbstractElement/Object} el The id or element to insert or a DomHelper config
  15948. * to create and insert
  15949. * @return {Ext.dom.AbstractElement} The new child
  15950. */
  15951. insertFirst: function(el, returnDom) {
  15952. el = el || {};
  15953. if (el.nodeType || el.dom || typeof el == 'string') { // element
  15954. el = Ext.getDom(el);
  15955. this.dom.insertBefore(el, this.dom.firstChild);
  15956. return !returnDom ? Ext.get(el) : el;
  15957. }
  15958. else { // dh config
  15959. return this.createChild(el, this.dom.firstChild, returnDom);
  15960. }
  15961. },
  15962. /**
  15963. * Inserts (or creates) the passed element (or DomHelper config) as a sibling of this element
  15964. * @param {String/HTMLElement/Ext.dom.AbstractElement/Object/Array} el The id, element to insert or a DomHelper config
  15965. * to create and insert *or* an array of any of those.
  15966. * @param {String} [where='before'] 'before' or 'after'
  15967. * @param {Boolean} [returnDom=false] True to return the .;ll;l,raw DOM element instead of Ext.dom.AbstractElement
  15968. * @return {Ext.dom.AbstractElement} The inserted Element. If an array is passed, the last inserted element is returned.
  15969. */
  15970. insertSibling: function(el, where, returnDom){
  15971. var me = this,
  15972. isAfter = (where || 'before').toLowerCase() == 'after',
  15973. rt, insertEl, eLen, e;
  15974. if (Ext.isArray(el)) {
  15975. insertEl = me;
  15976. eLen = el.length;
  15977. for (e = 0; e < eLen; e++) {
  15978. rt = Ext.fly(insertEl, '_internal').insertSibling(el[e], where, returnDom);
  15979. if (isAfter) {
  15980. insertEl = rt;
  15981. }
  15982. }
  15983. return rt;
  15984. }
  15985. el = el || {};
  15986. if(el.nodeType || el.dom){
  15987. rt = me.dom.parentNode.insertBefore(Ext.getDom(el), isAfter ? me.dom.nextSibling : me.dom);
  15988. if (!returnDom) {
  15989. rt = Ext.get(rt);
  15990. }
  15991. }else{
  15992. if (isAfter && !me.dom.nextSibling) {
  15993. rt = Ext.core.DomHelper.append(me.dom.parentNode, el, !returnDom);
  15994. } else {
  15995. rt = Ext.core.DomHelper[isAfter ? 'insertAfter' : 'insertBefore'](me.dom, el, !returnDom);
  15996. }
  15997. }
  15998. return rt;
  15999. },
  16000. /**
  16001. * Replaces the passed element with this element
  16002. * @param {String/HTMLElement/Ext.dom.AbstractElement} el The element to replace.
  16003. * The id of the node, a DOM Node or an existing Element.
  16004. * @return {Ext.dom.AbstractElement} This element
  16005. */
  16006. replace: function(el) {
  16007. el = Ext.get(el);
  16008. this.insertBefore(el);
  16009. el.remove();
  16010. return this;
  16011. },
  16012. /**
  16013. * Replaces this element with the passed element
  16014. * @param {String/HTMLElement/Ext.dom.AbstractElement/Object} el The new element (id of the node, a DOM Node
  16015. * or an existing Element) or a DomHelper config of an element to create
  16016. * @return {Ext.dom.AbstractElement} This element
  16017. */
  16018. replaceWith: function(el){
  16019. var me = this;
  16020. if(el.nodeType || el.dom || typeof el == 'string'){
  16021. el = Ext.get(el);
  16022. me.dom.parentNode.insertBefore(el, me.dom);
  16023. }else{
  16024. el = Ext.core.DomHelper.insertBefore(me.dom, el);
  16025. }
  16026. delete Ext.cache[me.id];
  16027. Ext.removeNode(me.dom);
  16028. me.id = Ext.id(me.dom = el);
  16029. Ext.dom.AbstractElement.addToCache(me.isFlyweight ? new Ext.dom.AbstractElement(me.dom) : me);
  16030. return me;
  16031. },
  16032. /**
  16033. * Creates the passed DomHelper config and appends it to this element or optionally inserts it before the passed child element.
  16034. * @param {Object} config DomHelper element config object. If no tag is specified (e.g., {tag:'input'}) then a div will be
  16035. * automatically generated with the specified attributes.
  16036. * @param {HTMLElement} [insertBefore] a child element of this element
  16037. * @param {Boolean} [returnDom=false] true to return the dom node instead of creating an Element
  16038. * @return {Ext.dom.AbstractElement} The new child element
  16039. */
  16040. createChild: function(config, insertBefore, returnDom) {
  16041. config = config || {tag:'div'};
  16042. if (insertBefore) {
  16043. return Ext.core.DomHelper.insertBefore(insertBefore, config, returnDom !== true);
  16044. }
  16045. else {
  16046. return Ext.core.DomHelper[!this.dom.firstChild ? 'insertFirst' : 'append'](this.dom, config, returnDom !== true);
  16047. }
  16048. },
  16049. /**
  16050. * Creates and wraps this element with another element
  16051. * @param {Object} [config] DomHelper element config object for the wrapper element or null for an empty div
  16052. * @param {Boolean} [returnDom=false] True to return the raw DOM element instead of Ext.dom.AbstractElement
  16053. * @param {String} [selector] A {@link Ext.dom.Query DomQuery} selector to select a descendant node within the created element to use as the wrapping element.
  16054. * @return {HTMLElement/Ext.dom.AbstractElement} The newly created wrapper element
  16055. */
  16056. wrap: function(config, returnDom, selector) {
  16057. var newEl = Ext.core.DomHelper.insertBefore(this.dom, config || {tag: "div"}, true),
  16058. target = newEl;
  16059. if (selector) {
  16060. target = Ext.DomQuery.selectNode(selector, newEl.dom);
  16061. }
  16062. target.appendChild(this.dom);
  16063. return returnDom ? newEl.dom : newEl;
  16064. },
  16065. /**
  16066. * Inserts an html fragment into this element
  16067. * @param {String} where Where to insert the html in relation to this element - beforeBegin, afterBegin, beforeEnd, afterEnd.
  16068. * See {@link Ext.dom.Helper#insertHtml} for details.
  16069. * @param {String} html The HTML fragment
  16070. * @param {Boolean} [returnEl=false] True to return an Ext.dom.AbstractElement
  16071. * @return {HTMLElement/Ext.dom.AbstractElement} The inserted node (or nearest related if more than 1 inserted)
  16072. */
  16073. insertHtml: function(where, html, returnEl) {
  16074. var el = Ext.core.DomHelper.insertHtml(where, this.dom, html);
  16075. return returnEl ? Ext.get(el) : el;
  16076. }
  16077. });
  16078. //@tag dom,core
  16079. //@require Ext.dom.AbstractElement-insertion
  16080. //@define Ext.dom.AbstractElement-position
  16081. //@define Ext.dom.AbstractElement
  16082. /**
  16083. * @class Ext.dom.AbstractElement
  16084. */
  16085. (function(){
  16086. var Element = Ext.dom.AbstractElement;
  16087. Element.override({
  16088. /**
  16089. * Gets the current X position of the element based on page coordinates. Element must be part of the DOM
  16090. * tree to have page coordinates (display:none or elements not appended return false).
  16091. * @return {Number} The X position of the element
  16092. */
  16093. getX: function(el) {
  16094. return this.getXY(el)[0];
  16095. },
  16096. /**
  16097. * Gets the current Y position of the element based on page coordinates. Element must be part of the DOM
  16098. * tree to have page coordinates (display:none or elements not appended return false).
  16099. * @return {Number} The Y position of the element
  16100. */
  16101. getY: function(el) {
  16102. return this.getXY(el)[1];
  16103. },
  16104. /**
  16105. * Gets the current position of the element based on page coordinates. Element must be part of the DOM
  16106. * tree to have page coordinates (display:none or elements not appended return false).
  16107. * @return {Array} The XY position of the element
  16108. */
  16109. getXY: function() {
  16110. // @FEATUREDETECT
  16111. var point = window.webkitConvertPointFromNodeToPage(this.dom, new WebKitPoint(0, 0));
  16112. return [point.x, point.y];
  16113. },
  16114. /**
  16115. * Returns the offsets of this element from the passed element. Both element must be part of the DOM
  16116. * tree and not have display:none to have page coordinates.
  16117. * @param {Ext.Element/HTMLElement/String} element The element to get the offsets from.
  16118. * @return {Array} The XY page offsets (e.g. [100, -200])
  16119. */
  16120. getOffsetsTo: function(el){
  16121. var o = this.getXY(),
  16122. e = Ext.fly(el, '_internal').getXY();
  16123. return [o[0]-e[0],o[1]-e[1]];
  16124. },
  16125. /**
  16126. * Sets the X position of the element based on page coordinates. Element must be part of the DOM tree
  16127. * to have page coordinates (display:none or elements not appended return false).
  16128. * @param {Number} The X position of the element
  16129. * @param {Boolean/Object} [animate] True for the default animation, or a standard Element
  16130. * animation config object
  16131. * @return {Ext.dom.AbstractElement} this
  16132. */
  16133. setX: function(x){
  16134. return this.setXY([x, this.getY()]);
  16135. },
  16136. /**
  16137. * Sets the Y position of the element based on page coordinates. Element must be part of the DOM tree
  16138. * to have page coordinates (display:none or elements not appended return false).
  16139. * @param {Number} The Y position of the element
  16140. * @param {Boolean/Object} [animate] True for the default animation, or a standard Element
  16141. * animation config object
  16142. * @return {Ext.dom.AbstractElement} this
  16143. */
  16144. setY: function(y) {
  16145. return this.setXY([this.getX(), y]);
  16146. },
  16147. /**
  16148. * Sets the element's left position directly using CSS style (instead of {@link #setX}).
  16149. * @param {String} left The left CSS property value
  16150. * @return {Ext.dom.AbstractElement} this
  16151. */
  16152. setLeft: function(left) {
  16153. this.setStyle('left', Element.addUnits(left));
  16154. return this;
  16155. },
  16156. /**
  16157. * Sets the element's top position directly using CSS style (instead of {@link #setY}).
  16158. * @param {String} top The top CSS property value
  16159. * @return {Ext.dom.AbstractElement} this
  16160. */
  16161. setTop: function(top) {
  16162. this.setStyle('top', Element.addUnits(top));
  16163. return this;
  16164. },
  16165. /**
  16166. * Sets the element's CSS right style.
  16167. * @param {String} right The right CSS property value
  16168. * @return {Ext.dom.AbstractElement} this
  16169. */
  16170. setRight: function(right) {
  16171. this.setStyle('right', Element.addUnits(right));
  16172. return this;
  16173. },
  16174. /**
  16175. * Sets the element's CSS bottom style.
  16176. * @param {String} bottom The bottom CSS property value
  16177. * @return {Ext.dom.AbstractElement} this
  16178. */
  16179. setBottom: function(bottom) {
  16180. this.setStyle('bottom', Element.addUnits(bottom));
  16181. return this;
  16182. },
  16183. /**
  16184. * Sets the position of the element in page coordinates, regardless of how the element is positioned.
  16185. * The element must be part of the DOM tree to have page coordinates (display:none or elements not appended return false).
  16186. * @param {Array} pos Contains X & Y [x, y] values for new position (coordinates are page-based)
  16187. * @param {Boolean/Object} [animate] True for the default animation, or a standard Element animation config object
  16188. * @return {Ext.dom.AbstractElement} this
  16189. */
  16190. setXY: function(pos) {
  16191. var me = this,
  16192. pts,
  16193. style,
  16194. pt;
  16195. if (arguments.length > 1) {
  16196. pos = [pos, arguments[1]];
  16197. }
  16198. // me.position();
  16199. pts = me.translatePoints(pos);
  16200. style = me.dom.style;
  16201. for (pt in pts) {
  16202. if (!pts.hasOwnProperty(pt)) {
  16203. continue;
  16204. }
  16205. if (!isNaN(pts[pt])) {
  16206. style[pt] = pts[pt] + "px";
  16207. }
  16208. }
  16209. return me;
  16210. },
  16211. /**
  16212. * Gets the left X coordinate
  16213. * @param {Boolean} local True to get the local css position instead of page coordinate
  16214. * @return {Number}
  16215. */
  16216. getLeft: function(local) {
  16217. return parseInt(this.getStyle('left'), 10) || 0;
  16218. },
  16219. /**
  16220. * Gets the right X coordinate of the element (element X position + element width)
  16221. * @param {Boolean} local True to get the local css position instead of page coordinate
  16222. * @return {Number}
  16223. */
  16224. getRight: function(local) {
  16225. return parseInt(this.getStyle('right'), 10) || 0;
  16226. },
  16227. /**
  16228. * Gets the top Y coordinate
  16229. * @param {Boolean} local True to get the local css position instead of page coordinate
  16230. * @return {Number}
  16231. */
  16232. getTop: function(local) {
  16233. return parseInt(this.getStyle('top'), 10) || 0;
  16234. },
  16235. /**
  16236. * Gets the bottom Y coordinate of the element (element Y position + element height)
  16237. * @param {Boolean} local True to get the local css position instead of page coordinate
  16238. * @return {Number}
  16239. */
  16240. getBottom: function(local) {
  16241. return parseInt(this.getStyle('bottom'), 10) || 0;
  16242. },
  16243. /**
  16244. * Translates the passed page coordinates into left/top css values for this element
  16245. * @param {Number/Array} x The page x or an array containing [x, y]
  16246. * @param {Number} [y] The page y, required if x is not an array
  16247. * @return {Object} An object with left and top properties. e.g. {left: (value), top: (value)}
  16248. */
  16249. translatePoints: function(x, y) {
  16250. y = isNaN(x[1]) ? y : x[1];
  16251. x = isNaN(x[0]) ? x : x[0];
  16252. var me = this,
  16253. relative = me.isStyle('position', 'relative'),
  16254. o = me.getXY(),
  16255. l = parseInt(me.getStyle('left'), 10),
  16256. t = parseInt(me.getStyle('top'), 10);
  16257. l = !isNaN(l) ? l : (relative ? 0 : me.dom.offsetLeft);
  16258. t = !isNaN(t) ? t : (relative ? 0 : me.dom.offsetTop);
  16259. return {left: (x - o[0] + l), top: (y - o[1] + t)};
  16260. },
  16261. /**
  16262. * Sets the element's box. Use getBox() on another element to get a box obj.
  16263. * If animate is true then width, height, x and y will be animated concurrently.
  16264. * @param {Object} box The box to fill {x, y, width, height}
  16265. * @param {Boolean} [adjust] Whether to adjust for box-model issues automatically
  16266. * @param {Boolean/Object} [animate] true for the default animation or a standard
  16267. * Element animation config object
  16268. * @return {Ext.dom.AbstractElement} this
  16269. */
  16270. setBox: function(box) {
  16271. var me = this,
  16272. width = box.width,
  16273. height = box.height,
  16274. top = box.top,
  16275. left = box.left;
  16276. if (left !== undefined) {
  16277. me.setLeft(left);
  16278. }
  16279. if (top !== undefined) {
  16280. me.setTop(top);
  16281. }
  16282. if (width !== undefined) {
  16283. me.setWidth(width);
  16284. }
  16285. if (height !== undefined) {
  16286. me.setHeight(height);
  16287. }
  16288. return this;
  16289. },
  16290. /**
  16291. * Return an object defining the area of this Element which can be passed to {@link #setBox} to
  16292. * set another Element's size/location to match this element.
  16293. *
  16294. * @param {Boolean} [contentBox] If true a box for the content of the element is returned.
  16295. * @param {Boolean} [local] If true the element's left and top are returned instead of page x/y.
  16296. * @return {Object} box An object in the format:
  16297. *
  16298. * {
  16299. * x: <Element's X position>,
  16300. * y: <Element's Y position>,
  16301. * width: <Element's width>,
  16302. * height: <Element's height>,
  16303. * bottom: <Element's lower bound>,
  16304. * right: <Element's rightmost bound>
  16305. * }
  16306. *
  16307. * The returned object may also be addressed as an Array where index 0 contains the X position
  16308. * and index 1 contains the Y position. So the result may also be used for {@link #setXY}
  16309. */
  16310. getBox: function(contentBox, local) {
  16311. var me = this,
  16312. dom = me.dom,
  16313. width = dom.offsetWidth,
  16314. height = dom.offsetHeight,
  16315. xy, box, l, r, t, b;
  16316. if (!local) {
  16317. xy = me.getXY();
  16318. }
  16319. else if (contentBox) {
  16320. xy = [0,0];
  16321. }
  16322. else {
  16323. xy = [parseInt(me.getStyle("left"), 10) || 0, parseInt(me.getStyle("top"), 10) || 0];
  16324. }
  16325. if (!contentBox) {
  16326. box = {
  16327. x: xy[0],
  16328. y: xy[1],
  16329. 0: xy[0],
  16330. 1: xy[1],
  16331. width: width,
  16332. height: height
  16333. };
  16334. }
  16335. else {
  16336. l = me.getBorderWidth.call(me, "l") + me.getPadding.call(me, "l");
  16337. r = me.getBorderWidth.call(me, "r") + me.getPadding.call(me, "r");
  16338. t = me.getBorderWidth.call(me, "t") + me.getPadding.call(me, "t");
  16339. b = me.getBorderWidth.call(me, "b") + me.getPadding.call(me, "b");
  16340. box = {
  16341. x: xy[0] + l,
  16342. y: xy[1] + t,
  16343. 0: xy[0] + l,
  16344. 1: xy[1] + t,
  16345. width: width - (l + r),
  16346. height: height - (t + b)
  16347. };
  16348. }
  16349. box.left = box.x;
  16350. box.top = box.y;
  16351. box.right = box.x + box.width;
  16352. box.bottom = box.y + box.height;
  16353. return box;
  16354. },
  16355. /**
  16356. * Return an object defining the area of this Element which can be passed to {@link #setBox} to
  16357. * set another Element's size/location to match this element.
  16358. *
  16359. * @param {Boolean} [asRegion] If true an Ext.util.Region will be returned
  16360. * @return {Object} box An object in the format
  16361. *
  16362. * {
  16363. * left: <Element's X position>,
  16364. * top: <Element's Y position>,
  16365. * width: <Element's width>,
  16366. * height: <Element's height>,
  16367. * bottom: <Element's lower bound>,
  16368. * right: <Element's rightmost bound>
  16369. * }
  16370. *
  16371. * The returned object may also be addressed as an Array where index 0 contains the X position
  16372. * and index 1 contains the Y position. So the result may also be used for {@link #setXY}
  16373. */
  16374. getPageBox: function(getRegion) {
  16375. var me = this,
  16376. el = me.dom,
  16377. w = el.offsetWidth,
  16378. h = el.offsetHeight,
  16379. xy = me.getXY(),
  16380. t = xy[1],
  16381. r = xy[0] + w,
  16382. b = xy[1] + h,
  16383. l = xy[0];
  16384. if (!el) {
  16385. return new Ext.util.Region();
  16386. }
  16387. if (getRegion) {
  16388. return new Ext.util.Region(t, r, b, l);
  16389. }
  16390. else {
  16391. return {
  16392. left: l,
  16393. top: t,
  16394. width: w,
  16395. height: h,
  16396. right: r,
  16397. bottom: b
  16398. };
  16399. }
  16400. }
  16401. });
  16402. }());
  16403. //@tag dom,core
  16404. //@require Ext.dom.AbstractElement-position
  16405. //@define Ext.dom.AbstractElement-style
  16406. //@define Ext.dom.AbstractElement
  16407. /**
  16408. * @class Ext.dom.AbstractElement
  16409. */
  16410. (function(){
  16411. // local style camelizing for speed
  16412. var Element = Ext.dom.AbstractElement,
  16413. view = document.defaultView,
  16414. array = Ext.Array,
  16415. trimRe = /^\s+|\s+$/g,
  16416. wordsRe = /\w/g,
  16417. spacesRe = /\s+/,
  16418. transparentRe = /^(?:transparent|(?:rgba[(](?:\s*\d+\s*[,]){3}\s*0\s*[)]))$/i,
  16419. hasClassList = Ext.supports.ClassList,
  16420. PADDING = 'padding',
  16421. MARGIN = 'margin',
  16422. BORDER = 'border',
  16423. LEFT_SUFFIX = '-left',
  16424. RIGHT_SUFFIX = '-right',
  16425. TOP_SUFFIX = '-top',
  16426. BOTTOM_SUFFIX = '-bottom',
  16427. WIDTH = '-width',
  16428. // special markup used throughout Ext when box wrapping elements
  16429. borders = {l: BORDER + LEFT_SUFFIX + WIDTH, r: BORDER + RIGHT_SUFFIX + WIDTH, t: BORDER + TOP_SUFFIX + WIDTH, b: BORDER + BOTTOM_SUFFIX + WIDTH},
  16430. paddings = {l: PADDING + LEFT_SUFFIX, r: PADDING + RIGHT_SUFFIX, t: PADDING + TOP_SUFFIX, b: PADDING + BOTTOM_SUFFIX},
  16431. margins = {l: MARGIN + LEFT_SUFFIX, r: MARGIN + RIGHT_SUFFIX, t: MARGIN + TOP_SUFFIX, b: MARGIN + BOTTOM_SUFFIX};
  16432. Element.override({
  16433. /**
  16434. * This shared object is keyed by style name (e.g., 'margin-left' or 'marginLeft'). The
  16435. * values are objects with the following properties:
  16436. *
  16437. * * `name` (String) : The actual name to be presented to the DOM. This is typically the value
  16438. * returned by {@link #normalize}.
  16439. * * `get` (Function) : A hook function that will perform the get on this style. These
  16440. * functions receive "(dom, el)" arguments. The `dom` parameter is the DOM Element
  16441. * from which to get ths tyle. The `el` argument (may be null) is the Ext.Element.
  16442. * * `set` (Function) : A hook function that will perform the set on this style. These
  16443. * functions receive "(dom, value, el)" arguments. The `dom` parameter is the DOM Element
  16444. * from which to get ths tyle. The `value` parameter is the new value for the style. The
  16445. * `el` argument (may be null) is the Ext.Element.
  16446. *
  16447. * The `this` pointer is the object that contains `get` or `set`, which means that
  16448. * `this.name` can be accessed if needed. The hook functions are both optional.
  16449. * @private
  16450. */
  16451. styleHooks: {},
  16452. // private
  16453. addStyles : function(sides, styles){
  16454. var totalSize = 0,
  16455. sidesArr = (sides || '').match(wordsRe),
  16456. i,
  16457. len = sidesArr.length,
  16458. side,
  16459. styleSides = [];
  16460. if (len == 1) {
  16461. totalSize = Math.abs(parseFloat(this.getStyle(styles[sidesArr[0]])) || 0);
  16462. } else if (len) {
  16463. for (i = 0; i < len; i++) {
  16464. side = sidesArr[i];
  16465. styleSides.push(styles[side]);
  16466. }
  16467. //Gather all at once, returning a hash
  16468. styleSides = this.getStyle(styleSides);
  16469. for (i=0; i < len; i++) {
  16470. side = sidesArr[i];
  16471. totalSize += Math.abs(parseFloat(styleSides[styles[side]]) || 0);
  16472. }
  16473. }
  16474. return totalSize;
  16475. },
  16476. /**
  16477. * Adds one or more CSS classes to the element. Duplicate classes are automatically filtered out.
  16478. * @param {String/String[]} className The CSS classes to add separated by space, or an array of classes
  16479. * @return {Ext.dom.Element} this
  16480. * @method
  16481. */
  16482. addCls: hasClassList ?
  16483. function (className) {
  16484. var me = this,
  16485. dom = me.dom,
  16486. classList,
  16487. newCls,
  16488. i,
  16489. len,
  16490. cls;
  16491. if (typeof(className) == 'string') {
  16492. // split string on spaces to make an array of className
  16493. className = className.replace(trimRe, '').split(spacesRe);
  16494. }
  16495. // the gain we have here is that we can skip parsing className and use the
  16496. // classList.contains method, so now O(M) not O(M+N)
  16497. if (dom && className && !!(len = className.length)) {
  16498. if (!dom.className) {
  16499. dom.className = className.join(' ');
  16500. } else {
  16501. classList = dom.classList;
  16502. for (i = 0; i < len; ++i) {
  16503. cls = className[i];
  16504. if (cls) {
  16505. if (!classList.contains(cls)) {
  16506. if (newCls) {
  16507. newCls.push(cls);
  16508. } else {
  16509. newCls = dom.className.replace(trimRe, '');
  16510. newCls = newCls ? [newCls, cls] : [cls];
  16511. }
  16512. }
  16513. }
  16514. }
  16515. if (newCls) {
  16516. dom.className = newCls.join(' '); // write to DOM once
  16517. }
  16518. }
  16519. }
  16520. return me;
  16521. } :
  16522. function(className) {
  16523. var me = this,
  16524. dom = me.dom,
  16525. changed,
  16526. elClasses;
  16527. if (dom && className && className.length) {
  16528. elClasses = Ext.Element.mergeClsList(dom.className, className);
  16529. if (elClasses.changed) {
  16530. dom.className = elClasses.join(' '); // write to DOM once
  16531. }
  16532. }
  16533. return me;
  16534. },
  16535. /**
  16536. * Removes one or more CSS classes from the element.
  16537. * @param {String/String[]} className The CSS classes to remove separated by space, or an array of classes
  16538. * @return {Ext.dom.Element} this
  16539. */
  16540. removeCls: function(className) {
  16541. var me = this,
  16542. dom = me.dom,
  16543. len,
  16544. elClasses;
  16545. if (typeof(className) == 'string') {
  16546. // split string on spaces to make an array of className
  16547. className = className.replace(trimRe, '').split(spacesRe);
  16548. }
  16549. if (dom && dom.className && className && !!(len = className.length)) {
  16550. if (len == 1 && hasClassList) {
  16551. if (className[0]) {
  16552. dom.classList.remove(className[0]); // one DOM write
  16553. }
  16554. } else {
  16555. elClasses = Ext.Element.removeCls(dom.className, className);
  16556. if (elClasses.changed) {
  16557. dom.className = elClasses.join(' ');
  16558. }
  16559. }
  16560. }
  16561. return me;
  16562. },
  16563. /**
  16564. * Adds one or more CSS classes to this element and removes the same class(es) from all siblings.
  16565. * @param {String/String[]} className The CSS class to add, or an array of classes
  16566. * @return {Ext.dom.Element} this
  16567. */
  16568. radioCls: function(className) {
  16569. var cn = this.dom.parentNode.childNodes,
  16570. v,
  16571. i, len;
  16572. className = Ext.isArray(className) ? className: [className];
  16573. for (i = 0, len = cn.length; i < len; i++) {
  16574. v = cn[i];
  16575. if (v && v.nodeType == 1) {
  16576. Ext.fly(v, '_internal').removeCls(className);
  16577. }
  16578. }
  16579. return this.addCls(className);
  16580. },
  16581. /**
  16582. * Toggles the specified CSS class on this element (removes it if it already exists, otherwise adds it).
  16583. * @param {String} className The CSS class to toggle
  16584. * @return {Ext.dom.Element} this
  16585. * @method
  16586. */
  16587. toggleCls: hasClassList ?
  16588. function (className) {
  16589. var me = this,
  16590. dom = me.dom;
  16591. if (dom) {
  16592. className = className.replace(trimRe, '');
  16593. if (className) {
  16594. dom.classList.toggle(className);
  16595. }
  16596. }
  16597. return me;
  16598. } :
  16599. function(className) {
  16600. var me = this;
  16601. return me.hasCls(className) ? me.removeCls(className) : me.addCls(className);
  16602. },
  16603. /**
  16604. * Checks if the specified CSS class exists on this element's DOM node.
  16605. * @param {String} className The CSS class to check for
  16606. * @return {Boolean} True if the class exists, else false
  16607. * @method
  16608. */
  16609. hasCls: hasClassList ?
  16610. function (className) {
  16611. var dom = this.dom;
  16612. return (dom && className) ? dom.classList.contains(className) : false;
  16613. } :
  16614. function(className) {
  16615. var dom = this.dom;
  16616. return dom ? className && (' '+dom.className+' ').indexOf(' '+className+' ') != -1 : false;
  16617. },
  16618. /**
  16619. * Replaces a CSS class on the element with another. If the old name does not exist, the new name will simply be added.
  16620. * @param {String} oldClassName The CSS class to replace
  16621. * @param {String} newClassName The replacement CSS class
  16622. * @return {Ext.dom.Element} this
  16623. */
  16624. replaceCls: function(oldClassName, newClassName){
  16625. return this.removeCls(oldClassName).addCls(newClassName);
  16626. },
  16627. /**
  16628. * Checks if the current value of a style is equal to a given value.
  16629. * @param {String} style property whose value is returned.
  16630. * @param {String} value to check against.
  16631. * @return {Boolean} true for when the current value equals the given value.
  16632. */
  16633. isStyle: function(style, val) {
  16634. return this.getStyle(style) == val;
  16635. },
  16636. /**
  16637. * Returns a named style property based on computed/currentStyle (primary) and
  16638. * inline-style if primary is not available.
  16639. *
  16640. * @param {String/String[]} property The style property (or multiple property names
  16641. * in an array) whose value is returned.
  16642. * @param {Boolean} [inline=false] if `true` only inline styles will be returned.
  16643. * @return {String/Object} The current value of the style property for this element
  16644. * (or a hash of named style values if multiple property arguments are requested).
  16645. * @method
  16646. */
  16647. getStyle: function (property, inline) {
  16648. var me = this,
  16649. dom = me.dom,
  16650. multiple = typeof property != 'string',
  16651. hooks = me.styleHooks,
  16652. prop = property,
  16653. props = prop,
  16654. len = 1,
  16655. domStyle, camel, values, hook, out, style, i;
  16656. if (multiple) {
  16657. values = {};
  16658. prop = props[0];
  16659. i = 0;
  16660. if (!(len = props.length)) {
  16661. return values;
  16662. }
  16663. }
  16664. if (!dom || dom.documentElement) {
  16665. return values || '';
  16666. }
  16667. domStyle = dom.style;
  16668. if (inline) {
  16669. style = domStyle;
  16670. } else {
  16671. // Caution: Firefox will not render "presentation" (ie. computed styles) in
  16672. // iframes that are display:none or those inheriting display:none. Similar
  16673. // issues with legacy Safari.
  16674. //
  16675. style = dom.ownerDocument.defaultView.getComputedStyle(dom, null);
  16676. // fallback to inline style if rendering context not available
  16677. if (!style) {
  16678. inline = true;
  16679. style = domStyle;
  16680. }
  16681. }
  16682. do {
  16683. hook = hooks[prop];
  16684. if (!hook) {
  16685. hooks[prop] = hook = { name: Element.normalize(prop) };
  16686. }
  16687. if (hook.get) {
  16688. out = hook.get(dom, me, inline, style);
  16689. } else {
  16690. camel = hook.name;
  16691. out = style[camel];
  16692. }
  16693. if (!multiple) {
  16694. return out;
  16695. }
  16696. values[prop] = out;
  16697. prop = props[++i];
  16698. } while (i < len);
  16699. return values;
  16700. },
  16701. getStyles: function () {
  16702. var props = Ext.Array.slice(arguments),
  16703. len = props.length,
  16704. inline;
  16705. if (len && typeof props[len-1] == 'boolean') {
  16706. inline = props.pop();
  16707. }
  16708. return this.getStyle(props, inline);
  16709. },
  16710. /**
  16711. * Returns true if the value of the given property is visually transparent. This
  16712. * may be due to a 'transparent' style value or an rgba value with 0 in the alpha
  16713. * component.
  16714. * @param {String} prop The style property whose value is to be tested.
  16715. * @return {Boolean} True if the style property is visually transparent.
  16716. */
  16717. isTransparent: function (prop) {
  16718. var value = this.getStyle(prop);
  16719. return value ? transparentRe.test(value) : false;
  16720. },
  16721. /**
  16722. * Wrapper for setting style properties, also takes single object parameter of multiple styles.
  16723. * @param {String/Object} property The style property to be set, or an object of multiple styles.
  16724. * @param {String} [value] The value to apply to the given property, or null if an object was passed.
  16725. * @return {Ext.dom.Element} this
  16726. */
  16727. setStyle: function(prop, value) {
  16728. var me = this,
  16729. dom = me.dom,
  16730. hooks = me.styleHooks,
  16731. style = dom.style,
  16732. name = prop,
  16733. hook;
  16734. // we don't promote the 2-arg form to object-form to avoid the overhead...
  16735. if (typeof name == 'string') {
  16736. hook = hooks[name];
  16737. if (!hook) {
  16738. hooks[name] = hook = { name: Element.normalize(name) };
  16739. }
  16740. value = (value == null) ? '' : value;
  16741. if (hook.set) {
  16742. hook.set(dom, value, me);
  16743. } else {
  16744. style[hook.name] = value;
  16745. }
  16746. if (hook.afterSet) {
  16747. hook.afterSet(dom, value, me);
  16748. }
  16749. } else {
  16750. for (name in prop) {
  16751. if (prop.hasOwnProperty(name)) {
  16752. hook = hooks[name];
  16753. if (!hook) {
  16754. hooks[name] = hook = { name: Element.normalize(name) };
  16755. }
  16756. value = prop[name];
  16757. value = (value == null) ? '' : value;
  16758. if (hook.set) {
  16759. hook.set(dom, value, me);
  16760. } else {
  16761. style[hook.name] = value;
  16762. }
  16763. if (hook.afterSet) {
  16764. hook.afterSet(dom, value, me);
  16765. }
  16766. }
  16767. }
  16768. }
  16769. return me;
  16770. },
  16771. /**
  16772. * Returns the offset height of the element
  16773. * @param {Boolean} [contentHeight] true to get the height minus borders and padding
  16774. * @return {Number} The element's height
  16775. */
  16776. getHeight: function(contentHeight) {
  16777. var dom = this.dom,
  16778. height = contentHeight ? (dom.clientHeight - this.getPadding("tb")) : dom.offsetHeight;
  16779. return height > 0 ? height: 0;
  16780. },
  16781. /**
  16782. * Returns the offset width of the element
  16783. * @param {Boolean} [contentWidth] true to get the width minus borders and padding
  16784. * @return {Number} The element's width
  16785. */
  16786. getWidth: function(contentWidth) {
  16787. var dom = this.dom,
  16788. width = contentWidth ? (dom.clientWidth - this.getPadding("lr")) : dom.offsetWidth;
  16789. return width > 0 ? width: 0;
  16790. },
  16791. /**
  16792. * Set the width of this Element.
  16793. * @param {Number/String} width The new width. This may be one of:
  16794. *
  16795. * - A Number specifying the new width in this Element's {@link #defaultUnit}s (by default, pixels).
  16796. * - A String used to set the CSS width style. Animation may **not** be used.
  16797. *
  16798. * @param {Boolean/Object} [animate] true for the default animation or a standard Element animation config object
  16799. * @return {Ext.dom.Element} this
  16800. */
  16801. setWidth: function(width) {
  16802. var me = this;
  16803. me.dom.style.width = Element.addUnits(width);
  16804. return me;
  16805. },
  16806. /**
  16807. * Set the height of this Element.
  16808. *
  16809. * // change the height to 200px and animate with default configuration
  16810. * Ext.fly('elementId').setHeight(200, true);
  16811. *
  16812. * // change the height to 150px and animate with a custom configuration
  16813. * Ext.fly('elId').setHeight(150, {
  16814. * duration : 500, // animation will have a duration of .5 seconds
  16815. * // will change the content to "finished"
  16816. * callback: function(){ this.{@link #update}("finished"); }
  16817. * });
  16818. *
  16819. * @param {Number/String} height The new height. This may be one of:
  16820. *
  16821. * - A Number specifying the new height in this Element's {@link #defaultUnit}s (by default, pixels.)
  16822. * - A String used to set the CSS height style. Animation may **not** be used.
  16823. *
  16824. * @param {Boolean/Object} [animate] true for the default animation or a standard Element animation config object
  16825. * @return {Ext.dom.Element} this
  16826. */
  16827. setHeight: function(height) {
  16828. var me = this;
  16829. me.dom.style.height = Element.addUnits(height);
  16830. return me;
  16831. },
  16832. /**
  16833. * Gets the width of the border(s) for the specified side(s)
  16834. * @param {String} side Can be t, l, r, b or any combination of those to add multiple values. For example,
  16835. * passing `'lr'` would get the border **l**eft width + the border **r**ight width.
  16836. * @return {Number} The width of the sides passed added together
  16837. */
  16838. getBorderWidth: function(side){
  16839. return this.addStyles(side, borders);
  16840. },
  16841. /**
  16842. * Gets the width of the padding(s) for the specified side(s)
  16843. * @param {String} side Can be t, l, r, b or any combination of those to add multiple values. For example,
  16844. * passing `'lr'` would get the padding **l**eft + the padding **r**ight.
  16845. * @return {Number} The padding of the sides passed added together
  16846. */
  16847. getPadding: function(side){
  16848. return this.addStyles(side, paddings);
  16849. },
  16850. margins : margins,
  16851. /**
  16852. * More flexible version of {@link #setStyle} for setting style properties.
  16853. * @param {String/Object/Function} styles A style specification string, e.g. "width:100px", or object in the form {width:"100px"}, or
  16854. * a function which returns such a specification.
  16855. * @return {Ext.dom.Element} this
  16856. */
  16857. applyStyles: function(styles) {
  16858. if (styles) {
  16859. var i,
  16860. len,
  16861. dom = this.dom;
  16862. if (typeof styles == 'function') {
  16863. styles = styles.call();
  16864. }
  16865. if (typeof styles == 'string') {
  16866. styles = Ext.util.Format.trim(styles).split(/\s*(?::|;)\s*/);
  16867. for (i = 0, len = styles.length; i < len;) {
  16868. dom.style[Element.normalize(styles[i++])] = styles[i++];
  16869. }
  16870. }
  16871. else if (typeof styles == 'object') {
  16872. this.setStyle(styles);
  16873. }
  16874. }
  16875. },
  16876. /**
  16877. * Set the size of this Element. If animation is true, both width and height will be animated concurrently.
  16878. * @param {Number/String} width The new width. This may be one of:
  16879. *
  16880. * - A Number specifying the new width in this Element's {@link #defaultUnit}s (by default, pixels).
  16881. * - A String used to set the CSS width style. Animation may **not** be used.
  16882. * - A size object in the format `{width: widthValue, height: heightValue}`.
  16883. *
  16884. * @param {Number/String} height The new height. This may be one of:
  16885. *
  16886. * - A Number specifying the new height in this Element's {@link #defaultUnit}s (by default, pixels).
  16887. * - A String used to set the CSS height style. Animation may **not** be used.
  16888. *
  16889. * @param {Boolean/Object} [animate] true for the default animation or a standard Element animation config object
  16890. * @return {Ext.dom.Element} this
  16891. */
  16892. setSize: function(width, height) {
  16893. var me = this,
  16894. style = me.dom.style;
  16895. if (Ext.isObject(width)) {
  16896. // in case of object from getSize()
  16897. height = width.height;
  16898. width = width.width;
  16899. }
  16900. style.width = Element.addUnits(width);
  16901. style.height = Element.addUnits(height);
  16902. return me;
  16903. },
  16904. /**
  16905. * Returns the dimensions of the element available to lay content out in.
  16906. *
  16907. * If the element (or any ancestor element) has CSS style `display: none`, the dimensions will be zero.
  16908. *
  16909. * Example:
  16910. *
  16911. * var vpSize = Ext.getBody().getViewSize();
  16912. *
  16913. * // all Windows created afterwards will have a default value of 90% height and 95% width
  16914. * Ext.Window.override({
  16915. * width: vpSize.width * 0.9,
  16916. * height: vpSize.height * 0.95
  16917. * });
  16918. * // To handle window resizing you would have to hook onto onWindowResize.
  16919. *
  16920. * getViewSize utilizes clientHeight/clientWidth which excludes sizing of scrollbars.
  16921. * To obtain the size including scrollbars, use getStyleSize
  16922. *
  16923. * Sizing of the document body is handled at the adapter level which handles special cases for IE and strict modes, etc.
  16924. *
  16925. * @return {Object} Object describing width and height.
  16926. * @return {Number} return.width
  16927. * @return {Number} return.height
  16928. */
  16929. getViewSize: function() {
  16930. var doc = document,
  16931. dom = this.dom;
  16932. if (dom == doc || dom == doc.body) {
  16933. return {
  16934. width: Element.getViewportWidth(),
  16935. height: Element.getViewportHeight()
  16936. };
  16937. }
  16938. else {
  16939. return {
  16940. width: dom.clientWidth,
  16941. height: dom.clientHeight
  16942. };
  16943. }
  16944. },
  16945. /**
  16946. * Returns the size of the element.
  16947. * @param {Boolean} [contentSize] true to get the width/size minus borders and padding
  16948. * @return {Object} An object containing the element's size:
  16949. * @return {Number} return.width
  16950. * @return {Number} return.height
  16951. */
  16952. getSize: function(contentSize) {
  16953. var dom = this.dom;
  16954. return {
  16955. width: Math.max(0, contentSize ? (dom.clientWidth - this.getPadding("lr")) : dom.offsetWidth),
  16956. height: Math.max(0, contentSize ? (dom.clientHeight - this.getPadding("tb")) : dom.offsetHeight)
  16957. };
  16958. },
  16959. /**
  16960. * Forces the browser to repaint this element
  16961. * @return {Ext.dom.Element} this
  16962. */
  16963. repaint: function(){
  16964. var dom = this.dom;
  16965. this.addCls(Ext.baseCSSPrefix + 'repaint');
  16966. setTimeout(function(){
  16967. Ext.fly(dom).removeCls(Ext.baseCSSPrefix + 'repaint');
  16968. }, 1);
  16969. return this;
  16970. },
  16971. /**
  16972. * Returns an object with properties top, left, right and bottom representing the margins of this element unless sides is passed,
  16973. * then it returns the calculated width of the sides (see getPadding)
  16974. * @param {String} [sides] Any combination of l, r, t, b to get the sum of those sides
  16975. * @return {Object/Number}
  16976. */
  16977. getMargin: function(side){
  16978. var me = this,
  16979. hash = {t:"top", l:"left", r:"right", b: "bottom"},
  16980. key,
  16981. o,
  16982. margins;
  16983. if (!side) {
  16984. margins = [];
  16985. for (key in me.margins) {
  16986. if(me.margins.hasOwnProperty(key)) {
  16987. margins.push(me.margins[key]);
  16988. }
  16989. }
  16990. o = me.getStyle(margins);
  16991. if(o && typeof o == 'object') {
  16992. //now mixin nomalized values (from hash table)
  16993. for (key in me.margins) {
  16994. if(me.margins.hasOwnProperty(key)) {
  16995. o[hash[key]] = parseFloat(o[me.margins[key]]) || 0;
  16996. }
  16997. }
  16998. }
  16999. return o;
  17000. } else {
  17001. return me.addStyles.call(me, side, me.margins);
  17002. }
  17003. },
  17004. /**
  17005. * Puts a mask over this element to disable user interaction. Requires core.css.
  17006. * This method can only be applied to elements which accept child nodes.
  17007. * @param {String} [msg] A message to display in the mask
  17008. * @param {String} [msgCls] A css class to apply to the msg element
  17009. */
  17010. mask: function(msg, msgCls, transparent) {
  17011. var me = this,
  17012. dom = me.dom,
  17013. data = (me.$cache || me.getCache()).data,
  17014. el = data.mask,
  17015. mask,
  17016. size,
  17017. cls = '',
  17018. prefix = Ext.baseCSSPrefix;
  17019. me.addCls(prefix + 'masked');
  17020. if (me.getStyle("position") == "static") {
  17021. me.addCls(prefix + 'masked-relative');
  17022. }
  17023. if (el) {
  17024. el.remove();
  17025. }
  17026. if (msgCls && typeof msgCls == 'string' ) {
  17027. cls = ' ' + msgCls;
  17028. }
  17029. else {
  17030. cls = ' ' + prefix + 'mask-gray';
  17031. }
  17032. mask = me.createChild({
  17033. cls: prefix + 'mask' + ((transparent !== false) ? '' : (' ' + prefix + 'mask-gray')),
  17034. html: msg ? ('<div class="' + (msgCls || (prefix + 'mask-message')) + '">' + msg + '</div>') : ''
  17035. });
  17036. size = me.getSize();
  17037. data.mask = mask;
  17038. if (dom === document.body) {
  17039. size.height = window.innerHeight;
  17040. if (me.orientationHandler) {
  17041. Ext.EventManager.unOrientationChange(me.orientationHandler, me);
  17042. }
  17043. me.orientationHandler = function() {
  17044. size = me.getSize();
  17045. size.height = window.innerHeight;
  17046. mask.setSize(size);
  17047. };
  17048. Ext.EventManager.onOrientationChange(me.orientationHandler, me);
  17049. }
  17050. mask.setSize(size);
  17051. if (Ext.is.iPad) {
  17052. Ext.repaint();
  17053. }
  17054. },
  17055. /**
  17056. * Removes a previously applied mask.
  17057. */
  17058. unmask: function() {
  17059. var me = this,
  17060. data = (me.$cache || me.getCache()).data,
  17061. mask = data.mask,
  17062. prefix = Ext.baseCSSPrefix;
  17063. if (mask) {
  17064. mask.remove();
  17065. delete data.mask;
  17066. }
  17067. me.removeCls([prefix + 'masked', prefix + 'masked-relative']);
  17068. if (me.dom === document.body) {
  17069. Ext.EventManager.unOrientationChange(me.orientationHandler, me);
  17070. delete me.orientationHandler;
  17071. }
  17072. }
  17073. });
  17074. /**
  17075. * Creates mappings for 'margin-before' to 'marginLeft' (etc.) given the output
  17076. * map and an ordering pair (e.g., ['left', 'right']). The ordering pair is in
  17077. * before/after order.
  17078. */
  17079. Element.populateStyleMap = function (map, order) {
  17080. var baseStyles = ['margin-', 'padding-', 'border-width-'],
  17081. beforeAfter = ['before', 'after'],
  17082. index, style, name, i;
  17083. for (index = baseStyles.length; index--; ) {
  17084. for (i = 2; i--; ) {
  17085. style = baseStyles[index] + beforeAfter[i]; // margin-before
  17086. // ex: maps margin-before and marginBefore to marginLeft
  17087. map[Element.normalize(style)] = map[style] = {
  17088. name: Element.normalize(baseStyles[index] + order[i])
  17089. };
  17090. }
  17091. }
  17092. };
  17093. Ext.onReady(function () {
  17094. var supports = Ext.supports,
  17095. styleHooks,
  17096. colorStyles, i, name, camel;
  17097. function fixTransparent (dom, el, inline, style) {
  17098. var value = style[this.name] || '';
  17099. return transparentRe.test(value) ? 'transparent' : value;
  17100. }
  17101. function fixRightMargin (dom, el, inline, style) {
  17102. var result = style.marginRight,
  17103. domStyle, display;
  17104. // Ignore cases when the margin is correctly reported as 0, the bug only shows
  17105. // numbers larger.
  17106. if (result != '0px') {
  17107. domStyle = dom.style;
  17108. display = domStyle.display;
  17109. domStyle.display = 'inline-block';
  17110. result = (inline ? style : dom.ownerDocument.defaultView.getComputedStyle(dom, null)).marginRight;
  17111. domStyle.display = display;
  17112. }
  17113. return result;
  17114. }
  17115. function fixRightMarginAndInputFocus (dom, el, inline, style) {
  17116. var result = style.marginRight,
  17117. domStyle, cleaner, display;
  17118. if (result != '0px') {
  17119. domStyle = dom.style;
  17120. cleaner = Element.getRightMarginFixCleaner(dom);
  17121. display = domStyle.display;
  17122. domStyle.display = 'inline-block';
  17123. result = (inline ? style : dom.ownerDocument.defaultView.getComputedStyle(dom, '')).marginRight;
  17124. domStyle.display = display;
  17125. cleaner();
  17126. }
  17127. return result;
  17128. }
  17129. styleHooks = Element.prototype.styleHooks;
  17130. // Populate the LTR flavors of margin-before et.al. (see Ext.rtl.AbstractElement):
  17131. Element.populateStyleMap(styleHooks, ['left', 'right']);
  17132. // Ext.supports needs to be initialized (we run very early in the onready sequence),
  17133. // but it is OK to call Ext.supports.init() more times than necessary...
  17134. if (supports.init) {
  17135. supports.init();
  17136. }
  17137. // Fix bug caused by this: https://bugs.webkit.org/show_bug.cgi?id=13343
  17138. if (!supports.RightMargin) {
  17139. styleHooks.marginRight = styleHooks['margin-right'] = {
  17140. name: 'marginRight',
  17141. // TODO - Touch should use conditional compilation here or ensure that the
  17142. // underlying Ext.supports flags are set correctly...
  17143. get: (supports.DisplayChangeInputSelectionBug || supports.DisplayChangeTextAreaSelectionBug) ?
  17144. fixRightMarginAndInputFocus : fixRightMargin
  17145. };
  17146. }
  17147. if (!supports.TransparentColor) {
  17148. colorStyles = ['background-color', 'border-color', 'color', 'outline-color'];
  17149. for (i = colorStyles.length; i--; ) {
  17150. name = colorStyles[i];
  17151. camel = Element.normalize(name);
  17152. styleHooks[name] = styleHooks[camel] = {
  17153. name: camel,
  17154. get: fixTransparent
  17155. };
  17156. }
  17157. }
  17158. });
  17159. }());
  17160. //@tag dom,core
  17161. //@require Ext.dom.AbstractElement-style
  17162. //@define Ext.dom.AbstractElement-traversal
  17163. //@define Ext.dom.AbstractElement
  17164. /**
  17165. * @class Ext.dom.AbstractElement
  17166. */
  17167. Ext.dom.AbstractElement.override({
  17168. /**
  17169. * Looks at this node and then at parent nodes for a match of the passed simple selector (e.g. div.some-class or span:first-child)
  17170. * @param {String} selector The simple selector to test
  17171. * @param {Number/String/HTMLElement/Ext.Element} [limit]
  17172. * The max depth to search as a number or an element which causes the upward traversal to stop
  17173. * and is <b>not</b> considered for inclusion as the result. (defaults to 50 || document.documentElement)
  17174. * @param {Boolean} [returnEl=false] True to return a Ext.Element object instead of DOM node
  17175. * @return {HTMLElement} The matching DOM node (or null if no match was found)
  17176. */
  17177. findParent: function(simpleSelector, limit, returnEl) {
  17178. var target = this.dom,
  17179. topmost = document.documentElement,
  17180. depth = 0,
  17181. stopEl;
  17182. limit = limit || 50;
  17183. if (isNaN(limit)) {
  17184. stopEl = Ext.getDom(limit);
  17185. limit = Number.MAX_VALUE;
  17186. }
  17187. while (target && target.nodeType == 1 && depth < limit && target != topmost && target != stopEl) {
  17188. if (Ext.DomQuery.is(target, simpleSelector)) {
  17189. return returnEl ? Ext.get(target) : target;
  17190. }
  17191. depth++;
  17192. target = target.parentNode;
  17193. }
  17194. return null;
  17195. },
  17196. /**
  17197. * Looks at parent nodes for a match of the passed simple selector (e.g. div.some-class or span:first-child)
  17198. * @param {String} selector The simple selector to test
  17199. * @param {Number/String/HTMLElement/Ext.Element} [limit]
  17200. * The max depth to search as a number or an element which causes the upward traversal to stop
  17201. * and is <b>not</b> considered for inclusion as the result. (defaults to 50 || document.documentElement)
  17202. * @param {Boolean} [returnEl=false] True to return a Ext.Element object instead of DOM node
  17203. * @return {HTMLElement} The matching DOM node (or null if no match was found)
  17204. */
  17205. findParentNode: function(simpleSelector, limit, returnEl) {
  17206. var p = Ext.fly(this.dom.parentNode, '_internal');
  17207. return p ? p.findParent(simpleSelector, limit, returnEl) : null;
  17208. },
  17209. /**
  17210. * Walks up the dom looking for a parent node that matches the passed simple selector (e.g. div.some-class or span:first-child).
  17211. * This is a shortcut for findParentNode() that always returns an Ext.dom.Element.
  17212. * @param {String} selector The simple selector to test
  17213. * @param {Number/String/HTMLElement/Ext.Element} [limit]
  17214. * The max depth to search as a number or an element which causes the upward traversal to stop
  17215. * and is <b>not</b> considered for inclusion as the result. (defaults to 50 || document.documentElement)
  17216. * @return {Ext.Element} The matching DOM node (or null if no match was found)
  17217. */
  17218. up: function(simpleSelector, limit) {
  17219. return this.findParentNode(simpleSelector, limit, true);
  17220. },
  17221. /**
  17222. * Creates a {@link Ext.CompositeElement} for child nodes based on the passed CSS selector (the selector should not contain an id).
  17223. * @param {String} selector The CSS selector
  17224. * @param {Boolean} [unique] True to create a unique Ext.Element for each element. Defaults to a shared flyweight object.
  17225. * @return {Ext.CompositeElement} The composite element
  17226. */
  17227. select: function(selector, composite) {
  17228. return Ext.dom.Element.select(selector, this.dom, composite);
  17229. },
  17230. /**
  17231. * Selects child nodes based on the passed CSS selector (the selector should not contain an id).
  17232. * @param {String} selector The CSS selector
  17233. * @return {HTMLElement[]} An array of the matched nodes
  17234. */
  17235. query: function(selector) {
  17236. return Ext.DomQuery.select(selector, this.dom);
  17237. },
  17238. /**
  17239. * Selects a single child at any depth below this element based on the passed CSS selector (the selector should not contain an id).
  17240. * @param {String} selector The CSS selector
  17241. * @param {Boolean} [returnDom=false] True to return the DOM node instead of Ext.dom.Element
  17242. * @return {HTMLElement/Ext.dom.Element} The child Ext.dom.Element (or DOM node if returnDom = true)
  17243. */
  17244. down: function(selector, returnDom) {
  17245. var n = Ext.DomQuery.selectNode(selector, this.dom);
  17246. return returnDom ? n : Ext.get(n);
  17247. },
  17248. /**
  17249. * Selects a single *direct* child based on the passed CSS selector (the selector should not contain an id).
  17250. * @param {String} selector The CSS selector
  17251. * @param {Boolean} [returnDom=false] True to return the DOM node instead of Ext.dom.Element.
  17252. * @return {HTMLElement/Ext.dom.Element} The child Ext.dom.Element (or DOM node if returnDom = true)
  17253. */
  17254. child: function(selector, returnDom) {
  17255. var node,
  17256. me = this,
  17257. id;
  17258. // Pull the ID from the DOM (Ext.id also ensures that there *is* an ID).
  17259. // If this object is a Flyweight, it will not have an ID
  17260. id = Ext.id(me.dom);
  17261. // Escape "invalid" chars
  17262. id = Ext.escapeId(id);
  17263. node = Ext.DomQuery.selectNode('#' + id + " > " + selector, me.dom);
  17264. return returnDom ? node : Ext.get(node);
  17265. },
  17266. /**
  17267. * Gets the parent node for this element, optionally chaining up trying to match a selector
  17268. * @param {String} [selector] Find a parent node that matches the passed simple selector
  17269. * @param {Boolean} [returnDom=false] True to return a raw dom node instead of an Ext.dom.Element
  17270. * @return {Ext.dom.Element/HTMLElement} The parent node or null
  17271. */
  17272. parent: function(selector, returnDom) {
  17273. return this.matchNode('parentNode', 'parentNode', selector, returnDom);
  17274. },
  17275. /**
  17276. * Gets the next sibling, skipping text nodes
  17277. * @param {String} [selector] Find the next sibling that matches the passed simple selector
  17278. * @param {Boolean} [returnDom=false] True to return a raw dom node instead of an Ext.dom.Element
  17279. * @return {Ext.dom.Element/HTMLElement} The next sibling or null
  17280. */
  17281. next: function(selector, returnDom) {
  17282. return this.matchNode('nextSibling', 'nextSibling', selector, returnDom);
  17283. },
  17284. /**
  17285. * Gets the previous sibling, skipping text nodes
  17286. * @param {String} [selector] Find the previous sibling that matches the passed simple selector
  17287. * @param {Boolean} [returnDom=false] True to return a raw dom node instead of an Ext.dom.Element
  17288. * @return {Ext.dom.Element/HTMLElement} The previous sibling or null
  17289. */
  17290. prev: function(selector, returnDom) {
  17291. return this.matchNode('previousSibling', 'previousSibling', selector, returnDom);
  17292. },
  17293. /**
  17294. * Gets the first child, skipping text nodes
  17295. * @param {String} [selector] Find the next sibling that matches the passed simple selector
  17296. * @param {Boolean} [returnDom=false] True to return a raw dom node instead of an Ext.dom.Element
  17297. * @return {Ext.dom.Element/HTMLElement} The first child or null
  17298. */
  17299. first: function(selector, returnDom) {
  17300. return this.matchNode('nextSibling', 'firstChild', selector, returnDom);
  17301. },
  17302. /**
  17303. * Gets the last child, skipping text nodes
  17304. * @param {String} [selector] Find the previous sibling that matches the passed simple selector
  17305. * @param {Boolean} [returnDom=false] True to return a raw dom node instead of an Ext.dom.Element
  17306. * @return {Ext.dom.Element/HTMLElement} The last child or null
  17307. */
  17308. last: function(selector, returnDom) {
  17309. return this.matchNode('previousSibling', 'lastChild', selector, returnDom);
  17310. },
  17311. matchNode: function(dir, start, selector, returnDom) {
  17312. if (!this.dom) {
  17313. return null;
  17314. }
  17315. var n = this.dom[start];
  17316. while (n) {
  17317. if (n.nodeType == 1 && (!selector || Ext.DomQuery.is(n, selector))) {
  17318. return !returnDom ? Ext.get(n) : n;
  17319. }
  17320. n = n[dir];
  17321. }
  17322. return null;
  17323. },
  17324. isAncestor: function(element) {
  17325. return this.self.isAncestor.call(this.self, this.dom, element);
  17326. }
  17327. });
  17328. //@tag dom,core
  17329. //@define Ext.DomHelper
  17330. //@define Ext.core.DomHelper
  17331. //@require Ext.dom.AbstractElement-traversal
  17332. /**
  17333. * @class Ext.DomHelper
  17334. * @extends Ext.dom.Helper
  17335. * @alternateClassName Ext.core.DomHelper
  17336. * @singleton
  17337. *
  17338. * The DomHelper class provides a layer of abstraction from DOM and transparently supports creating elements via DOM or
  17339. * using HTML fragments. It also has the ability to create HTML fragment templates from your DOM building code.
  17340. *
  17341. * # DomHelper element specification object
  17342. *
  17343. * A specification object is used when creating elements. Attributes of this object are assumed to be element
  17344. * attributes, except for 4 special attributes:
  17345. *
  17346. * - **tag** - The tag name of the element.
  17347. * - **children** or **cn** - An array of the same kind of element definition objects to be created and appended.
  17348. * These can be nested as deep as you want.
  17349. * - **cls** - The class attribute of the element. This will end up being either the "class" attribute on a HTML
  17350. * fragment or className for a DOM node, depending on whether DomHelper is using fragments or DOM.
  17351. * - **html** - The innerHTML for the element.
  17352. *
  17353. * **NOTE:** For other arbitrary attributes, the value will currently **not** be automatically HTML-escaped prior to
  17354. * building the element's HTML string. This means that if your attribute value contains special characters that would
  17355. * not normally be allowed in a double-quoted attribute value, you **must** manually HTML-encode it beforehand (see
  17356. * {@link Ext.String#htmlEncode}) or risk malformed HTML being created. This behavior may change in a future release.
  17357. *
  17358. * # Insertion methods
  17359. *
  17360. * Commonly used insertion methods:
  17361. *
  17362. * - **{@link #append}**
  17363. * - **{@link #insertBefore}**
  17364. * - **{@link #insertAfter}**
  17365. * - **{@link #overwrite}**
  17366. * - **{@link #createTemplate}**
  17367. * - **{@link #insertHtml}**
  17368. *
  17369. * # Example
  17370. *
  17371. * This is an example, where an unordered list with 3 children items is appended to an existing element with
  17372. * id 'my-div':
  17373. *
  17374. * var dh = Ext.DomHelper; // create shorthand alias
  17375. * // specification object
  17376. * var spec = {
  17377. * id: 'my-ul',
  17378. * tag: 'ul',
  17379. * cls: 'my-list',
  17380. * // append children after creating
  17381. * children: [ // may also specify 'cn' instead of 'children'
  17382. * {tag: 'li', id: 'item0', html: 'List Item 0'},
  17383. * {tag: 'li', id: 'item1', html: 'List Item 1'},
  17384. * {tag: 'li', id: 'item2', html: 'List Item 2'}
  17385. * ]
  17386. * };
  17387. * var list = dh.append(
  17388. * 'my-div', // the context element 'my-div' can either be the id or the actual node
  17389. * spec // the specification object
  17390. * );
  17391. *
  17392. * Element creation specification parameters in this class may also be passed as an Array of specification objects. This
  17393. * can be used to insert multiple sibling nodes into an existing container very efficiently. For example, to add more
  17394. * list items to the example above:
  17395. *
  17396. * dh.append('my-ul', [
  17397. * {tag: 'li', id: 'item3', html: 'List Item 3'},
  17398. * {tag: 'li', id: 'item4', html: 'List Item 4'}
  17399. * ]);
  17400. *
  17401. * # Templating
  17402. *
  17403. * The real power is in the built-in templating. Instead of creating or appending any elements, {@link #createTemplate}
  17404. * returns a Template object which can be used over and over to insert new elements. Revisiting the example above, we
  17405. * could utilize templating this time:
  17406. *
  17407. * // create the node
  17408. * var list = dh.append('my-div', {tag: 'ul', cls: 'my-list'});
  17409. * // get template
  17410. * var tpl = dh.createTemplate({tag: 'li', id: 'item{0}', html: 'List Item {0}'});
  17411. *
  17412. * for(var i = 0; i < 5, i++){
  17413. * tpl.append(list, [i]); // use template to append to the actual node
  17414. * }
  17415. *
  17416. * An example using a template:
  17417. *
  17418. * var html = '<a id="{0}" href="{1}" class="nav">{2}</a>';
  17419. *
  17420. * var tpl = new Ext.DomHelper.createTemplate(html);
  17421. * tpl.append('blog-roll', ['link1', 'http://www.edspencer.net/', "Ed's Site"]);
  17422. * tpl.append('blog-roll', ['link2', 'http://www.dustindiaz.com/', "Dustin's Site"]);
  17423. *
  17424. * The same example using named parameters:
  17425. *
  17426. * var html = '<a id="{id}" href="{url}" class="nav">{text}</a>';
  17427. *
  17428. * var tpl = new Ext.DomHelper.createTemplate(html);
  17429. * tpl.append('blog-roll', {
  17430. * id: 'link1',
  17431. * url: 'http://www.edspencer.net/',
  17432. * text: "Ed's Site"
  17433. * });
  17434. * tpl.append('blog-roll', {
  17435. * id: 'link2',
  17436. * url: 'http://www.dustindiaz.com/',
  17437. * text: "Dustin's Site"
  17438. * });
  17439. *
  17440. * # Compiling Templates
  17441. *
  17442. * Templates are applied using regular expressions. The performance is great, but if you are adding a bunch of DOM
  17443. * elements using the same template, you can increase performance even further by {@link Ext.Template#compile
  17444. * "compiling"} the template. The way "{@link Ext.Template#compile compile()}" works is the template is parsed and
  17445. * broken up at the different variable points and a dynamic function is created and eval'ed. The generated function
  17446. * performs string concatenation of these parts and the passed variables instead of using regular expressions.
  17447. *
  17448. * var html = '<a id="{id}" href="{url}" class="nav">{text}</a>';
  17449. *
  17450. * var tpl = new Ext.DomHelper.createTemplate(html);
  17451. * tpl.compile();
  17452. *
  17453. * //... use template like normal
  17454. *
  17455. * # Performance Boost
  17456. *
  17457. * DomHelper will transparently create HTML fragments when it can. Using HTML fragments instead of DOM can significantly
  17458. * boost performance.
  17459. *
  17460. * Element creation specification parameters may also be strings. If {@link #useDom} is false, then the string is used
  17461. * as innerHTML. If {@link #useDom} is true, a string specification results in the creation of a text node. Usage:
  17462. *
  17463. * Ext.DomHelper.useDom = true; // force it to use DOM; reduces performance
  17464. *
  17465. */
  17466. (function() {
  17467. // kill repeat to save bytes
  17468. var afterbegin = 'afterbegin',
  17469. afterend = 'afterend',
  17470. beforebegin = 'beforebegin',
  17471. beforeend = 'beforeend',
  17472. ts = '<table>',
  17473. te = '</table>',
  17474. tbs = ts+'<tbody>',
  17475. tbe = '</tbody>'+te,
  17476. trs = tbs + '<tr>',
  17477. tre = '</tr>'+tbe,
  17478. detachedDiv = document.createElement('div'),
  17479. bbValues = ['BeforeBegin', 'previousSibling'],
  17480. aeValues = ['AfterEnd', 'nextSibling'],
  17481. bb_ae_PositionHash = {
  17482. beforebegin: bbValues,
  17483. afterend: aeValues
  17484. },
  17485. fullPositionHash = {
  17486. beforebegin: bbValues,
  17487. afterend: aeValues,
  17488. afterbegin: ['AfterBegin', 'firstChild'],
  17489. beforeend: ['BeforeEnd', 'lastChild']
  17490. };
  17491. /**
  17492. * The actual class of which {@link Ext.DomHelper} is instance of.
  17493. *
  17494. * Use singleton {@link Ext.DomHelper} instead.
  17495. *
  17496. * @private
  17497. */
  17498. Ext.define('Ext.dom.Helper', {
  17499. extend: 'Ext.dom.AbstractHelper',
  17500. requires:['Ext.dom.AbstractElement'],
  17501. tableRe: /^table|tbody|tr|td$/i,
  17502. tableElRe: /td|tr|tbody/i,
  17503. /**
  17504. * @property {Boolean} useDom
  17505. * True to force the use of DOM instead of html fragments.
  17506. */
  17507. useDom : false,
  17508. /**
  17509. * Creates new DOM element(s) without inserting them to the document.
  17510. * @param {Object/String} o The DOM object spec (and children) or raw HTML blob
  17511. * @return {HTMLElement} The new uninserted node
  17512. */
  17513. createDom: function(o, parentNode){
  17514. var el,
  17515. doc = document,
  17516. useSet,
  17517. attr,
  17518. val,
  17519. cn,
  17520. i, l;
  17521. if (Ext.isArray(o)) { // Allow Arrays of siblings to be inserted
  17522. el = doc.createDocumentFragment(); // in one shot using a DocumentFragment
  17523. for (i = 0, l = o.length; i < l; i++) {
  17524. this.createDom(o[i], el);
  17525. }
  17526. } else if (typeof o == 'string') { // Allow a string as a child spec.
  17527. el = doc.createTextNode(o);
  17528. } else {
  17529. el = doc.createElement(o.tag || 'div');
  17530. useSet = !!el.setAttribute; // In IE some elements don't have setAttribute
  17531. for (attr in o) {
  17532. if (!this.confRe.test(attr)) {
  17533. val = o[attr];
  17534. if (attr == 'cls') {
  17535. el.className = val;
  17536. } else {
  17537. if (useSet) {
  17538. el.setAttribute(attr, val);
  17539. } else {
  17540. el[attr] = val;
  17541. }
  17542. }
  17543. }
  17544. }
  17545. Ext.DomHelper.applyStyles(el, o.style);
  17546. if ((cn = o.children || o.cn)) {
  17547. this.createDom(cn, el);
  17548. } else if (o.html) {
  17549. el.innerHTML = o.html;
  17550. }
  17551. }
  17552. if (parentNode) {
  17553. parentNode.appendChild(el);
  17554. }
  17555. return el;
  17556. },
  17557. ieTable: function(depth, openingTags, htmlContent, closingTags){
  17558. detachedDiv.innerHTML = [openingTags, htmlContent, closingTags].join('');
  17559. var i = -1,
  17560. el = detachedDiv,
  17561. ns;
  17562. while (++i < depth) {
  17563. el = el.firstChild;
  17564. }
  17565. // If the result is multiple siblings, then encapsulate them into one fragment.
  17566. ns = el.nextSibling;
  17567. if (ns) {
  17568. el = document.createDocumentFragment();
  17569. while (ns) {
  17570. el.appendChild(ns);
  17571. ns = ns.nextSibling;
  17572. }
  17573. }
  17574. return el;
  17575. },
  17576. /**
  17577. * @private
  17578. * Nasty code for IE's broken table implementation
  17579. */
  17580. insertIntoTable: function(tag, where, destinationEl, html) {
  17581. var node,
  17582. before,
  17583. bb = where == beforebegin,
  17584. ab = where == afterbegin,
  17585. be = where == beforeend,
  17586. ae = where == afterend;
  17587. if (tag == 'td' && (ab || be) || !this.tableElRe.test(tag) && (bb || ae)) {
  17588. return null;
  17589. }
  17590. before = bb ? destinationEl :
  17591. ae ? destinationEl.nextSibling :
  17592. ab ? destinationEl.firstChild : null;
  17593. if (bb || ae) {
  17594. destinationEl = destinationEl.parentNode;
  17595. }
  17596. if (tag == 'td' || (tag == 'tr' && (be || ab))) {
  17597. node = this.ieTable(4, trs, html, tre);
  17598. } else if ((tag == 'tbody' && (be || ab)) ||
  17599. (tag == 'tr' && (bb || ae))) {
  17600. node = this.ieTable(3, tbs, html, tbe);
  17601. } else {
  17602. node = this.ieTable(2, ts, html, te);
  17603. }
  17604. destinationEl.insertBefore(node, before);
  17605. return node;
  17606. },
  17607. /**
  17608. * @private
  17609. * Fix for IE9 createContextualFragment missing method
  17610. */
  17611. createContextualFragment: function(html) {
  17612. var fragment = document.createDocumentFragment(),
  17613. length, childNodes;
  17614. detachedDiv.innerHTML = html;
  17615. childNodes = detachedDiv.childNodes;
  17616. length = childNodes.length;
  17617. // Move nodes into fragment, don't clone: http://jsperf.com/create-fragment
  17618. while (length--) {
  17619. fragment.appendChild(childNodes[0]);
  17620. }
  17621. return fragment;
  17622. },
  17623. applyStyles: function(el, styles) {
  17624. if (styles) {
  17625. el = Ext.fly(el);
  17626. if (typeof styles == "function") {
  17627. styles = styles.call();
  17628. }
  17629. if (typeof styles == "string") {
  17630. styles = Ext.dom.Element.parseStyles(styles);
  17631. }
  17632. if (typeof styles == "object") {
  17633. el.setStyle(styles);
  17634. }
  17635. }
  17636. },
  17637. /**
  17638. * Alias for {@link #markup}.
  17639. * @inheritdoc Ext.dom.AbstractHelper#markup
  17640. */
  17641. createHtml: function(spec) {
  17642. return this.markup(spec);
  17643. },
  17644. doInsert: function(el, o, returnElement, pos, sibling, append) {
  17645. el = el.dom || Ext.getDom(el);
  17646. var newNode;
  17647. if (this.useDom) {
  17648. newNode = this.createDom(o, null);
  17649. if (append) {
  17650. el.appendChild(newNode);
  17651. }
  17652. else {
  17653. (sibling == 'firstChild' ? el : el.parentNode).insertBefore(newNode, el[sibling] || el);
  17654. }
  17655. } else {
  17656. newNode = this.insertHtml(pos, el, this.markup(o));
  17657. }
  17658. return returnElement ? Ext.get(newNode, true) : newNode;
  17659. },
  17660. /**
  17661. * Creates new DOM element(s) and overwrites the contents of el with them.
  17662. * @param {String/HTMLElement/Ext.Element} el The context element
  17663. * @param {Object/String} o The DOM object spec (and children) or raw HTML blob
  17664. * @param {Boolean} [returnElement] true to return an Ext.Element
  17665. * @return {HTMLElement/Ext.Element} The new node
  17666. */
  17667. overwrite: function(el, html, returnElement) {
  17668. var newNode;
  17669. el = Ext.getDom(el);
  17670. html = this.markup(html);
  17671. // IE Inserting HTML into a table/tbody/tr requires extra processing: http://www.ericvasilik.com/2006/07/code-karma.html
  17672. if (Ext.isIE && this.tableRe.test(el.tagName)) {
  17673. // Clearing table elements requires removal of all elements.
  17674. while (el.firstChild) {
  17675. el.removeChild(el.firstChild);
  17676. }
  17677. if (html) {
  17678. newNode = this.insertHtml('afterbegin', el, html);
  17679. return returnElement ? Ext.get(newNode) : newNode;
  17680. }
  17681. return null;
  17682. }
  17683. el.innerHTML = html;
  17684. return returnElement ? Ext.get(el.firstChild) : el.firstChild;
  17685. },
  17686. insertHtml: function(where, el, html) {
  17687. var hashVal,
  17688. range,
  17689. rangeEl,
  17690. setStart,
  17691. frag;
  17692. where = where.toLowerCase();
  17693. // Has fast HTML insertion into existing DOM: http://www.w3.org/TR/html5/apis-in-html-documents.html#insertadjacenthtml
  17694. if (el.insertAdjacentHTML) {
  17695. // IE's incomplete table implementation: http://www.ericvasilik.com/2006/07/code-karma.html
  17696. if (Ext.isIE && this.tableRe.test(el.tagName) && (frag = this.insertIntoTable(el.tagName.toLowerCase(), where, el, html))) {
  17697. return frag;
  17698. }
  17699. if ((hashVal = fullPositionHash[where])) {
  17700. el.insertAdjacentHTML(hashVal[0], html);
  17701. return el[hashVal[1]];
  17702. }
  17703. // if (not IE and context element is an HTMLElement) or TextNode
  17704. } else {
  17705. // we cannot insert anything inside a textnode so...
  17706. if (el.nodeType === 3) {
  17707. where = where === 'afterbegin' ? 'beforebegin' : where;
  17708. where = where === 'beforeend' ? 'afterend' : where;
  17709. }
  17710. range = Ext.supports.CreateContextualFragment ? el.ownerDocument.createRange() : undefined;
  17711. setStart = 'setStart' + (this.endRe.test(where) ? 'After' : 'Before');
  17712. if (bb_ae_PositionHash[where]) {
  17713. if (range) {
  17714. range[setStart](el);
  17715. frag = range.createContextualFragment(html);
  17716. } else {
  17717. frag = this.createContextualFragment(html);
  17718. }
  17719. el.parentNode.insertBefore(frag, where == beforebegin ? el : el.nextSibling);
  17720. return el[(where == beforebegin ? 'previous' : 'next') + 'Sibling'];
  17721. } else {
  17722. rangeEl = (where == afterbegin ? 'first' : 'last') + 'Child';
  17723. if (el.firstChild) {
  17724. if (range) {
  17725. range[setStart](el[rangeEl]);
  17726. frag = range.createContextualFragment(html);
  17727. } else {
  17728. frag = this.createContextualFragment(html);
  17729. }
  17730. if (where == afterbegin) {
  17731. el.insertBefore(frag, el.firstChild);
  17732. } else {
  17733. el.appendChild(frag);
  17734. }
  17735. } else {
  17736. el.innerHTML = html;
  17737. }
  17738. return el[rangeEl];
  17739. }
  17740. }
  17741. },
  17742. /**
  17743. * Creates a new Ext.Template from the DOM object spec.
  17744. * @param {Object} o The DOM object spec (and children)
  17745. * @return {Ext.Template} The new template
  17746. */
  17747. createTemplate: function(o) {
  17748. var html = this.markup(o);
  17749. return new Ext.Template(html);
  17750. }
  17751. }, function() {
  17752. Ext.ns('Ext.core');
  17753. Ext.DomHelper = Ext.core.DomHelper = new this;
  17754. });
  17755. }());
  17756. //@tag dom,core
  17757. //@require Helper.js
  17758. //@define Ext.dom.Query
  17759. //@define Ext.core.Query
  17760. //@define Ext.DomQuery
  17761. /*
  17762. * This is code is also distributed under MIT license for use
  17763. * with jQuery and prototype JavaScript libraries.
  17764. */
  17765. /**
  17766. * @class Ext.dom.Query
  17767. * @alternateClassName Ext.DomQuery
  17768. * @alternateClassName Ext.core.DomQuery
  17769. * @singleton
  17770. *
  17771. * Provides high performance selector/xpath processing by compiling queries into reusable functions. New pseudo classes
  17772. * and matchers can be plugged. It works on HTML and XML documents (if a content node is passed in).
  17773. *
  17774. * DomQuery supports most of the [CSS3 selectors spec][1], along with some custom selectors and basic XPath.
  17775. *
  17776. * All selectors, attribute filters and pseudos below can be combined infinitely in any order. For example
  17777. * `div.foo:nth-child(odd)[@foo=bar].bar:first` would be a perfectly valid selector. Node filters are processed
  17778. * in the order in which they appear, which allows you to optimize your queries for your document structure.
  17779. *
  17780. * ## Element Selectors:
  17781. *
  17782. * - **`*`** any element
  17783. * - **`E`** an element with the tag E
  17784. * - **`E F`** All descendent elements of E that have the tag F
  17785. * - **`E > F`** or **E/F** all direct children elements of E that have the tag F
  17786. * - **`E + F`** all elements with the tag F that are immediately preceded by an element with the tag E
  17787. * - **`E ~ F`** all elements with the tag F that are preceded by a sibling element with the tag E
  17788. *
  17789. * ## Attribute Selectors:
  17790. *
  17791. * The use of `@` and quotes are optional. For example, `div[@foo='bar']` is also a valid attribute selector.
  17792. *
  17793. * - **`E[foo]`** has an attribute "foo"
  17794. * - **`E[foo=bar]`** has an attribute "foo" that equals "bar"
  17795. * - **`E[foo^=bar]`** has an attribute "foo" that starts with "bar"
  17796. * - **`E[foo$=bar]`** has an attribute "foo" that ends with "bar"
  17797. * - **`E[foo*=bar]`** has an attribute "foo" that contains the substring "bar"
  17798. * - **`E[foo%=2]`** has an attribute "foo" that is evenly divisible by 2
  17799. * - **`E[foo!=bar]`** attribute "foo" does not equal "bar"
  17800. *
  17801. * ## Pseudo Classes:
  17802. *
  17803. * - **`E:first-child`** E is the first child of its parent
  17804. * - **`E:last-child`** E is the last child of its parent
  17805. * - **`E:nth-child(_n_)`** E is the _n_th child of its parent (1 based as per the spec)
  17806. * - **`E:nth-child(odd)`** E is an odd child of its parent
  17807. * - **`E:nth-child(even)`** E is an even child of its parent
  17808. * - **`E:only-child`** E is the only child of its parent
  17809. * - **`E:checked`** E is an element that is has a checked attribute that is true (e.g. a radio or checkbox)
  17810. * - **`E:first`** the first E in the resultset
  17811. * - **`E:last`** the last E in the resultset
  17812. * - **`E:nth(_n_)`** the _n_th E in the resultset (1 based)
  17813. * - **`E:odd`** shortcut for :nth-child(odd)
  17814. * - **`E:even`** shortcut for :nth-child(even)
  17815. * - **`E:contains(foo)`** E's innerHTML contains the substring "foo"
  17816. * - **`E:nodeValue(foo)`** E contains a textNode with a nodeValue that equals "foo"
  17817. * - **`E:not(S)`** an E element that does not match simple selector S
  17818. * - **`E:has(S)`** an E element that has a descendent that matches simple selector S
  17819. * - **`E:next(S)`** an E element whose next sibling matches simple selector S
  17820. * - **`E:prev(S)`** an E element whose previous sibling matches simple selector S
  17821. * - **`E:any(S1|S2|S2)`** an E element which matches any of the simple selectors S1, S2 or S3
  17822. *
  17823. * ## CSS Value Selectors:
  17824. *
  17825. * - **`E{display=none}`** css value "display" that equals "none"
  17826. * - **`E{display^=none}`** css value "display" that starts with "none"
  17827. * - **`E{display$=none}`** css value "display" that ends with "none"
  17828. * - **`E{display*=none}`** css value "display" that contains the substring "none"
  17829. * - **`E{display%=2}`** css value "display" that is evenly divisible by 2
  17830. * - **`E{display!=none}`** css value "display" that does not equal "none"
  17831. *
  17832. * [1]: http://www.w3.org/TR/2005/WD-css3-selectors-20051215/#selectors
  17833. */
  17834. Ext.ns('Ext.core');
  17835. Ext.dom.Query = Ext.core.DomQuery = Ext.DomQuery = (function(){
  17836. var cache = {},
  17837. simpleCache = {},
  17838. valueCache = {},
  17839. nonSpace = /\S/,
  17840. trimRe = /^\s+|\s+$/g,
  17841. tplRe = /\{(\d+)\}/g,
  17842. modeRe = /^(\s?[\/>+~]\s?|\s|$)/,
  17843. tagTokenRe = /^(#)?([\w\-\*\\]+)/,
  17844. nthRe = /(\d*)n\+?(\d*)/,
  17845. nthRe2 = /\D/,
  17846. startIdRe = /^\s*\#/,
  17847. // This is for IE MSXML which does not support expandos.
  17848. // IE runs the same speed using setAttribute, however FF slows way down
  17849. // and Safari completely fails so they need to continue to use expandos.
  17850. isIE = window.ActiveXObject ? true : false,
  17851. key = 30803,
  17852. longHex = /\\([0-9a-fA-F]{6})/g,
  17853. shortHex = /\\([0-9a-fA-F]{1,6})\s{0,1}/g,
  17854. nonHex = /\\([^0-9a-fA-F]{1})/g,
  17855. escapes = /\\/g,
  17856. num, hasEscapes,
  17857. // replaces a long hex regex match group with the appropriate ascii value
  17858. // $args indicate regex match pos
  17859. longHexToChar = function($0, $1) {
  17860. return String.fromCharCode(parseInt($1, 16));
  17861. },
  17862. // converts a shortHex regex match to the long form
  17863. shortToLongHex = function($0, $1) {
  17864. while ($1.length < 6) {
  17865. $1 = '0' + $1;
  17866. }
  17867. return '\\' + $1;
  17868. },
  17869. // converts a single char escape to long escape form
  17870. charToLongHex = function($0, $1) {
  17871. num = $1.charCodeAt(0).toString(16);
  17872. if (num.length === 1) {
  17873. num = '0' + num;
  17874. }
  17875. return '\\0000' + num;
  17876. },
  17877. // Un-escapes an input selector string. Assumes all escape sequences have been
  17878. // normalized to the css '\\0000##' 6-hex-digit style escape sequence :
  17879. // will not handle any other escape formats
  17880. unescapeCssSelector = function (selector) {
  17881. return (hasEscapes)
  17882. ? selector.replace(longHex, longHexToChar)
  17883. : selector;
  17884. },
  17885. // checks if the path has escaping & does any appropriate replacements
  17886. setupEscapes = function(path){
  17887. hasEscapes = (path.indexOf('\\') > -1);
  17888. if (hasEscapes) {
  17889. path = path
  17890. .replace(shortHex, shortToLongHex)
  17891. .replace(nonHex, charToLongHex)
  17892. .replace(escapes, '\\\\'); // double the '\' for js compilation
  17893. }
  17894. return path;
  17895. };
  17896. // this eval is stop the compressor from
  17897. // renaming the variable to something shorter
  17898. eval("var batch = 30803;");
  17899. // Retrieve the child node from a particular
  17900. // parent at the specified index.
  17901. function child(parent, index){
  17902. var i = 0,
  17903. n = parent.firstChild;
  17904. while(n){
  17905. if(n.nodeType == 1){
  17906. if(++i == index){
  17907. return n;
  17908. }
  17909. }
  17910. n = n.nextSibling;
  17911. }
  17912. return null;
  17913. }
  17914. // retrieve the next element node
  17915. function next(n){
  17916. while((n = n.nextSibling) && n.nodeType != 1);
  17917. return n;
  17918. }
  17919. // retrieve the previous element node
  17920. function prev(n){
  17921. while((n = n.previousSibling) && n.nodeType != 1);
  17922. return n;
  17923. }
  17924. // Mark each child node with a nodeIndex skipping and
  17925. // removing empty text nodes.
  17926. function children(parent){
  17927. var n = parent.firstChild,
  17928. nodeIndex = -1,
  17929. nextNode;
  17930. while(n){
  17931. nextNode = n.nextSibling;
  17932. // clean worthless empty nodes.
  17933. if(n.nodeType == 3 && !nonSpace.test(n.nodeValue)){
  17934. parent.removeChild(n);
  17935. }else{
  17936. // add an expando nodeIndex
  17937. n.nodeIndex = ++nodeIndex;
  17938. }
  17939. n = nextNode;
  17940. }
  17941. return this;
  17942. }
  17943. // nodeSet - array of nodes
  17944. // cls - CSS Class
  17945. function byClassName(nodeSet, cls){
  17946. cls = unescapeCssSelector(cls);
  17947. if(!cls){
  17948. return nodeSet;
  17949. }
  17950. var result = [], ri = -1,
  17951. i, ci;
  17952. for(i = 0, ci; ci = nodeSet[i]; i++){
  17953. if((' '+ci.className+' ').indexOf(cls) != -1){
  17954. result[++ri] = ci;
  17955. }
  17956. }
  17957. return result;
  17958. }
  17959. function attrValue(n, attr){
  17960. // if its an array, use the first node.
  17961. if(!n.tagName && typeof n.length != "undefined"){
  17962. n = n[0];
  17963. }
  17964. if(!n){
  17965. return null;
  17966. }
  17967. if(attr == "for"){
  17968. return n.htmlFor;
  17969. }
  17970. if(attr == "class" || attr == "className"){
  17971. return n.className;
  17972. }
  17973. return n.getAttribute(attr) || n[attr];
  17974. }
  17975. // ns - nodes
  17976. // mode - false, /, >, +, ~
  17977. // tagName - defaults to "*"
  17978. function getNodes(ns, mode, tagName){
  17979. var result = [], ri = -1, cs,
  17980. i, ni, j, ci, cn, utag, n, cj;
  17981. if(!ns){
  17982. return result;
  17983. }
  17984. tagName = tagName || "*";
  17985. // convert to array
  17986. if(typeof ns.getElementsByTagName != "undefined"){
  17987. ns = [ns];
  17988. }
  17989. // no mode specified, grab all elements by tagName
  17990. // at any depth
  17991. if(!mode){
  17992. for(i = 0, ni; ni = ns[i]; i++){
  17993. cs = ni.getElementsByTagName(tagName);
  17994. for(j = 0, ci; ci = cs[j]; j++){
  17995. result[++ri] = ci;
  17996. }
  17997. }
  17998. // Direct Child mode (/ or >)
  17999. // E > F or E/F all direct children elements of E that have the tag
  18000. } else if(mode == "/" || mode == ">"){
  18001. utag = tagName.toUpperCase();
  18002. for(i = 0, ni, cn; ni = ns[i]; i++){
  18003. cn = ni.childNodes;
  18004. for(j = 0, cj; cj = cn[j]; j++){
  18005. if(cj.nodeName == utag || cj.nodeName == tagName || tagName == '*'){
  18006. result[++ri] = cj;
  18007. }
  18008. }
  18009. }
  18010. // Immediately Preceding mode (+)
  18011. // E + F all elements with the tag F that are immediately preceded by an element with the tag E
  18012. }else if(mode == "+"){
  18013. utag = tagName.toUpperCase();
  18014. for(i = 0, n; n = ns[i]; i++){
  18015. while((n = n.nextSibling) && n.nodeType != 1);
  18016. if(n && (n.nodeName == utag || n.nodeName == tagName || tagName == '*')){
  18017. result[++ri] = n;
  18018. }
  18019. }
  18020. // Sibling mode (~)
  18021. // E ~ F all elements with the tag F that are preceded by a sibling element with the tag E
  18022. }else if(mode == "~"){
  18023. utag = tagName.toUpperCase();
  18024. for(i = 0, n; n = ns[i]; i++){
  18025. while((n = n.nextSibling)){
  18026. if (n.nodeName == utag || n.nodeName == tagName || tagName == '*'){
  18027. result[++ri] = n;
  18028. }
  18029. }
  18030. }
  18031. }
  18032. return result;
  18033. }
  18034. function concat(a, b){
  18035. if(b.slice){
  18036. return a.concat(b);
  18037. }
  18038. for(var i = 0, l = b.length; i < l; i++){
  18039. a[a.length] = b[i];
  18040. }
  18041. return a;
  18042. }
  18043. function byTag(cs, tagName){
  18044. if(cs.tagName || cs == document){
  18045. cs = [cs];
  18046. }
  18047. if(!tagName){
  18048. return cs;
  18049. }
  18050. var result = [], ri = -1,
  18051. i, ci;
  18052. tagName = tagName.toLowerCase();
  18053. for(i = 0, ci; ci = cs[i]; i++){
  18054. if(ci.nodeType == 1 && ci.tagName.toLowerCase() == tagName){
  18055. result[++ri] = ci;
  18056. }
  18057. }
  18058. return result;
  18059. }
  18060. function byId(cs, id){
  18061. id = unescapeCssSelector(id);
  18062. if(cs.tagName || cs == document){
  18063. cs = [cs];
  18064. }
  18065. if(!id){
  18066. return cs;
  18067. }
  18068. var result = [], ri = -1,
  18069. i, ci;
  18070. for(i = 0, ci; ci = cs[i]; i++){
  18071. if(ci && ci.id == id){
  18072. result[++ri] = ci;
  18073. return result;
  18074. }
  18075. }
  18076. return result;
  18077. }
  18078. // operators are =, !=, ^=, $=, *=, %=, |= and ~=
  18079. // custom can be "{"
  18080. function byAttribute(cs, attr, value, op, custom){
  18081. var result = [],
  18082. ri = -1,
  18083. useGetStyle = custom == "{",
  18084. fn = Ext.DomQuery.operators[op],
  18085. a,
  18086. xml,
  18087. hasXml,
  18088. i, ci;
  18089. value = unescapeCssSelector(value);
  18090. for(i = 0, ci; ci = cs[i]; i++){
  18091. // skip non-element nodes.
  18092. if(ci.nodeType != 1){
  18093. continue;
  18094. }
  18095. // only need to do this for the first node
  18096. if(!hasXml){
  18097. xml = Ext.DomQuery.isXml(ci);
  18098. hasXml = true;
  18099. }
  18100. // we only need to change the property names if we're dealing with html nodes, not XML
  18101. if(!xml){
  18102. if(useGetStyle){
  18103. a = Ext.DomQuery.getStyle(ci, attr);
  18104. } else if (attr == "class" || attr == "className"){
  18105. a = ci.className;
  18106. } else if (attr == "for"){
  18107. a = ci.htmlFor;
  18108. } else if (attr == "href"){
  18109. // getAttribute href bug
  18110. // http://www.glennjones.net/Post/809/getAttributehrefbug.htm
  18111. a = ci.getAttribute("href", 2);
  18112. } else{
  18113. a = ci.getAttribute(attr);
  18114. }
  18115. }else{
  18116. a = ci.getAttribute(attr);
  18117. }
  18118. if((fn && fn(a, value)) || (!fn && a)){
  18119. result[++ri] = ci;
  18120. }
  18121. }
  18122. return result;
  18123. }
  18124. function byPseudo(cs, name, value){
  18125. value = unescapeCssSelector(value);
  18126. return Ext.DomQuery.pseudos[name](cs, value);
  18127. }
  18128. function nodupIEXml(cs){
  18129. var d = ++key,
  18130. r,
  18131. i, len, c;
  18132. cs[0].setAttribute("_nodup", d);
  18133. r = [cs[0]];
  18134. for(i = 1, len = cs.length; i < len; i++){
  18135. c = cs[i];
  18136. if(!c.getAttribute("_nodup") != d){
  18137. c.setAttribute("_nodup", d);
  18138. r[r.length] = c;
  18139. }
  18140. }
  18141. for(i = 0, len = cs.length; i < len; i++){
  18142. cs[i].removeAttribute("_nodup");
  18143. }
  18144. return r;
  18145. }
  18146. function nodup(cs){
  18147. if(!cs){
  18148. return [];
  18149. }
  18150. var len = cs.length, c, i, r = cs, cj, ri = -1, d, j;
  18151. if(!len || typeof cs.nodeType != "undefined" || len == 1){
  18152. return cs;
  18153. }
  18154. if(isIE && typeof cs[0].selectSingleNode != "undefined"){
  18155. return nodupIEXml(cs);
  18156. }
  18157. d = ++key;
  18158. cs[0]._nodup = d;
  18159. for(i = 1; c = cs[i]; i++){
  18160. if(c._nodup != d){
  18161. c._nodup = d;
  18162. }else{
  18163. r = [];
  18164. for(j = 0; j < i; j++){
  18165. r[++ri] = cs[j];
  18166. }
  18167. for(j = i+1; cj = cs[j]; j++){
  18168. if(cj._nodup != d){
  18169. cj._nodup = d;
  18170. r[++ri] = cj;
  18171. }
  18172. }
  18173. return r;
  18174. }
  18175. }
  18176. return r;
  18177. }
  18178. function quickDiffIEXml(c1, c2){
  18179. var d = ++key,
  18180. r = [],
  18181. i, len;
  18182. for(i = 0, len = c1.length; i < len; i++){
  18183. c1[i].setAttribute("_qdiff", d);
  18184. }
  18185. for(i = 0, len = c2.length; i < len; i++){
  18186. if(c2[i].getAttribute("_qdiff") != d){
  18187. r[r.length] = c2[i];
  18188. }
  18189. }
  18190. for(i = 0, len = c1.length; i < len; i++){
  18191. c1[i].removeAttribute("_qdiff");
  18192. }
  18193. return r;
  18194. }
  18195. function quickDiff(c1, c2){
  18196. var len1 = c1.length,
  18197. d = ++key,
  18198. r = [],
  18199. i, len;
  18200. if(!len1){
  18201. return c2;
  18202. }
  18203. if(isIE && typeof c1[0].selectSingleNode != "undefined"){
  18204. return quickDiffIEXml(c1, c2);
  18205. }
  18206. for(i = 0; i < len1; i++){
  18207. c1[i]._qdiff = d;
  18208. }
  18209. for(i = 0, len = c2.length; i < len; i++){
  18210. if(c2[i]._qdiff != d){
  18211. r[r.length] = c2[i];
  18212. }
  18213. }
  18214. return r;
  18215. }
  18216. function quickId(ns, mode, root, id){
  18217. if(ns == root){
  18218. id = unescapeCssSelector(id);
  18219. var d = root.ownerDocument || root;
  18220. return d.getElementById(id);
  18221. }
  18222. ns = getNodes(ns, mode, "*");
  18223. return byId(ns, id);
  18224. }
  18225. return {
  18226. getStyle : function(el, name){
  18227. return Ext.fly(el).getStyle(name);
  18228. },
  18229. /**
  18230. * Compiles a selector/xpath query into a reusable function. The returned function
  18231. * takes one parameter "root" (optional), which is the context node from where the query should start.
  18232. * @param {String} selector The selector/xpath query
  18233. * @param {String} [type="select"] Either "select" or "simple" for a simple selector match
  18234. * @return {Function}
  18235. */
  18236. compile : function(path, type){
  18237. type = type || "select";
  18238. // setup fn preamble
  18239. var fn = ["var f = function(root){\n var mode; ++batch; var n = root || document;\n"],
  18240. mode,
  18241. lastPath,
  18242. matchers = Ext.DomQuery.matchers,
  18243. matchersLn = matchers.length,
  18244. modeMatch,
  18245. // accept leading mode switch
  18246. lmode = path.match(modeRe),
  18247. tokenMatch, matched, j, t, m;
  18248. path = setupEscapes(path);
  18249. if(lmode && lmode[1]){
  18250. fn[fn.length] = 'mode="'+lmode[1].replace(trimRe, "")+'";';
  18251. path = path.replace(lmode[1], "");
  18252. }
  18253. // strip leading slashes
  18254. while(path.substr(0, 1)=="/"){
  18255. path = path.substr(1);
  18256. }
  18257. while(path && lastPath != path){
  18258. lastPath = path;
  18259. tokenMatch = path.match(tagTokenRe);
  18260. if(type == "select"){
  18261. if(tokenMatch){
  18262. // ID Selector
  18263. if(tokenMatch[1] == "#"){
  18264. fn[fn.length] = 'n = quickId(n, mode, root, "'+tokenMatch[2]+'");';
  18265. }else{
  18266. fn[fn.length] = 'n = getNodes(n, mode, "'+tokenMatch[2]+'");';
  18267. }
  18268. path = path.replace(tokenMatch[0], "");
  18269. }else if(path.substr(0, 1) != '@'){
  18270. fn[fn.length] = 'n = getNodes(n, mode, "*");';
  18271. }
  18272. // type of "simple"
  18273. }else{
  18274. if(tokenMatch){
  18275. if(tokenMatch[1] == "#"){
  18276. fn[fn.length] = 'n = byId(n, "'+tokenMatch[2]+'");';
  18277. }else{
  18278. fn[fn.length] = 'n = byTag(n, "'+tokenMatch[2]+'");';
  18279. }
  18280. path = path.replace(tokenMatch[0], "");
  18281. }
  18282. }
  18283. while(!(modeMatch = path.match(modeRe))){
  18284. matched = false;
  18285. for(j = 0; j < matchersLn; j++){
  18286. t = matchers[j];
  18287. m = path.match(t.re);
  18288. if(m){
  18289. fn[fn.length] = t.select.replace(tplRe, function(x, i){
  18290. return m[i];
  18291. });
  18292. path = path.replace(m[0], "");
  18293. matched = true;
  18294. break;
  18295. }
  18296. }
  18297. // prevent infinite loop on bad selector
  18298. if(!matched){
  18299. Ext.Error.raise({
  18300. sourceClass: 'Ext.DomQuery',
  18301. sourceMethod: 'compile',
  18302. msg: 'Error parsing selector. Parsing failed at "' + path + '"'
  18303. });
  18304. }
  18305. }
  18306. if(modeMatch[1]){
  18307. fn[fn.length] = 'mode="'+modeMatch[1].replace(trimRe, "")+'";';
  18308. path = path.replace(modeMatch[1], "");
  18309. }
  18310. }
  18311. // close fn out
  18312. fn[fn.length] = "return nodup(n);\n}";
  18313. // eval fn and return it
  18314. eval(fn.join(""));
  18315. return f;
  18316. },
  18317. /**
  18318. * Selects an array of DOM nodes using JavaScript-only implementation.
  18319. *
  18320. * Use {@link #select} to take advantage of browsers built-in support for CSS selectors.
  18321. * @param {String} selector The selector/xpath query (can be a comma separated list of selectors)
  18322. * @param {HTMLElement/String} [root=document] The start of the query.
  18323. * @return {HTMLElement[]} An Array of DOM elements which match the selector. If there are
  18324. * no matches, and empty Array is returned.
  18325. */
  18326. jsSelect: function(path, root, type){
  18327. // set root to doc if not specified.
  18328. root = root || document;
  18329. if(typeof root == "string"){
  18330. root = document.getElementById(root);
  18331. }
  18332. var paths = path.split(","),
  18333. results = [],
  18334. i, len, subPath, result;
  18335. // loop over each selector
  18336. for(i = 0, len = paths.length; i < len; i++){
  18337. subPath = paths[i].replace(trimRe, "");
  18338. // compile and place in cache
  18339. if(!cache[subPath]){
  18340. // When we compile, escaping is handled inside the compile method
  18341. cache[subPath] = Ext.DomQuery.compile(subPath, type);
  18342. if(!cache[subPath]){
  18343. Ext.Error.raise({
  18344. sourceClass: 'Ext.DomQuery',
  18345. sourceMethod: 'jsSelect',
  18346. msg: subPath + ' is not a valid selector'
  18347. });
  18348. }
  18349. } else {
  18350. // If we've already compiled, we still need to check if the
  18351. // selector has escaping and setup the appropriate flags
  18352. setupEscapes(subPath);
  18353. }
  18354. result = cache[subPath](root);
  18355. if(result && result != document){
  18356. results = results.concat(result);
  18357. }
  18358. }
  18359. // if there were multiple selectors, make sure dups
  18360. // are eliminated
  18361. if(paths.length > 1){
  18362. return nodup(results);
  18363. }
  18364. return results;
  18365. },
  18366. isXml: function(el) {
  18367. var docEl = (el ? el.ownerDocument || el : 0).documentElement;
  18368. return docEl ? docEl.nodeName !== "HTML" : false;
  18369. },
  18370. /**
  18371. * Selects an array of DOM nodes by CSS/XPath selector.
  18372. *
  18373. * Uses [document.querySelectorAll][0] if browser supports that, otherwise falls back to
  18374. * {@link Ext.dom.Query#jsSelect} to do the work.
  18375. *
  18376. * Aliased as {@link Ext#query}.
  18377. *
  18378. * [0]: https://developer.mozilla.org/en/DOM/document.querySelectorAll
  18379. *
  18380. * @param {String} path The selector/xpath query
  18381. * @param {HTMLElement} [root=document] The start of the query.
  18382. * @return {HTMLElement[]} An array of DOM elements (not a NodeList as returned by `querySelectorAll`).
  18383. * @param {String} [type="select"] Either "select" or "simple" for a simple selector match (only valid when
  18384. * used when the call is deferred to the jsSelect method)
  18385. * @method
  18386. */
  18387. select : document.querySelectorAll ? function(path, root, type) {
  18388. root = root || document;
  18389. if (!Ext.DomQuery.isXml(root)) {
  18390. try {
  18391. /*
  18392. * This checking here is to "fix" the behaviour of querySelectorAll
  18393. * for non root document queries. The way qsa works is intentional,
  18394. * however it's definitely not the expected way it should work.
  18395. * When descendant selectors are used, only the lowest selector must be inside the root!
  18396. * More info: http://ejohn.org/blog/thoughts-on-queryselectorall/
  18397. * So we create a descendant selector by prepending the root's ID, and query the parent node.
  18398. * UNLESS the root has no parent in which qsa will work perfectly.
  18399. *
  18400. * We only modify the path for single selectors (ie, no multiples),
  18401. * without a full parser it makes it difficult to do this correctly.
  18402. */
  18403. if (root.parentNode && (root.nodeType !== 9) && path.indexOf(',') === -1 && !startIdRe.test(path)) {
  18404. path = '#' + Ext.escapeId(Ext.id(root)) + ' ' + path;
  18405. root = root.parentNode;
  18406. }
  18407. return Ext.Array.toArray(root.querySelectorAll(path));
  18408. }
  18409. catch (e) {
  18410. }
  18411. }
  18412. return Ext.DomQuery.jsSelect.call(this, path, root, type);
  18413. } : function(path, root, type) {
  18414. return Ext.DomQuery.jsSelect.call(this, path, root, type);
  18415. },
  18416. /**
  18417. * Selects a single element.
  18418. * @param {String} selector The selector/xpath query
  18419. * @param {HTMLElement} [root=document] The start of the query.
  18420. * @return {HTMLElement} The DOM element which matched the selector.
  18421. */
  18422. selectNode : function(path, root){
  18423. return Ext.DomQuery.select(path, root)[0];
  18424. },
  18425. /**
  18426. * Selects the value of a node, optionally replacing null with the defaultValue.
  18427. * @param {String} selector The selector/xpath query
  18428. * @param {HTMLElement} [root=document] The start of the query.
  18429. * @param {String} [defaultValue] When specified, this is return as empty value.
  18430. * @return {String}
  18431. */
  18432. selectValue : function(path, root, defaultValue){
  18433. path = path.replace(trimRe, "");
  18434. if (!valueCache[path]) {
  18435. valueCache[path] = Ext.DomQuery.compile(path, "select");
  18436. } else {
  18437. setupEscapes(path);
  18438. }
  18439. var n = valueCache[path](root),
  18440. v;
  18441. n = n[0] ? n[0] : n;
  18442. // overcome a limitation of maximum textnode size
  18443. // Rumored to potentially crash IE6 but has not been confirmed.
  18444. // http://reference.sitepoint.com/javascript/Node/normalize
  18445. // https://developer.mozilla.org/En/DOM/Node.normalize
  18446. if (typeof n.normalize == 'function') {
  18447. n.normalize();
  18448. }
  18449. v = (n && n.firstChild ? n.firstChild.nodeValue : null);
  18450. return ((v === null||v === undefined||v==='') ? defaultValue : v);
  18451. },
  18452. /**
  18453. * Selects the value of a node, parsing integers and floats.
  18454. * Returns the defaultValue, or 0 if none is specified.
  18455. * @param {String} selector The selector/xpath query
  18456. * @param {HTMLElement} [root=document] The start of the query.
  18457. * @param {Number} [defaultValue] When specified, this is return as empty value.
  18458. * @return {Number}
  18459. */
  18460. selectNumber : function(path, root, defaultValue){
  18461. var v = Ext.DomQuery.selectValue(path, root, defaultValue || 0);
  18462. return parseFloat(v);
  18463. },
  18464. /**
  18465. * Returns true if the passed element(s) match the passed simple selector
  18466. * (e.g. `div.some-class` or `span:first-child`)
  18467. * @param {String/HTMLElement/HTMLElement[]} el An element id, element or array of elements
  18468. * @param {String} selector The simple selector to test
  18469. * @return {Boolean}
  18470. */
  18471. is : function(el, ss){
  18472. if(typeof el == "string"){
  18473. el = document.getElementById(el);
  18474. }
  18475. var isArray = Ext.isArray(el),
  18476. result = Ext.DomQuery.filter(isArray ? el : [el], ss);
  18477. return isArray ? (result.length == el.length) : (result.length > 0);
  18478. },
  18479. /**
  18480. * Filters an array of elements to only include matches of a simple selector
  18481. * (e.g. `div.some-class` or `span:first-child`)
  18482. * @param {HTMLElement[]} el An array of elements to filter
  18483. * @param {String} selector The simple selector to test
  18484. * @param {Boolean} nonMatches If true, it returns the elements that DON'T match the selector instead of the
  18485. * ones that match
  18486. * @return {HTMLElement[]} An Array of DOM elements which match the selector. If there are no matches, and empty
  18487. * Array is returned.
  18488. */
  18489. filter : function(els, ss, nonMatches){
  18490. ss = ss.replace(trimRe, "");
  18491. if (!simpleCache[ss]) {
  18492. simpleCache[ss] = Ext.DomQuery.compile(ss, "simple");
  18493. } else {
  18494. setupEscapes(ss);
  18495. }
  18496. var result = simpleCache[ss](els);
  18497. return nonMatches ? quickDiff(result, els) : result;
  18498. },
  18499. /**
  18500. * Collection of matching regular expressions and code snippets.
  18501. * Each capture group within `()` will be replace the `{}` in the select
  18502. * statement as specified by their index.
  18503. */
  18504. matchers : [{
  18505. re: /^\.([\w\-\\]+)/,
  18506. select: 'n = byClassName(n, " {1} ");'
  18507. }, {
  18508. re: /^\:([\w\-]+)(?:\(((?:[^\s>\/]*|.*?))\))?/,
  18509. select: 'n = byPseudo(n, "{1}", "{2}");'
  18510. },{
  18511. re: /^(?:([\[\{])(?:@)?([\w\-]+)\s?(?:(=|.=)\s?['"]?(.*?)["']?)?[\]\}])/,
  18512. select: 'n = byAttribute(n, "{2}", "{4}", "{3}", "{1}");'
  18513. }, {
  18514. re: /^#([\w\-\\]+)/,
  18515. select: 'n = byId(n, "{1}");'
  18516. },{
  18517. re: /^@([\w\-]+)/,
  18518. select: 'return {firstChild:{nodeValue:attrValue(n, "{1}")}};'
  18519. }
  18520. ],
  18521. /**
  18522. * Collection of operator comparison functions.
  18523. * The default operators are `=`, `!=`, `^=`, `$=`, `*=`, `%=`, `|=` and `~=`.
  18524. * New operators can be added as long as the match the format *c*`=` where *c*
  18525. * is any character other than space, `>`, or `<`.
  18526. */
  18527. operators : {
  18528. "=" : function(a, v){
  18529. return a == v;
  18530. },
  18531. "!=" : function(a, v){
  18532. return a != v;
  18533. },
  18534. "^=" : function(a, v){
  18535. return a && a.substr(0, v.length) == v;
  18536. },
  18537. "$=" : function(a, v){
  18538. return a && a.substr(a.length-v.length) == v;
  18539. },
  18540. "*=" : function(a, v){
  18541. return a && a.indexOf(v) !== -1;
  18542. },
  18543. "%=" : function(a, v){
  18544. return (a % v) == 0;
  18545. },
  18546. "|=" : function(a, v){
  18547. return a && (a == v || a.substr(0, v.length+1) == v+'-');
  18548. },
  18549. "~=" : function(a, v){
  18550. return a && (' '+a+' ').indexOf(' '+v+' ') != -1;
  18551. }
  18552. },
  18553. /**
  18554. * Object hash of "pseudo class" filter functions which are used when filtering selections.
  18555. * Each function is passed two parameters:
  18556. *
  18557. * - **c** : Array
  18558. * An Array of DOM elements to filter.
  18559. *
  18560. * - **v** : String
  18561. * The argument (if any) supplied in the selector.
  18562. *
  18563. * A filter function returns an Array of DOM elements which conform to the pseudo class.
  18564. * In addition to the provided pseudo classes listed above such as `first-child` and `nth-child`,
  18565. * developers may add additional, custom psuedo class filters to select elements according to application-specific requirements.
  18566. *
  18567. * For example, to filter `a` elements to only return links to __external__ resources:
  18568. *
  18569. * Ext.DomQuery.pseudos.external = function(c, v){
  18570. * var r = [], ri = -1;
  18571. * for(var i = 0, ci; ci = c[i]; i++){
  18572. * // Include in result set only if it's a link to an external resource
  18573. * if(ci.hostname != location.hostname){
  18574. * r[++ri] = ci;
  18575. * }
  18576. * }
  18577. * return r;
  18578. * };
  18579. *
  18580. * Then external links could be gathered with the following statement:
  18581. *
  18582. * var externalLinks = Ext.select("a:external");
  18583. */
  18584. pseudos : {
  18585. "first-child" : function(c){
  18586. var r = [], ri = -1, n,
  18587. i, ci;
  18588. for(i = 0; (ci = n = c[i]); i++){
  18589. while((n = n.previousSibling) && n.nodeType != 1);
  18590. if(!n){
  18591. r[++ri] = ci;
  18592. }
  18593. }
  18594. return r;
  18595. },
  18596. "last-child" : function(c){
  18597. var r = [], ri = -1, n,
  18598. i, ci;
  18599. for(i = 0; (ci = n = c[i]); i++){
  18600. while((n = n.nextSibling) && n.nodeType != 1);
  18601. if(!n){
  18602. r[++ri] = ci;
  18603. }
  18604. }
  18605. return r;
  18606. },
  18607. "nth-child" : function(c, a) {
  18608. var r = [], ri = -1,
  18609. m = nthRe.exec(a == "even" && "2n" || a == "odd" && "2n+1" || !nthRe2.test(a) && "n+" + a || a),
  18610. f = (m[1] || 1) - 0, l = m[2] - 0,
  18611. i, n, j, cn, pn;
  18612. for(i = 0; n = c[i]; i++){
  18613. pn = n.parentNode;
  18614. if (batch != pn._batch) {
  18615. j = 0;
  18616. for(cn = pn.firstChild; cn; cn = cn.nextSibling){
  18617. if(cn.nodeType == 1){
  18618. cn.nodeIndex = ++j;
  18619. }
  18620. }
  18621. pn._batch = batch;
  18622. }
  18623. if (f == 1) {
  18624. if (l == 0 || n.nodeIndex == l){
  18625. r[++ri] = n;
  18626. }
  18627. } else if ((n.nodeIndex + l) % f == 0){
  18628. r[++ri] = n;
  18629. }
  18630. }
  18631. return r;
  18632. },
  18633. "only-child" : function(c){
  18634. var r = [], ri = -1,
  18635. i, ci;
  18636. for(i = 0; ci = c[i]; i++){
  18637. if(!prev(ci) && !next(ci)){
  18638. r[++ri] = ci;
  18639. }
  18640. }
  18641. return r;
  18642. },
  18643. "empty" : function(c){
  18644. var r = [], ri = -1,
  18645. i, ci, cns, j, cn, empty;
  18646. for(i = 0, ci; ci = c[i]; i++){
  18647. cns = ci.childNodes;
  18648. j = 0;
  18649. empty = true;
  18650. while(cn = cns[j]){
  18651. ++j;
  18652. if(cn.nodeType == 1 || cn.nodeType == 3){
  18653. empty = false;
  18654. break;
  18655. }
  18656. }
  18657. if(empty){
  18658. r[++ri] = ci;
  18659. }
  18660. }
  18661. return r;
  18662. },
  18663. "contains" : function(c, v){
  18664. var r = [], ri = -1,
  18665. i, ci;
  18666. for(i = 0; ci = c[i]; i++){
  18667. if((ci.textContent||ci.innerText||ci.text||'').indexOf(v) != -1){
  18668. r[++ri] = ci;
  18669. }
  18670. }
  18671. return r;
  18672. },
  18673. "nodeValue" : function(c, v){
  18674. var r = [], ri = -1,
  18675. i, ci;
  18676. for(i = 0; ci = c[i]; i++){
  18677. if(ci.firstChild && ci.firstChild.nodeValue == v){
  18678. r[++ri] = ci;
  18679. }
  18680. }
  18681. return r;
  18682. },
  18683. "checked" : function(c){
  18684. var r = [], ri = -1,
  18685. i, ci;
  18686. for(i = 0; ci = c[i]; i++){
  18687. if(ci.checked == true){
  18688. r[++ri] = ci;
  18689. }
  18690. }
  18691. return r;
  18692. },
  18693. "not" : function(c, ss){
  18694. return Ext.DomQuery.filter(c, ss, true);
  18695. },
  18696. "any" : function(c, selectors){
  18697. var ss = selectors.split('|'),
  18698. r = [], ri = -1, s,
  18699. i, ci, j;
  18700. for(i = 0; ci = c[i]; i++){
  18701. for(j = 0; s = ss[j]; j++){
  18702. if(Ext.DomQuery.is(ci, s)){
  18703. r[++ri] = ci;
  18704. break;
  18705. }
  18706. }
  18707. }
  18708. return r;
  18709. },
  18710. "odd" : function(c){
  18711. return this["nth-child"](c, "odd");
  18712. },
  18713. "even" : function(c){
  18714. return this["nth-child"](c, "even");
  18715. },
  18716. "nth" : function(c, a){
  18717. return c[a-1] || [];
  18718. },
  18719. "first" : function(c){
  18720. return c[0] || [];
  18721. },
  18722. "last" : function(c){
  18723. return c[c.length-1] || [];
  18724. },
  18725. "has" : function(c, ss){
  18726. var s = Ext.DomQuery.select,
  18727. r = [], ri = -1,
  18728. i, ci;
  18729. for(i = 0; ci = c[i]; i++){
  18730. if(s(ss, ci).length > 0){
  18731. r[++ri] = ci;
  18732. }
  18733. }
  18734. return r;
  18735. },
  18736. "next" : function(c, ss){
  18737. var is = Ext.DomQuery.is,
  18738. r = [], ri = -1,
  18739. i, ci, n;
  18740. for(i = 0; ci = c[i]; i++){
  18741. n = next(ci);
  18742. if(n && is(n, ss)){
  18743. r[++ri] = ci;
  18744. }
  18745. }
  18746. return r;
  18747. },
  18748. "prev" : function(c, ss){
  18749. var is = Ext.DomQuery.is,
  18750. r = [], ri = -1,
  18751. i, ci, n;
  18752. for(i = 0; ci = c[i]; i++){
  18753. n = prev(ci);
  18754. if(n && is(n, ss)){
  18755. r[++ri] = ci;
  18756. }
  18757. }
  18758. return r;
  18759. }
  18760. }
  18761. };
  18762. }());
  18763. /**
  18764. * Shorthand of {@link Ext.dom.Query#select}
  18765. * @member Ext
  18766. * @method query
  18767. * @inheritdoc Ext.dom.Query#select
  18768. */
  18769. Ext.query = Ext.DomQuery.select;
  18770. //@tag dom,core
  18771. //@require Query.js
  18772. //@define Ext.dom.Element
  18773. //@require Ext.dom.AbstractElement
  18774. /**
  18775. * @class Ext.dom.Element
  18776. * @alternateClassName Ext.Element
  18777. * @alternateClassName Ext.core.Element
  18778. * @extend Ext.dom.AbstractElement
  18779. *
  18780. * Encapsulates a DOM element, adding simple DOM manipulation facilities, normalizing for browser differences.
  18781. *
  18782. * All instances of this class inherit the methods of {@link Ext.fx.Anim} making visual effects easily available to all
  18783. * DOM elements.
  18784. *
  18785. * Note that the events documented in this class are not Ext events, they encapsulate browser events. Some older browsers
  18786. * may not support the full range of events. Which events are supported is beyond the control of Ext JS.
  18787. *
  18788. * Usage:
  18789. *
  18790. * // by id
  18791. * var el = Ext.get("my-div");
  18792. *
  18793. * // by DOM element reference
  18794. * var el = Ext.get(myDivElement);
  18795. *
  18796. * # Animations
  18797. *
  18798. * When an element is manipulated, by default there is no animation.
  18799. *
  18800. * var el = Ext.get("my-div");
  18801. *
  18802. * // no animation
  18803. * el.setWidth(100);
  18804. *
  18805. * Many of the functions for manipulating an element have an optional "animate" parameter. This parameter can be
  18806. * specified as boolean (true) for default animation effects.
  18807. *
  18808. * // default animation
  18809. * el.setWidth(100, true);
  18810. *
  18811. * To configure the effects, an object literal with animation options to use as the Element animation configuration
  18812. * object can also be specified. Note that the supported Element animation configuration options are a subset of the
  18813. * {@link Ext.fx.Anim} animation options specific to Fx effects. The supported Element animation configuration options
  18814. * are:
  18815. *
  18816. * Option Default Description
  18817. * --------- -------- ---------------------------------------------
  18818. * {@link Ext.fx.Anim#duration duration} 350 The duration of the animation in milliseconds
  18819. * {@link Ext.fx.Anim#easing easing} easeOut The easing method
  18820. * {@link Ext.fx.Anim#callback callback} none A function to execute when the anim completes
  18821. * {@link Ext.fx.Anim#scope scope} this The scope (this) of the callback function
  18822. *
  18823. * Usage:
  18824. *
  18825. * // Element animation options object
  18826. * var opt = {
  18827. * {@link Ext.fx.Anim#duration duration}: 1000,
  18828. * {@link Ext.fx.Anim#easing easing}: 'elasticIn',
  18829. * {@link Ext.fx.Anim#callback callback}: this.foo,
  18830. * {@link Ext.fx.Anim#scope scope}: this
  18831. * };
  18832. * // animation with some options set
  18833. * el.setWidth(100, opt);
  18834. *
  18835. * The Element animation object being used for the animation will be set on the options object as "anim", which allows
  18836. * you to stop or manipulate the animation. Here is an example:
  18837. *
  18838. * // using the "anim" property to get the Anim object
  18839. * if(opt.anim.isAnimated()){
  18840. * opt.anim.stop();
  18841. * }
  18842. *
  18843. * # Composite (Collections of) Elements
  18844. *
  18845. * For working with collections of Elements, see {@link Ext.CompositeElement}
  18846. *
  18847. * @constructor
  18848. * Creates new Element directly.
  18849. * @param {String/HTMLElement} element
  18850. * @param {Boolean} [forceNew] By default the constructor checks to see if there is already an instance of this
  18851. * element in the cache and if there is it returns the same instance. This will skip that check (useful for extending
  18852. * this class).
  18853. * @return {Object}
  18854. */
  18855. (function() {
  18856. var HIDDEN = 'hidden',
  18857. DOC = document,
  18858. VISIBILITY = "visibility",
  18859. DISPLAY = "display",
  18860. NONE = "none",
  18861. XMASKED = Ext.baseCSSPrefix + "masked",
  18862. XMASKEDRELATIVE = Ext.baseCSSPrefix + "masked-relative",
  18863. EXTELMASKMSG = Ext.baseCSSPrefix + "mask-msg",
  18864. bodyRe = /^body/i,
  18865. visFly,
  18866. // speedy lookup for elements never to box adjust
  18867. noBoxAdjust = Ext.isStrict ? {
  18868. select: 1
  18869. }: {
  18870. input: 1,
  18871. select: 1,
  18872. textarea: 1
  18873. },
  18874. // Pseudo for use by cacheScrollValues
  18875. isScrolled = function(c) {
  18876. var r = [], ri = -1,
  18877. i, ci;
  18878. for (i = 0; ci = c[i]; i++) {
  18879. if (ci.scrollTop > 0 || ci.scrollLeft > 0) {
  18880. r[++ri] = ci;
  18881. }
  18882. }
  18883. return r;
  18884. },
  18885. Element = Ext.define('Ext.dom.Element', {
  18886. extend: 'Ext.dom.AbstractElement',
  18887. alternateClassName: ['Ext.Element', 'Ext.core.Element'],
  18888. addUnits: function() {
  18889. return this.self.addUnits.apply(this.self, arguments);
  18890. },
  18891. /**
  18892. * Tries to focus the element. Any exceptions are caught and ignored.
  18893. * @param {Number} [defer] Milliseconds to defer the focus
  18894. * @return {Ext.dom.Element} this
  18895. */
  18896. focus: function(defer, /* private */ dom) {
  18897. var me = this,
  18898. scrollTop,
  18899. body;
  18900. dom = dom || me.dom;
  18901. body = (dom.ownerDocument || DOC).body || DOC.body;
  18902. try {
  18903. if (Number(defer)) {
  18904. Ext.defer(me.focus, defer, me, [null, dom]);
  18905. } else {
  18906. // Focusing a large element, the browser attempts to scroll as much of it into view
  18907. // as possible. We need to override this behaviour.
  18908. if (dom.offsetHeight > Element.getViewHeight()) {
  18909. scrollTop = body.scrollTop;
  18910. }
  18911. dom.focus();
  18912. if (scrollTop !== undefined) {
  18913. body.scrollTop = scrollTop;
  18914. }
  18915. }
  18916. } catch(e) {
  18917. }
  18918. return me;
  18919. },
  18920. /**
  18921. * Tries to blur the element. Any exceptions are caught and ignored.
  18922. * @return {Ext.dom.Element} this
  18923. */
  18924. blur: function() {
  18925. try {
  18926. this.dom.blur();
  18927. } catch(e) {
  18928. }
  18929. return this;
  18930. },
  18931. /**
  18932. * Tests various css rules/browsers to determine if this element uses a border box
  18933. * @return {Boolean}
  18934. */
  18935. isBorderBox: function() {
  18936. var box = Ext.isBorderBox;
  18937. if (box) {
  18938. box = !((this.dom.tagName || "").toLowerCase() in noBoxAdjust);
  18939. }
  18940. return box;
  18941. },
  18942. /**
  18943. * Sets up event handlers to call the passed functions when the mouse is moved into and out of the Element.
  18944. * @param {Function} overFn The function to call when the mouse enters the Element.
  18945. * @param {Function} outFn The function to call when the mouse leaves the Element.
  18946. * @param {Object} [scope] The scope (`this` reference) in which the functions are executed. Defaults
  18947. * to the Element's DOM element.
  18948. * @param {Object} [options] Options for the listener. See {@link Ext.util.Observable#addListener the
  18949. * options parameter}.
  18950. * @return {Ext.dom.Element} this
  18951. */
  18952. hover: function(overFn, outFn, scope, options) {
  18953. var me = this;
  18954. me.on('mouseenter', overFn, scope || me.dom, options);
  18955. me.on('mouseleave', outFn, scope || me.dom, options);
  18956. return me;
  18957. },
  18958. /**
  18959. * Returns the value of a namespaced attribute from the element's underlying DOM node.
  18960. * @param {String} namespace The namespace in which to look for the attribute
  18961. * @param {String} name The attribute name
  18962. * @return {String} The attribute value
  18963. */
  18964. getAttributeNS: function(ns, name) {
  18965. return this.getAttribute(name, ns);
  18966. },
  18967. getAttribute: (Ext.isIE && !(Ext.isIE9 && DOC.documentMode === 9)) ?
  18968. function(name, ns) {
  18969. var d = this.dom,
  18970. type;
  18971. if (ns) {
  18972. type = typeof d[ns + ":" + name];
  18973. if (type != 'undefined' && type != 'unknown') {
  18974. return d[ns + ":" + name] || null;
  18975. }
  18976. return null;
  18977. }
  18978. if (name === "for") {
  18979. name = "htmlFor";
  18980. }
  18981. return d[name] || null;
  18982. } : function(name, ns) {
  18983. var d = this.dom;
  18984. if (ns) {
  18985. return d.getAttributeNS(ns, name) || d.getAttribute(ns + ":" + name);
  18986. }
  18987. return d.getAttribute(name) || d[name] || null;
  18988. },
  18989. /**
  18990. * When an element is moved around in the DOM, or is hidden using `display:none`, it loses layout, and therefore
  18991. * all scroll positions of all descendant elements are lost.
  18992. *
  18993. * This function caches them, and returns a function, which when run will restore the cached positions.
  18994. * In the following example, the Panel is moved from one Container to another which will cause it to lose all scroll positions:
  18995. *
  18996. * var restoreScroll = myPanel.el.cacheScrollValues();
  18997. * myOtherContainer.add(myPanel);
  18998. * restoreScroll();
  18999. *
  19000. * @return {Function} A function which will restore all descentant elements of this Element to their scroll
  19001. * positions recorded when this function was executed. Be aware that the returned function is a closure which has
  19002. * captured the scope of `cacheScrollValues`, so take care to derefence it as soon as not needed - if is it is a `var`
  19003. * it will drop out of scope, and the reference will be freed.
  19004. */
  19005. cacheScrollValues: function() {
  19006. var me = this,
  19007. scrolledDescendants,
  19008. el, i,
  19009. scrollValues = [],
  19010. result = function() {
  19011. for (i = 0; i < scrolledDescendants.length; i++) {
  19012. el = scrolledDescendants[i];
  19013. el.scrollLeft = scrollValues[i][0];
  19014. el.scrollTop = scrollValues[i][1];
  19015. }
  19016. };
  19017. if (!Ext.DomQuery.pseudos.isScrolled) {
  19018. Ext.DomQuery.pseudos.isScrolled = isScrolled;
  19019. }
  19020. scrolledDescendants = me.query(':isScrolled');
  19021. for (i = 0; i < scrolledDescendants.length; i++) {
  19022. el = scrolledDescendants[i];
  19023. scrollValues[i] = [el.scrollLeft, el.scrollTop];
  19024. }
  19025. return result;
  19026. },
  19027. /**
  19028. * @property {Boolean} autoBoxAdjust
  19029. * True to automatically adjust width and height settings for box-model issues.
  19030. */
  19031. autoBoxAdjust: true,
  19032. /**
  19033. * Checks whether the element is currently visible using both visibility and display properties.
  19034. * @param {Boolean} [deep=false] True to walk the dom and see if parent elements are hidden.
  19035. * If false, the function only checks the visibility of the element itself and it may return
  19036. * `true` even though a parent is not visible.
  19037. * @return {Boolean} `true` if the element is currently visible, else `false`
  19038. */
  19039. isVisible : function(deep) {
  19040. var me = this,
  19041. dom = me.dom,
  19042. stopNode = dom.ownerDocument.documentElement;
  19043. if (!visFly) {
  19044. visFly = new Element.Fly();
  19045. }
  19046. while (dom !== stopNode) {
  19047. // We're invisible if we hit a nonexistent parentNode or a document
  19048. // fragment or computed style visibility:hidden or display:none
  19049. if (!dom || dom.nodeType === 11 || (visFly.attach(dom)).isStyle(VISIBILITY, HIDDEN) || visFly.isStyle(DISPLAY, NONE)) {
  19050. return false;
  19051. }
  19052. // Quit now unless we are being asked to check parent nodes.
  19053. if (!deep) {
  19054. break;
  19055. }
  19056. dom = dom.parentNode;
  19057. }
  19058. return true;
  19059. },
  19060. /**
  19061. * Returns true if display is not "none"
  19062. * @return {Boolean}
  19063. */
  19064. isDisplayed : function() {
  19065. return !this.isStyle(DISPLAY, NONE);
  19066. },
  19067. /**
  19068. * Convenience method for setVisibilityMode(Element.DISPLAY)
  19069. * @param {String} [display] What to set display to when visible
  19070. * @return {Ext.dom.Element} this
  19071. */
  19072. enableDisplayMode : function(display) {
  19073. var me = this;
  19074. me.setVisibilityMode(Element.DISPLAY);
  19075. if (!Ext.isEmpty(display)) {
  19076. (me.$cache || me.getCache()).data.originalDisplay = display;
  19077. }
  19078. return me;
  19079. },
  19080. /**
  19081. * Puts a mask over this element to disable user interaction. Requires core.css.
  19082. * This method can only be applied to elements which accept child nodes.
  19083. * @param {String} [msg] A message to display in the mask
  19084. * @param {String} [msgCls] A css class to apply to the msg element
  19085. * @return {Ext.dom.Element} The mask element
  19086. */
  19087. mask : function(msg, msgCls /* private - passed by AbstractComponent.mask to avoid the need to interrogate the DOM to get the height*/, elHeight) {
  19088. var me = this,
  19089. dom = me.dom,
  19090. // In some cases, setExpression will exist but not be of a function type,
  19091. // so we check it explicitly here to stop IE throwing errors
  19092. setExpression = dom.style.setExpression,
  19093. data = (me.$cache || me.getCache()).data,
  19094. maskEl = data.maskEl,
  19095. maskMsg = data.maskMsg;
  19096. if (!(bodyRe.test(dom.tagName) && me.getStyle('position') == 'static')) {
  19097. me.addCls(XMASKEDRELATIVE);
  19098. }
  19099. // We always needs to recreate the mask since the DOM element may have been re-created
  19100. if (maskEl) {
  19101. maskEl.remove();
  19102. }
  19103. if (maskMsg) {
  19104. maskMsg.remove();
  19105. }
  19106. Ext.DomHelper.append(dom, [{
  19107. cls : Ext.baseCSSPrefix + "mask"
  19108. }, {
  19109. cls : msgCls ? EXTELMASKMSG + " " + msgCls : EXTELMASKMSG,
  19110. cn : {
  19111. tag: 'div',
  19112. html: msg || ''
  19113. }
  19114. }]);
  19115. maskMsg = Ext.get(dom.lastChild);
  19116. maskEl = Ext.get(maskMsg.dom.previousSibling);
  19117. data.maskMsg = maskMsg;
  19118. data.maskEl = maskEl;
  19119. me.addCls(XMASKED);
  19120. maskEl.setDisplayed(true);
  19121. if (typeof msg == 'string') {
  19122. maskMsg.setDisplayed(true);
  19123. maskMsg.center(me);
  19124. } else {
  19125. maskMsg.setDisplayed(false);
  19126. }
  19127. // NOTE: CSS expressions are resource intensive and to be used only as a last resort
  19128. // These expressions are removed as soon as they are no longer necessary - in the unmask method.
  19129. // In normal use cases an element will be masked for a limited period of time.
  19130. // Fix for https://sencha.jira.com/browse/EXTJSIV-19.
  19131. // IE6 strict mode and IE6-9 quirks mode takes off left+right padding when calculating width!
  19132. if (!Ext.supports.IncludePaddingInWidthCalculation && setExpression) {
  19133. // In an occasional case setExpression will throw an exception
  19134. try {
  19135. maskEl.dom.style.setExpression('width', 'this.parentNode.clientWidth + "px"');
  19136. } catch (e) {}
  19137. }
  19138. // Some versions and modes of IE subtract top+bottom padding when calculating height.
  19139. // Different versions from those which make the same error for width!
  19140. if (!Ext.supports.IncludePaddingInHeightCalculation && setExpression) {
  19141. // In an occasional case setExpression will throw an exception
  19142. try {
  19143. maskEl.dom.style.setExpression('height', 'this.parentNode.' + (dom == DOC.body ? 'scrollHeight' : 'offsetHeight') + ' + "px"');
  19144. } catch (e) {}
  19145. }
  19146. // ie will not expand full height automatically
  19147. else if (Ext.isIE && !(Ext.isIE7 && Ext.isStrict) && me.getStyle('height') == 'auto') {
  19148. maskEl.setSize(undefined, elHeight || me.getHeight());
  19149. }
  19150. return maskEl;
  19151. },
  19152. /**
  19153. * Hides a previously applied mask.
  19154. */
  19155. unmask : function() {
  19156. var me = this,
  19157. data = (me.$cache || me.getCache()).data,
  19158. maskEl = data.maskEl,
  19159. maskMsg = data.maskMsg,
  19160. style;
  19161. if (maskEl) {
  19162. style = maskEl.dom.style;
  19163. // Remove resource-intensive CSS expressions as soon as they are not required.
  19164. if (style.clearExpression) {
  19165. style.clearExpression('width');
  19166. style.clearExpression('height');
  19167. }
  19168. if (maskEl) {
  19169. maskEl.remove();
  19170. delete data.maskEl;
  19171. }
  19172. if (maskMsg) {
  19173. maskMsg.remove();
  19174. delete data.maskMsg;
  19175. }
  19176. me.removeCls([XMASKED, XMASKEDRELATIVE]);
  19177. }
  19178. },
  19179. /**
  19180. * Returns true if this element is masked. Also re-centers any displayed message within the mask.
  19181. * @return {Boolean}
  19182. */
  19183. isMasked : function() {
  19184. var me = this,
  19185. data = (me.$cache || me.getCache()).data,
  19186. maskEl = data.maskEl,
  19187. maskMsg = data.maskMsg,
  19188. hasMask = false;
  19189. if (maskEl && maskEl.isVisible()) {
  19190. if (maskMsg) {
  19191. maskMsg.center(me);
  19192. }
  19193. hasMask = true;
  19194. }
  19195. return hasMask;
  19196. },
  19197. /**
  19198. * Creates an iframe shim for this element to keep selects and other windowed objects from
  19199. * showing through.
  19200. * @return {Ext.dom.Element} The new shim element
  19201. */
  19202. createShim : function() {
  19203. var el = DOC.createElement('iframe'),
  19204. shim;
  19205. el.frameBorder = '0';
  19206. el.className = Ext.baseCSSPrefix + 'shim';
  19207. el.src = Ext.SSL_SECURE_URL;
  19208. shim = Ext.get(this.dom.parentNode.insertBefore(el, this.dom));
  19209. shim.autoBoxAdjust = false;
  19210. return shim;
  19211. },
  19212. /**
  19213. * Convenience method for constructing a KeyMap
  19214. * @param {String/Number/Number[]/Object} key Either a string with the keys to listen for, the numeric key code,
  19215. * array of key codes or an object with the following options:
  19216. * @param {Number/Array} key.key
  19217. * @param {Boolean} key.shift
  19218. * @param {Boolean} key.ctrl
  19219. * @param {Boolean} key.alt
  19220. * @param {Function} fn The function to call
  19221. * @param {Object} [scope] The scope (`this` reference) in which the specified function is executed. Defaults to this Element.
  19222. * @return {Ext.util.KeyMap} The KeyMap created
  19223. */
  19224. addKeyListener : function(key, fn, scope){
  19225. var config;
  19226. if(typeof key != 'object' || Ext.isArray(key)){
  19227. config = {
  19228. target: this,
  19229. key: key,
  19230. fn: fn,
  19231. scope: scope
  19232. };
  19233. }else{
  19234. config = {
  19235. target: this,
  19236. key : key.key,
  19237. shift : key.shift,
  19238. ctrl : key.ctrl,
  19239. alt : key.alt,
  19240. fn: fn,
  19241. scope: scope
  19242. };
  19243. }
  19244. return new Ext.util.KeyMap(config);
  19245. },
  19246. /**
  19247. * Creates a KeyMap for this element
  19248. * @param {Object} config The KeyMap config. See {@link Ext.util.KeyMap} for more details
  19249. * @return {Ext.util.KeyMap} The KeyMap created
  19250. */
  19251. addKeyMap : function(config) {
  19252. return new Ext.util.KeyMap(Ext.apply({
  19253. target: this
  19254. }, config));
  19255. },
  19256. // Mouse events
  19257. /**
  19258. * @event click
  19259. * Fires when a mouse click is detected within the element.
  19260. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  19261. * @param {HTMLElement} t The target of the event.
  19262. */
  19263. /**
  19264. * @event contextmenu
  19265. * Fires when a right click is detected within the element.
  19266. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  19267. * @param {HTMLElement} t The target of the event.
  19268. */
  19269. /**
  19270. * @event dblclick
  19271. * Fires when a mouse double click is detected within the element.
  19272. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  19273. * @param {HTMLElement} t The target of the event.
  19274. */
  19275. /**
  19276. * @event mousedown
  19277. * Fires when a mousedown is detected within the element.
  19278. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  19279. * @param {HTMLElement} t The target of the event.
  19280. */
  19281. /**
  19282. * @event mouseup
  19283. * Fires when a mouseup is detected within the element.
  19284. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  19285. * @param {HTMLElement} t The target of the event.
  19286. */
  19287. /**
  19288. * @event mouseover
  19289. * Fires when a mouseover is detected within the element.
  19290. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  19291. * @param {HTMLElement} t The target of the event.
  19292. */
  19293. /**
  19294. * @event mousemove
  19295. * Fires when a mousemove is detected with the element.
  19296. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  19297. * @param {HTMLElement} t The target of the event.
  19298. */
  19299. /**
  19300. * @event mouseout
  19301. * Fires when a mouseout is detected with the element.
  19302. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  19303. * @param {HTMLElement} t The target of the event.
  19304. */
  19305. /**
  19306. * @event mouseenter
  19307. * Fires when the mouse enters the element.
  19308. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  19309. * @param {HTMLElement} t The target of the event.
  19310. */
  19311. /**
  19312. * @event mouseleave
  19313. * Fires when the mouse leaves the element.
  19314. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  19315. * @param {HTMLElement} t The target of the event.
  19316. */
  19317. // Keyboard events
  19318. /**
  19319. * @event keypress
  19320. * Fires when a keypress is detected within the element.
  19321. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  19322. * @param {HTMLElement} t The target of the event.
  19323. */
  19324. /**
  19325. * @event keydown
  19326. * Fires when a keydown is detected within the element.
  19327. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  19328. * @param {HTMLElement} t The target of the event.
  19329. */
  19330. /**
  19331. * @event keyup
  19332. * Fires when a keyup is detected within the element.
  19333. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  19334. * @param {HTMLElement} t The target of the event.
  19335. */
  19336. // HTML frame/object events
  19337. /**
  19338. * @event load
  19339. * Fires when the user agent finishes loading all content within the element. Only supported by window, frames,
  19340. * objects and images.
  19341. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  19342. * @param {HTMLElement} t The target of the event.
  19343. */
  19344. /**
  19345. * @event unload
  19346. * Fires when the user agent removes all content from a window or frame. For elements, it fires when the target
  19347. * element or any of its content has been removed.
  19348. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  19349. * @param {HTMLElement} t The target of the event.
  19350. */
  19351. /**
  19352. * @event abort
  19353. * Fires when an object/image is stopped from loading before completely loaded.
  19354. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  19355. * @param {HTMLElement} t The target of the event.
  19356. */
  19357. /**
  19358. * @event error
  19359. * Fires when an object/image/frame cannot be loaded properly.
  19360. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  19361. * @param {HTMLElement} t The target of the event.
  19362. */
  19363. /**
  19364. * @event resize
  19365. * Fires when a document view is resized.
  19366. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  19367. * @param {HTMLElement} t The target of the event.
  19368. */
  19369. /**
  19370. * @event scroll
  19371. * Fires when a document view is scrolled.
  19372. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  19373. * @param {HTMLElement} t The target of the event.
  19374. */
  19375. // Form events
  19376. /**
  19377. * @event select
  19378. * Fires when a user selects some text in a text field, including input and textarea.
  19379. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  19380. * @param {HTMLElement} t The target of the event.
  19381. */
  19382. /**
  19383. * @event change
  19384. * Fires when a control loses the input focus and its value has been modified since gaining focus.
  19385. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  19386. * @param {HTMLElement} t The target of the event.
  19387. */
  19388. /**
  19389. * @event submit
  19390. * Fires when a form is submitted.
  19391. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  19392. * @param {HTMLElement} t The target of the event.
  19393. */
  19394. /**
  19395. * @event reset
  19396. * Fires when a form is reset.
  19397. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  19398. * @param {HTMLElement} t The target of the event.
  19399. */
  19400. /**
  19401. * @event focus
  19402. * Fires when an element receives focus either via the pointing device or by tab navigation.
  19403. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  19404. * @param {HTMLElement} t The target of the event.
  19405. */
  19406. /**
  19407. * @event blur
  19408. * Fires when an element loses focus either via the pointing device or by tabbing navigation.
  19409. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  19410. * @param {HTMLElement} t The target of the event.
  19411. */
  19412. // User Interface events
  19413. /**
  19414. * @event DOMFocusIn
  19415. * Where supported. Similar to HTML focus event, but can be applied to any focusable element.
  19416. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  19417. * @param {HTMLElement} t The target of the event.
  19418. */
  19419. /**
  19420. * @event DOMFocusOut
  19421. * Where supported. Similar to HTML blur event, but can be applied to any focusable element.
  19422. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  19423. * @param {HTMLElement} t The target of the event.
  19424. */
  19425. /**
  19426. * @event DOMActivate
  19427. * Where supported. Fires when an element is activated, for instance, through a mouse click or a keypress.
  19428. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  19429. * @param {HTMLElement} t The target of the event.
  19430. */
  19431. // DOM Mutation events
  19432. /**
  19433. * @event DOMSubtreeModified
  19434. * Where supported. Fires when the subtree is modified.
  19435. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  19436. * @param {HTMLElement} t The target of the event.
  19437. */
  19438. /**
  19439. * @event DOMNodeInserted
  19440. * Where supported. Fires when a node has been added as a child of another node.
  19441. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  19442. * @param {HTMLElement} t The target of the event.
  19443. */
  19444. /**
  19445. * @event DOMNodeRemoved
  19446. * Where supported. Fires when a descendant node of the element is removed.
  19447. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  19448. * @param {HTMLElement} t The target of the event.
  19449. */
  19450. /**
  19451. * @event DOMNodeRemovedFromDocument
  19452. * Where supported. Fires when a node is being removed from a document.
  19453. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  19454. * @param {HTMLElement} t The target of the event.
  19455. */
  19456. /**
  19457. * @event DOMNodeInsertedIntoDocument
  19458. * Where supported. Fires when a node is being inserted into a document.
  19459. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  19460. * @param {HTMLElement} t The target of the event.
  19461. */
  19462. /**
  19463. * @event DOMAttrModified
  19464. * Where supported. Fires when an attribute has been modified.
  19465. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  19466. * @param {HTMLElement} t The target of the event.
  19467. */
  19468. /**
  19469. * @event DOMCharacterDataModified
  19470. * Where supported. Fires when the character data has been modified.
  19471. * @param {Ext.EventObject} e The {@link Ext.EventObject} encapsulating the DOM event.
  19472. * @param {HTMLElement} t The target of the event.
  19473. */
  19474. /**
  19475. * Appends an event handler to this element.
  19476. *
  19477. * @param {String} eventName The name of event to handle.
  19478. *
  19479. * @param {Function} fn The handler function the event invokes. This function is passed the following parameters:
  19480. *
  19481. * - **evt** : EventObject
  19482. *
  19483. * The {@link Ext.EventObject EventObject} describing the event.
  19484. *
  19485. * - **el** : HtmlElement
  19486. *
  19487. * The DOM element which was the target of the event. Note that this may be filtered by using the delegate option.
  19488. *
  19489. * - **o** : Object
  19490. *
  19491. * The options object from the call that setup the listener.
  19492. *
  19493. * @param {Object} scope (optional) The scope (**this** reference) in which the handler function is executed. **If
  19494. * omitted, defaults to this Element.**
  19495. *
  19496. * @param {Object} options (optional) An object containing handler configuration properties. This may contain any of
  19497. * the following properties:
  19498. *
  19499. * - **scope** Object :
  19500. *
  19501. * The scope (**this** reference) in which the handler function is executed. **If omitted, defaults to this
  19502. * Element.**
  19503. *
  19504. * - **delegate** String:
  19505. *
  19506. * A simple selector to filter the target or look for a descendant of the target. See below for additional details.
  19507. *
  19508. * - **stopEvent** Boolean:
  19509. *
  19510. * True to stop the event. That is stop propagation, and prevent the default action.
  19511. *
  19512. * - **preventDefault** Boolean:
  19513. *
  19514. * True to prevent the default action
  19515. *
  19516. * - **stopPropagation** Boolean:
  19517. *
  19518. * True to prevent event propagation
  19519. *
  19520. * - **normalized** Boolean:
  19521. *
  19522. * False to pass a browser event to the handler function instead of an Ext.EventObject
  19523. *
  19524. * - **target** Ext.dom.Element:
  19525. *
  19526. * Only call the handler if the event was fired on the target Element, _not_ if the event was bubbled up from a
  19527. * child node.
  19528. *
  19529. * - **delay** Number:
  19530. *
  19531. * The number of milliseconds to delay the invocation of the handler after the event fires.
  19532. *
  19533. * - **single** Boolean:
  19534. *
  19535. * True to add a handler to handle just the next firing of the event, and then remove itself.
  19536. *
  19537. * - **buffer** Number:
  19538. *
  19539. * Causes the handler to be scheduled to run in an {@link Ext.util.DelayedTask} delayed by the specified number of
  19540. * milliseconds. If the event fires again within that time, the original handler is _not_ invoked, but the new
  19541. * handler is scheduled in its place.
  19542. *
  19543. * **Combining Options**
  19544. *
  19545. * Using the options argument, it is possible to combine different types of listeners:
  19546. *
  19547. * A delayed, one-time listener that auto stops the event and adds a custom argument (forumId) to the options
  19548. * object. The options object is available as the third parameter in the handler function.
  19549. *
  19550. * Code:
  19551. *
  19552. * el.on('click', this.onClick, this, {
  19553. * single: true,
  19554. * delay: 100,
  19555. * stopEvent : true,
  19556. * forumId: 4
  19557. * });
  19558. *
  19559. * **Attaching multiple handlers in 1 call**
  19560. *
  19561. * The method also allows for a single argument to be passed which is a config object containing properties which
  19562. * specify multiple handlers.
  19563. *
  19564. * Code:
  19565. *
  19566. * el.on({
  19567. * 'click' : {
  19568. * fn: this.onClick,
  19569. * scope: this,
  19570. * delay: 100
  19571. * },
  19572. * 'mouseover' : {
  19573. * fn: this.onMouseOver,
  19574. * scope: this
  19575. * },
  19576. * 'mouseout' : {
  19577. * fn: this.onMouseOut,
  19578. * scope: this
  19579. * }
  19580. * });
  19581. *
  19582. * Or a shorthand syntax:
  19583. *
  19584. * Code:
  19585. *
  19586. * el.on({
  19587. * 'click' : this.onClick,
  19588. * 'mouseover' : this.onMouseOver,
  19589. * 'mouseout' : this.onMouseOut,
  19590. * scope: this
  19591. * });
  19592. *
  19593. * **delegate**
  19594. *
  19595. * This is a configuration option that you can pass along when registering a handler for an event to assist with
  19596. * event delegation. Event delegation is a technique that is used to reduce memory consumption and prevent exposure
  19597. * to memory-leaks. By registering an event for a container element as opposed to each element within a container.
  19598. * By setting this configuration option to a simple selector, the target element will be filtered to look for a
  19599. * descendant of the target. For example:
  19600. *
  19601. * // using this markup:
  19602. * <div id='elId'>
  19603. * <p id='p1'>paragraph one</p>
  19604. * <p id='p2' class='clickable'>paragraph two</p>
  19605. * <p id='p3'>paragraph three</p>
  19606. * </div>
  19607. *
  19608. * // utilize event delegation to registering just one handler on the container element:
  19609. * el = Ext.get('elId');
  19610. * el.on(
  19611. * 'click',
  19612. * function(e,t) {
  19613. * // handle click
  19614. * console.info(t.id); // 'p2'
  19615. * },
  19616. * this,
  19617. * {
  19618. * // filter the target element to be a descendant with the class 'clickable'
  19619. * delegate: '.clickable'
  19620. * }
  19621. * );
  19622. *
  19623. * @return {Ext.dom.Element} this
  19624. */
  19625. on: function(eventName, fn, scope, options) {
  19626. Ext.EventManager.on(this, eventName, fn, scope || this, options);
  19627. return this;
  19628. },
  19629. /**
  19630. * Removes an event handler from this element.
  19631. *
  19632. * **Note**: if a *scope* was explicitly specified when {@link #on adding} the listener,
  19633. * the same scope must be specified here.
  19634. *
  19635. * Example:
  19636. *
  19637. * el.un('click', this.handlerFn);
  19638. * // or
  19639. * el.removeListener('click', this.handlerFn);
  19640. *
  19641. * @param {String} eventName The name of the event from which to remove the handler.
  19642. * @param {Function} fn The handler function to remove. **This must be a reference to the function passed into the
  19643. * {@link #on} call.**
  19644. * @param {Object} scope If a scope (**this** reference) was specified when the listener was added, then this must
  19645. * refer to the same object.
  19646. * @return {Ext.dom.Element} this
  19647. */
  19648. un: function(eventName, fn, scope) {
  19649. Ext.EventManager.un(this, eventName, fn, scope || this);
  19650. return this;
  19651. },
  19652. /**
  19653. * Removes all previous added listeners from this element
  19654. * @return {Ext.dom.Element} this
  19655. */
  19656. removeAllListeners: function() {
  19657. Ext.EventManager.removeAll(this);
  19658. return this;
  19659. },
  19660. /**
  19661. * Recursively removes all previous added listeners from this element and its children
  19662. * @return {Ext.dom.Element} this
  19663. */
  19664. purgeAllListeners: function() {
  19665. Ext.EventManager.purgeElement(this);
  19666. return this;
  19667. }
  19668. }, function() {
  19669. var EC = Ext.cache,
  19670. El = this,
  19671. AbstractElement = Ext.dom.AbstractElement,
  19672. focusRe = /a|button|embed|iframe|img|input|object|select|textarea/i,
  19673. nonSpaceRe = /\S/,
  19674. scriptTagRe = /(?:<script([^>]*)?>)((\n|\r|.)*?)(?:<\/script>)/ig,
  19675. replaceScriptTagRe = /(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)/ig,
  19676. srcRe = /\ssrc=([\'\"])(.*?)\1/i,
  19677. typeRe = /\stype=([\'\"])(.*?)\1/i,
  19678. useDocForId = !(Ext.isIE6 || Ext.isIE7 || Ext.isIE8);
  19679. 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>';
  19680. //</!if>
  19681. // private
  19682. // Garbage collection - uncache elements/purge listeners on orphaned elements
  19683. // so we don't hold a reference and cause the browser to retain them
  19684. function garbageCollect() {
  19685. if (!Ext.enableGarbageCollector) {
  19686. clearInterval(El.collectorThreadId);
  19687. } else {
  19688. var eid,
  19689. d,
  19690. o,
  19691. t;
  19692. for (eid in EC) {
  19693. if (!EC.hasOwnProperty(eid)) {
  19694. continue;
  19695. }
  19696. o = EC[eid];
  19697. // Skip document and window elements
  19698. if (o.skipGarbageCollection) {
  19699. continue;
  19700. }
  19701. d = o.dom;
  19702. // -------------------------------------------------------
  19703. // Determining what is garbage:
  19704. // -------------------------------------------------------
  19705. // !d.parentNode
  19706. // no parentNode == direct orphan, definitely garbage
  19707. // -------------------------------------------------------
  19708. // !d.offsetParent && !document.getElementById(eid)
  19709. // display none elements have no offsetParent so we will
  19710. // also try to look it up by it's id. However, check
  19711. // offsetParent first so we don't do unneeded lookups.
  19712. // This enables collection of elements that are not orphans
  19713. // directly, but somewhere up the line they have an orphan
  19714. // parent.
  19715. // -------------------------------------------------------
  19716. if (!d.parentNode || (!d.offsetParent && !Ext.getElementById(eid))) {
  19717. if (d && Ext.enableListenerCollection) {
  19718. Ext.EventManager.removeAll(d);
  19719. }
  19720. delete EC[eid];
  19721. }
  19722. }
  19723. // Cleanup IE Object leaks
  19724. if (Ext.isIE) {
  19725. t = {};
  19726. for (eid in EC) {
  19727. if (!EC.hasOwnProperty(eid)) {
  19728. continue;
  19729. }
  19730. t[eid] = EC[eid];
  19731. }
  19732. EC = Ext.cache = t;
  19733. }
  19734. }
  19735. }
  19736. El.collectorThreadId = setInterval(garbageCollect, 30000);
  19737. //Stuff from Element-more.js
  19738. El.addMethods({
  19739. /**
  19740. * Monitors this Element for the mouse leaving. Calls the function after the specified delay only if
  19741. * the mouse was not moved back into the Element within the delay. If the mouse *was* moved
  19742. * back in, the function is not called.
  19743. * @param {Number} delay The delay **in milliseconds** to wait for possible mouse re-entry before calling the handler function.
  19744. * @param {Function} handler The function to call if the mouse remains outside of this Element for the specified time.
  19745. * @param {Object} [scope] The scope (`this` reference) in which the handler function executes. Defaults to this Element.
  19746. * @return {Object} The listeners object which was added to this element so that monitoring can be stopped. Example usage:
  19747. *
  19748. * // Hide the menu if the mouse moves out for 250ms or more
  19749. * this.mouseLeaveMonitor = this.menuEl.monitorMouseLeave(250, this.hideMenu, this);
  19750. *
  19751. * ...
  19752. * // Remove mouseleave monitor on menu destroy
  19753. * this.menuEl.un(this.mouseLeaveMonitor);
  19754. *
  19755. */
  19756. monitorMouseLeave: function(delay, handler, scope) {
  19757. var me = this,
  19758. timer,
  19759. listeners = {
  19760. mouseleave: function(e) {
  19761. timer = setTimeout(Ext.Function.bind(handler, scope||me, [e]), delay);
  19762. },
  19763. mouseenter: function() {
  19764. clearTimeout(timer);
  19765. },
  19766. freezeEvent: true
  19767. };
  19768. me.on(listeners);
  19769. return listeners;
  19770. },
  19771. /**
  19772. * Stops the specified event(s) from bubbling and optionally prevents the default action
  19773. * @param {String/String[]} eventName an event / array of events to stop from bubbling
  19774. * @param {Boolean} [preventDefault] true to prevent the default action too
  19775. * @return {Ext.dom.Element} this
  19776. */
  19777. swallowEvent : function(eventName, preventDefault) {
  19778. var me = this,
  19779. e, eLen;
  19780. function fn(e) {
  19781. e.stopPropagation();
  19782. if (preventDefault) {
  19783. e.preventDefault();
  19784. }
  19785. }
  19786. if (Ext.isArray(eventName)) {
  19787. eLen = eventName.length;
  19788. for (e = 0; e < eLen; e++) {
  19789. me.on(eventName[e], fn);
  19790. }
  19791. return me;
  19792. }
  19793. me.on(eventName, fn);
  19794. return me;
  19795. },
  19796. /**
  19797. * Create an event handler on this element such that when the event fires and is handled by this element,
  19798. * it will be relayed to another object (i.e., fired again as if it originated from that object instead).
  19799. * @param {String} eventName The type of event to relay
  19800. * @param {Object} observable Any object that extends {@link Ext.util.Observable} that will provide the context
  19801. * for firing the relayed event
  19802. */
  19803. relayEvent : function(eventName, observable) {
  19804. this.on(eventName, function(e) {
  19805. observable.fireEvent(eventName, e);
  19806. });
  19807. },
  19808. /**
  19809. * Removes Empty, or whitespace filled text nodes. Combines adjacent text nodes.
  19810. * @param {Boolean} [forceReclean=false] By default the element keeps track if it has been cleaned already
  19811. * so you can call this over and over. However, if you update the element and need to force a reclean, you
  19812. * can pass true.
  19813. */
  19814. clean : function(forceReclean) {
  19815. var me = this,
  19816. dom = me.dom,
  19817. data = (me.$cache || me.getCache()).data,
  19818. n = dom.firstChild,
  19819. ni = -1,
  19820. nx;
  19821. if (data.isCleaned && forceReclean !== true) {
  19822. return me;
  19823. }
  19824. while (n) {
  19825. nx = n.nextSibling;
  19826. if (n.nodeType == 3) {
  19827. // Remove empty/whitespace text nodes
  19828. if (!(nonSpaceRe.test(n.nodeValue))) {
  19829. dom.removeChild(n);
  19830. // Combine adjacent text nodes
  19831. } else if (nx && nx.nodeType == 3) {
  19832. n.appendData(Ext.String.trim(nx.data));
  19833. dom.removeChild(nx);
  19834. nx = n.nextSibling;
  19835. n.nodeIndex = ++ni;
  19836. }
  19837. } else {
  19838. // Recursively clean
  19839. Ext.fly(n).clean();
  19840. n.nodeIndex = ++ni;
  19841. }
  19842. n = nx;
  19843. }
  19844. data.isCleaned = true;
  19845. return me;
  19846. },
  19847. /**
  19848. * Direct access to the Ext.ElementLoader {@link Ext.ElementLoader#method-load} method. The method takes the same object
  19849. * parameter as {@link Ext.ElementLoader#method-load}
  19850. * @return {Ext.dom.Element} this
  19851. */
  19852. load : function(options) {
  19853. this.getLoader().load(options);
  19854. return this;
  19855. },
  19856. /**
  19857. * Gets this element's {@link Ext.ElementLoader ElementLoader}
  19858. * @return {Ext.ElementLoader} The loader
  19859. */
  19860. getLoader : function() {
  19861. var me = this,
  19862. data = (me.$cache || me.getCache()).data,
  19863. loader = data.loader;
  19864. if (!loader) {
  19865. data.loader = loader = new Ext.ElementLoader({
  19866. target: me
  19867. });
  19868. }
  19869. return loader;
  19870. },
  19871. /**
  19872. * @private.
  19873. * Currently used for updating grid cells without modifying DOM structure
  19874. *
  19875. * Synchronizes content of this Element with the content of the passed element.
  19876. *
  19877. * Style and CSS class are copied from source into this Element, and contents are synched
  19878. * recursively. If a child node is a text node, the textual data is copied.
  19879. */
  19880. syncContent: function(source) {
  19881. source = Ext.getDom(source);
  19882. var me = this,
  19883. sourceNodes = source.childNodes,
  19884. sourceLen = sourceNodes.length,
  19885. dest = me.dom,
  19886. destNodes = dest.childNodes,
  19887. destLen = destNodes.length,
  19888. i, destNode, sourceNode,
  19889. nodeType;
  19890. // Copy top node's style and CSS class
  19891. dest.style.cssText = source.style.cssText;
  19892. dest.className = source.className;
  19893. // If the number of child nodes does not match, fall back to replacing innerHTML
  19894. if (sourceLen !== destLen) {
  19895. source.innerHTML = dest.innerHTML;
  19896. return;
  19897. }
  19898. // Loop through source nodes.
  19899. // If there are fewer, we must remove excess
  19900. for (i = 0; i < sourceLen; i++) {
  19901. sourceNode = sourceNodes[i];
  19902. destNode = destNodes[i];
  19903. nodeType = sourceNode.nodeType;
  19904. // If node structure is out of sync, just drop innerHTML in and return
  19905. if (nodeType !== destNode.nodeType || (nodeType === 1 && sourceNode.tagName !== destNode.tagName)) {
  19906. dest.innerHTML = source.innerHTML;
  19907. return;
  19908. }
  19909. // Update text node
  19910. if (nodeType === 3) {
  19911. destNode.data = sourceNode.data;
  19912. }
  19913. // Sync element content
  19914. else {
  19915. if (sourceNode.id && destNode.id !== sourceNode.id) {
  19916. destNode.id = sourceNode.id;
  19917. }
  19918. destNode.style.cssText = sourceNode.style.cssText;
  19919. destNode.className = sourceNode.className;
  19920. Ext.fly(destNode).syncContent(sourceNode);
  19921. }
  19922. }
  19923. },
  19924. /**
  19925. * Updates the innerHTML of this element, optionally searching for and processing scripts.
  19926. * @param {String} html The new HTML
  19927. * @param {Boolean} [loadScripts] True to look for and process scripts (defaults to false)
  19928. * @param {Function} [callback] For async script loading you can be notified when the update completes
  19929. * @return {Ext.dom.Element} this
  19930. */
  19931. update : function(html, loadScripts, callback) {
  19932. var me = this,
  19933. id,
  19934. dom,
  19935. interval;
  19936. if (!me.dom) {
  19937. return me;
  19938. }
  19939. html = html || '';
  19940. dom = me.dom;
  19941. if (loadScripts !== true) {
  19942. dom.innerHTML = html;
  19943. Ext.callback(callback, me);
  19944. return me;
  19945. }
  19946. id = Ext.id();
  19947. html += '<span id="' + id + '"></span>';
  19948. interval = setInterval(function() {
  19949. var hd,
  19950. match,
  19951. attrs,
  19952. srcMatch,
  19953. typeMatch,
  19954. el,
  19955. s;
  19956. if (!(el = DOC.getElementById(id))) {
  19957. return false;
  19958. }
  19959. clearInterval(interval);
  19960. Ext.removeNode(el);
  19961. hd = Ext.getHead().dom;
  19962. while ((match = scriptTagRe.exec(html))) {
  19963. attrs = match[1];
  19964. srcMatch = attrs ? attrs.match(srcRe) : false;
  19965. if (srcMatch && srcMatch[2]) {
  19966. s = DOC.createElement("script");
  19967. s.src = srcMatch[2];
  19968. typeMatch = attrs.match(typeRe);
  19969. if (typeMatch && typeMatch[2]) {
  19970. s.type = typeMatch[2];
  19971. }
  19972. hd.appendChild(s);
  19973. } else if (match[2] && match[2].length > 0) {
  19974. if (window.execScript) {
  19975. window.execScript(match[2]);
  19976. } else {
  19977. window.eval(match[2]);
  19978. }
  19979. }
  19980. }
  19981. Ext.callback(callback, me);
  19982. }, 20);
  19983. dom.innerHTML = html.replace(replaceScriptTagRe, '');
  19984. return me;
  19985. },
  19986. // inherit docs, overridden so we can add removeAnchor
  19987. removeAllListeners : function() {
  19988. this.removeAnchor();
  19989. Ext.EventManager.removeAll(this.dom);
  19990. return this;
  19991. },
  19992. /**
  19993. * Creates a proxy element of this element
  19994. * @param {String/Object} config The class name of the proxy element or a DomHelper config object
  19995. * @param {String/HTMLElement} [renderTo] The element or element id to render the proxy to. Defaults to: document.body.
  19996. * @param {Boolean} [matchBox=false] True to align and size the proxy to this element now.
  19997. * @return {Ext.dom.Element} The new proxy element
  19998. */
  19999. createProxy : function(config, renderTo, matchBox) {
  20000. config = (typeof config == 'object') ? config : {tag : "div", cls: config};
  20001. var me = this,
  20002. proxy = renderTo ? Ext.DomHelper.append(renderTo, config, true) :
  20003. Ext.DomHelper.insertBefore(me.dom, config, true);
  20004. proxy.setVisibilityMode(Element.DISPLAY);
  20005. proxy.hide();
  20006. if (matchBox && me.setBox && me.getBox) { // check to make sure Element.position.js is loaded
  20007. proxy.setBox(me.getBox());
  20008. }
  20009. return proxy;
  20010. },
  20011. /**
  20012. * Gets the parent node of the current element taking into account Ext.scopeResetCSS
  20013. * @protected
  20014. * @return {HTMLElement} The parent element
  20015. */
  20016. getScopeParent: function() {
  20017. var parent = this.dom.parentNode;
  20018. if (Ext.scopeResetCSS) {
  20019. // If it's a normal reset, we will be wrapped in a single x-reset element, so grab the parent
  20020. parent = parent.parentNode;
  20021. if (!Ext.supports.CSS3LinearGradient || !Ext.supports.CSS3BorderRadius) {
  20022. // In the cases where we have nbr or nlg, it will be wrapped in a second element,
  20023. // so we need to go and get the parent again.
  20024. parent = parent.parentNode;
  20025. }
  20026. }
  20027. return parent;
  20028. },
  20029. /**
  20030. * Returns true if this element needs an explicit tabIndex to make it focusable. Input fields, text areas, buttons
  20031. * anchors elements **with an href** etc do not need a tabIndex, but structural elements do.
  20032. */
  20033. needsTabIndex: function() {
  20034. if (this.dom) {
  20035. if ((this.dom.nodeName === 'a') && (!this.dom.href)) {
  20036. return true;
  20037. }
  20038. return !focusRe.test(this.dom.nodeName);
  20039. }
  20040. },
  20041. /**
  20042. * Checks whether this element can be focused.
  20043. * @return {Boolean} True if the element is focusable
  20044. */
  20045. focusable: function () {
  20046. var dom = this.dom,
  20047. nodeName = dom.nodeName,
  20048. canFocus = false;
  20049. if (!dom.disabled) {
  20050. if (focusRe.test(nodeName)) {
  20051. if ((nodeName !== 'a') || dom.href) {
  20052. canFocus = true;
  20053. }
  20054. } else {
  20055. canFocus = !isNaN(dom.tabIndex);
  20056. }
  20057. }
  20058. return canFocus && this.isVisible(true);
  20059. }
  20060. });
  20061. if (Ext.isIE) {
  20062. El.prototype.getById = function (id, asDom) {
  20063. var dom = this.dom,
  20064. cacheItem, el, ret;
  20065. if (dom) {
  20066. // for normal elements getElementById is the best solution, but if the el is
  20067. // not part of the document.body, we need to use all[]
  20068. el = (useDocForId && DOC.getElementById(id)) || dom.all[id];
  20069. if (el) {
  20070. if (asDom) {
  20071. ret = el;
  20072. } else {
  20073. // calling El.get here is a real hit (2x slower) because it has to
  20074. // redetermine that we are giving it a dom el.
  20075. cacheItem = EC[id];
  20076. if (cacheItem && cacheItem.el) {
  20077. ret = Ext.updateCacheEntry(cacheItem, el).el;
  20078. } else {
  20079. ret = new Element(el);
  20080. }
  20081. }
  20082. return ret;
  20083. }
  20084. }
  20085. return asDom ? Ext.getDom(id) : El.get(id);
  20086. };
  20087. }
  20088. El.createAlias({
  20089. /**
  20090. * @method
  20091. * @inheritdoc Ext.dom.Element#on
  20092. * Shorthand for {@link #on}.
  20093. */
  20094. addListener: 'on',
  20095. /**
  20096. * @method
  20097. * @inheritdoc Ext.dom.Element#un
  20098. * Shorthand for {@link #un}.
  20099. */
  20100. removeListener: 'un',
  20101. /**
  20102. * @method
  20103. * @inheritdoc Ext.dom.Element#removeAllListeners
  20104. * Alias for {@link #removeAllListeners}.
  20105. */
  20106. clearListeners: 'removeAllListeners'
  20107. });
  20108. El.Fly = AbstractElement.Fly = new Ext.Class({
  20109. extend: El,
  20110. constructor: function(dom) {
  20111. this.dom = dom;
  20112. },
  20113. attach: AbstractElement.Fly.prototype.attach
  20114. });
  20115. if (Ext.isIE) {
  20116. Ext.getElementById = function (id) {
  20117. var el = DOC.getElementById(id),
  20118. detachedBodyEl;
  20119. if (!el && (detachedBodyEl = AbstractElement.detachedBodyEl)) {
  20120. el = detachedBodyEl.dom.all[id];
  20121. }
  20122. return el;
  20123. };
  20124. } else if (!DOC.querySelector) {
  20125. Ext.getDetachedBody = Ext.getBody;
  20126. Ext.getElementById = function (id) {
  20127. return DOC.getElementById(id);
  20128. };
  20129. }
  20130. });
  20131. }());
  20132. //@tag dom,core
  20133. //@require Element.js
  20134. //@define Ext.dom.Element-alignment
  20135. //@define Ext.dom.Element
  20136. /**
  20137. * @class Ext.dom.Element
  20138. */
  20139. Ext.dom.Element.override((function() {
  20140. var doc = document,
  20141. win = window,
  20142. alignRe = /^([a-z]+)-([a-z]+)(\?)?$/,
  20143. round = Math.round;
  20144. return {
  20145. /**
  20146. * Gets the x,y coordinates specified by the anchor position on the element.
  20147. * @param {String} [anchor='c'] The specified anchor position. See {@link #alignTo}
  20148. * for details on supported anchor positions.
  20149. * @param {Boolean} [local] True to get the local (element top/left-relative) anchor position instead
  20150. * of page coordinates
  20151. * @param {Object} [size] An object containing the size to use for calculating anchor position
  20152. * {width: (target width), height: (target height)} (defaults to the element's current size)
  20153. * @return {Number[]} [x, y] An array containing the element's x and y coordinates
  20154. */
  20155. getAnchorXY: function(anchor, local, mySize) {
  20156. //Passing a different size is useful for pre-calculating anchors,
  20157. //especially for anchored animations that change the el size.
  20158. anchor = (anchor || "tl").toLowerCase();
  20159. mySize = mySize || {};
  20160. var me = this,
  20161. isViewport = me.dom == doc.body || me.dom == doc,
  20162. myWidth = mySize.width || isViewport ? Ext.dom.Element.getViewWidth() : me.getWidth(),
  20163. myHeight = mySize.height || isViewport ? Ext.dom.Element.getViewHeight() : me.getHeight(),
  20164. xy,
  20165. myPos = me.getXY(),
  20166. scroll = me.getScroll(),
  20167. extraX = isViewport ? scroll.left : !local ? myPos[0] : 0,
  20168. extraY = isViewport ? scroll.top : !local ? myPos[1] : 0;
  20169. // Calculate anchor position.
  20170. // Test most common cases for picker alignment first.
  20171. switch (anchor) {
  20172. case 'tl' : xy = [ 0, 0];
  20173. break;
  20174. case 'bl' : xy = [ 0, myHeight];
  20175. break;
  20176. case 'tr' : xy = [ myWidth, 0];
  20177. break;
  20178. case 'c' : xy = [ round(myWidth * 0.5), round(myHeight * 0.5)];
  20179. break;
  20180. case 't' : xy = [ round(myWidth * 0.5), 0];
  20181. break;
  20182. case 'l' : xy = [ 0, round(myHeight * 0.5)];
  20183. break;
  20184. case 'r' : xy = [ myWidth, round(myHeight * 0.5)];
  20185. break;
  20186. case 'b' : xy = [ round(myWidth * 0.5), myHeight];
  20187. break;
  20188. case 'br' : xy = [ myWidth, myHeight];
  20189. }
  20190. return [xy[0] + extraX, xy[1] + extraY];
  20191. },
  20192. /**
  20193. * Gets the x,y coordinates to align this element with another element. See {@link #alignTo} for more info on the
  20194. * supported position values.
  20195. * @param {String/HTMLElement/Ext.Element} element The element to align to.
  20196. * @param {String} [position="tl-bl?"] The position to align to (defaults to )
  20197. * @param {Number[]} [offsets] Offset the positioning by [x, y]
  20198. * @return {Number[]} [x, y]
  20199. */
  20200. getAlignToXY : function(alignToEl, posSpec, offset) {
  20201. alignToEl = Ext.get(alignToEl);
  20202. if (!alignToEl || !alignToEl.dom) {
  20203. }
  20204. offset = offset || [0,0];
  20205. posSpec = (!posSpec || posSpec == "?" ? "tl-bl?" : (!(/-/).test(posSpec) && posSpec !== "" ? "tl-" + posSpec : posSpec || "tl-bl")).toLowerCase();
  20206. var me = this,
  20207. myPosition,
  20208. alignToElPosition,
  20209. x,
  20210. y,
  20211. myWidth,
  20212. myHeight,
  20213. alignToElRegion,
  20214. viewportWidth = Ext.dom.Element.getViewWidth() - 10, // 10px of margin for ie
  20215. viewportHeight = Ext.dom.Element.getViewHeight() - 10, // 10px of margin for ie
  20216. p1y,
  20217. p1x,
  20218. p2y,
  20219. p2x,
  20220. swapY,
  20221. swapX,
  20222. docElement = doc.documentElement,
  20223. docBody = doc.body,
  20224. scrollX = (docElement.scrollLeft || docBody.scrollLeft || 0),// + 5, WHY was 5 ever added?
  20225. scrollY = (docElement.scrollTop || docBody.scrollTop || 0),// + 5, It means align will fail if the alignTo el was at less than 5,5
  20226. constrain, //constrain to viewport
  20227. align1,
  20228. align2,
  20229. alignMatch = posSpec.match(alignRe);
  20230. align1 = alignMatch[1];
  20231. align2 = alignMatch[2];
  20232. constrain = !!alignMatch[3];
  20233. //Subtract the aligned el's internal xy from the target's offset xy
  20234. //plus custom offset to get this Element's new offset xy
  20235. myPosition = me.getAnchorXY(align1, true);
  20236. alignToElPosition = alignToEl.getAnchorXY(align2, false);
  20237. x = alignToElPosition[0] - myPosition[0] + offset[0];
  20238. y = alignToElPosition[1] - myPosition[1] + offset[1];
  20239. // If position spec ended with a "?", then constrain to viewport is necessary
  20240. if (constrain) {
  20241. myWidth = me.getWidth();
  20242. myHeight = me.getHeight();
  20243. alignToElRegion = alignToEl.getRegion();
  20244. //If we are at a viewport boundary and the aligned el is anchored on a target border that is
  20245. //perpendicular to the vp border, allow the aligned el to slide on that border,
  20246. //otherwise swap the aligned el to the opposite border of the target.
  20247. p1y = align1.charAt(0);
  20248. p1x = align1.charAt(align1.length - 1);
  20249. p2y = align2.charAt(0);
  20250. p2x = align2.charAt(align2.length - 1);
  20251. swapY = ((p1y == "t" && p2y == "b") || (p1y == "b" && p2y == "t"));
  20252. swapX = ((p1x == "r" && p2x == "l") || (p1x == "l" && p2x == "r"));
  20253. if (x + myWidth > viewportWidth + scrollX) {
  20254. x = swapX ? alignToElRegion.left - myWidth : viewportWidth + scrollX - myWidth;
  20255. }
  20256. if (x < scrollX) {
  20257. x = swapX ? alignToElRegion.right : scrollX;
  20258. }
  20259. if (y + myHeight > viewportHeight + scrollY) {
  20260. y = swapY ? alignToElRegion.top - myHeight : viewportHeight + scrollY - myHeight;
  20261. }
  20262. if (y < scrollY) {
  20263. y = swapY ? alignToElRegion.bottom : scrollY;
  20264. }
  20265. }
  20266. return [x,y];
  20267. },
  20268. /**
  20269. * Anchors an element to another element and realigns it when the window is resized.
  20270. * @param {String/HTMLElement/Ext.Element} element The element to align to.
  20271. * @param {String} position The position to align to.
  20272. * @param {Number[]} [offsets] Offset the positioning by [x, y]
  20273. * @param {Boolean/Object} [animate] True for the default animation or a standard Element animation config object
  20274. * @param {Boolean/Number} [monitorScroll] True to monitor body scroll and reposition. If this parameter
  20275. * is a number, it is used as the buffer delay (defaults to 50ms).
  20276. * @param {Function} [callback] The function to call after the animation finishes
  20277. * @return {Ext.Element} this
  20278. */
  20279. anchorTo : function(el, alignment, offsets, animate, monitorScroll, callback) {
  20280. var me = this,
  20281. dom = me.dom,
  20282. scroll = !Ext.isEmpty(monitorScroll),
  20283. action = function() {
  20284. Ext.fly(dom).alignTo(el, alignment, offsets, animate);
  20285. Ext.callback(callback, Ext.fly(dom));
  20286. },
  20287. anchor = this.getAnchor();
  20288. // previous listener anchor, remove it
  20289. this.removeAnchor();
  20290. Ext.apply(anchor, {
  20291. fn: action,
  20292. scroll: scroll
  20293. });
  20294. Ext.EventManager.onWindowResize(action, null);
  20295. if (scroll) {
  20296. Ext.EventManager.on(win, 'scroll', action, null,
  20297. {buffer: !isNaN(monitorScroll) ? monitorScroll : 50});
  20298. }
  20299. action.call(me); // align immediately
  20300. return me;
  20301. },
  20302. /**
  20303. * Remove any anchor to this element. See {@link #anchorTo}.
  20304. * @return {Ext.dom.Element} this
  20305. */
  20306. removeAnchor : function() {
  20307. var me = this,
  20308. anchor = this.getAnchor();
  20309. if (anchor && anchor.fn) {
  20310. Ext.EventManager.removeResizeListener(anchor.fn);
  20311. if (anchor.scroll) {
  20312. Ext.EventManager.un(win, 'scroll', anchor.fn);
  20313. }
  20314. delete anchor.fn;
  20315. }
  20316. return me;
  20317. },
  20318. getAlignVector: function(el, spec, offset) {
  20319. var me = this,
  20320. myPos = me.getXY(),
  20321. alignedPos = me.getAlignToXY(el, spec, offset);
  20322. el = Ext.get(el);
  20323. alignedPos[0] -= myPos[0];
  20324. alignedPos[1] -= myPos[1];
  20325. return alignedPos;
  20326. },
  20327. /**
  20328. * Aligns this element with another element relative to the specified anchor points. If the other element is the
  20329. * document it aligns it to the viewport. The position parameter is optional, and can be specified in any one of
  20330. * the following formats:
  20331. *
  20332. * - **Blank**: Defaults to aligning the element's top-left corner to the target's bottom-left corner ("tl-bl").
  20333. * - **One anchor (deprecated)**: The passed anchor position is used as the target element's anchor point.
  20334. * The element being aligned will position its top-left corner (tl) to that point. *This method has been
  20335. * deprecated in favor of the newer two anchor syntax below*.
  20336. * - **Two anchors**: If two values from the table below are passed separated by a dash, the first value is used as the
  20337. * element's anchor point, and the second value is used as the target's anchor point.
  20338. *
  20339. * In addition to the anchor points, the position parameter also supports the "?" character. If "?" is passed at the end of
  20340. * the position string, the element will attempt to align as specified, but the position will be adjusted to constrain to
  20341. * the viewport if necessary. Note that the element being aligned might be swapped to align to a different position than
  20342. * that specified in order to enforce the viewport constraints.
  20343. * Following are all of the supported anchor positions:
  20344. *
  20345. * <pre>
  20346. * Value Description
  20347. * ----- -----------------------------
  20348. * tl The top left corner (default)
  20349. * t The center of the top edge
  20350. * tr The top right corner
  20351. * l The center of the left edge
  20352. * c In the center of the element
  20353. * r The center of the right edge
  20354. * bl The bottom left corner
  20355. * b The center of the bottom edge
  20356. * br The bottom right corner
  20357. * </pre>
  20358. *
  20359. * Example Usage:
  20360. *
  20361. * // align el to other-el using the default positioning ("tl-bl", non-constrained)
  20362. * el.alignTo("other-el");
  20363. *
  20364. * // align the top left corner of el with the top right corner of other-el (constrained to viewport)
  20365. * el.alignTo("other-el", "tr?");
  20366. *
  20367. * // align the bottom right corner of el with the center left edge of other-el
  20368. * el.alignTo("other-el", "br-l?");
  20369. *
  20370. * // align the center of el with the bottom left corner of other-el and
  20371. * // adjust the x position by -6 pixels (and the y position by 0)
  20372. * el.alignTo("other-el", "c-bl", [-6, 0]);
  20373. *
  20374. * @param {String/HTMLElement/Ext.Element} element The element to align to.
  20375. * @param {String} [position="tl-bl?"] The position to align to
  20376. * @param {Number[]} [offsets] Offset the positioning by [x, y]
  20377. * @param {Boolean/Object} [animate] true for the default animation or a standard Element animation config object
  20378. * @return {Ext.Element} this
  20379. */
  20380. alignTo: function(element, position, offsets, animate) {
  20381. var me = this;
  20382. return me.setXY(me.getAlignToXY(element, position, offsets),
  20383. me.anim && !!animate ? me.anim(animate) : false);
  20384. },
  20385. /**
  20386. * Returns the `[X, Y]` vector by which this element must be translated to make a best attempt
  20387. * to constrain within the passed constraint. Returns `false` is this element does not need to be moved.
  20388. *
  20389. * Priority is given to constraining the top and left within the constraint.
  20390. *
  20391. * The constraint may either be an existing element into which this element is to be constrained, or
  20392. * an {@link Ext.util.Region Region} into which this element is to be constrained.
  20393. *
  20394. * @param {Ext.Element/Ext.util.Region} constrainTo The Element or Region into which this element is to be constrained.
  20395. * @param {Number[]} proposedPosition A proposed `[X, Y]` position to test for validity and to produce a vector for instead
  20396. * of using this Element's current position;
  20397. * @returns {Number[]/Boolean} **If** this element *needs* to be translated, an `[X, Y]`
  20398. * vector by which this element must be translated. Otherwise, `false`.
  20399. */
  20400. getConstrainVector: function(constrainTo, proposedPosition) {
  20401. if (!(constrainTo instanceof Ext.util.Region)) {
  20402. constrainTo = Ext.get(constrainTo).getViewRegion();
  20403. }
  20404. var thisRegion = this.getRegion(),
  20405. vector = [0, 0],
  20406. shadowSize = (this.shadow && !this.shadowDisabled) ? this.shadow.getShadowSize() : undefined,
  20407. overflowed = false;
  20408. // Shift this region to occupy the proposed position
  20409. if (proposedPosition) {
  20410. thisRegion.translateBy(proposedPosition[0] - thisRegion.x, proposedPosition[1] - thisRegion.y);
  20411. }
  20412. // Reduce the constrain region to allow for shadow
  20413. if (shadowSize) {
  20414. constrainTo.adjust(shadowSize[0], -shadowSize[1], -shadowSize[2], shadowSize[3]);
  20415. }
  20416. // Constrain the X coordinate by however much this Element overflows
  20417. if (thisRegion.right > constrainTo.right) {
  20418. overflowed = true;
  20419. vector[0] = (constrainTo.right - thisRegion.right); // overflowed the right
  20420. }
  20421. if (thisRegion.left + vector[0] < constrainTo.left) {
  20422. overflowed = true;
  20423. vector[0] = (constrainTo.left - thisRegion.left); // overflowed the left
  20424. }
  20425. // Constrain the Y coordinate by however much this Element overflows
  20426. if (thisRegion.bottom > constrainTo.bottom) {
  20427. overflowed = true;
  20428. vector[1] = (constrainTo.bottom - thisRegion.bottom); // overflowed the bottom
  20429. }
  20430. if (thisRegion.top + vector[1] < constrainTo.top) {
  20431. overflowed = true;
  20432. vector[1] = (constrainTo.top - thisRegion.top); // overflowed the top
  20433. }
  20434. return overflowed ? vector : false;
  20435. },
  20436. /**
  20437. * Calculates the x, y to center this element on the screen
  20438. * @return {Number[]} The x, y values [x, y]
  20439. */
  20440. getCenterXY : function(){
  20441. return this.getAlignToXY(doc, 'c-c');
  20442. },
  20443. /**
  20444. * Centers the Element in either the viewport, or another Element.
  20445. * @param {String/HTMLElement/Ext.Element} [centerIn] The element in which to center the element.
  20446. */
  20447. center : function(centerIn){
  20448. return this.alignTo(centerIn || doc, 'c-c');
  20449. }
  20450. };
  20451. }()));
  20452. //@tag dom,core
  20453. //@require Ext.dom.Element-alignment
  20454. //@define Ext.dom.Element-anim
  20455. //@define Ext.dom.Element
  20456. /**
  20457. * @class Ext.dom.Element
  20458. */
  20459. /* ================================
  20460. * A Note About Wrapped Animations
  20461. * ================================
  20462. * A few of the effects below implement two different animations per effect, one wrapping
  20463. * animation that performs the visual effect and a "no-op" animation on this Element where
  20464. * no attributes of the element itself actually change. The purpose for this is that the
  20465. * wrapper is required for the effect to work and so it does the actual animation work, but
  20466. * we always animate `this` so that the element's events and callbacks work as expected to
  20467. * the callers of this API.
  20468. *
  20469. * Because of this, we always want each wrap animation to complete first (we don't want to
  20470. * cut off the visual effect early). To ensure that, we arbitrarily increase the duration of
  20471. * the element's no-op animation, also ensuring that it has a decent minimum value -- on slow
  20472. * systems, too-low durations can cause race conditions between the wrap animation and the
  20473. * element animation being removed out of order. Note that in each wrap's `afteranimate`
  20474. * callback it will explicitly terminate the element animation as soon as the wrap is complete,
  20475. * so there's no real danger in making the duration too long.
  20476. *
  20477. * This applies to all effects that get wrapped, including slideIn, slideOut, switchOff and frame.
  20478. */
  20479. Ext.dom.Element.override({
  20480. /**
  20481. * Performs custom animation on this Element.
  20482. *
  20483. * The following properties may be specified in `from`, `to`, and `keyframe` objects:
  20484. *
  20485. * - `x` - The page X position in pixels.
  20486. *
  20487. * - `y` - The page Y position in pixels
  20488. *
  20489. * - `left` - The element's CSS `left` value. Units must be supplied.
  20490. *
  20491. * - `top` - The element's CSS `top` value. Units must be supplied.
  20492. *
  20493. * - `width` - The element's CSS `width` value. Units must be supplied.
  20494. *
  20495. * - `height` - The element's CSS `height` value. Units must be supplied.
  20496. *
  20497. * - `scrollLeft` - The element's `scrollLeft` value.
  20498. *
  20499. * - `scrollTop` - The element's `scrollTop` value.
  20500. *
  20501. * - `opacity` - The element's `opacity` value. This must be a value between `0` and `1`.
  20502. *
  20503. * **Be aware** that animating an Element which is being used by an Ext Component without in some way informing the
  20504. * Component about the changed element state will result in incorrect Component behaviour. This is because the
  20505. * Component will be using the old state of the element. To avoid this problem, it is now possible to directly
  20506. * animate certain properties of Components.
  20507. *
  20508. * @param {Object} config Configuration for {@link Ext.fx.Anim}.
  20509. * Note that the {@link Ext.fx.Anim#to to} config is required.
  20510. * @return {Ext.dom.Element} this
  20511. */
  20512. animate: function(config) {
  20513. var me = this,
  20514. listeners,
  20515. anim,
  20516. animId = me.dom.id || Ext.id(me.dom);
  20517. if (!Ext.fx.Manager.hasFxBlock(animId)) {
  20518. // Bit of gymnastics here to ensure our internal listeners get bound first
  20519. if (config.listeners) {
  20520. listeners = config.listeners;
  20521. delete config.listeners;
  20522. }
  20523. if (config.internalListeners) {
  20524. config.listeners = config.internalListeners;
  20525. delete config.internalListeners;
  20526. }
  20527. anim = new Ext.fx.Anim(me.anim(config));
  20528. if (listeners) {
  20529. anim.on(listeners);
  20530. }
  20531. Ext.fx.Manager.queueFx(anim);
  20532. }
  20533. return me;
  20534. },
  20535. // @private - process the passed fx configuration.
  20536. anim: function(config) {
  20537. if (!Ext.isObject(config)) {
  20538. return (config) ? {} : false;
  20539. }
  20540. var me = this,
  20541. duration = config.duration || Ext.fx.Anim.prototype.duration,
  20542. easing = config.easing || 'ease',
  20543. animConfig;
  20544. if (config.stopAnimation) {
  20545. me.stopAnimation();
  20546. }
  20547. Ext.applyIf(config, Ext.fx.Manager.getFxDefaults(me.id));
  20548. // Clear any 'paused' defaults.
  20549. Ext.fx.Manager.setFxDefaults(me.id, {
  20550. delay: 0
  20551. });
  20552. animConfig = {
  20553. // Pass the DOM reference. That's tested first so will be converted to an Ext.fx.Target fastest.
  20554. target: me.dom,
  20555. remove: config.remove,
  20556. alternate: config.alternate || false,
  20557. duration: duration,
  20558. easing: easing,
  20559. callback: config.callback,
  20560. listeners: config.listeners,
  20561. iterations: config.iterations || 1,
  20562. scope: config.scope,
  20563. block: config.block,
  20564. concurrent: config.concurrent,
  20565. delay: config.delay || 0,
  20566. paused: true,
  20567. keyframes: config.keyframes,
  20568. from: config.from || {},
  20569. to: Ext.apply({}, config)
  20570. };
  20571. Ext.apply(animConfig.to, config.to);
  20572. // Anim API properties - backward compat
  20573. delete animConfig.to.to;
  20574. delete animConfig.to.from;
  20575. delete animConfig.to.remove;
  20576. delete animConfig.to.alternate;
  20577. delete animConfig.to.keyframes;
  20578. delete animConfig.to.iterations;
  20579. delete animConfig.to.listeners;
  20580. delete animConfig.to.target;
  20581. delete animConfig.to.paused;
  20582. delete animConfig.to.callback;
  20583. delete animConfig.to.scope;
  20584. delete animConfig.to.duration;
  20585. delete animConfig.to.easing;
  20586. delete animConfig.to.concurrent;
  20587. delete animConfig.to.block;
  20588. delete animConfig.to.stopAnimation;
  20589. delete animConfig.to.delay;
  20590. return animConfig;
  20591. },
  20592. /**
  20593. * Slides the element into view. An anchor point can be optionally passed to set the point of origin for the slide
  20594. * effect. This function automatically handles wrapping the element with a fixed-size container if needed. See the
  20595. * Fx class overview for valid anchor point options. Usage:
  20596. *
  20597. * // default: slide the element in from the top
  20598. * el.slideIn();
  20599. *
  20600. * // custom: slide the element in from the right with a 2-second duration
  20601. * el.slideIn('r', { duration: 2000 });
  20602. *
  20603. * // common config options shown with default values
  20604. * el.slideIn('t', {
  20605. * easing: 'easeOut',
  20606. * duration: 500
  20607. * });
  20608. *
  20609. * @param {String} anchor (optional) One of the valid Fx anchor positions (defaults to top: 't')
  20610. * @param {Object} options (optional) Object literal with any of the Fx config options
  20611. * @param {Boolean} options.preserveScroll Set to true if preservation of any descendant elements'
  20612. * `scrollTop` values is required. By default the DOM wrapping operation performed by `slideIn` and
  20613. * `slideOut` causes the browser to lose all scroll positions.
  20614. * @return {Ext.dom.Element} The Element
  20615. */
  20616. slideIn: function(anchor, obj, slideOut) {
  20617. var me = this,
  20618. elStyle = me.dom.style,
  20619. beforeAnim,
  20620. wrapAnim,
  20621. restoreScroll,
  20622. wrapDomParentNode;
  20623. anchor = anchor || "t";
  20624. obj = obj || {};
  20625. beforeAnim = function() {
  20626. var animScope = this,
  20627. listeners = obj.listeners,
  20628. box, originalStyles, anim, wrap;
  20629. if (!slideOut) {
  20630. me.fixDisplay();
  20631. }
  20632. box = me.getBox();
  20633. if ((anchor == 't' || anchor == 'b') && box.height === 0) {
  20634. box.height = me.dom.scrollHeight;
  20635. }
  20636. else if ((anchor == 'l' || anchor == 'r') && box.width === 0) {
  20637. box.width = me.dom.scrollWidth;
  20638. }
  20639. originalStyles = me.getStyles('width', 'height', 'left', 'right', 'top', 'bottom', 'position', 'z-index', true);
  20640. me.setSize(box.width, box.height);
  20641. // Cache all descendants' scrollTop & scrollLeft values if configured to preserve scroll.
  20642. if (obj.preserveScroll) {
  20643. restoreScroll = me.cacheScrollValues();
  20644. }
  20645. wrap = me.wrap({
  20646. id: Ext.id() + '-anim-wrap-for-' + me.id,
  20647. style: {
  20648. visibility: slideOut ? 'visible' : 'hidden'
  20649. }
  20650. });
  20651. wrapDomParentNode = wrap.dom.parentNode;
  20652. wrap.setPositioning(me.getPositioning());
  20653. if (wrap.isStyle('position', 'static')) {
  20654. wrap.position('relative');
  20655. }
  20656. me.clearPositioning('auto');
  20657. wrap.clip();
  20658. // The wrap will have reset all descendant scrollTops. Restore them if we cached them.
  20659. if (restoreScroll) {
  20660. restoreScroll();
  20661. }
  20662. // This element is temporarily positioned absolute within its wrapper.
  20663. // Restore to its default, CSS-inherited visibility setting.
  20664. // We cannot explicitly poke visibility:visible into its style because that overrides the visibility of the wrap.
  20665. me.setStyle({
  20666. visibility: '',
  20667. position: 'absolute'
  20668. });
  20669. if (slideOut) {
  20670. wrap.setSize(box.width, box.height);
  20671. }
  20672. switch (anchor) {
  20673. case 't':
  20674. anim = {
  20675. from: {
  20676. width: box.width + 'px',
  20677. height: '0px'
  20678. },
  20679. to: {
  20680. width: box.width + 'px',
  20681. height: box.height + 'px'
  20682. }
  20683. };
  20684. elStyle.bottom = '0px';
  20685. break;
  20686. case 'l':
  20687. anim = {
  20688. from: {
  20689. width: '0px',
  20690. height: box.height + 'px'
  20691. },
  20692. to: {
  20693. width: box.width + 'px',
  20694. height: box.height + 'px'
  20695. }
  20696. };
  20697. elStyle.right = '0px';
  20698. break;
  20699. case 'r':
  20700. anim = {
  20701. from: {
  20702. x: box.x + box.width,
  20703. width: '0px',
  20704. height: box.height + 'px'
  20705. },
  20706. to: {
  20707. x: box.x,
  20708. width: box.width + 'px',
  20709. height: box.height + 'px'
  20710. }
  20711. };
  20712. break;
  20713. case 'b':
  20714. anim = {
  20715. from: {
  20716. y: box.y + box.height,
  20717. width: box.width + 'px',
  20718. height: '0px'
  20719. },
  20720. to: {
  20721. y: box.y,
  20722. width: box.width + 'px',
  20723. height: box.height + 'px'
  20724. }
  20725. };
  20726. break;
  20727. case 'tl':
  20728. anim = {
  20729. from: {
  20730. x: box.x,
  20731. y: box.y,
  20732. width: '0px',
  20733. height: '0px'
  20734. },
  20735. to: {
  20736. width: box.width + 'px',
  20737. height: box.height + 'px'
  20738. }
  20739. };
  20740. elStyle.bottom = '0px';
  20741. elStyle.right = '0px';
  20742. break;
  20743. case 'bl':
  20744. anim = {
  20745. from: {
  20746. y: box.y + box.height,
  20747. width: '0px',
  20748. height: '0px'
  20749. },
  20750. to: {
  20751. y: box.y,
  20752. width: box.width + 'px',
  20753. height: box.height + 'px'
  20754. }
  20755. };
  20756. elStyle.bottom = '0px';
  20757. break;
  20758. case 'br':
  20759. anim = {
  20760. from: {
  20761. x: box.x + box.width,
  20762. y: box.y + box.height,
  20763. width: '0px',
  20764. height: '0px'
  20765. },
  20766. to: {
  20767. x: box.x,
  20768. y: box.y,
  20769. width: box.width + 'px',
  20770. height: box.height + 'px'
  20771. }
  20772. };
  20773. break;
  20774. case 'tr':
  20775. anim = {
  20776. from: {
  20777. x: box.x + box.width,
  20778. width: '0px',
  20779. height: '0px'
  20780. },
  20781. to: {
  20782. x: box.x,
  20783. width: box.width + 'px',
  20784. height: box.height + 'px'
  20785. }
  20786. };
  20787. elStyle.right = '0px';
  20788. break;
  20789. }
  20790. wrap.show();
  20791. wrapAnim = Ext.apply({}, obj);
  20792. delete wrapAnim.listeners;
  20793. wrapAnim = new Ext.fx.Anim(Ext.applyIf(wrapAnim, {
  20794. target: wrap,
  20795. duration: 500,
  20796. easing: 'ease-out',
  20797. from: slideOut ? anim.to : anim.from,
  20798. to: slideOut ? anim.from : anim.to
  20799. }));
  20800. // In the absence of a callback, this listener MUST be added first
  20801. wrapAnim.on('afteranimate', function() {
  20802. me.setStyle(originalStyles);
  20803. if (slideOut) {
  20804. if (obj.useDisplay) {
  20805. me.setDisplayed(false);
  20806. } else {
  20807. me.hide();
  20808. }
  20809. }
  20810. if (wrap.dom) {
  20811. if (wrap.dom.parentNode) {
  20812. wrap.dom.parentNode.insertBefore(me.dom, wrap.dom);
  20813. } else {
  20814. wrapDomParentNode.appendChild(me.dom);
  20815. }
  20816. wrap.remove();
  20817. }
  20818. // The unwrap will have reset all descendant scrollTops. Restore them if we cached them.
  20819. if (restoreScroll) {
  20820. restoreScroll();
  20821. }
  20822. // kill the no-op element animation created below
  20823. animScope.end();
  20824. });
  20825. // Add configured listeners after
  20826. if (listeners) {
  20827. wrapAnim.on(listeners);
  20828. }
  20829. };
  20830. me.animate({
  20831. // See "A Note About Wrapped Animations" at the top of this class:
  20832. duration: obj.duration ? Math.max(obj.duration, 500) * 2 : 1000,
  20833. listeners: {
  20834. beforeanimate: beforeAnim // kick off the wrap animation
  20835. }
  20836. });
  20837. return me;
  20838. },
  20839. /**
  20840. * Slides the element out of view. An anchor point can be optionally passed to set the end point for the slide
  20841. * effect. When the effect is completed, the element will be hidden (visibility = 'hidden') but block elements will
  20842. * still take up space in the document. The element must be removed from the DOM using the 'remove' config option if
  20843. * desired. This function automatically handles wrapping the element with a fixed-size container if needed. See the
  20844. * Fx class overview for valid anchor point options. Usage:
  20845. *
  20846. * // default: slide the element out to the top
  20847. * el.slideOut();
  20848. *
  20849. * // custom: slide the element out to the right with a 2-second duration
  20850. * el.slideOut('r', { duration: 2000 });
  20851. *
  20852. * // common config options shown with default values
  20853. * el.slideOut('t', {
  20854. * easing: 'easeOut',
  20855. * duration: 500,
  20856. * remove: false,
  20857. * useDisplay: false
  20858. * });
  20859. *
  20860. * @param {String} anchor (optional) One of the valid Fx anchor positions (defaults to top: 't')
  20861. * @param {Object} options (optional) Object literal with any of the Fx config options
  20862. * @return {Ext.dom.Element} The Element
  20863. */
  20864. slideOut: function(anchor, o) {
  20865. return this.slideIn(anchor, o, true);
  20866. },
  20867. /**
  20868. * Fades the element out while slowly expanding it in all directions. When the effect is completed, the element will
  20869. * be hidden (visibility = 'hidden') but block elements will still take up space in the document. Usage:
  20870. *
  20871. * // default
  20872. * el.puff();
  20873. *
  20874. * // common config options shown with default values
  20875. * el.puff({
  20876. * easing: 'easeOut',
  20877. * duration: 500,
  20878. * useDisplay: false
  20879. * });
  20880. *
  20881. * @param {Object} options (optional) Object literal with any of the Fx config options
  20882. * @return {Ext.dom.Element} The Element
  20883. */
  20884. puff: function(obj) {
  20885. var me = this,
  20886. beforeAnim,
  20887. box = me.getBox(),
  20888. originalStyles = me.getStyles('width', 'height', 'left', 'right', 'top', 'bottom', 'position', 'z-index', 'font-size', 'opacity', true);
  20889. obj = Ext.applyIf(obj || {}, {
  20890. easing: 'ease-out',
  20891. duration: 500,
  20892. useDisplay: false
  20893. });
  20894. beforeAnim = function() {
  20895. me.clearOpacity();
  20896. me.show();
  20897. this.to = {
  20898. width: box.width * 2,
  20899. height: box.height * 2,
  20900. x: box.x - (box.width / 2),
  20901. y: box.y - (box.height /2),
  20902. opacity: 0,
  20903. fontSize: '200%'
  20904. };
  20905. this.on('afteranimate',function() {
  20906. if (me.dom) {
  20907. if (obj.useDisplay) {
  20908. me.setDisplayed(false);
  20909. } else {
  20910. me.hide();
  20911. }
  20912. me.setStyle(originalStyles);
  20913. obj.callback.call(obj.scope);
  20914. }
  20915. });
  20916. };
  20917. me.animate({
  20918. duration: obj.duration,
  20919. easing: obj.easing,
  20920. listeners: {
  20921. beforeanimate: {
  20922. fn: beforeAnim
  20923. }
  20924. }
  20925. });
  20926. return me;
  20927. },
  20928. /**
  20929. * Blinks the element as if it was clicked and then collapses on its center (similar to switching off a television).
  20930. * When the effect is completed, the element will be hidden (visibility = 'hidden') but block elements will still
  20931. * take up space in the document. The element must be removed from the DOM using the 'remove' config option if
  20932. * desired. Usage:
  20933. *
  20934. * // default
  20935. * el.switchOff();
  20936. *
  20937. * // all config options shown with default values
  20938. * el.switchOff({
  20939. * easing: 'easeIn',
  20940. * duration: .3,
  20941. * remove: false,
  20942. * useDisplay: false
  20943. * });
  20944. *
  20945. * @param {Object} options (optional) Object literal with any of the Fx config options
  20946. * @return {Ext.dom.Element} The Element
  20947. */
  20948. switchOff: function(obj) {
  20949. var me = this,
  20950. beforeAnim;
  20951. obj = Ext.applyIf(obj || {}, {
  20952. easing: 'ease-in',
  20953. duration: 500,
  20954. remove: false,
  20955. useDisplay: false
  20956. });
  20957. beforeAnim = function() {
  20958. var animScope = this,
  20959. size = me.getSize(),
  20960. xy = me.getXY(),
  20961. keyframe, position;
  20962. me.clearOpacity();
  20963. me.clip();
  20964. position = me.getPositioning();
  20965. keyframe = new Ext.fx.Animator({
  20966. target: me,
  20967. duration: obj.duration,
  20968. easing: obj.easing,
  20969. keyframes: {
  20970. 33: {
  20971. opacity: 0.3
  20972. },
  20973. 66: {
  20974. height: 1,
  20975. y: xy[1] + size.height / 2
  20976. },
  20977. 100: {
  20978. width: 1,
  20979. x: xy[0] + size.width / 2
  20980. }
  20981. }
  20982. });
  20983. keyframe.on('afteranimate', function() {
  20984. if (obj.useDisplay) {
  20985. me.setDisplayed(false);
  20986. } else {
  20987. me.hide();
  20988. }
  20989. me.clearOpacity();
  20990. me.setPositioning(position);
  20991. me.setSize(size);
  20992. // kill the no-op element animation created below
  20993. animScope.end();
  20994. });
  20995. };
  20996. me.animate({
  20997. // See "A Note About Wrapped Animations" at the top of this class:
  20998. duration: (Math.max(obj.duration, 500) * 2),
  20999. listeners: {
  21000. beforeanimate: {
  21001. fn: beforeAnim
  21002. }
  21003. }
  21004. });
  21005. return me;
  21006. },
  21007. /**
  21008. * Shows a ripple of exploding, attenuating borders to draw attention to an Element. Usage:
  21009. *
  21010. * // default: a single light blue ripple
  21011. * el.frame();
  21012. *
  21013. * // custom: 3 red ripples lasting 3 seconds total
  21014. * el.frame("#ff0000", 3, { duration: 3000 });
  21015. *
  21016. * // common config options shown with default values
  21017. * el.frame("#C3DAF9", 1, {
  21018. * duration: 1000 // duration of each individual ripple.
  21019. * // Note: Easing is not configurable and will be ignored if included
  21020. * });
  21021. *
  21022. * @param {String} [color='#C3DAF9'] The hex color value for the border.
  21023. * @param {Number} [count=1] The number of ripples to display.
  21024. * @param {Object} [options] Object literal with any of the Fx config options
  21025. * @return {Ext.dom.Element} The Element
  21026. */
  21027. frame : function(color, count, obj){
  21028. var me = this,
  21029. beforeAnim;
  21030. color = color || '#C3DAF9';
  21031. count = count || 1;
  21032. obj = obj || {};
  21033. beforeAnim = function() {
  21034. me.show();
  21035. var animScope = this,
  21036. box = me.getBox(),
  21037. proxy = Ext.getBody().createChild({
  21038. id: me.id + '-anim-proxy',
  21039. style: {
  21040. position : 'absolute',
  21041. 'pointer-events': 'none',
  21042. 'z-index': 35000,
  21043. border : '0px solid ' + color
  21044. }
  21045. }),
  21046. proxyAnim;
  21047. proxyAnim = new Ext.fx.Anim({
  21048. target: proxy,
  21049. duration: obj.duration || 1000,
  21050. iterations: count,
  21051. from: {
  21052. top: box.y,
  21053. left: box.x,
  21054. borderWidth: 0,
  21055. opacity: 1,
  21056. height: box.height,
  21057. width: box.width
  21058. },
  21059. to: {
  21060. top: box.y - 20,
  21061. left: box.x - 20,
  21062. borderWidth: 10,
  21063. opacity: 0,
  21064. height: box.height + 40,
  21065. width: box.width + 40
  21066. }
  21067. });
  21068. proxyAnim.on('afteranimate', function() {
  21069. proxy.remove();
  21070. // kill the no-op element animation created below
  21071. animScope.end();
  21072. });
  21073. };
  21074. me.animate({
  21075. // See "A Note About Wrapped Animations" at the top of this class:
  21076. duration: (Math.max(obj.duration, 500) * 2) || 2000,
  21077. listeners: {
  21078. beforeanimate: {
  21079. fn: beforeAnim
  21080. }
  21081. }
  21082. });
  21083. return me;
  21084. },
  21085. /**
  21086. * Slides the element while fading it out of view. An anchor point can be optionally passed to set the ending point
  21087. * of the effect. Usage:
  21088. *
  21089. * // default: slide the element downward while fading out
  21090. * el.ghost();
  21091. *
  21092. * // custom: slide the element out to the right with a 2-second duration
  21093. * el.ghost('r', { duration: 2000 });
  21094. *
  21095. * // common config options shown with default values
  21096. * el.ghost('b', {
  21097. * easing: 'easeOut',
  21098. * duration: 500
  21099. * });
  21100. *
  21101. * @param {String} anchor (optional) One of the valid Fx anchor positions (defaults to bottom: 'b')
  21102. * @param {Object} options (optional) Object literal with any of the Fx config options
  21103. * @return {Ext.dom.Element} The Element
  21104. */
  21105. ghost: function(anchor, obj) {
  21106. var me = this,
  21107. beforeAnim;
  21108. anchor = anchor || "b";
  21109. beforeAnim = function() {
  21110. var width = me.getWidth(),
  21111. height = me.getHeight(),
  21112. xy = me.getXY(),
  21113. position = me.getPositioning(),
  21114. to = {
  21115. opacity: 0
  21116. };
  21117. switch (anchor) {
  21118. case 't':
  21119. to.y = xy[1] - height;
  21120. break;
  21121. case 'l':
  21122. to.x = xy[0] - width;
  21123. break;
  21124. case 'r':
  21125. to.x = xy[0] + width;
  21126. break;
  21127. case 'b':
  21128. to.y = xy[1] + height;
  21129. break;
  21130. case 'tl':
  21131. to.x = xy[0] - width;
  21132. to.y = xy[1] - height;
  21133. break;
  21134. case 'bl':
  21135. to.x = xy[0] - width;
  21136. to.y = xy[1] + height;
  21137. break;
  21138. case 'br':
  21139. to.x = xy[0] + width;
  21140. to.y = xy[1] + height;
  21141. break;
  21142. case 'tr':
  21143. to.x = xy[0] + width;
  21144. to.y = xy[1] - height;
  21145. break;
  21146. }
  21147. this.to = to;
  21148. this.on('afteranimate', function () {
  21149. if (me.dom) {
  21150. me.hide();
  21151. me.clearOpacity();
  21152. me.setPositioning(position);
  21153. }
  21154. });
  21155. };
  21156. me.animate(Ext.applyIf(obj || {}, {
  21157. duration: 500,
  21158. easing: 'ease-out',
  21159. listeners: {
  21160. beforeanimate: {
  21161. fn: beforeAnim
  21162. }
  21163. }
  21164. }));
  21165. return me;
  21166. },
  21167. /**
  21168. * Highlights the Element by setting a color (applies to the background-color by default, but can be changed using
  21169. * the "attr" config option) and then fading back to the original color. If no original color is available, you
  21170. * should provide the "endColor" config option which will be cleared after the animation. Usage:
  21171. *
  21172. * // default: highlight background to yellow
  21173. * el.highlight();
  21174. *
  21175. * // custom: highlight foreground text to blue for 2 seconds
  21176. * el.highlight("0000ff", { attr: 'color', duration: 2000 });
  21177. *
  21178. * // common config options shown with default values
  21179. * el.highlight("ffff9c", {
  21180. * attr: "backgroundColor", //can be any valid CSS property (attribute) that supports a color value
  21181. * endColor: (current color) or "ffffff",
  21182. * easing: 'easeIn',
  21183. * duration: 1000
  21184. * });
  21185. *
  21186. * @param {String} color (optional) The highlight color. Should be a 6 char hex color without the leading #
  21187. * (defaults to yellow: 'ffff9c')
  21188. * @param {Object} options (optional) Object literal with any of the Fx config options
  21189. * @return {Ext.dom.Element} The Element
  21190. */
  21191. highlight: function(color, o) {
  21192. var me = this,
  21193. dom = me.dom,
  21194. from = {},
  21195. restore, to, attr, lns, event, fn;
  21196. o = o || {};
  21197. lns = o.listeners || {};
  21198. attr = o.attr || 'backgroundColor';
  21199. from[attr] = color || 'ffff9c';
  21200. if (!o.to) {
  21201. to = {};
  21202. to[attr] = o.endColor || me.getColor(attr, 'ffffff', '');
  21203. }
  21204. else {
  21205. to = o.to;
  21206. }
  21207. // Don't apply directly on lns, since we reference it in our own callbacks below
  21208. o.listeners = Ext.apply(Ext.apply({}, lns), {
  21209. beforeanimate: function() {
  21210. restore = dom.style[attr];
  21211. me.clearOpacity();
  21212. me.show();
  21213. event = lns.beforeanimate;
  21214. if (event) {
  21215. fn = event.fn || event;
  21216. return fn.apply(event.scope || lns.scope || window, arguments);
  21217. }
  21218. },
  21219. afteranimate: function() {
  21220. if (dom) {
  21221. dom.style[attr] = restore;
  21222. }
  21223. event = lns.afteranimate;
  21224. if (event) {
  21225. fn = event.fn || event;
  21226. fn.apply(event.scope || lns.scope || window, arguments);
  21227. }
  21228. }
  21229. });
  21230. me.animate(Ext.apply({}, o, {
  21231. duration: 1000,
  21232. easing: 'ease-in',
  21233. from: from,
  21234. to: to
  21235. }));
  21236. return me;
  21237. },
  21238. /**
  21239. * Creates a pause before any subsequent queued effects begin. If there are no effects queued after the pause it will
  21240. * have no effect. Usage:
  21241. *
  21242. * el.pause(1);
  21243. *
  21244. * @deprecated 4.0 Use the `delay` config to {@link #animate} instead.
  21245. * @param {Number} seconds The length of time to pause (in seconds)
  21246. * @return {Ext.Element} The Element
  21247. */
  21248. pause: function(ms) {
  21249. var me = this;
  21250. Ext.fx.Manager.setFxDefaults(me.id, {
  21251. delay: ms
  21252. });
  21253. return me;
  21254. },
  21255. /**
  21256. * Fade an element in (from transparent to opaque). The ending opacity can be specified using the `opacity`
  21257. * config option. Usage:
  21258. *
  21259. * // default: fade in from opacity 0 to 100%
  21260. * el.fadeIn();
  21261. *
  21262. * // custom: fade in from opacity 0 to 75% over 2 seconds
  21263. * el.fadeIn({ opacity: .75, duration: 2000});
  21264. *
  21265. * // common config options shown with default values
  21266. * el.fadeIn({
  21267. * opacity: 1, //can be any value between 0 and 1 (e.g. .5)
  21268. * easing: 'easeOut',
  21269. * duration: 500
  21270. * });
  21271. *
  21272. * @param {Object} options (optional) Object literal with any of the Fx config options
  21273. * @return {Ext.Element} The Element
  21274. */
  21275. fadeIn: function(o) {
  21276. var me = this;
  21277. me.animate(Ext.apply({}, o, {
  21278. opacity: 1,
  21279. internalListeners: {
  21280. beforeanimate: function(anim){
  21281. // restore any visibility/display that may have
  21282. // been applied by a fadeout animation
  21283. if (me.isStyle('display', 'none')) {
  21284. me.setDisplayed('');
  21285. } else {
  21286. me.show();
  21287. }
  21288. }
  21289. }
  21290. }));
  21291. return this;
  21292. },
  21293. /**
  21294. * Fade an element out (from opaque to transparent). The ending opacity can be specified using the `opacity`
  21295. * config option. Note that IE may require `useDisplay:true` in order to redisplay correctly.
  21296. * Usage:
  21297. *
  21298. * // default: fade out from the element's current opacity to 0
  21299. * el.fadeOut();
  21300. *
  21301. * // custom: fade out from the element's current opacity to 25% over 2 seconds
  21302. * el.fadeOut({ opacity: .25, duration: 2000});
  21303. *
  21304. * // common config options shown with default values
  21305. * el.fadeOut({
  21306. * opacity: 0, //can be any value between 0 and 1 (e.g. .5)
  21307. * easing: 'easeOut',
  21308. * duration: 500,
  21309. * remove: false,
  21310. * useDisplay: false
  21311. * });
  21312. *
  21313. * @param {Object} options (optional) Object literal with any of the Fx config options
  21314. * @return {Ext.Element} The Element
  21315. */
  21316. fadeOut: function(o) {
  21317. var me = this;
  21318. o = Ext.apply({
  21319. opacity: 0,
  21320. internalListeners: {
  21321. afteranimate: function(anim){
  21322. var dom = me.dom;
  21323. if (dom && anim.to.opacity === 0) {
  21324. if (o.useDisplay) {
  21325. me.setDisplayed(false);
  21326. } else {
  21327. me.hide();
  21328. }
  21329. }
  21330. }
  21331. }
  21332. }, o);
  21333. me.animate(o);
  21334. return me;
  21335. },
  21336. /**
  21337. * Animates the transition of an element's dimensions from a starting height/width to an ending height/width. This
  21338. * method is a convenience implementation of {@link #shift}. Usage:
  21339. *
  21340. * // change height and width to 100x100 pixels
  21341. * el.scale(100, 100);
  21342. *
  21343. * // common config options shown with default values. The height and width will default to
  21344. * // the element's existing values if passed as null.
  21345. * el.scale(
  21346. * [element's width],
  21347. * [element's height], {
  21348. * easing: 'easeOut',
  21349. * duration: 350
  21350. * }
  21351. * );
  21352. *
  21353. * @deprecated 4.0 Just use {@link #animate} instead.
  21354. * @param {Number} width The new width (pass undefined to keep the original width)
  21355. * @param {Number} height The new height (pass undefined to keep the original height)
  21356. * @param {Object} options (optional) Object literal with any of the Fx config options
  21357. * @return {Ext.Element} The Element
  21358. */
  21359. scale: function(w, h, o) {
  21360. this.animate(Ext.apply({}, o, {
  21361. width: w,
  21362. height: h
  21363. }));
  21364. return this;
  21365. },
  21366. /**
  21367. * Animates the transition of any combination of an element's dimensions, xy position and/or opacity. Any of these
  21368. * properties not specified in the config object will not be changed. This effect requires that at least one new
  21369. * dimension, position or opacity setting must be passed in on the config object in order for the function to have
  21370. * any effect. Usage:
  21371. *
  21372. * // slide the element horizontally to x position 200 while changing the height and opacity
  21373. * el.shift({ x: 200, height: 50, opacity: .8 });
  21374. *
  21375. * // common config options shown with default values.
  21376. * el.shift({
  21377. * width: [element's width],
  21378. * height: [element's height],
  21379. * x: [element's x position],
  21380. * y: [element's y position],
  21381. * opacity: [element's opacity],
  21382. * easing: 'easeOut',
  21383. * duration: 350
  21384. * });
  21385. *
  21386. * @deprecated 4.0 Just use {@link #animate} instead.
  21387. * @param {Object} options Object literal with any of the Fx config options
  21388. * @return {Ext.Element} The Element
  21389. */
  21390. shift: function(config) {
  21391. this.animate(config);
  21392. return this;
  21393. }
  21394. });
  21395. //@tag dom,core
  21396. //@require Ext.dom.Element-anim
  21397. //@define Ext.dom.Element-dd
  21398. //@define Ext.dom.Element
  21399. /**
  21400. * @class Ext.dom.Element
  21401. */
  21402. Ext.dom.Element.override({
  21403. /**
  21404. * Initializes a {@link Ext.dd.DD} drag drop object for this element.
  21405. * @param {String} group The group the DD object is member of
  21406. * @param {Object} config The DD config object
  21407. * @param {Object} overrides An object containing methods to override/implement on the DD object
  21408. * @return {Ext.dd.DD} The DD object
  21409. */
  21410. initDD : function(group, config, overrides){
  21411. var dd = new Ext.dd.DD(Ext.id(this.dom), group, config);
  21412. return Ext.apply(dd, overrides);
  21413. },
  21414. /**
  21415. * Initializes a {@link Ext.dd.DDProxy} object for this element.
  21416. * @param {String} group The group the DDProxy object is member of
  21417. * @param {Object} config The DDProxy config object
  21418. * @param {Object} overrides An object containing methods to override/implement on the DDProxy object
  21419. * @return {Ext.dd.DDProxy} The DDProxy object
  21420. */
  21421. initDDProxy : function(group, config, overrides){
  21422. var dd = new Ext.dd.DDProxy(Ext.id(this.dom), group, config);
  21423. return Ext.apply(dd, overrides);
  21424. },
  21425. /**
  21426. * Initializes a {@link Ext.dd.DDTarget} object for this element.
  21427. * @param {String} group The group the DDTarget object is member of
  21428. * @param {Object} config The DDTarget config object
  21429. * @param {Object} overrides An object containing methods to override/implement on the DDTarget object
  21430. * @return {Ext.dd.DDTarget} The DDTarget object
  21431. */
  21432. initDDTarget : function(group, config, overrides){
  21433. var dd = new Ext.dd.DDTarget(Ext.id(this.dom), group, config);
  21434. return Ext.apply(dd, overrides);
  21435. }
  21436. });
  21437. //@tag dom,core
  21438. //@require Ext.dom.Element-dd
  21439. //@define Ext.dom.Element-fx
  21440. //@define Ext.dom.Element
  21441. /**
  21442. * @class Ext.dom.Element
  21443. */
  21444. (function() {
  21445. var Element = Ext.dom.Element,
  21446. VISIBILITY = "visibility",
  21447. DISPLAY = "display",
  21448. NONE = "none",
  21449. HIDDEN = 'hidden',
  21450. VISIBLE = 'visible',
  21451. OFFSETS = "offsets",
  21452. ASCLASS = "asclass",
  21453. NOSIZE = 'nosize',
  21454. ORIGINALDISPLAY = 'originalDisplay',
  21455. VISMODE = 'visibilityMode',
  21456. ISVISIBLE = 'isVisible',
  21457. OFFSETCLASS = Ext.baseCSSPrefix + 'hide-offsets',
  21458. getDisplay = function(el) {
  21459. var data = (el.$cache || el.getCache()).data,
  21460. display = data[ORIGINALDISPLAY];
  21461. if (display === undefined) {
  21462. data[ORIGINALDISPLAY] = display = '';
  21463. }
  21464. return display;
  21465. },
  21466. getVisMode = function(el){
  21467. var data = (el.$cache || el.getCache()).data,
  21468. visMode = data[VISMODE];
  21469. if (visMode === undefined) {
  21470. data[VISMODE] = visMode = Element.VISIBILITY;
  21471. }
  21472. return visMode;
  21473. };
  21474. Element.override({
  21475. /**
  21476. * The element's default display mode.
  21477. */
  21478. originalDisplay : "",
  21479. visibilityMode : 1,
  21480. /**
  21481. * Sets the visibility of the element (see details). If the visibilityMode is set to Element.DISPLAY, it will use
  21482. * the display property to hide the element, otherwise it uses visibility. The default is to hide and show using the visibility property.
  21483. * @param {Boolean} visible Whether the element is visible
  21484. * @param {Boolean/Object} [animate] True for the default animation, or a standard Element animation config object
  21485. * @return {Ext.dom.Element} this
  21486. */
  21487. setVisible : function(visible, animate) {
  21488. var me = this,
  21489. dom = me.dom,
  21490. visMode = getVisMode(me);
  21491. // hideMode string override
  21492. if (typeof animate == 'string') {
  21493. switch (animate) {
  21494. case DISPLAY:
  21495. visMode = Element.DISPLAY;
  21496. break;
  21497. case VISIBILITY:
  21498. visMode = Element.VISIBILITY;
  21499. break;
  21500. case OFFSETS:
  21501. visMode = Element.OFFSETS;
  21502. break;
  21503. case NOSIZE:
  21504. case ASCLASS:
  21505. visMode = Element.ASCLASS;
  21506. break;
  21507. }
  21508. me.setVisibilityMode(visMode);
  21509. animate = false;
  21510. }
  21511. if (!animate || !me.anim) {
  21512. if (visMode == Element.DISPLAY) {
  21513. return me.setDisplayed(visible);
  21514. } else if (visMode == Element.OFFSETS) {
  21515. me[visible?'removeCls':'addCls'](OFFSETCLASS);
  21516. } else if (visMode == Element.VISIBILITY) {
  21517. me.fixDisplay();
  21518. // Show by clearing visibility style. Explicitly setting to "visible" overrides parent visibility setting
  21519. dom.style.visibility = visible ? '' : HIDDEN;
  21520. } else if (visMode == Element.ASCLASS) {
  21521. me[visible?'removeCls':'addCls'](me.visibilityCls || Element.visibilityCls);
  21522. }
  21523. } else {
  21524. // closure for composites
  21525. if (visible) {
  21526. me.setOpacity(0.01);
  21527. me.setVisible(true);
  21528. }
  21529. if (!Ext.isObject(animate)) {
  21530. animate = {
  21531. duration: 350,
  21532. easing: 'ease-in'
  21533. };
  21534. }
  21535. me.animate(Ext.applyIf({
  21536. callback: function() {
  21537. if (!visible) {
  21538. me.setVisible(false).setOpacity(1);
  21539. }
  21540. },
  21541. to: {
  21542. opacity: (visible) ? 1 : 0
  21543. }
  21544. }, animate));
  21545. }
  21546. (me.$cache || me.getCache()).data[ISVISIBLE] = visible;
  21547. return me;
  21548. },
  21549. /**
  21550. * @private
  21551. * Determine if the Element has a relevant height and width available based
  21552. * upon current logical visibility state
  21553. */
  21554. hasMetrics : function(){
  21555. var visMode = getVisMode(this);
  21556. return this.isVisible() || (visMode == Element.OFFSETS) || (visMode == Element.VISIBILITY);
  21557. },
  21558. /**
  21559. * Toggles the element's visibility or display, depending on visibility mode.
  21560. * @param {Boolean/Object} [animate] True for the default animation, or a standard Element animation config object
  21561. * @return {Ext.dom.Element} this
  21562. */
  21563. toggle : function(animate){
  21564. var me = this;
  21565. me.setVisible(!me.isVisible(), me.anim(animate));
  21566. return me;
  21567. },
  21568. /**
  21569. * Sets the CSS display property. Uses originalDisplay if the specified value is a boolean true.
  21570. * @param {Boolean/String} value Boolean value to display the element using its default display, or a string to set the display directly.
  21571. * @return {Ext.dom.Element} this
  21572. */
  21573. setDisplayed : function(value) {
  21574. if(typeof value == "boolean"){
  21575. value = value ? getDisplay(this) : NONE;
  21576. }
  21577. this.setStyle(DISPLAY, value);
  21578. return this;
  21579. },
  21580. // private
  21581. fixDisplay : function(){
  21582. var me = this;
  21583. if (me.isStyle(DISPLAY, NONE)) {
  21584. me.setStyle(VISIBILITY, HIDDEN);
  21585. me.setStyle(DISPLAY, getDisplay(me)); // first try reverting to default
  21586. if (me.isStyle(DISPLAY, NONE)) { // if that fails, default to block
  21587. me.setStyle(DISPLAY, "block");
  21588. }
  21589. }
  21590. },
  21591. /**
  21592. * Hide this element - Uses display mode to determine whether to use "display" or "visibility". See {@link #setVisible}.
  21593. * @param {Boolean/Object} [animate] true for the default animation or a standard Element animation config object
  21594. * @return {Ext.dom.Element} this
  21595. */
  21596. hide : function(animate){
  21597. // hideMode override
  21598. if (typeof animate == 'string'){
  21599. this.setVisible(false, animate);
  21600. return this;
  21601. }
  21602. this.setVisible(false, this.anim(animate));
  21603. return this;
  21604. },
  21605. /**
  21606. * Show this element - Uses display mode to determine whether to use "display" or "visibility". See {@link #setVisible}.
  21607. * @param {Boolean/Object} [animate] true for the default animation or a standard Element animation config object
  21608. * @return {Ext.dom.Element} this
  21609. */
  21610. show : function(animate){
  21611. // hideMode override
  21612. if (typeof animate == 'string'){
  21613. this.setVisible(true, animate);
  21614. return this;
  21615. }
  21616. this.setVisible(true, this.anim(animate));
  21617. return this;
  21618. }
  21619. });
  21620. }());
  21621. //@tag dom,core
  21622. //@require Ext.dom.Element-fx
  21623. //@define Ext.dom.Element-position
  21624. //@define Ext.dom.Element
  21625. /**
  21626. * @class Ext.dom.Element
  21627. */
  21628. (function() {
  21629. var Element = Ext.dom.Element,
  21630. LEFT = "left",
  21631. RIGHT = "right",
  21632. TOP = "top",
  21633. BOTTOM = "bottom",
  21634. POSITION = "position",
  21635. STATIC = "static",
  21636. RELATIVE = "relative",
  21637. AUTO = "auto",
  21638. ZINDEX = "z-index",
  21639. BODY = 'BODY',
  21640. PADDING = 'padding',
  21641. BORDER = 'border',
  21642. SLEFT = '-left',
  21643. SRIGHT = '-right',
  21644. STOP = '-top',
  21645. SBOTTOM = '-bottom',
  21646. SWIDTH = '-width',
  21647. // special markup used throughout Ext when box wrapping elements
  21648. borders = {l: BORDER + SLEFT + SWIDTH, r: BORDER + SRIGHT + SWIDTH, t: BORDER + STOP + SWIDTH, b: BORDER + SBOTTOM + SWIDTH},
  21649. paddings = {l: PADDING + SLEFT, r: PADDING + SRIGHT, t: PADDING + STOP, b: PADDING + SBOTTOM},
  21650. paddingsTLRB = [paddings.l, paddings.r, paddings.t, paddings.b],
  21651. bordersTLRB = [borders.l, borders.r, borders.t, borders.b],
  21652. positionTopLeft = ['position', 'top', 'left'];
  21653. Element.override({
  21654. getX: function() {
  21655. return Element.getX(this.dom);
  21656. },
  21657. getY: function() {
  21658. return Element.getY(this.dom);
  21659. },
  21660. /**
  21661. * Gets the current position of the element based on page coordinates.
  21662. * Element must be part of the DOM tree to have page coordinates
  21663. * (display:none or elements not appended return false).
  21664. * @return {Number[]} The XY position of the element
  21665. */
  21666. getXY: function() {
  21667. return Element.getXY(this.dom);
  21668. },
  21669. /**
  21670. * Returns the offsets of this element from the passed element. Both element must be part
  21671. * of the DOM tree and not have display:none to have page coordinates.
  21672. * @param {String/HTMLElement/Ext.Element} element The element to get the offsets from.
  21673. * @return {Number[]} The XY page offsets (e.g. `[100, -200]`)
  21674. */
  21675. getOffsetsTo : function(el){
  21676. var o = this.getXY(),
  21677. e = Ext.fly(el, '_internal').getXY();
  21678. return [o[0] - e[0],o[1] - e[1]];
  21679. },
  21680. setX: function(x, animate) {
  21681. return this.setXY([x, this.getY()], animate);
  21682. },
  21683. setY: function(y, animate) {
  21684. return this.setXY([this.getX(), y], animate);
  21685. },
  21686. setLeft: function(left) {
  21687. this.setStyle(LEFT, this.addUnits(left));
  21688. return this;
  21689. },
  21690. setTop: function(top) {
  21691. this.setStyle(TOP, this.addUnits(top));
  21692. return this;
  21693. },
  21694. setRight: function(right) {
  21695. this.setStyle(RIGHT, this.addUnits(right));
  21696. return this;
  21697. },
  21698. setBottom: function(bottom) {
  21699. this.setStyle(BOTTOM, this.addUnits(bottom));
  21700. return this;
  21701. },
  21702. /**
  21703. * Sets the position of the element in page coordinates, regardless of how the element
  21704. * is positioned. The element must be part of the DOM tree to have page coordinates
  21705. * (`display:none` or elements not appended return false).
  21706. * @param {Number[]} pos Contains X & Y [x, y] values for new position (coordinates are page-based)
  21707. * @param {Boolean/Object} [animate] True for the default animation, or a standard Element
  21708. * animation config object
  21709. * @return {Ext.Element} this
  21710. */
  21711. setXY: function(pos, animate) {
  21712. var me = this;
  21713. if (!animate || !me.anim) {
  21714. Element.setXY(me.dom, pos);
  21715. }
  21716. else {
  21717. if (!Ext.isObject(animate)) {
  21718. animate = {};
  21719. }
  21720. me.animate(Ext.applyIf({ to: { x: pos[0], y: pos[1] } }, animate));
  21721. }
  21722. return me;
  21723. },
  21724. pxRe: /^\d+(?:\.\d*)?px$/i,
  21725. /**
  21726. * Returns the x-coordinate of this element reletive to its `offsetParent`.
  21727. * @return {Number} The local x-coordinate (relative to the `offsetParent`).
  21728. */
  21729. getLocalX: function() {
  21730. var me = this,
  21731. offsetParent,
  21732. x = me.getStyle(LEFT);
  21733. if (!x || x === AUTO) {
  21734. return 0;
  21735. }
  21736. if (x && me.pxRe.test(x)) {
  21737. return parseFloat(x);
  21738. }
  21739. x = me.getX();
  21740. offsetParent = me.dom.offsetParent;
  21741. if (offsetParent) {
  21742. x -= Ext.fly(offsetParent).getX();
  21743. }
  21744. return x;
  21745. },
  21746. /**
  21747. * Returns the y-coordinate of this element reletive to its `offsetParent`.
  21748. * @return {Number} The local y-coordinate (relative to the `offsetParent`).
  21749. */
  21750. getLocalY: function() {
  21751. var me = this,
  21752. offsetParent,
  21753. y = me.getStyle(TOP);
  21754. if (!y || y === AUTO) {
  21755. return 0;
  21756. }
  21757. if (y && me.pxRe.test(y)) {
  21758. return parseFloat(y);
  21759. }
  21760. y = me.getY();
  21761. offsetParent = me.dom.offsetParent;
  21762. if (offsetParent) {
  21763. y -= Ext.fly(offsetParent).getY();
  21764. }
  21765. return y;
  21766. },
  21767. getLeft: function(local) {
  21768. return local ? this.getLocalX() : this.getX();
  21769. },
  21770. getRight: function(local) {
  21771. return (local ? this.getLocalX() : this.getX()) + this.getWidth();
  21772. },
  21773. getTop: function(local) {
  21774. return local ? this.getLocalY() : this.getY();
  21775. },
  21776. getBottom: function(local) {
  21777. return (local ? this.getLocalY() : this.getY()) + this.getHeight();
  21778. },
  21779. translatePoints: function(x, y) {
  21780. var me = this,
  21781. styles = me.getStyle(positionTopLeft),
  21782. relative = styles.position == 'relative',
  21783. left = parseFloat(styles.left),
  21784. top = parseFloat(styles.top),
  21785. xy = me.getXY();
  21786. if (Ext.isArray(x)) {
  21787. y = x[1];
  21788. x = x[0];
  21789. }
  21790. if (isNaN(left)) {
  21791. left = relative ? 0 : me.dom.offsetLeft;
  21792. }
  21793. if (isNaN(top)) {
  21794. top = relative ? 0 : me.dom.offsetTop;
  21795. }
  21796. left = (typeof x == 'number') ? x - xy[0] + left : undefined;
  21797. top = (typeof y == 'number') ? y - xy[1] + top : undefined;
  21798. return {
  21799. left: left,
  21800. top: top
  21801. };
  21802. },
  21803. setBox: function(box, adjust, animate) {
  21804. var me = this,
  21805. w = box.width,
  21806. h = box.height;
  21807. if ((adjust && !me.autoBoxAdjust) && !me.isBorderBox()) {
  21808. w -= (me.getBorderWidth("lr") + me.getPadding("lr"));
  21809. h -= (me.getBorderWidth("tb") + me.getPadding("tb"));
  21810. }
  21811. me.setBounds(box.x, box.y, w, h, animate);
  21812. return me;
  21813. },
  21814. getBox: function(contentBox, local) {
  21815. var me = this,
  21816. xy,
  21817. left,
  21818. top,
  21819. paddingWidth,
  21820. bordersWidth,
  21821. l, r, t, b, w, h, bx;
  21822. if (!local) {
  21823. xy = me.getXY();
  21824. } else {
  21825. xy = me.getStyle([LEFT, TOP]);
  21826. xy = [ parseFloat(xy.left) || 0, parseFloat(xy.top) || 0];
  21827. }
  21828. w = me.getWidth();
  21829. h = me.getHeight();
  21830. if (!contentBox) {
  21831. bx = {
  21832. x: xy[0],
  21833. y: xy[1],
  21834. 0: xy[0],
  21835. 1: xy[1],
  21836. width: w,
  21837. height: h
  21838. };
  21839. } else {
  21840. paddingWidth = me.getStyle(paddingsTLRB);
  21841. bordersWidth = me.getStyle(bordersTLRB);
  21842. l = (parseFloat(bordersWidth[borders.l]) || 0) + (parseFloat(paddingWidth[paddings.l]) || 0);
  21843. r = (parseFloat(bordersWidth[borders.r]) || 0) + (parseFloat(paddingWidth[paddings.r]) || 0);
  21844. t = (parseFloat(bordersWidth[borders.t]) || 0) + (parseFloat(paddingWidth[paddings.t]) || 0);
  21845. b = (parseFloat(bordersWidth[borders.b]) || 0) + (parseFloat(paddingWidth[paddings.b]) || 0);
  21846. bx = {
  21847. x: xy[0] + l,
  21848. y: xy[1] + t,
  21849. 0: xy[0] + l,
  21850. 1: xy[1] + t,
  21851. width: w - (l + r),
  21852. height: h - (t + b)
  21853. };
  21854. }
  21855. bx.right = bx.x + bx.width;
  21856. bx.bottom = bx.y + bx.height;
  21857. return bx;
  21858. },
  21859. getPageBox: function(getRegion) {
  21860. var me = this,
  21861. el = me.dom,
  21862. isDoc = el.nodeName == BODY,
  21863. w = isDoc ? Ext.dom.AbstractElement.getViewWidth() : el.offsetWidth,
  21864. h = isDoc ? Ext.dom.AbstractElement.getViewHeight() : el.offsetHeight,
  21865. xy = me.getXY(),
  21866. t = xy[1],
  21867. r = xy[0] + w,
  21868. b = xy[1] + h,
  21869. l = xy[0];
  21870. if (getRegion) {
  21871. return new Ext.util.Region(t, r, b, l);
  21872. }
  21873. else {
  21874. return {
  21875. left: l,
  21876. top: t,
  21877. width: w,
  21878. height: h,
  21879. right: r,
  21880. bottom: b
  21881. };
  21882. }
  21883. },
  21884. /**
  21885. * Sets the position of the element in page coordinates, regardless of how the element
  21886. * is positioned. The element must be part of the DOM tree to have page coordinates
  21887. * (`display:none` or elements not appended return false).
  21888. * @param {Number} x X value for new position (coordinates are page-based)
  21889. * @param {Number} y Y value for new position (coordinates are page-based)
  21890. * @param {Boolean/Object} [animate] True for the default animation, or a standard Element
  21891. * animation config object
  21892. * @return {Ext.dom.AbstractElement} this
  21893. */
  21894. setLocation : function(x, y, animate) {
  21895. return this.setXY([x, y], animate);
  21896. },
  21897. /**
  21898. * Sets the position of the element in page coordinates, regardless of how the element
  21899. * is positioned. The element must be part of the DOM tree to have page coordinates
  21900. * (`display:none` or elements not appended return false).
  21901. * @param {Number} x X value for new position (coordinates are page-based)
  21902. * @param {Number} y Y value for new position (coordinates are page-based)
  21903. * @param {Boolean/Object} [animate] True for the default animation, or a standard Element
  21904. * animation config object
  21905. * @return {Ext.dom.AbstractElement} this
  21906. */
  21907. moveTo : function(x, y, animate) {
  21908. return this.setXY([x, y], animate);
  21909. },
  21910. /**
  21911. * Initializes positioning on this element. If a desired position is not passed, it will make the
  21912. * the element positioned relative IF it is not already positioned.
  21913. * @param {String} [pos] Positioning to use "relative", "absolute" or "fixed"
  21914. * @param {Number} [zIndex] The zIndex to apply
  21915. * @param {Number} [x] Set the page X position
  21916. * @param {Number} [y] Set the page Y position
  21917. */
  21918. position : function(pos, zIndex, x, y) {
  21919. var me = this;
  21920. if (!pos && me.isStyle(POSITION, STATIC)) {
  21921. me.setStyle(POSITION, RELATIVE);
  21922. } else if (pos) {
  21923. me.setStyle(POSITION, pos);
  21924. }
  21925. if (zIndex) {
  21926. me.setStyle(ZINDEX, zIndex);
  21927. }
  21928. if (x || y) {
  21929. me.setXY([x || false, y || false]);
  21930. }
  21931. },
  21932. /**
  21933. * Clears positioning back to the default when the document was loaded.
  21934. * @param {String} [value=''] The value to use for the left, right, top, bottom. You could use 'auto'.
  21935. * @return {Ext.dom.AbstractElement} this
  21936. */
  21937. clearPositioning : function(value) {
  21938. value = value || '';
  21939. this.setStyle({
  21940. left : value,
  21941. right : value,
  21942. top : value,
  21943. bottom : value,
  21944. "z-index" : "",
  21945. position : STATIC
  21946. });
  21947. return this;
  21948. },
  21949. /**
  21950. * Gets an object with all CSS positioning properties. Useful along with #setPostioning to get
  21951. * snapshot before performing an update and then restoring the element.
  21952. * @return {Object}
  21953. */
  21954. getPositioning : function(){
  21955. var styles = this.getStyle([LEFT, TOP, POSITION, RIGHT, BOTTOM, ZINDEX]);
  21956. styles[RIGHT] = styles[LEFT] ? '' : styles[RIGHT];
  21957. styles[BOTTOM] = styles[TOP] ? '' : styles[BOTTOM];
  21958. return styles;
  21959. },
  21960. /**
  21961. * Set positioning with an object returned by #getPositioning.
  21962. * @param {Object} posCfg
  21963. * @return {Ext.dom.AbstractElement} this
  21964. */
  21965. setPositioning : function(pc) {
  21966. var me = this,
  21967. style = me.dom.style;
  21968. me.setStyle(pc);
  21969. if (pc.right == AUTO) {
  21970. style.right = "";
  21971. }
  21972. if (pc.bottom == AUTO) {
  21973. style.bottom = "";
  21974. }
  21975. return me;
  21976. },
  21977. /**
  21978. * Move this element relative to its current position.
  21979. * @param {String} direction Possible values are:
  21980. *
  21981. * - `"l"` (or `"left"`)
  21982. * - `"r"` (or `"right"`)
  21983. * - `"t"` (or `"top"`, or `"up"`)
  21984. * - `"b"` (or `"bottom"`, or `"down"`)
  21985. *
  21986. * @param {Number} distance How far to move the element in pixels
  21987. * @param {Boolean/Object} [animate] true for the default animation or a standard Element
  21988. * animation config object
  21989. */
  21990. move: function(direction, distance, animate) {
  21991. var me = this,
  21992. xy = me.getXY(),
  21993. x = xy[0],
  21994. y = xy[1],
  21995. left = [x - distance, y],
  21996. right = [x + distance, y],
  21997. top = [x, y - distance],
  21998. bottom = [x, y + distance],
  21999. hash = {
  22000. l: left,
  22001. left: left,
  22002. r: right,
  22003. right: right,
  22004. t: top,
  22005. top: top,
  22006. up: top,
  22007. b: bottom,
  22008. bottom: bottom,
  22009. down: bottom
  22010. };
  22011. direction = direction.toLowerCase();
  22012. me.moveTo(hash[direction][0], hash[direction][1], animate);
  22013. },
  22014. /**
  22015. * Conveniently sets left and top adding default units.
  22016. * @param {String} left The left CSS property value
  22017. * @param {String} top The top CSS property value
  22018. * @return {Ext.dom.Element} this
  22019. */
  22020. setLeftTop: function(left, top) {
  22021. var style = this.dom.style;
  22022. style.left = Element.addUnits(left);
  22023. style.top = Element.addUnits(top);
  22024. return this;
  22025. },
  22026. /**
  22027. * Returns the region of this element.
  22028. * The element must be part of the DOM tree to have a region
  22029. * (display:none or elements not appended return false).
  22030. * @return {Ext.util.Region} A Region containing "top, left, bottom, right" member data.
  22031. */
  22032. getRegion: function() {
  22033. return this.getPageBox(true);
  22034. },
  22035. /**
  22036. * Returns the **content** region of this element. That is the region within the borders and padding.
  22037. * @return {Ext.util.Region} A Region containing "top, left, bottom, right" member data.
  22038. */
  22039. getViewRegion: function() {
  22040. var me = this,
  22041. isBody = me.dom.nodeName == BODY,
  22042. scroll, pos, top, left, width, height;
  22043. // For the body we want to do some special logic
  22044. if (isBody) {
  22045. scroll = me.getScroll();
  22046. left = scroll.left;
  22047. top = scroll.top;
  22048. width = Ext.dom.AbstractElement.getViewportWidth();
  22049. height = Ext.dom.AbstractElement.getViewportHeight();
  22050. }
  22051. else {
  22052. pos = me.getXY();
  22053. left = pos[0] + me.getBorderWidth('l') + me.getPadding('l');
  22054. top = pos[1] + me.getBorderWidth('t') + me.getPadding('t');
  22055. width = me.getWidth(true);
  22056. height = me.getHeight(true);
  22057. }
  22058. return new Ext.util.Region(top, left + width - 1, top + height - 1, left);
  22059. },
  22060. /**
  22061. * Sets the element's position and size in one shot. If animation is true then width, height,
  22062. * x and y will be animated concurrently.
  22063. *
  22064. * @param {Number} x X value for new position (coordinates are page-based)
  22065. * @param {Number} y Y value for new position (coordinates are page-based)
  22066. * @param {Number/String} width The new width. This may be one of:
  22067. *
  22068. * - A Number specifying the new width in this Element's {@link #defaultUnit}s (by default, pixels)
  22069. * - A String used to set the CSS width style. Animation may **not** be used.
  22070. *
  22071. * @param {Number/String} height The new height. This may be one of:
  22072. *
  22073. * - A Number specifying the new height in this Element's {@link #defaultUnit}s (by default, pixels)
  22074. * - A String used to set the CSS height style. Animation may **not** be used.
  22075. *
  22076. * @param {Boolean/Object} [animate] true for the default animation or a standard Element
  22077. * animation config object
  22078. *
  22079. * @return {Ext.dom.AbstractElement} this
  22080. */
  22081. setBounds: function(x, y, width, height, animate) {
  22082. var me = this;
  22083. if (!animate || !me.anim) {
  22084. me.setSize(width, height);
  22085. me.setLocation(x, y);
  22086. } else {
  22087. if (!Ext.isObject(animate)) {
  22088. animate = {};
  22089. }
  22090. me.animate(Ext.applyIf({
  22091. to: {
  22092. x: x,
  22093. y: y,
  22094. width: me.adjustWidth(width),
  22095. height: me.adjustHeight(height)
  22096. }
  22097. }, animate));
  22098. }
  22099. return me;
  22100. },
  22101. /**
  22102. * Sets the element's position and size the specified region. If animation is true then width, height,
  22103. * x and y will be animated concurrently.
  22104. *
  22105. * @param {Ext.util.Region} region The region to fill
  22106. * @param {Boolean/Object} [animate] true for the default animation or a standard Element
  22107. * animation config object
  22108. * @return {Ext.dom.AbstractElement} this
  22109. */
  22110. setRegion: function(region, animate) {
  22111. return this.setBounds(region.left, region.top, region.right - region.left, region.bottom - region.top, animate);
  22112. }
  22113. });
  22114. }());
  22115. //@tag dom,core
  22116. //@require Ext.dom.Element-position
  22117. //@define Ext.dom.Element-scroll
  22118. //@define Ext.dom.Element
  22119. /**
  22120. * @class Ext.dom.Element
  22121. */
  22122. Ext.dom.Element.override({
  22123. /**
  22124. * Returns true if this element is scrollable.
  22125. * @return {Boolean}
  22126. */
  22127. isScrollable: function() {
  22128. var dom = this.dom;
  22129. return dom.scrollHeight > dom.clientHeight || dom.scrollWidth > dom.clientWidth;
  22130. },
  22131. /**
  22132. * Returns the current scroll position of the element.
  22133. * @return {Object} An object containing the scroll position in the format
  22134. * `{left: (scrollLeft), top: (scrollTop)}`
  22135. */
  22136. getScroll: function() {
  22137. var d = this.dom,
  22138. doc = document,
  22139. body = doc.body,
  22140. docElement = doc.documentElement,
  22141. l,
  22142. t,
  22143. ret;
  22144. if (d == doc || d == body) {
  22145. if (Ext.isIE && Ext.isStrict) {
  22146. l = docElement.scrollLeft;
  22147. t = docElement.scrollTop;
  22148. } else {
  22149. l = window.pageXOffset;
  22150. t = window.pageYOffset;
  22151. }
  22152. ret = {
  22153. left: l || (body ? body.scrollLeft : 0),
  22154. top : t || (body ? body.scrollTop : 0)
  22155. };
  22156. } else {
  22157. ret = {
  22158. left: d.scrollLeft,
  22159. top : d.scrollTop
  22160. };
  22161. }
  22162. return ret;
  22163. },
  22164. /**
  22165. * Scrolls this element by the passed delta values, optionally animating.
  22166. *
  22167. * All of the following are equivalent:
  22168. *
  22169. * el.scrollBy(10, 10, true);
  22170. * el.scrollBy([10, 10], true);
  22171. * el.scrollBy({ x: 10, y: 10 }, true);
  22172. *
  22173. * @param {Number/Number[]/Object} deltaX Either the x delta, an Array specifying x and y deltas or
  22174. * an object with "x" and "y" properties.
  22175. * @param {Number/Boolean/Object} deltaY Either the y delta, or an animate flag or config object.
  22176. * @param {Boolean/Object} animate Animate flag/config object if the delta values were passed separately.
  22177. * @return {Ext.Element} this
  22178. */
  22179. scrollBy: function(deltaX, deltaY, animate) {
  22180. var me = this,
  22181. dom = me.dom;
  22182. // Extract args if deltas were passed as an Array.
  22183. if (deltaX.length) {
  22184. animate = deltaY;
  22185. deltaY = deltaX[1];
  22186. deltaX = deltaX[0];
  22187. } else if (typeof deltaX != 'number') { // or an object
  22188. animate = deltaY;
  22189. deltaY = deltaX.y;
  22190. deltaX = deltaX.x;
  22191. }
  22192. if (deltaX) {
  22193. me.scrollTo('left', Math.max(Math.min(dom.scrollLeft + deltaX, dom.scrollWidth - dom.clientWidth), 0), animate);
  22194. }
  22195. if (deltaY) {
  22196. me.scrollTo('top', Math.max(Math.min(dom.scrollTop + deltaY, dom.scrollHeight - dom.clientHeight), 0), animate);
  22197. }
  22198. return me;
  22199. },
  22200. /**
  22201. * Scrolls this element the specified scroll point. It does NOT do bounds checking so
  22202. * if you scroll to a weird value it will try to do it. For auto bounds checking, use #scroll.
  22203. * @param {String} side Either "left" for scrollLeft values or "top" for scrollTop values.
  22204. * @param {Number} value The new scroll value
  22205. * @param {Boolean/Object} [animate] true for the default animation or a standard Element
  22206. * animation config object
  22207. * @return {Ext.Element} this
  22208. */
  22209. scrollTo: function(side, value, animate) {
  22210. //check if we're scrolling top or left
  22211. var top = /top/i.test(side),
  22212. me = this,
  22213. dom = me.dom,
  22214. animCfg,
  22215. prop;
  22216. if (!animate || !me.anim) {
  22217. // just setting the value, so grab the direction
  22218. prop = 'scroll' + (top ? 'Top' : 'Left');
  22219. dom[prop] = value;
  22220. // corrects IE, other browsers will ignore
  22221. dom[prop] = value;
  22222. }
  22223. else {
  22224. animCfg = {
  22225. to: {}
  22226. };
  22227. animCfg.to['scroll' + (top ? 'Top' : 'Left')] = value;
  22228. if (Ext.isObject(animate)) {
  22229. Ext.applyIf(animCfg, animate);
  22230. }
  22231. me.animate(animCfg);
  22232. }
  22233. return me;
  22234. },
  22235. /**
  22236. * Scrolls this element into view within the passed container.
  22237. * @param {String/HTMLElement/Ext.Element} [container=document.body] The container element
  22238. * to scroll. Should be a string (id), dom node, or Ext.Element.
  22239. * @param {Boolean} [hscroll=true] False to disable horizontal scroll.
  22240. * @param {Boolean/Object} [animate] true for the default animation or a standard Element
  22241. * animation config object
  22242. * @return {Ext.dom.Element} this
  22243. */
  22244. scrollIntoView: function(container, hscroll, animate) {
  22245. container = Ext.getDom(container) || Ext.getBody().dom;
  22246. var el = this.dom,
  22247. offsets = this.getOffsetsTo(container),
  22248. // el's box
  22249. left = offsets[0] + container.scrollLeft,
  22250. top = offsets[1] + container.scrollTop,
  22251. bottom = top + el.offsetHeight,
  22252. right = left + el.offsetWidth,
  22253. // ct's box
  22254. ctClientHeight = container.clientHeight,
  22255. ctScrollTop = parseInt(container.scrollTop, 10),
  22256. ctScrollLeft = parseInt(container.scrollLeft, 10),
  22257. ctBottom = ctScrollTop + ctClientHeight,
  22258. ctRight = ctScrollLeft + container.clientWidth,
  22259. newPos;
  22260. if (el.offsetHeight > ctClientHeight || top < ctScrollTop) {
  22261. newPos = top;
  22262. } else if (bottom > ctBottom) {
  22263. newPos = bottom - ctClientHeight;
  22264. }
  22265. if (newPos != null) {
  22266. Ext.get(container).scrollTo('top', newPos, animate);
  22267. }
  22268. if (hscroll !== false) {
  22269. newPos = null;
  22270. if (el.offsetWidth > container.clientWidth || left < ctScrollLeft) {
  22271. newPos = left;
  22272. } else if (right > ctRight) {
  22273. newPos = right - container.clientWidth;
  22274. }
  22275. if (newPos != null) {
  22276. Ext.get(container).scrollTo('left', newPos, animate);
  22277. }
  22278. }
  22279. return this;
  22280. },
  22281. // @private
  22282. scrollChildIntoView: function(child, hscroll) {
  22283. Ext.fly(child, '_scrollChildIntoView').scrollIntoView(this, hscroll);
  22284. },
  22285. /**
  22286. * Scrolls this element the specified direction. Does bounds checking to make sure the scroll is
  22287. * within this element's scrollable range.
  22288. * @param {String} direction Possible values are:
  22289. *
  22290. * - `"l"` (or `"left"`)
  22291. * - `"r"` (or `"right"`)
  22292. * - `"t"` (or `"top"`, or `"up"`)
  22293. * - `"b"` (or `"bottom"`, or `"down"`)
  22294. *
  22295. * @param {Number} distance How far to scroll the element in pixels
  22296. * @param {Boolean/Object} [animate] true for the default animation or a standard Element
  22297. * animation config object
  22298. * @return {Boolean} Returns true if a scroll was triggered or false if the element
  22299. * was scrolled as far as it could go.
  22300. */
  22301. scroll: function(direction, distance, animate) {
  22302. if (!this.isScrollable()) {
  22303. return false;
  22304. }
  22305. var el = this.dom,
  22306. l = el.scrollLeft, t = el.scrollTop,
  22307. w = el.scrollWidth, h = el.scrollHeight,
  22308. cw = el.clientWidth, ch = el.clientHeight,
  22309. scrolled = false, v,
  22310. hash = {
  22311. l: Math.min(l + distance, w - cw),
  22312. r: v = Math.max(l - distance, 0),
  22313. t: Math.max(t - distance, 0),
  22314. b: Math.min(t + distance, h - ch)
  22315. };
  22316. hash.d = hash.b;
  22317. hash.u = hash.t;
  22318. direction = direction.substr(0, 1);
  22319. if ((v = hash[direction]) > -1) {
  22320. scrolled = true;
  22321. this.scrollTo(direction == 'l' || direction == 'r' ? 'left' : 'top', v, this.anim(animate));
  22322. }
  22323. return scrolled;
  22324. }
  22325. });
  22326. //@tag dom,core
  22327. //@require Ext.dom.Element-scroll
  22328. //@define Ext.dom.Element-style
  22329. //@define Ext.dom.Element
  22330. /**
  22331. * @class Ext.dom.Element
  22332. */
  22333. (function() {
  22334. var Element = Ext.dom.Element,
  22335. view = document.defaultView,
  22336. adjustDirect2DTableRe = /table-row|table-.*-group/,
  22337. INTERNAL = '_internal',
  22338. HIDDEN = 'hidden',
  22339. HEIGHT = 'height',
  22340. WIDTH = 'width',
  22341. ISCLIPPED = 'isClipped',
  22342. OVERFLOW = 'overflow',
  22343. OVERFLOWX = 'overflow-x',
  22344. OVERFLOWY = 'overflow-y',
  22345. ORIGINALCLIP = 'originalClip',
  22346. DOCORBODYRE = /#document|body/i,
  22347. // This reduces the lookup of 'me.styleHooks' by one hop in the prototype chain. It is
  22348. // the same object.
  22349. styleHooks,
  22350. edges, k, edge, borderWidth;
  22351. if (!view || !view.getComputedStyle) {
  22352. Element.prototype.getStyle = function (property, inline) {
  22353. var me = this,
  22354. dom = me.dom,
  22355. multiple = typeof property != 'string',
  22356. hooks = me.styleHooks,
  22357. prop = property,
  22358. props = prop,
  22359. len = 1,
  22360. isInline = inline,
  22361. camel, domStyle, values, hook, out, style, i;
  22362. if (multiple) {
  22363. values = {};
  22364. prop = props[0];
  22365. i = 0;
  22366. if (!(len = props.length)) {
  22367. return values;
  22368. }
  22369. }
  22370. if (!dom || dom.documentElement) {
  22371. return values || '';
  22372. }
  22373. domStyle = dom.style;
  22374. if (inline) {
  22375. style = domStyle;
  22376. } else {
  22377. style = dom.currentStyle;
  22378. // fallback to inline style if rendering context not available
  22379. if (!style) {
  22380. isInline = true;
  22381. style = domStyle;
  22382. }
  22383. }
  22384. do {
  22385. hook = hooks[prop];
  22386. if (!hook) {
  22387. hooks[prop] = hook = { name: Element.normalize(prop) };
  22388. }
  22389. if (hook.get) {
  22390. out = hook.get(dom, me, isInline, style);
  22391. } else {
  22392. camel = hook.name;
  22393. // In some cases, IE6 will throw Invalid Argument exceptions for properties
  22394. // like fontSize (/examples/tabs/tabs.html in 4.0 used to exhibit this but
  22395. // no longer does due to font style changes). There is a real cost to a try
  22396. // block, so we avoid it where possible...
  22397. if (hook.canThrow) {
  22398. try {
  22399. out = style[camel];
  22400. } catch (e) {
  22401. out = '';
  22402. }
  22403. } else {
  22404. // EXTJSIV-5657 - In IE9 quirks mode there is a chance that VML root element
  22405. // has neither `currentStyle` nor `style`. Return '' this case.
  22406. out = style ? style[camel] : '';
  22407. }
  22408. }
  22409. if (!multiple) {
  22410. return out;
  22411. }
  22412. values[prop] = out;
  22413. prop = props[++i];
  22414. } while (i < len);
  22415. return values;
  22416. };
  22417. }
  22418. Element.override({
  22419. getHeight: function(contentHeight, preciseHeight) {
  22420. var me = this,
  22421. dom = me.dom,
  22422. hidden = me.isStyle('display', 'none'),
  22423. height,
  22424. floating;
  22425. if (hidden) {
  22426. return 0;
  22427. }
  22428. height = Math.max(dom.offsetHeight, dom.clientHeight) || 0;
  22429. // IE9 Direct2D dimension rounding bug
  22430. if (Ext.supports.Direct2DBug) {
  22431. floating = me.adjustDirect2DDimension(HEIGHT);
  22432. if (preciseHeight) {
  22433. height += floating;
  22434. }
  22435. else if (floating > 0 && floating < 0.5) {
  22436. height++;
  22437. }
  22438. }
  22439. if (contentHeight) {
  22440. height -= me.getBorderWidth("tb") + me.getPadding("tb");
  22441. }
  22442. return (height < 0) ? 0 : height;
  22443. },
  22444. getWidth: function(contentWidth, preciseWidth) {
  22445. var me = this,
  22446. dom = me.dom,
  22447. hidden = me.isStyle('display', 'none'),
  22448. rect, width, floating;
  22449. if (hidden) {
  22450. return 0;
  22451. }
  22452. // Gecko will in some cases report an offsetWidth that is actually less than the width of the
  22453. // text contents, because it measures fonts with sub-pixel precision but rounds the calculated
  22454. // value down. Using getBoundingClientRect instead of offsetWidth allows us to get the precise
  22455. // subpixel measurements so we can force them to always be rounded up. See
  22456. // https://bugzilla.mozilla.org/show_bug.cgi?id=458617
  22457. // Rounding up ensures that the width includes the full width of the text contents.
  22458. if (Ext.supports.BoundingClientRect) {
  22459. rect = dom.getBoundingClientRect();
  22460. width = rect.right - rect.left;
  22461. width = preciseWidth ? width : Math.ceil(width);
  22462. } else {
  22463. width = dom.offsetWidth;
  22464. }
  22465. width = Math.max(width, dom.clientWidth) || 0;
  22466. // IE9 Direct2D dimension rounding bug
  22467. if (Ext.supports.Direct2DBug) {
  22468. // get the fractional portion of the sub-pixel precision width of the element's text contents
  22469. floating = me.adjustDirect2DDimension(WIDTH);
  22470. if (preciseWidth) {
  22471. width += floating;
  22472. }
  22473. // IE9 also measures fonts with sub-pixel precision, but unlike Gecko, instead of rounding the offsetWidth down,
  22474. // it rounds to the nearest integer. This means that in order to ensure that the width includes the full
  22475. // width of the text contents we need to increment the width by 1 only if the fractional portion is less than 0.5
  22476. else if (floating > 0 && floating < 0.5) {
  22477. width++;
  22478. }
  22479. }
  22480. if (contentWidth) {
  22481. width -= me.getBorderWidth("lr") + me.getPadding("lr");
  22482. }
  22483. return (width < 0) ? 0 : width;
  22484. },
  22485. setWidth: function(width, animate) {
  22486. var me = this;
  22487. width = me.adjustWidth(width);
  22488. if (!animate || !me.anim) {
  22489. me.dom.style.width = me.addUnits(width);
  22490. }
  22491. else {
  22492. if (!Ext.isObject(animate)) {
  22493. animate = {};
  22494. }
  22495. me.animate(Ext.applyIf({
  22496. to: {
  22497. width: width
  22498. }
  22499. }, animate));
  22500. }
  22501. return me;
  22502. },
  22503. setHeight : function(height, animate) {
  22504. var me = this;
  22505. height = me.adjustHeight(height);
  22506. if (!animate || !me.anim) {
  22507. me.dom.style.height = me.addUnits(height);
  22508. }
  22509. else {
  22510. if (!Ext.isObject(animate)) {
  22511. animate = {};
  22512. }
  22513. me.animate(Ext.applyIf({
  22514. to: {
  22515. height: height
  22516. }
  22517. }, animate));
  22518. }
  22519. return me;
  22520. },
  22521. applyStyles: function(style) {
  22522. Ext.DomHelper.applyStyles(this.dom, style);
  22523. return this;
  22524. },
  22525. setSize: function(width, height, animate) {
  22526. var me = this;
  22527. if (Ext.isObject(width)) { // in case of object from getSize()
  22528. animate = height;
  22529. height = width.height;
  22530. width = width.width;
  22531. }
  22532. width = me.adjustWidth(width);
  22533. height = me.adjustHeight(height);
  22534. if (!animate || !me.anim) {
  22535. me.dom.style.width = me.addUnits(width);
  22536. me.dom.style.height = me.addUnits(height);
  22537. }
  22538. else {
  22539. if (animate === true) {
  22540. animate = {};
  22541. }
  22542. me.animate(Ext.applyIf({
  22543. to: {
  22544. width: width,
  22545. height: height
  22546. }
  22547. }, animate));
  22548. }
  22549. return me;
  22550. },
  22551. getViewSize : function() {
  22552. var me = this,
  22553. dom = me.dom,
  22554. isDoc = DOCORBODYRE.test(dom.nodeName),
  22555. ret;
  22556. // If the body, use static methods
  22557. if (isDoc) {
  22558. ret = {
  22559. width : Element.getViewWidth(),
  22560. height : Element.getViewHeight()
  22561. };
  22562. } else {
  22563. ret = {
  22564. width : dom.clientWidth,
  22565. height : dom.clientHeight
  22566. };
  22567. }
  22568. return ret;
  22569. },
  22570. getSize: function(contentSize) {
  22571. return {width: this.getWidth(contentSize), height: this.getHeight(contentSize)};
  22572. },
  22573. // TODO: Look at this
  22574. // private ==> used by Fx
  22575. adjustWidth : function(width) {
  22576. var me = this,
  22577. isNum = (typeof width == 'number');
  22578. if (isNum && me.autoBoxAdjust && !me.isBorderBox()) {
  22579. width -= (me.getBorderWidth("lr") + me.getPadding("lr"));
  22580. }
  22581. return (isNum && width < 0) ? 0 : width;
  22582. },
  22583. // private ==> used by Fx
  22584. adjustHeight : function(height) {
  22585. var me = this,
  22586. isNum = (typeof height == "number");
  22587. if (isNum && me.autoBoxAdjust && !me.isBorderBox()) {
  22588. height -= (me.getBorderWidth("tb") + me.getPadding("tb"));
  22589. }
  22590. return (isNum && height < 0) ? 0 : height;
  22591. },
  22592. /**
  22593. * Return the CSS color for the specified CSS attribute. rgb, 3 digit (like `#fff`) and valid values
  22594. * are convert to standard 6 digit hex color.
  22595. * @param {String} attr The css attribute
  22596. * @param {String} defaultValue The default value to use when a valid color isn't found
  22597. * @param {String} [prefix] defaults to #. Use an empty string when working with
  22598. * color anims.
  22599. */
  22600. getColor : function(attr, defaultValue, prefix) {
  22601. var v = this.getStyle(attr),
  22602. color = prefix || prefix === '' ? prefix : '#',
  22603. h, len, i=0;
  22604. if (!v || (/transparent|inherit/.test(v))) {
  22605. return defaultValue;
  22606. }
  22607. if (/^r/.test(v)) {
  22608. v = v.slice(4, v.length - 1).split(',');
  22609. len = v.length;
  22610. for (; i<len; i++) {
  22611. h = parseInt(v[i], 10);
  22612. color += (h < 16 ? '0' : '') + h.toString(16);
  22613. }
  22614. } else {
  22615. v = v.replace('#', '');
  22616. color += v.length == 3 ? v.replace(/^(\w)(\w)(\w)$/, '$1$1$2$2$3$3') : v;
  22617. }
  22618. return(color.length > 5 ? color.toLowerCase() : defaultValue);
  22619. },
  22620. /**
  22621. * Set the opacity of the element
  22622. * @param {Number} opacity The new opacity. 0 = transparent, .5 = 50% visibile, 1 = fully visible, etc
  22623. * @param {Boolean/Object} [animate] a standard Element animation config object or `true` for
  22624. * the default animation (`{duration: 350, easing: 'easeIn'}`)
  22625. * @return {Ext.dom.Element} this
  22626. */
  22627. setOpacity: function(opacity, animate) {
  22628. var me = this;
  22629. if (!me.dom) {
  22630. return me;
  22631. }
  22632. if (!animate || !me.anim) {
  22633. me.setStyle('opacity', opacity);
  22634. }
  22635. else {
  22636. if (typeof animate != 'object') {
  22637. animate = {
  22638. duration: 350,
  22639. easing: 'ease-in'
  22640. };
  22641. }
  22642. me.animate(Ext.applyIf({
  22643. to: {
  22644. opacity: opacity
  22645. }
  22646. }, animate));
  22647. }
  22648. return me;
  22649. },
  22650. /**
  22651. * Clears any opacity settings from this element. Required in some cases for IE.
  22652. * @return {Ext.dom.Element} this
  22653. */
  22654. clearOpacity : function() {
  22655. return this.setOpacity('');
  22656. },
  22657. /**
  22658. * @private
  22659. * Returns 1 if the browser returns the subpixel dimension rounded to the lowest pixel.
  22660. * @return {Number} 0 or 1
  22661. */
  22662. adjustDirect2DDimension: function(dimension) {
  22663. var me = this,
  22664. dom = me.dom,
  22665. display = me.getStyle('display'),
  22666. inlineDisplay = dom.style.display,
  22667. inlinePosition = dom.style.position,
  22668. originIndex = dimension === WIDTH ? 0 : 1,
  22669. currentStyle = dom.currentStyle,
  22670. floating;
  22671. if (display === 'inline') {
  22672. dom.style.display = 'inline-block';
  22673. }
  22674. dom.style.position = display.match(adjustDirect2DTableRe) ? 'absolute' : 'static';
  22675. // floating will contain digits that appears after the decimal point
  22676. // if height or width are set to auto we fallback to msTransformOrigin calculation
  22677. // Use currentStyle here instead of getStyle. In some difficult to reproduce
  22678. // instances it resets the scrollWidth of the element
  22679. floating = (parseFloat(currentStyle[dimension]) || parseFloat(currentStyle.msTransformOrigin.split(' ')[originIndex]) * 2) % 1;
  22680. dom.style.position = inlinePosition;
  22681. if (display === 'inline') {
  22682. dom.style.display = inlineDisplay;
  22683. }
  22684. return floating;
  22685. },
  22686. /**
  22687. * Store the current overflow setting and clip overflow on the element - use {@link #unclip} to remove
  22688. * @return {Ext.dom.Element} this
  22689. */
  22690. clip : function() {
  22691. var me = this,
  22692. data = (me.$cache || me.getCache()).data,
  22693. style;
  22694. if (!data[ISCLIPPED]) {
  22695. data[ISCLIPPED] = true;
  22696. style = me.getStyle([OVERFLOW, OVERFLOWX, OVERFLOWY]);
  22697. data[ORIGINALCLIP] = {
  22698. o: style[OVERFLOW],
  22699. x: style[OVERFLOWX],
  22700. y: style[OVERFLOWY]
  22701. };
  22702. me.setStyle(OVERFLOW, HIDDEN);
  22703. me.setStyle(OVERFLOWX, HIDDEN);
  22704. me.setStyle(OVERFLOWY, HIDDEN);
  22705. }
  22706. return me;
  22707. },
  22708. /**
  22709. * Return clipping (overflow) to original clipping before {@link #clip} was called
  22710. * @return {Ext.dom.Element} this
  22711. */
  22712. unclip : function() {
  22713. var me = this,
  22714. data = (me.$cache || me.getCache()).data,
  22715. clip;
  22716. if (data[ISCLIPPED]) {
  22717. data[ISCLIPPED] = false;
  22718. clip = data[ORIGINALCLIP];
  22719. if (clip.o) {
  22720. me.setStyle(OVERFLOW, clip.o);
  22721. }
  22722. if (clip.x) {
  22723. me.setStyle(OVERFLOWX, clip.x);
  22724. }
  22725. if (clip.y) {
  22726. me.setStyle(OVERFLOWY, clip.y);
  22727. }
  22728. }
  22729. return me;
  22730. },
  22731. /**
  22732. * Wraps the specified element with a special 9 element markup/CSS block that renders by default as
  22733. * a gray container with a gradient background, rounded corners and a 4-way shadow.
  22734. *
  22735. * This special markup is used throughout Ext when box wrapping elements ({@link Ext.button.Button},
  22736. * {@link Ext.panel.Panel} when {@link Ext.panel.Panel#frame frame=true}, {@link Ext.window.Window}).
  22737. * The markup is of this form:
  22738. *
  22739. * Ext.dom.Element.boxMarkup =
  22740. * '<div class="{0}-tl"><div class="{0}-tr"><div class="{0}-tc"></div></div></div>
  22741. * <div class="{0}-ml"><div class="{0}-mr"><div class="{0}-mc"></div></div></div>
  22742. * <div class="{0}-bl"><div class="{0}-br"><div class="{0}-bc"></div></div></div>';
  22743. *
  22744. * Example usage:
  22745. *
  22746. * // Basic box wrap
  22747. * Ext.get("foo").boxWrap();
  22748. *
  22749. * // You can also add a custom class and use CSS inheritance rules to customize the box look.
  22750. * // 'x-box-blue' is a built-in alternative -- look at the related CSS definitions as an example
  22751. * // for how to create a custom box wrap style.
  22752. * Ext.get("foo").boxWrap().addCls("x-box-blue");
  22753. *
  22754. * @param {String} [class='x-box'] A base CSS class to apply to the containing wrapper element.
  22755. * Note that there are a number of CSS rules that are dependent on this name to make the overall effect work,
  22756. * so if you supply an alternate base class, make sure you also supply all of the necessary rules.
  22757. * @return {Ext.dom.Element} The outermost wrapping element of the created box structure.
  22758. */
  22759. boxWrap : function(cls) {
  22760. cls = cls || Ext.baseCSSPrefix + 'box';
  22761. var el = Ext.get(this.insertHtml("beforeBegin", "<div class='" + cls + "'>" + Ext.String.format(Element.boxMarkup, cls) + "</div>"));
  22762. Ext.DomQuery.selectNode('.' + cls + '-mc', el.dom).appendChild(this.dom);
  22763. return el;
  22764. },
  22765. /**
  22766. * Returns either the offsetHeight or the height of this element based on CSS height adjusted by padding or borders
  22767. * when needed to simulate offsetHeight when offsets aren't available. This may not work on display:none elements
  22768. * if a height has not been set using CSS.
  22769. * @return {Number}
  22770. */
  22771. getComputedHeight : function() {
  22772. var me = this,
  22773. h = Math.max(me.dom.offsetHeight, me.dom.clientHeight);
  22774. if (!h) {
  22775. h = parseFloat(me.getStyle(HEIGHT)) || 0;
  22776. if (!me.isBorderBox()) {
  22777. h += me.getFrameWidth('tb');
  22778. }
  22779. }
  22780. return h;
  22781. },
  22782. /**
  22783. * Returns either the offsetWidth or the width of this element based on CSS width adjusted by padding or borders
  22784. * when needed to simulate offsetWidth when offsets aren't available. This may not work on display:none elements
  22785. * if a width has not been set using CSS.
  22786. * @return {Number}
  22787. */
  22788. getComputedWidth : function() {
  22789. var me = this,
  22790. w = Math.max(me.dom.offsetWidth, me.dom.clientWidth);
  22791. if (!w) {
  22792. w = parseFloat(me.getStyle(WIDTH)) || 0;
  22793. if (!me.isBorderBox()) {
  22794. w += me.getFrameWidth('lr');
  22795. }
  22796. }
  22797. return w;
  22798. },
  22799. /**
  22800. * Returns the sum width of the padding and borders for the passed "sides". See getBorderWidth()
  22801. * for more information about the sides.
  22802. * @param {String} sides
  22803. * @return {Number}
  22804. */
  22805. getFrameWidth : function(sides, onlyContentBox) {
  22806. return (onlyContentBox && this.isBorderBox()) ? 0 : (this.getPadding(sides) + this.getBorderWidth(sides));
  22807. },
  22808. /**
  22809. * Sets up event handlers to add and remove a css class when the mouse is over this element
  22810. * @param {String} className The class to add
  22811. * @param {Function} [testFn] A test function to execute before adding the class. The passed parameter
  22812. * will be the Element instance. If this functions returns false, the class will not be added.
  22813. * @param {Object} [scope] The scope to execute the testFn in.
  22814. * @return {Ext.dom.Element} this
  22815. */
  22816. addClsOnOver : function(className, testFn, scope) {
  22817. var me = this,
  22818. dom = me.dom,
  22819. hasTest = Ext.isFunction(testFn);
  22820. me.hover(
  22821. function() {
  22822. if (hasTest && testFn.call(scope || me, me) === false) {
  22823. return;
  22824. }
  22825. Ext.fly(dom, INTERNAL).addCls(className);
  22826. },
  22827. function() {
  22828. Ext.fly(dom, INTERNAL).removeCls(className);
  22829. }
  22830. );
  22831. return me;
  22832. },
  22833. /**
  22834. * Sets up event handlers to add and remove a css class when this element has the focus
  22835. * @param {String} className The class to add
  22836. * @param {Function} [testFn] A test function to execute before adding the class. The passed parameter
  22837. * will be the Element instance. If this functions returns false, the class will not be added.
  22838. * @param {Object} [scope] The scope to execute the testFn in.
  22839. * @return {Ext.dom.Element} this
  22840. */
  22841. addClsOnFocus : function(className, testFn, scope) {
  22842. var me = this,
  22843. dom = me.dom,
  22844. hasTest = Ext.isFunction(testFn);
  22845. me.on("focus", function() {
  22846. if (hasTest && testFn.call(scope || me, me) === false) {
  22847. return false;
  22848. }
  22849. Ext.fly(dom, INTERNAL).addCls(className);
  22850. });
  22851. me.on("blur", function() {
  22852. Ext.fly(dom, INTERNAL).removeCls(className);
  22853. });
  22854. return me;
  22855. },
  22856. /**
  22857. * Sets up event handlers to add and remove a css class when the mouse is down and then up on this element (a click effect)
  22858. * @param {String} className The class to add
  22859. * @param {Function} [testFn] A test function to execute before adding the class. The passed parameter
  22860. * will be the Element instance. If this functions returns false, the class will not be added.
  22861. * @param {Object} [scope] The scope to execute the testFn in.
  22862. * @return {Ext.dom.Element} this
  22863. */
  22864. addClsOnClick : function(className, testFn, scope) {
  22865. var me = this,
  22866. dom = me.dom,
  22867. hasTest = Ext.isFunction(testFn);
  22868. me.on("mousedown", function() {
  22869. if (hasTest && testFn.call(scope || me, me) === false) {
  22870. return false;
  22871. }
  22872. Ext.fly(dom, INTERNAL).addCls(className);
  22873. var d = Ext.getDoc(),
  22874. fn = function() {
  22875. Ext.fly(dom, INTERNAL).removeCls(className);
  22876. d.removeListener("mouseup", fn);
  22877. };
  22878. d.on("mouseup", fn);
  22879. });
  22880. return me;
  22881. },
  22882. /**
  22883. * Returns the dimensions of the element available to lay content out in.
  22884. *
  22885. * getStyleSize utilizes prefers style sizing if present, otherwise it chooses the larger of offsetHeight/clientHeight and
  22886. * offsetWidth/clientWidth. To obtain the size excluding scrollbars, use getViewSize.
  22887. *
  22888. * Sizing of the document body is handled at the adapter level which handles special cases for IE and strict modes, etc.
  22889. *
  22890. * @return {Object} Object describing width and height.
  22891. * @return {Number} return.width
  22892. * @return {Number} return.height
  22893. */
  22894. getStyleSize : function() {
  22895. var me = this,
  22896. d = this.dom,
  22897. isDoc = DOCORBODYRE.test(d.nodeName),
  22898. s ,
  22899. w, h;
  22900. // If the body, use static methods
  22901. if (isDoc) {
  22902. return {
  22903. width : Element.getViewWidth(),
  22904. height : Element.getViewHeight()
  22905. };
  22906. }
  22907. s = me.getStyle([HEIGHT, WIDTH], true); //seek inline
  22908. // Use Styles if they are set
  22909. if (s.width && s.width != 'auto') {
  22910. w = parseFloat(s.width);
  22911. if (me.isBorderBox()) {
  22912. w -= me.getFrameWidth('lr');
  22913. }
  22914. }
  22915. // Use Styles if they are set
  22916. if (s.height && s.height != 'auto') {
  22917. h = parseFloat(s.height);
  22918. if (me.isBorderBox()) {
  22919. h -= me.getFrameWidth('tb');
  22920. }
  22921. }
  22922. // Use getWidth/getHeight if style not set.
  22923. return {width: w || me.getWidth(true), height: h || me.getHeight(true)};
  22924. },
  22925. /**
  22926. * Enable text selection for this element (normalized across browsers)
  22927. * @return {Ext.Element} this
  22928. */
  22929. selectable : function() {
  22930. var me = this;
  22931. me.dom.unselectable = "off";
  22932. // Prevent it from bubles up and enables it to be selectable
  22933. me.on('selectstart', function (e) {
  22934. e.stopPropagation();
  22935. return true;
  22936. });
  22937. me.applyStyles("-moz-user-select: text; -khtml-user-select: text;");
  22938. me.removeCls(Ext.baseCSSPrefix + 'unselectable');
  22939. return me;
  22940. },
  22941. /**
  22942. * Disables text selection for this element (normalized across browsers)
  22943. * @return {Ext.dom.Element} this
  22944. */
  22945. unselectable : function() {
  22946. var me = this;
  22947. me.dom.unselectable = "on";
  22948. me.swallowEvent("selectstart", true);
  22949. me.applyStyles("-moz-user-select:-moz-none;-khtml-user-select:none;");
  22950. me.addCls(Ext.baseCSSPrefix + 'unselectable');
  22951. return me;
  22952. }
  22953. });
  22954. Element.prototype.styleHooks = styleHooks = Ext.dom.AbstractElement.prototype.styleHooks;
  22955. if (Ext.isIE6 || Ext.isIE7) {
  22956. styleHooks.fontSize = styleHooks['font-size'] = {
  22957. name: 'fontSize',
  22958. canThrow: true
  22959. };
  22960. styleHooks.fontStyle = styleHooks['font-style'] = {
  22961. name: 'fontStyle',
  22962. canThrow: true
  22963. };
  22964. styleHooks.fontFamily = styleHooks['font-family'] = {
  22965. name: 'fontFamily',
  22966. canThrow: true
  22967. };
  22968. }
  22969. // override getStyle for border-*-width
  22970. if (Ext.isIEQuirks || Ext.isIE && Ext.ieVersion <= 8) {
  22971. function getBorderWidth (dom, el, inline, style) {
  22972. if (style[this.styleName] == 'none') {
  22973. return '0px';
  22974. }
  22975. return style[this.name];
  22976. }
  22977. edges = ['Top','Right','Bottom','Left'];
  22978. k = edges.length;
  22979. while (k--) {
  22980. edge = edges[k];
  22981. borderWidth = 'border' + edge + 'Width';
  22982. styleHooks['border-'+edge.toLowerCase()+'-width'] = styleHooks[borderWidth] = {
  22983. name: borderWidth,
  22984. styleName: 'border' + edge + 'Style',
  22985. get: getBorderWidth
  22986. };
  22987. }
  22988. }
  22989. }());
  22990. Ext.onReady(function () {
  22991. var opacityRe = /alpha\(opacity=(.*)\)/i,
  22992. trimRe = /^\s+|\s+$/g,
  22993. hooks = Ext.dom.Element.prototype.styleHooks;
  22994. // Ext.supports flags are not populated until onReady...
  22995. hooks.opacity = {
  22996. name: 'opacity',
  22997. afterSet: function(dom, value, el) {
  22998. if (el.isLayer) {
  22999. el.onOpacitySet(value);
  23000. }
  23001. }
  23002. };
  23003. if (!Ext.supports.Opacity && Ext.isIE) {
  23004. Ext.apply(hooks.opacity, {
  23005. get: function (dom) {
  23006. var filter = dom.style.filter,
  23007. match, opacity;
  23008. if (filter.match) {
  23009. match = filter.match(opacityRe);
  23010. if (match) {
  23011. opacity = parseFloat(match[1]);
  23012. if (!isNaN(opacity)) {
  23013. return opacity ? opacity / 100 : 0;
  23014. }
  23015. }
  23016. }
  23017. return 1;
  23018. },
  23019. set: function (dom, value) {
  23020. var style = dom.style,
  23021. val = style.filter.replace(opacityRe, '').replace(trimRe, '');
  23022. style.zoom = 1; // ensure dom.hasLayout
  23023. // value can be a number or '' or null... so treat falsey as no opacity
  23024. if (typeof(value) == 'number' && value >= 0 && value < 1) {
  23025. value *= 100;
  23026. style.filter = val + (val.length ? ' ' : '') + 'alpha(opacity='+value+')';
  23027. } else {
  23028. style.filter = val;
  23029. }
  23030. }
  23031. });
  23032. }
  23033. // else there is no work around for the lack of opacity support. Should not be a
  23034. // problem given that this has been supported for a long time now...
  23035. });
  23036. //@tag dom,core
  23037. //@require Ext.dom.Element-style
  23038. //@define Ext.dom.Element-traversal
  23039. //@define Ext.dom.Element
  23040. /**
  23041. * @class Ext.dom.Element
  23042. */
  23043. Ext.dom.Element.override({
  23044. select: function(selector) {
  23045. return Ext.dom.Element.select(selector, false, this.dom);
  23046. }
  23047. });
  23048. //@tag dom,core
  23049. //@require Ext.dom.Element-traversal
  23050. /**
  23051. * This class encapsulates a *collection* of DOM elements, providing methods to filter members, or to perform collective
  23052. * actions upon the whole set.
  23053. *
  23054. * Although they are not listed, this class supports all of the methods of {@link Ext.dom.Element} and
  23055. * {@link Ext.fx.Anim}. The methods from these classes will be performed on all the elements in this collection.
  23056. *
  23057. * Example:
  23058. *
  23059. * var els = Ext.select("#some-el div.some-class");
  23060. * // or select directly from an existing element
  23061. * var el = Ext.get('some-el');
  23062. * el.select('div.some-class');
  23063. *
  23064. * els.setWidth(100); // all elements become 100 width
  23065. * els.hide(true); // all elements fade out and hide
  23066. * // or
  23067. * els.setWidth(100).hide(true);
  23068. */
  23069. Ext.define('Ext.dom.CompositeElementLite', {
  23070. alternateClassName: 'Ext.CompositeElementLite',
  23071. requires: ['Ext.dom.Element', 'Ext.dom.Query'],
  23072. statics: {
  23073. /**
  23074. * @private
  23075. * Copies all of the functions from Ext.dom.Element's prototype onto CompositeElementLite's prototype.
  23076. * This is called twice - once immediately below, and once again after additional Ext.dom.Element
  23077. * are added in Ext JS
  23078. */
  23079. importElementMethods: function() {
  23080. var name,
  23081. elementPrototype = Ext.dom.Element.prototype,
  23082. prototype = this.prototype;
  23083. for (name in elementPrototype) {
  23084. if (typeof elementPrototype[name] == 'function'){
  23085. (function(key) {
  23086. prototype[key] = prototype[key] || function() {
  23087. return this.invoke(key, arguments);
  23088. };
  23089. }).call(prototype, name);
  23090. }
  23091. }
  23092. }
  23093. },
  23094. constructor: function(elements, root) {
  23095. /**
  23096. * @property {HTMLElement[]} elements
  23097. * The Array of DOM elements which this CompositeElement encapsulates.
  23098. *
  23099. * This will not *usually* be accessed in developers' code, but developers wishing to augment the capabilities
  23100. * of the CompositeElementLite class may use it when adding methods to the class.
  23101. *
  23102. * For example to add the `nextAll` method to the class to **add** all following siblings of selected elements,
  23103. * the code would be
  23104. *
  23105. * Ext.override(Ext.dom.CompositeElementLite, {
  23106. * nextAll: function() {
  23107. * var elements = this.elements, i, l = elements.length, n, r = [], ri = -1;
  23108. *
  23109. * // Loop through all elements in this Composite, accumulating
  23110. * // an Array of all siblings.
  23111. * for (i = 0; i < l; i++) {
  23112. * for (n = elements[i].nextSibling; n; n = n.nextSibling) {
  23113. * r[++ri] = n;
  23114. * }
  23115. * }
  23116. *
  23117. * // Add all found siblings to this Composite
  23118. * return this.add(r);
  23119. * }
  23120. * });
  23121. *
  23122. * @readonly
  23123. */
  23124. this.elements = [];
  23125. this.add(elements, root);
  23126. this.el = new Ext.dom.AbstractElement.Fly();
  23127. },
  23128. /**
  23129. * @property {Boolean} isComposite
  23130. * `true` in this class to identify an object as an instantiated CompositeElement, or subclass thereof.
  23131. */
  23132. isComposite: true,
  23133. // private
  23134. getElement: function(el) {
  23135. // Set the shared flyweight dom property to the current element
  23136. return this.el.attach(el);
  23137. },
  23138. // private
  23139. transformElement: function(el) {
  23140. return Ext.getDom(el);
  23141. },
  23142. /**
  23143. * Returns the number of elements in this Composite.
  23144. * @return {Number}
  23145. */
  23146. getCount: function() {
  23147. return this.elements.length;
  23148. },
  23149. /**
  23150. * Adds elements to this Composite object.
  23151. * @param {HTMLElement[]/Ext.dom.CompositeElement} els Either an Array of DOM elements to add, or another Composite
  23152. * object who's elements should be added.
  23153. * @return {Ext.dom.CompositeElement} This Composite object.
  23154. */
  23155. add: function(els, root) {
  23156. var elements = this.elements,
  23157. i, ln;
  23158. if (!els) {
  23159. return this;
  23160. }
  23161. if (typeof els == "string") {
  23162. els = Ext.dom.Element.selectorFunction(els, root);
  23163. }
  23164. else if (els.isComposite) {
  23165. els = els.elements;
  23166. }
  23167. else if (!Ext.isIterable(els)) {
  23168. els = [els];
  23169. }
  23170. for (i = 0, ln = els.length; i < ln; ++i) {
  23171. elements.push(this.transformElement(els[i]));
  23172. }
  23173. return this;
  23174. },
  23175. invoke: function(fn, args) {
  23176. var elements = this.elements,
  23177. ln = elements.length,
  23178. element,
  23179. i;
  23180. fn = Ext.dom.Element.prototype[fn];
  23181. for (i = 0; i < ln; i++) {
  23182. element = elements[i];
  23183. if (element) {
  23184. fn.apply(this.getElement(element), args);
  23185. }
  23186. }
  23187. return this;
  23188. },
  23189. /**
  23190. * Returns a flyweight Element of the dom element object at the specified index
  23191. * @param {Number} index
  23192. * @return {Ext.dom.Element}
  23193. */
  23194. item: function(index) {
  23195. var el = this.elements[index],
  23196. out = null;
  23197. if (el) {
  23198. out = this.getElement(el);
  23199. }
  23200. return out;
  23201. },
  23202. // fixes scope with flyweight
  23203. addListener: function(eventName, handler, scope, opt) {
  23204. var els = this.elements,
  23205. len = els.length,
  23206. i, e;
  23207. for (i = 0; i < len; i++) {
  23208. e = els[i];
  23209. if (e) {
  23210. Ext.EventManager.on(e, eventName, handler, scope || e, opt);
  23211. }
  23212. }
  23213. return this;
  23214. },
  23215. /**
  23216. * Calls the passed function for each element in this composite.
  23217. * @param {Function} fn The function to call.
  23218. * @param {Ext.dom.Element} fn.el The current Element in the iteration. **This is the flyweight
  23219. * (shared) Ext.dom.Element instance, so if you require a a reference to the dom node, use el.dom.**
  23220. * @param {Ext.dom.CompositeElement} fn.c This Composite object.
  23221. * @param {Number} fn.index The zero-based index in the iteration.
  23222. * @param {Object} [scope] The scope (this reference) in which the function is executed.
  23223. * Defaults to the Element.
  23224. * @return {Ext.dom.CompositeElement} this
  23225. */
  23226. each: function(fn, scope) {
  23227. var me = this,
  23228. els = me.elements,
  23229. len = els.length,
  23230. i, e;
  23231. for (i = 0; i < len; i++) {
  23232. e = els[i];
  23233. if (e) {
  23234. e = this.getElement(e);
  23235. if (fn.call(scope || e, e, me, i) === false) {
  23236. break;
  23237. }
  23238. }
  23239. }
  23240. return me;
  23241. },
  23242. /**
  23243. * Clears this Composite and adds the elements passed.
  23244. * @param {HTMLElement[]/Ext.dom.CompositeElement} els Either an array of DOM elements, or another Composite from which
  23245. * to fill this Composite.
  23246. * @return {Ext.dom.CompositeElement} this
  23247. */
  23248. fill: function(els) {
  23249. var me = this;
  23250. me.elements = [];
  23251. me.add(els);
  23252. return me;
  23253. },
  23254. /**
  23255. * Filters this composite to only elements that match the passed selector.
  23256. * @param {String/Function} selector A string CSS selector or a comparison function. The comparison function will be
  23257. * called with the following arguments:
  23258. * @param {Ext.dom.Element} selector.el The current DOM element.
  23259. * @param {Number} selector.index The current index within the collection.
  23260. * @return {Ext.dom.CompositeElement} this
  23261. */
  23262. filter: function(selector) {
  23263. var me = this,
  23264. els = me.elements,
  23265. len = els.length,
  23266. out = [],
  23267. i = 0,
  23268. isFunc = typeof selector == 'function',
  23269. add,
  23270. el;
  23271. for (; i < len; i++) {
  23272. el = els[i];
  23273. add = false;
  23274. if (el) {
  23275. el = me.getElement(el);
  23276. if (isFunc) {
  23277. add = selector.call(el, el, me, i) !== false;
  23278. } else {
  23279. add = el.is(selector);
  23280. }
  23281. if (add) {
  23282. out.push(me.transformElement(el));
  23283. }
  23284. }
  23285. }
  23286. me.elements = out;
  23287. return me;
  23288. },
  23289. /**
  23290. * Find the index of the passed element within the composite collection.
  23291. * @param {String/HTMLElement/Ext.Element/Number} el The id of an element, or an Ext.dom.Element, or an HtmlElement
  23292. * to find within the composite collection.
  23293. * @return {Number} The index of the passed Ext.dom.Element in the composite collection, or -1 if not found.
  23294. */
  23295. indexOf: function(el) {
  23296. return Ext.Array.indexOf(this.elements, this.transformElement(el));
  23297. },
  23298. /**
  23299. * Replaces the specified element with the passed element.
  23300. * @param {String/HTMLElement/Ext.Element/Number} el The id of an element, the Element itself, the index of the
  23301. * element in this composite to replace.
  23302. * @param {String/Ext.Element} replacement The id of an element or the Element itself.
  23303. * @param {Boolean} [domReplace] True to remove and replace the element in the document too.
  23304. * @return {Ext.dom.CompositeElement} this
  23305. */
  23306. replaceElement: function(el, replacement, domReplace) {
  23307. var index = !isNaN(el) ? el : this.indexOf(el),
  23308. d;
  23309. if (index > -1) {
  23310. replacement = Ext.getDom(replacement);
  23311. if (domReplace) {
  23312. d = this.elements[index];
  23313. d.parentNode.insertBefore(replacement, d);
  23314. Ext.removeNode(d);
  23315. }
  23316. Ext.Array.splice(this.elements, index, 1, replacement);
  23317. }
  23318. return this;
  23319. },
  23320. /**
  23321. * Removes all elements.
  23322. */
  23323. clear: function() {
  23324. this.elements = [];
  23325. },
  23326. addElements: function(els, root) {
  23327. if (!els) {
  23328. return this;
  23329. }
  23330. if (typeof els == "string") {
  23331. els = Ext.dom.Element.selectorFunction(els, root);
  23332. }
  23333. var yels = this.elements,
  23334. eLen = els.length,
  23335. e;
  23336. for (e = 0; e < eLen; e++) {
  23337. yels.push(Ext.get(els[e]));
  23338. }
  23339. return this;
  23340. },
  23341. /**
  23342. * Returns the first Element
  23343. * @return {Ext.dom.Element}
  23344. */
  23345. first: function() {
  23346. return this.item(0);
  23347. },
  23348. /**
  23349. * Returns the last Element
  23350. * @return {Ext.dom.Element}
  23351. */
  23352. last: function() {
  23353. return this.item(this.getCount() - 1);
  23354. },
  23355. /**
  23356. * Returns true if this composite contains the passed element
  23357. * @param {String/HTMLElement/Ext.Element/Number} el The id of an element, or an Ext.Element, or an HtmlElement to
  23358. * find within the composite collection.
  23359. * @return {Boolean}
  23360. */
  23361. contains: function(el) {
  23362. return this.indexOf(el) != -1;
  23363. },
  23364. /**
  23365. * Removes the specified element(s).
  23366. * @param {String/HTMLElement/Ext.Element/Number} el The id of an element, the Element itself, the index of the
  23367. * element in this composite or an array of any of those.
  23368. * @param {Boolean} [removeDom] True to also remove the element from the document
  23369. * @return {Ext.dom.CompositeElement} this
  23370. */
  23371. removeElement: function(keys, removeDom) {
  23372. keys = [].concat(keys);
  23373. var me = this,
  23374. elements = me.elements,
  23375. kLen = keys.length,
  23376. val, el, k;
  23377. for (k = 0; k < kLen; k++) {
  23378. val = keys[k];
  23379. if ((el = (elements[val] || elements[val = me.indexOf(val)]))) {
  23380. if (removeDom) {
  23381. if (el.dom) {
  23382. el.remove();
  23383. } else {
  23384. Ext.removeNode(el);
  23385. }
  23386. }
  23387. Ext.Array.erase(elements, val, 1);
  23388. }
  23389. }
  23390. return me;
  23391. }
  23392. }, function() {
  23393. this.importElementMethods();
  23394. this.prototype.on = this.prototype.addListener;
  23395. if (Ext.DomQuery){
  23396. Ext.dom.Element.selectorFunction = Ext.DomQuery.select;
  23397. }
  23398. /**
  23399. * Selects elements based on the passed CSS selector to enable {@link Ext.Element Element} methods
  23400. * to be applied to many related elements in one statement through the returned
  23401. * {@link Ext.dom.CompositeElement CompositeElement} or
  23402. * {@link Ext.dom.CompositeElementLite CompositeElementLite} object.
  23403. * @param {String/HTMLElement[]} selector The CSS selector or an array of elements
  23404. * @param {HTMLElement/String} [root] The root element of the query or id of the root
  23405. * @return {Ext.dom.CompositeElementLite/Ext.dom.CompositeElement}
  23406. * @member Ext.dom.Element
  23407. * @method select
  23408. * @static
  23409. * @ignore
  23410. */
  23411. Ext.dom.Element.select = function(selector, root) {
  23412. var elements;
  23413. if (typeof selector == "string") {
  23414. elements = Ext.dom.Element.selectorFunction(selector, root);
  23415. }
  23416. else if (selector.length !== undefined) {
  23417. elements = selector;
  23418. }
  23419. else {
  23420. }
  23421. return new Ext.CompositeElementLite(elements);
  23422. };
  23423. /**
  23424. * @member Ext
  23425. * @method select
  23426. * @inheritdoc Ext.dom.Element#select
  23427. * @ignore
  23428. */
  23429. Ext.select = function() {
  23430. return Ext.dom.Element.select.apply(Ext.dom.Element, arguments);
  23431. };
  23432. });
  23433. //@tag dom,core
  23434. /**
  23435. * @class Ext.dom.CompositeElement
  23436. * <p>This class encapsulates a <i>collection</i> of DOM elements, providing methods to filter
  23437. * members, or to perform collective actions upon the whole set.</p>
  23438. * <p>Although they are not listed, this class supports all of the methods of {@link Ext.dom.Element} and
  23439. * {@link Ext.fx.Anim}. The methods from these classes will be performed on all the elements in this collection.</p>
  23440. * <p>All methods return <i>this</i> and can be chained.</p>
  23441. * Usage:
  23442. <pre><code>
  23443. var els = Ext.select("#some-el div.some-class", true);
  23444. // or select directly from an existing element
  23445. var el = Ext.get('some-el');
  23446. el.select('div.some-class', true);
  23447. els.setWidth(100); // all elements become 100 width
  23448. els.hide(true); // all elements fade out and hide
  23449. // or
  23450. els.setWidth(100).hide(true);
  23451. </code></pre>
  23452. */
  23453. Ext.define('Ext.dom.CompositeElement', {
  23454. alternateClassName: 'Ext.CompositeElement',
  23455. extend: 'Ext.dom.CompositeElementLite',
  23456. // private
  23457. getElement: function(el) {
  23458. // In this case just return it, since we already have a reference to it
  23459. return el;
  23460. },
  23461. // private
  23462. transformElement: function(el) {
  23463. return Ext.get(el);
  23464. }
  23465. }, function() {
  23466. /**
  23467. * Selects elements based on the passed CSS selector to enable {@link Ext.Element Element} methods
  23468. * to be applied to many related elements in one statement through the returned {@link Ext.CompositeElement CompositeElement} or
  23469. * {@link Ext.CompositeElementLite CompositeElementLite} object.
  23470. * @param {String/HTMLElement[]} selector The CSS selector or an array of elements
  23471. * @param {Boolean} [unique] true to create a unique Ext.Element for each element (defaults to a shared flyweight object)
  23472. * @param {HTMLElement/String} [root] The root element of the query or id of the root
  23473. * @return {Ext.CompositeElementLite/Ext.CompositeElement}
  23474. * @member Ext.dom.Element
  23475. * @method select
  23476. * @static
  23477. */
  23478. Ext.dom.Element.select = function(selector, unique, root) {
  23479. var elements;
  23480. if (typeof selector == "string") {
  23481. elements = Ext.dom.Element.selectorFunction(selector, root);
  23482. }
  23483. else if (selector.length !== undefined) {
  23484. elements = selector;
  23485. }
  23486. else {
  23487. }
  23488. return (unique === true) ? new Ext.CompositeElement(elements) : new Ext.CompositeElementLite(elements);
  23489. };
  23490. });
  23491. /**
  23492. * Shorthand of {@link Ext.Element#method-select}.
  23493. * @member Ext
  23494. * @method select
  23495. * @inheritdoc Ext.Element#select
  23496. */
  23497. Ext.select = Ext.Element.select;
  23498. Ext.ClassManager.addNameAlternateMappings({
  23499. "Ext.draw.engine.ImageExporter": [],
  23500. "Ext.layout.component.Auto": [],
  23501. "Ext.grid.property.Store": [
  23502. "Ext.grid.PropertyStore"
  23503. ],
  23504. "Ext.layout.container.Box": [
  23505. "Ext.layout.BoxLayout"
  23506. ],
  23507. "Ext.direct.JsonProvider": [],
  23508. "Ext.tree.Panel": [
  23509. "Ext.tree.TreePanel",
  23510. "Ext.TreePanel"
  23511. ],
  23512. "Ext.data.Model": [
  23513. "Ext.data.Record"
  23514. ],
  23515. "Ext.data.reader.Reader": [
  23516. "Ext.data.Reader",
  23517. "Ext.data.DataReader"
  23518. ],
  23519. "Ext.tab.Tab": [],
  23520. "Ext.button.Button": [
  23521. "Ext.Button"
  23522. ],
  23523. "Ext.util.Grouper": [],
  23524. "Ext.util.TaskRunner": [],
  23525. "Ext.direct.RemotingProvider": [],
  23526. "Ext.data.NodeInterface": [],
  23527. "Ext.grid.column.Date": [
  23528. "Ext.grid.DateColumn"
  23529. ],
  23530. "Ext.form.field.Trigger": [
  23531. "Ext.form.TriggerField",
  23532. "Ext.form.TwinTriggerField",
  23533. "Ext.form.Trigger"
  23534. ],
  23535. "Ext.grid.plugin.RowEditing": [],
  23536. "Ext.tip.QuickTip": [
  23537. "Ext.QuickTip"
  23538. ],
  23539. "Ext.form.action.Load": [
  23540. "Ext.form.Action.Load"
  23541. ],
  23542. "Ext.form.field.ComboBox": [
  23543. "Ext.form.ComboBox"
  23544. ],
  23545. "Ext.layout.container.Border": [
  23546. "Ext.layout.BorderLayout"
  23547. ],
  23548. "Ext.data.JsonPStore": [],
  23549. "Ext.layout.component.field.TextArea": [],
  23550. "Ext.dom.AbstractHelper": [],
  23551. "Ext.layout.container.Container": [
  23552. "Ext.layout.ContainerLayout"
  23553. ],
  23554. "Ext.util.Sortable": [],
  23555. "Ext.selection.Model": [
  23556. "Ext.AbstractSelectionModel"
  23557. ],
  23558. "Ext.draw.CompositeSprite": [],
  23559. "Ext.fx.Queue": [],
  23560. "Ext.dd.StatusProxy": [],
  23561. "Ext.form.field.Checkbox": [
  23562. "Ext.form.Checkbox"
  23563. ],
  23564. "Ext.XTemplateCompiler": [],
  23565. "Ext.direct.Transaction": [
  23566. "Ext.Direct.Transaction"
  23567. ],
  23568. "Ext.util.Offset": [],
  23569. "Ext.dom.Element": [
  23570. "Ext.Element",
  23571. "Ext.core.Element"
  23572. ],
  23573. "Ext.view.DragZone": [],
  23574. "Ext.util.KeyNav": [
  23575. "Ext.KeyNav"
  23576. ],
  23577. "Ext.form.field.File": [
  23578. "Ext.form.FileUploadField",
  23579. "Ext.ux.form.FileUploadField",
  23580. "Ext.form.File"
  23581. ],
  23582. "Ext.slider.Single": [
  23583. "Ext.Slider",
  23584. "Ext.form.SliderField",
  23585. "Ext.slider.SingleSlider",
  23586. "Ext.slider.Slider"
  23587. ],
  23588. "Ext.panel.Proxy": [
  23589. "Ext.dd.PanelProxy"
  23590. ],
  23591. "Ext.fx.target.Target": [],
  23592. "Ext.ComponentManager": [
  23593. "Ext.ComponentMgr"
  23594. ],
  23595. "Ext.grid.feature.GroupingSummary": [],
  23596. "Ext.grid.property.HeaderContainer": [
  23597. "Ext.grid.PropertyColumnModel"
  23598. ],
  23599. "Ext.layout.component.BoundList": [],
  23600. "Ext.tab.Bar": [],
  23601. "Ext.app.Application": [],
  23602. "Ext.ShadowPool": [],
  23603. "Ext.layout.container.Accordion": [
  23604. "Ext.layout.AccordionLayout"
  23605. ],
  23606. "Ext.resizer.ResizeTracker": [],
  23607. "Ext.layout.container.boxOverflow.None": [
  23608. "Ext.layout.boxOverflow.None"
  23609. ],
  23610. "Ext.panel.Tool": [],
  23611. "Ext.tree.View": [],
  23612. "Ext.ElementLoader": [],
  23613. "Ext.grid.ColumnComponentLayout": [],
  23614. "Ext.toolbar.Separator": [
  23615. "Ext.Toolbar.Separator"
  23616. ],
  23617. "Ext.dd.DragZone": [],
  23618. "Ext.util.Renderable": [],
  23619. "Ext.layout.component.FieldSet": [],
  23620. "Ext.util.Bindable": [],
  23621. "Ext.data.SortTypes": [],
  23622. "Ext.util.Animate": [],
  23623. "Ext.form.field.Date": [
  23624. "Ext.form.DateField",
  23625. "Ext.form.Date"
  23626. ],
  23627. "Ext.Component": [],
  23628. "Ext.chart.axis.Axis": [
  23629. "Ext.chart.Axis"
  23630. ],
  23631. "Ext.fx.target.CompositeSprite": [],
  23632. "Ext.menu.DatePicker": [],
  23633. "Ext.form.field.Picker": [
  23634. "Ext.form.Picker"
  23635. ],
  23636. "Ext.fx.Animator": [],
  23637. "Ext.Ajax": [],
  23638. "Ext.layout.component.Dock": [
  23639. "Ext.layout.component.AbstractDock"
  23640. ],
  23641. "Ext.util.Filter": [],
  23642. "Ext.dd.DragDrop": [],
  23643. "Ext.grid.Scroller": [],
  23644. "Ext.view.View": [
  23645. "Ext.DataView"
  23646. ],
  23647. "Ext.data.association.BelongsTo": [
  23648. "Ext.data.BelongsToAssociation"
  23649. ],
  23650. "Ext.fx.target.Element": [],
  23651. "Ext.draw.Surface": [],
  23652. "Ext.dd.DDProxy": [],
  23653. "Ext.data.AbstractStore": [],
  23654. "Ext.form.action.StandardSubmit": [],
  23655. "Ext.grid.Lockable": [],
  23656. "Ext.dd.Registry": [],
  23657. "Ext.picker.Month": [
  23658. "Ext.MonthPicker"
  23659. ],
  23660. "Ext.container.Container": [
  23661. "Ext.Container"
  23662. ],
  23663. "Ext.menu.Manager": [
  23664. "Ext.menu.MenuMgr"
  23665. ],
  23666. "Ext.util.KeyMap": [
  23667. "Ext.KeyMap"
  23668. ],
  23669. "Ext.data.Batch": [],
  23670. "Ext.resizer.Handle": [],
  23671. "Ext.util.ElementContainer": [],
  23672. "Ext.grid.feature.Grouping": [],
  23673. "Ext.tab.Panel": [
  23674. "Ext.TabPanel"
  23675. ],
  23676. "Ext.layout.component.Body": [],
  23677. "Ext.layout.Context": [],
  23678. "Ext.layout.component.field.ComboBox": [],
  23679. "Ext.dd.DDTarget": [],
  23680. "Ext.chart.Chart": [],
  23681. "Ext.data.Field": [],
  23682. "Ext.chart.series.Gauge": [],
  23683. "Ext.data.StoreManager": [
  23684. "Ext.StoreMgr",
  23685. "Ext.data.StoreMgr",
  23686. "Ext.StoreManager"
  23687. ],
  23688. "Ext.tip.QuickTipManager": [
  23689. "Ext.QuickTips"
  23690. ],
  23691. "Ext.data.IdGenerator": [],
  23692. "Ext.grid.plugin.Editing": [],
  23693. "Ext.grid.RowEditor": [],
  23694. "Ext.state.LocalStorageProvider": [],
  23695. "Ext.form.action.Action": [
  23696. "Ext.form.Action"
  23697. ],
  23698. "Ext.ProgressBar": [],
  23699. "Ext.tree.ViewDragZone": [],
  23700. "Ext.data.reader.Array": [
  23701. "Ext.data.ArrayReader"
  23702. ],
  23703. "Ext.picker.Date": [
  23704. "Ext.DatePicker"
  23705. ],
  23706. "Ext.data.proxy.JsonP": [
  23707. "Ext.data.ScriptTagProxy"
  23708. ],
  23709. "Ext.chart.series.Area": [],
  23710. "Ext.fx.Anim": [],
  23711. "Ext.menu.Item": [
  23712. "Ext.menu.TextItem"
  23713. ],
  23714. "Ext.chart.Legend": [],
  23715. "Ext.grid.plugin.HeaderReorderer": [],
  23716. "Ext.layout.container.VBox": [
  23717. "Ext.layout.VBoxLayout"
  23718. ],
  23719. "Ext.view.DropZone": [],
  23720. "Ext.layout.component.Button": [],
  23721. "Ext.form.field.Hidden": [
  23722. "Ext.form.Hidden"
  23723. ],
  23724. "Ext.form.FieldContainer": [],
  23725. "Ext.data.proxy.Server": [
  23726. "Ext.data.ServerProxy"
  23727. ],
  23728. "Ext.chart.series.Cartesian": [
  23729. "Ext.chart.CartesianSeries",
  23730. "Ext.chart.CartesianChart"
  23731. ],
  23732. "Ext.grid.column.Column": [
  23733. "Ext.grid.Column"
  23734. ],
  23735. "Ext.data.ResultSet": [],
  23736. "Ext.data.association.HasMany": [
  23737. "Ext.data.HasManyAssociation"
  23738. ],
  23739. "Ext.layout.container.Fit": [
  23740. "Ext.layout.FitLayout"
  23741. ],
  23742. "Ext.util.CSS": [],
  23743. "Ext.layout.component.field.Field": [],
  23744. "Ext.data.proxy.Ajax": [
  23745. "Ext.data.HttpProxy",
  23746. "Ext.data.AjaxProxy"
  23747. ],
  23748. "Ext.form.Label": [],
  23749. "Ext.data.writer.Writer": [
  23750. "Ext.data.DataWriter",
  23751. "Ext.data.Writer"
  23752. ],
  23753. "Ext.view.BoundListKeyNav": [],
  23754. "Ext.form.FieldSet": [],
  23755. "Ext.XTemplateParser": [],
  23756. "Ext.form.field.VTypes": [
  23757. "Ext.form.VTypes"
  23758. ],
  23759. "Ext.fx.PropertyHandler": [],
  23760. "Ext.form.CheckboxGroup": [],
  23761. "Ext.data.JsonP": [],
  23762. "Ext.draw.engine.Vml": [],
  23763. "Ext.layout.container.CheckboxGroup": [],
  23764. "Ext.panel.Header": [],
  23765. "Ext.app.Controller": [],
  23766. "Ext.grid.plugin.CellEditing": [],
  23767. "Ext.form.field.Time": [
  23768. "Ext.form.TimeField",
  23769. "Ext.form.Time"
  23770. ],
  23771. "Ext.fx.CubicBezier": [],
  23772. "Ext.button.Cycle": [
  23773. "Ext.CycleButton"
  23774. ],
  23775. "Ext.data.Tree": [],
  23776. "Ext.ModelManager": [
  23777. "Ext.ModelMgr"
  23778. ],
  23779. "Ext.data.XmlStore": [],
  23780. "Ext.grid.ViewDropZone": [],
  23781. "Ext.grid.header.DropZone": [],
  23782. "Ext.Layer": [],
  23783. "Ext.util.HashMap": [],
  23784. "Ext.grid.column.Template": [
  23785. "Ext.grid.TemplateColumn"
  23786. ],
  23787. "Ext.ComponentLoader": [],
  23788. "Ext.EventObjectImpl": [],
  23789. "Ext.form.FieldAncestor": [],
  23790. "Ext.chart.axis.Gauge": [],
  23791. "Ext.data.validations": [],
  23792. "Ext.data.Connection": [],
  23793. "Ext.dd.DropZone": [],
  23794. "Ext.direct.ExceptionEvent": [],
  23795. "Ext.resizer.Splitter": [],
  23796. "Ext.form.RadioManager": [],
  23797. "Ext.data.association.HasOne": [
  23798. "Ext.data.HasOneAssociation"
  23799. ],
  23800. "Ext.draw.Text": [],
  23801. "Ext.window.MessageBox": [],
  23802. "Ext.fx.target.CompositeElementCSS": [],
  23803. "Ext.chart.series.Line": [
  23804. "Ext.chart.LineSeries",
  23805. "Ext.chart.LineChart"
  23806. ],
  23807. "Ext.view.Table": [],
  23808. "Ext.data.writer.Json": [
  23809. "Ext.data.JsonWriter"
  23810. ],
  23811. "Ext.fx.Manager": [],
  23812. "Ext.fx.target.CompositeElement": [],
  23813. "Ext.chart.Label": [],
  23814. "Ext.grid.View": [],
  23815. "Ext.Action": [],
  23816. "Ext.form.Basic": [
  23817. "Ext.form.BasicForm"
  23818. ],
  23819. "Ext.container.Viewport": [
  23820. "Ext.Viewport"
  23821. ],
  23822. "Ext.state.Stateful": [],
  23823. "Ext.grid.feature.RowBody": [],
  23824. "Ext.form.field.Text": [
  23825. "Ext.form.TextField",
  23826. "Ext.form.Text"
  23827. ],
  23828. "Ext.data.reader.Xml": [
  23829. "Ext.data.XmlReader"
  23830. ],
  23831. "Ext.grid.feature.AbstractSummary": [],
  23832. "Ext.chart.axis.Category": [
  23833. "Ext.chart.CategoryAxis"
  23834. ],
  23835. "Ext.layout.container.Absolute": [
  23836. "Ext.layout.AbsoluteLayout"
  23837. ],
  23838. "Ext.data.reader.Json": [
  23839. "Ext.data.JsonReader"
  23840. ],
  23841. "Ext.util.TextMetrics": [],
  23842. "Ext.data.TreeStore": [],
  23843. "Ext.view.BoundList": [
  23844. "Ext.BoundList"
  23845. ],
  23846. "Ext.form.field.HtmlEditor": [
  23847. "Ext.form.HtmlEditor"
  23848. ],
  23849. "Ext.layout.container.Form": [
  23850. "Ext.layout.FormLayout"
  23851. ],
  23852. "Ext.chart.MaskLayer": [],
  23853. "Ext.util.Observable": [],
  23854. "Ext.resizer.BorderSplitterTracker": [],
  23855. "Ext.util.LruCache": [],
  23856. "Ext.tip.Tip": [
  23857. "Ext.Tip"
  23858. ],
  23859. "Ext.dom.CompositeElement": [
  23860. "Ext.CompositeElement"
  23861. ],
  23862. "Ext.grid.feature.RowWrap": [],
  23863. "Ext.data.proxy.Client": [
  23864. "Ext.data.ClientProxy"
  23865. ],
  23866. "Ext.data.Types": [],
  23867. "Ext.draw.SpriteDD": [],
  23868. "Ext.layout.container.boxOverflow.Menu": [
  23869. "Ext.layout.boxOverflow.Menu"
  23870. ],
  23871. "Ext.LoadMask": [],
  23872. "Ext.toolbar.Paging": [
  23873. "Ext.PagingToolbar"
  23874. ],
  23875. "Ext.data.association.Association": [
  23876. "Ext.data.Association"
  23877. ],
  23878. "Ext.tree.ViewDropZone": [],
  23879. "Ext.grid.LockingView": [],
  23880. "Ext.toolbar.Toolbar": [
  23881. "Ext.Toolbar"
  23882. ],
  23883. "Ext.tip.ToolTip": [
  23884. "Ext.ToolTip"
  23885. ],
  23886. "Ext.chart.Highlight": [],
  23887. "Ext.state.Manager": [],
  23888. "Ext.util.Inflector": [],
  23889. "Ext.grid.Panel": [
  23890. "Ext.list.ListView",
  23891. "Ext.ListView",
  23892. "Ext.grid.GridPanel"
  23893. ],
  23894. "Ext.XTemplate": [],
  23895. "Ext.data.NodeStore": [],
  23896. "Ext.Shadow": [],
  23897. "Ext.form.action.Submit": [
  23898. "Ext.form.Action.Submit"
  23899. ],
  23900. "Ext.form.Panel": [
  23901. "Ext.FormPanel",
  23902. "Ext.form.FormPanel"
  23903. ],
  23904. "Ext.chart.series.Series": [],
  23905. "Ext.perf.Accumulator": [],
  23906. "Ext.data.Request": [],
  23907. "Ext.dd.DD": [],
  23908. "Ext.dom.CompositeElementLite": [
  23909. "Ext.CompositeElementLite"
  23910. ],
  23911. "Ext.toolbar.Fill": [
  23912. "Ext.Toolbar.Fill"
  23913. ],
  23914. "Ext.grid.RowNumberer": [],
  23915. "Ext.data.proxy.WebStorage": [
  23916. "Ext.data.WebStorageProxy"
  23917. ],
  23918. "Ext.util.Floating": [],
  23919. "Ext.form.action.DirectSubmit": [
  23920. "Ext.form.Action.DirectSubmit"
  23921. ],
  23922. "Ext.util.Cookies": [],
  23923. "Ext.data.UuidGenerator": [],
  23924. "Ext.util.Point": [],
  23925. "Ext.fx.target.Component": [],
  23926. "Ext.form.CheckboxManager": [],
  23927. "Ext.form.field.Field": [],
  23928. "Ext.form.field.Display": [
  23929. "Ext.form.DisplayField",
  23930. "Ext.form.Display"
  23931. ],
  23932. "Ext.layout.container.Anchor": [
  23933. "Ext.layout.AnchorLayout"
  23934. ],
  23935. "Ext.layout.component.field.Text": [],
  23936. "Ext.data.DirectStore": [],
  23937. "Ext.data.BufferStore": [],
  23938. "Ext.grid.ColumnLayout": [],
  23939. "Ext.chart.series.Column": [
  23940. "Ext.chart.ColumnSeries",
  23941. "Ext.chart.ColumnChart",
  23942. "Ext.chart.StackedColumnChart"
  23943. ],
  23944. "Ext.Template": [],
  23945. "Ext.AbstractComponent": [],
  23946. "Ext.flash.Component": [
  23947. "Ext.FlashComponent"
  23948. ],
  23949. "Ext.form.field.Base": [
  23950. "Ext.form.Field",
  23951. "Ext.form.BaseField"
  23952. ],
  23953. "Ext.data.SequentialIdGenerator": [],
  23954. "Ext.grid.header.Container": [],
  23955. "Ext.container.ButtonGroup": [
  23956. "Ext.ButtonGroup"
  23957. ],
  23958. "Ext.grid.column.Action": [
  23959. "Ext.grid.ActionColumn"
  23960. ],
  23961. "Ext.layout.component.field.Trigger": [],
  23962. "Ext.layout.component.field.FieldContainer": [],
  23963. "Ext.chart.Shape": [],
  23964. "Ext.panel.DD": [],
  23965. "Ext.container.AbstractContainer": [],
  23966. "Ext.data.ArrayStore": [],
  23967. "Ext.window.Window": [
  23968. "Ext.Window"
  23969. ],
  23970. "Ext.picker.Color": [
  23971. "Ext.ColorPalette"
  23972. ],
  23973. "Ext.grid.feature.Feature": [],
  23974. "Ext.chart.theme.Theme": [],
  23975. "Ext.util.ClickRepeater": [],
  23976. "Ext.form.field.Spinner": [
  23977. "Ext.form.Spinner"
  23978. ],
  23979. "Ext.container.DockingContainer": [],
  23980. "Ext.selection.DataViewModel": [],
  23981. "Ext.dd.DragTracker": [],
  23982. "Ext.dd.DragDropManager": [
  23983. "Ext.dd.DragDropMgr",
  23984. "Ext.dd.DDM"
  23985. ],
  23986. "Ext.selection.CheckboxModel": [],
  23987. "Ext.layout.container.Column": [
  23988. "Ext.layout.ColumnLayout"
  23989. ],
  23990. "Ext.menu.KeyNav": [],
  23991. "Ext.draw.Matrix": [],
  23992. "Ext.form.field.Number": [
  23993. "Ext.form.NumberField",
  23994. "Ext.form.Number"
  23995. ],
  23996. "Ext.data.proxy.Direct": [
  23997. "Ext.data.DirectProxy"
  23998. ],
  23999. "Ext.chart.Navigation": [],
  24000. "Ext.slider.Tip": [],
  24001. "Ext.chart.theme.Base": [],
  24002. "Ext.form.field.TextArea": [
  24003. "Ext.form.TextArea"
  24004. ],
  24005. "Ext.form.field.Radio": [
  24006. "Ext.form.Radio"
  24007. ],
  24008. "Ext.layout.component.ProgressBar": [],
  24009. "Ext.chart.series.Pie": [
  24010. "Ext.chart.PieSeries",
  24011. "Ext.chart.PieChart"
  24012. ],
  24013. "Ext.view.TableChunker": [],
  24014. "Ext.tree.plugin.TreeViewDragDrop": [],
  24015. "Ext.direct.Provider": [],
  24016. "Ext.layout.Layout": [],
  24017. "Ext.toolbar.TextItem": [
  24018. "Ext.Toolbar.TextItem"
  24019. ],
  24020. "Ext.dom.Helper": [],
  24021. "Ext.util.AbstractMixedCollection": [],
  24022. "Ext.data.JsonStore": [],
  24023. "Ext.button.Split": [
  24024. "Ext.SplitButton"
  24025. ],
  24026. "Ext.dd.DropTarget": [],
  24027. "Ext.direct.RemotingEvent": [],
  24028. "Ext.draw.Sprite": [],
  24029. "Ext.fx.target.Sprite": [],
  24030. "Ext.data.proxy.LocalStorage": [
  24031. "Ext.data.LocalStorageProxy"
  24032. ],
  24033. "Ext.layout.component.Draw": [],
  24034. "Ext.AbstractPlugin": [],
  24035. "Ext.Editor": [],
  24036. "Ext.chart.axis.Radial": [],
  24037. "Ext.chart.Tip": [],
  24038. "Ext.layout.container.Table": [
  24039. "Ext.layout.TableLayout"
  24040. ],
  24041. "Ext.chart.axis.Abstract": [],
  24042. "Ext.data.proxy.Rest": [
  24043. "Ext.data.RestProxy"
  24044. ],
  24045. "Ext.util.Queue": [],
  24046. "Ext.state.CookieProvider": [],
  24047. "Ext.Img": [],
  24048. "Ext.dd.DragSource": [],
  24049. "Ext.grid.CellEditor": [],
  24050. "Ext.layout.ClassList": [],
  24051. "Ext.util.Sorter": [],
  24052. "Ext.resizer.SplitterTracker": [],
  24053. "Ext.panel.Table": [],
  24054. "Ext.draw.Color": [],
  24055. "Ext.chart.series.Bar": [
  24056. "Ext.chart.BarSeries",
  24057. "Ext.chart.BarChart",
  24058. "Ext.chart.StackedBarChart"
  24059. ],
  24060. "Ext.PluginManager": [
  24061. "Ext.PluginMgr"
  24062. ],
  24063. "Ext.util.ComponentDragger": [],
  24064. "Ext.chart.series.Scatter": [],
  24065. "Ext.chart.Callout": [],
  24066. "Ext.data.Store": [],
  24067. "Ext.grid.feature.Summary": [],
  24068. "Ext.layout.component.Component": [],
  24069. "Ext.util.ProtoElement": [],
  24070. "Ext.direct.Manager": [],
  24071. "Ext.data.proxy.Proxy": [
  24072. "Ext.data.DataProxy",
  24073. "Ext.data.Proxy"
  24074. ],
  24075. "Ext.menu.CheckItem": [],
  24076. "Ext.dom.AbstractElement": [],
  24077. "Ext.layout.container.Card": [
  24078. "Ext.layout.CardLayout"
  24079. ],
  24080. "Ext.draw.Component": [],
  24081. "Ext.toolbar.Item": [
  24082. "Ext.Toolbar.Item"
  24083. ],
  24084. "Ext.form.RadioGroup": [],
  24085. "Ext.slider.Thumb": [],
  24086. "Ext.grid.header.DragZone": [],
  24087. "Ext.form.action.DirectLoad": [
  24088. "Ext.form.Action.DirectLoad"
  24089. ],
  24090. "Ext.picker.Time": [],
  24091. "Ext.resizer.BorderSplitter": [],
  24092. "Ext.ZIndexManager": [
  24093. "Ext.WindowGroup"
  24094. ],
  24095. "Ext.menu.ColorPicker": [],
  24096. "Ext.menu.Menu": [],
  24097. "Ext.chart.LegendItem": [],
  24098. "Ext.toolbar.Spacer": [
  24099. "Ext.Toolbar.Spacer"
  24100. ],
  24101. "Ext.panel.Panel": [
  24102. "Ext.Panel"
  24103. ],
  24104. "Ext.util.Memento": [],
  24105. "Ext.data.proxy.Memory": [
  24106. "Ext.data.MemoryProxy"
  24107. ],
  24108. "Ext.chart.axis.Time": [
  24109. "Ext.chart.TimeAxis"
  24110. ],
  24111. "Ext.grid.plugin.DragDrop": [],
  24112. "Ext.layout.component.Tab": [],
  24113. "Ext.ComponentQuery": [],
  24114. "Ext.draw.engine.SvgExporter": [],
  24115. "Ext.grid.feature.Chunking": [],
  24116. "Ext.layout.container.Auto": [],
  24117. "Ext.view.AbstractView": [],
  24118. "Ext.util.Region": [],
  24119. "Ext.draw.Draw": [],
  24120. "Ext.fx.target.ElementCSS": [],
  24121. "Ext.grid.PagingScroller": [],
  24122. "Ext.layout.component.field.HtmlEditor": [],
  24123. "Ext.data.proxy.SessionStorage": [
  24124. "Ext.data.SessionStorageProxy"
  24125. ],
  24126. "Ext.app.EventBus": [],
  24127. "Ext.menu.Separator": [],
  24128. "Ext.util.History": [
  24129. "Ext.History"
  24130. ],
  24131. "Ext.direct.Event": [],
  24132. "Ext.direct.RemotingMethod": [],
  24133. "Ext.dd.ScrollManager": [],
  24134. "Ext.chart.Mask": [],
  24135. "Ext.selection.CellModel": [],
  24136. "Ext.view.TableLayout": [],
  24137. "Ext.state.Provider": [],
  24138. "Ext.layout.container.Editor": [],
  24139. "Ext.data.Errors": [],
  24140. "Ext.dom.AbstractQuery": [],
  24141. "Ext.selection.TreeModel": [],
  24142. "Ext.form.Labelable": [],
  24143. "Ext.grid.column.Number": [
  24144. "Ext.grid.NumberColumn"
  24145. ],
  24146. "Ext.draw.engine.Svg": [],
  24147. "Ext.grid.property.Grid": [
  24148. "Ext.grid.PropertyGrid"
  24149. ],
  24150. "Ext.FocusManager": [
  24151. "Ext.FocusMgr"
  24152. ],
  24153. "Ext.AbstractManager": [],
  24154. "Ext.chart.series.Radar": [],
  24155. "Ext.grid.property.Property": [
  24156. "Ext.PropGridProperty"
  24157. ],
  24158. "Ext.chart.TipSurface": [],
  24159. "Ext.grid.column.Boolean": [
  24160. "Ext.grid.BooleanColumn"
  24161. ],
  24162. "Ext.direct.PollingProvider": [],
  24163. "Ext.grid.plugin.HeaderResizer": [],
  24164. "Ext.data.writer.Xml": [
  24165. "Ext.data.XmlWriter"
  24166. ],
  24167. "Ext.tree.Column": [],
  24168. "Ext.slider.Multi": [
  24169. "Ext.slider.MultiSlider"
  24170. ],
  24171. "Ext.panel.AbstractPanel": [],
  24172. "Ext.layout.component.field.Slider": [],
  24173. "Ext.chart.axis.Numeric": [
  24174. "Ext.chart.NumericAxis"
  24175. ],
  24176. "Ext.layout.container.boxOverflow.Scroller": [
  24177. "Ext.layout.boxOverflow.Scroller"
  24178. ],
  24179. "Ext.data.Operation": [],
  24180. "Ext.layout.container.HBox": [
  24181. "Ext.layout.HBoxLayout"
  24182. ],
  24183. "Ext.resizer.Resizer": [
  24184. "Ext.Resizable"
  24185. ],
  24186. "Ext.selection.RowModel": [],
  24187. "Ext.layout.ContextItem": [],
  24188. "Ext.util.MixedCollection": [],
  24189. "Ext.perf.Monitor": [
  24190. "Ext.Perf"
  24191. ]
  24192. });Ext.ClassManager.addNameAliasMappings({
  24193. "Ext.draw.engine.ImageExporter": [],
  24194. "Ext.layout.component.Auto": [
  24195. "layout.autocomponent"
  24196. ],
  24197. "Ext.grid.property.Store": [],
  24198. "Ext.layout.container.Box": [
  24199. "layout.box"
  24200. ],
  24201. "Ext.direct.JsonProvider": [
  24202. "direct.jsonprovider"
  24203. ],
  24204. "Ext.tree.Panel": [
  24205. "widget.treepanel"
  24206. ],
  24207. "Ext.data.Model": [],
  24208. "Ext.data.reader.Reader": [],
  24209. "Ext.tab.Tab": [
  24210. "widget.tab"
  24211. ],
  24212. "Ext.button.Button": [
  24213. "widget.button"
  24214. ],
  24215. "Ext.util.Grouper": [],
  24216. "Ext.util.TaskRunner": [],
  24217. "Ext.direct.RemotingProvider": [
  24218. "direct.remotingprovider"
  24219. ],
  24220. "Ext.data.NodeInterface": [],
  24221. "Ext.grid.column.Date": [
  24222. "widget.datecolumn"
  24223. ],
  24224. "Ext.form.field.Trigger": [
  24225. "widget.triggerfield",
  24226. "widget.trigger"
  24227. ],
  24228. "Ext.grid.plugin.RowEditing": [
  24229. "plugin.rowediting"
  24230. ],
  24231. "Ext.tip.QuickTip": [
  24232. "widget.quicktip"
  24233. ],
  24234. "Ext.form.action.Load": [
  24235. "formaction.load"
  24236. ],
  24237. "Ext.form.field.ComboBox": [
  24238. "widget.combobox",
  24239. "widget.combo"
  24240. ],
  24241. "Ext.layout.container.Border": [
  24242. "layout.border"
  24243. ],
  24244. "Ext.data.JsonPStore": [
  24245. "store.jsonp"
  24246. ],
  24247. "Ext.layout.component.field.TextArea": [
  24248. "layout.textareafield"
  24249. ],
  24250. "Ext.dom.AbstractHelper": [],
  24251. "Ext.layout.container.Container": [],
  24252. "Ext.util.Sortable": [],
  24253. "Ext.selection.Model": [],
  24254. "Ext.draw.CompositeSprite": [],
  24255. "Ext.fx.Queue": [],
  24256. "Ext.dd.StatusProxy": [],
  24257. "Ext.form.field.Checkbox": [
  24258. "widget.checkboxfield",
  24259. "widget.checkbox"
  24260. ],
  24261. "Ext.XTemplateCompiler": [],
  24262. "Ext.direct.Transaction": [
  24263. "direct.transaction"
  24264. ],
  24265. "Ext.util.Offset": [],
  24266. "Ext.dom.Element": [],
  24267. "Ext.view.DragZone": [],
  24268. "Ext.util.KeyNav": [],
  24269. "Ext.form.field.File": [
  24270. "widget.filefield",
  24271. "widget.fileuploadfield"
  24272. ],
  24273. "Ext.slider.Single": [
  24274. "widget.slider",
  24275. "widget.sliderfield"
  24276. ],
  24277. "Ext.panel.Proxy": [],
  24278. "Ext.fx.target.Target": [],
  24279. "Ext.ComponentManager": [],
  24280. "Ext.grid.feature.GroupingSummary": [
  24281. "feature.groupingsummary"
  24282. ],
  24283. "Ext.grid.property.HeaderContainer": [],
  24284. "Ext.layout.component.BoundList": [
  24285. "layout.boundlist"
  24286. ],
  24287. "Ext.tab.Bar": [
  24288. "widget.tabbar"
  24289. ],
  24290. "Ext.app.Application": [],
  24291. "Ext.ShadowPool": [],
  24292. "Ext.layout.container.Accordion": [
  24293. "layout.accordion"
  24294. ],
  24295. "Ext.resizer.ResizeTracker": [],
  24296. "Ext.layout.container.boxOverflow.None": [],
  24297. "Ext.panel.Tool": [
  24298. "widget.tool"
  24299. ],
  24300. "Ext.tree.View": [
  24301. "widget.treeview"
  24302. ],
  24303. "Ext.ElementLoader": [],
  24304. "Ext.grid.ColumnComponentLayout": [
  24305. "layout.columncomponent"
  24306. ],
  24307. "Ext.toolbar.Separator": [
  24308. "widget.tbseparator"
  24309. ],
  24310. "Ext.dd.DragZone": [],
  24311. "Ext.util.Renderable": [],
  24312. "Ext.layout.component.FieldSet": [
  24313. "layout.fieldset"
  24314. ],
  24315. "Ext.util.Bindable": [],
  24316. "Ext.data.SortTypes": [],
  24317. "Ext.util.Animate": [],
  24318. "Ext.form.field.Date": [
  24319. "widget.datefield"
  24320. ],
  24321. "Ext.Component": [
  24322. "widget.component",
  24323. "widget.box"
  24324. ],
  24325. "Ext.chart.axis.Axis": [],
  24326. "Ext.fx.target.CompositeSprite": [],
  24327. "Ext.menu.DatePicker": [
  24328. "widget.datemenu"
  24329. ],
  24330. "Ext.form.field.Picker": [
  24331. "widget.pickerfield"
  24332. ],
  24333. "Ext.fx.Animator": [],
  24334. "Ext.Ajax": [],
  24335. "Ext.layout.component.Dock": [
  24336. "layout.dock"
  24337. ],
  24338. "Ext.util.Filter": [],
  24339. "Ext.dd.DragDrop": [],
  24340. "Ext.grid.Scroller": [],
  24341. "Ext.view.View": [
  24342. "widget.dataview"
  24343. ],
  24344. "Ext.data.association.BelongsTo": [
  24345. "association.belongsto"
  24346. ],
  24347. "Ext.fx.target.Element": [],
  24348. "Ext.draw.Surface": [],
  24349. "Ext.dd.DDProxy": [],
  24350. "Ext.data.AbstractStore": [],
  24351. "Ext.form.action.StandardSubmit": [
  24352. "formaction.standardsubmit"
  24353. ],
  24354. "Ext.grid.Lockable": [],
  24355. "Ext.dd.Registry": [],
  24356. "Ext.picker.Month": [
  24357. "widget.monthpicker"
  24358. ],
  24359. "Ext.container.Container": [
  24360. "widget.container"
  24361. ],
  24362. "Ext.menu.Manager": [],
  24363. "Ext.util.KeyMap": [],
  24364. "Ext.data.Batch": [],
  24365. "Ext.resizer.Handle": [],
  24366. "Ext.util.ElementContainer": [],
  24367. "Ext.grid.feature.Grouping": [
  24368. "feature.grouping"
  24369. ],
  24370. "Ext.tab.Panel": [
  24371. "widget.tabpanel"
  24372. ],
  24373. "Ext.layout.component.Body": [
  24374. "layout.body"
  24375. ],
  24376. "Ext.layout.Context": [],
  24377. "Ext.layout.component.field.ComboBox": [
  24378. "layout.combobox"
  24379. ],
  24380. "Ext.dd.DDTarget": [],
  24381. "Ext.chart.Chart": [
  24382. "widget.chart"
  24383. ],
  24384. "Ext.data.Field": [
  24385. "data.field"
  24386. ],
  24387. "Ext.chart.series.Gauge": [
  24388. "series.gauge"
  24389. ],
  24390. "Ext.data.StoreManager": [],
  24391. "Ext.tip.QuickTipManager": [],
  24392. "Ext.data.IdGenerator": [],
  24393. "Ext.grid.plugin.Editing": [
  24394. "editing.editing"
  24395. ],
  24396. "Ext.grid.RowEditor": [],
  24397. "Ext.state.LocalStorageProvider": [
  24398. "state.localstorage"
  24399. ],
  24400. "Ext.form.action.Action": [],
  24401. "Ext.ProgressBar": [
  24402. "widget.progressbar"
  24403. ],
  24404. "Ext.tree.ViewDragZone": [],
  24405. "Ext.data.reader.Array": [
  24406. "reader.array"
  24407. ],
  24408. "Ext.picker.Date": [
  24409. "widget.datepicker"
  24410. ],
  24411. "Ext.data.proxy.JsonP": [
  24412. "proxy.jsonp",
  24413. "proxy.scripttag"
  24414. ],
  24415. "Ext.chart.series.Area": [
  24416. "series.area"
  24417. ],
  24418. "Ext.fx.Anim": [],
  24419. "Ext.menu.Item": [
  24420. "widget.menuitem"
  24421. ],
  24422. "Ext.chart.Legend": [],
  24423. "Ext.grid.plugin.HeaderReorderer": [
  24424. "plugin.gridheaderreorderer"
  24425. ],
  24426. "Ext.layout.container.VBox": [
  24427. "layout.vbox"
  24428. ],
  24429. "Ext.view.DropZone": [],
  24430. "Ext.layout.component.Button": [
  24431. "layout.button"
  24432. ],
  24433. "Ext.form.field.Hidden": [
  24434. "widget.hiddenfield",
  24435. "widget.hidden"
  24436. ],
  24437. "Ext.form.FieldContainer": [
  24438. "widget.fieldcontainer"
  24439. ],
  24440. "Ext.data.proxy.Server": [
  24441. "proxy.server"
  24442. ],
  24443. "Ext.chart.series.Cartesian": [],
  24444. "Ext.grid.column.Column": [
  24445. "widget.gridcolumn"
  24446. ],
  24447. "Ext.data.ResultSet": [],
  24448. "Ext.data.association.HasMany": [
  24449. "association.hasmany"
  24450. ],
  24451. "Ext.layout.container.Fit": [
  24452. "layout.fit"
  24453. ],
  24454. "Ext.util.CSS": [],
  24455. "Ext.layout.component.field.Field": [
  24456. "layout.field"
  24457. ],
  24458. "Ext.data.proxy.Ajax": [
  24459. "proxy.ajax"
  24460. ],
  24461. "Ext.form.Label": [
  24462. "widget.label"
  24463. ],
  24464. "Ext.data.writer.Writer": [
  24465. "writer.base"
  24466. ],
  24467. "Ext.view.BoundListKeyNav": [],
  24468. "Ext.form.FieldSet": [
  24469. "widget.fieldset"
  24470. ],
  24471. "Ext.XTemplateParser": [],
  24472. "Ext.form.field.VTypes": [],
  24473. "Ext.fx.PropertyHandler": [],
  24474. "Ext.form.CheckboxGroup": [
  24475. "widget.checkboxgroup"
  24476. ],
  24477. "Ext.data.JsonP": [],
  24478. "Ext.draw.engine.Vml": [],
  24479. "Ext.layout.container.CheckboxGroup": [
  24480. "layout.checkboxgroup"
  24481. ],
  24482. "Ext.panel.Header": [
  24483. "widget.header"
  24484. ],
  24485. "Ext.app.Controller": [],
  24486. "Ext.grid.plugin.CellEditing": [
  24487. "plugin.cellediting"
  24488. ],
  24489. "Ext.form.field.Time": [
  24490. "widget.timefield"
  24491. ],
  24492. "Ext.fx.CubicBezier": [],
  24493. "Ext.button.Cycle": [
  24494. "widget.cycle"
  24495. ],
  24496. "Ext.data.Tree": [
  24497. "data.tree"
  24498. ],
  24499. "Ext.ModelManager": [],
  24500. "Ext.data.XmlStore": [
  24501. "store.xml"
  24502. ],
  24503. "Ext.grid.ViewDropZone": [],
  24504. "Ext.grid.header.DropZone": [],
  24505. "Ext.Layer": [],
  24506. "Ext.util.HashMap": [],
  24507. "Ext.grid.column.Template": [
  24508. "widget.templatecolumn"
  24509. ],
  24510. "Ext.ComponentLoader": [],
  24511. "Ext.EventObjectImpl": [],
  24512. "Ext.form.FieldAncestor": [],
  24513. "Ext.chart.axis.Gauge": [
  24514. "axis.gauge"
  24515. ],
  24516. "Ext.data.validations": [],
  24517. "Ext.data.Connection": [],
  24518. "Ext.dd.DropZone": [],
  24519. "Ext.direct.ExceptionEvent": [
  24520. "direct.exception"
  24521. ],
  24522. "Ext.resizer.Splitter": [
  24523. "widget.splitter"
  24524. ],
  24525. "Ext.form.RadioManager": [],
  24526. "Ext.data.association.HasOne": [
  24527. "association.hasone"
  24528. ],
  24529. "Ext.draw.Text": [
  24530. "widget.text"
  24531. ],
  24532. "Ext.window.MessageBox": [
  24533. "widget.messagebox"
  24534. ],
  24535. "Ext.fx.target.CompositeElementCSS": [],
  24536. "Ext.chart.series.Line": [
  24537. "series.line"
  24538. ],
  24539. "Ext.view.Table": [
  24540. "widget.tableview"
  24541. ],
  24542. "Ext.data.writer.Json": [
  24543. "writer.json"
  24544. ],
  24545. "Ext.fx.Manager": [],
  24546. "Ext.fx.target.CompositeElement": [],
  24547. "Ext.chart.Label": [],
  24548. "Ext.grid.View": [
  24549. "widget.gridview"
  24550. ],
  24551. "Ext.Action": [],
  24552. "Ext.form.Basic": [],
  24553. "Ext.container.Viewport": [
  24554. "widget.viewport"
  24555. ],
  24556. "Ext.state.Stateful": [],
  24557. "Ext.grid.feature.RowBody": [
  24558. "feature.rowbody"
  24559. ],
  24560. "Ext.form.field.Text": [
  24561. "widget.textfield"
  24562. ],
  24563. "Ext.data.reader.Xml": [
  24564. "reader.xml"
  24565. ],
  24566. "Ext.grid.feature.AbstractSummary": [
  24567. "feature.abstractsummary"
  24568. ],
  24569. "Ext.chart.axis.Category": [
  24570. "axis.category"
  24571. ],
  24572. "Ext.layout.container.Absolute": [
  24573. "layout.absolute"
  24574. ],
  24575. "Ext.data.reader.Json": [
  24576. "reader.json"
  24577. ],
  24578. "Ext.util.TextMetrics": [],
  24579. "Ext.data.TreeStore": [
  24580. "store.tree"
  24581. ],
  24582. "Ext.view.BoundList": [
  24583. "widget.boundlist"
  24584. ],
  24585. "Ext.form.field.HtmlEditor": [
  24586. "widget.htmleditor"
  24587. ],
  24588. "Ext.layout.container.Form": [
  24589. "layout.form"
  24590. ],
  24591. "Ext.chart.MaskLayer": [],
  24592. "Ext.util.Observable": [],
  24593. "Ext.resizer.BorderSplitterTracker": [],
  24594. "Ext.util.LruCache": [],
  24595. "Ext.tip.Tip": [],
  24596. "Ext.dom.CompositeElement": [],
  24597. "Ext.grid.feature.RowWrap": [
  24598. "feature.rowwrap"
  24599. ],
  24600. "Ext.data.proxy.Client": [],
  24601. "Ext.data.Types": [],
  24602. "Ext.draw.SpriteDD": [],
  24603. "Ext.layout.container.boxOverflow.Menu": [],
  24604. "Ext.LoadMask": [
  24605. "widget.loadmask"
  24606. ],
  24607. "Ext.toolbar.Paging": [
  24608. "widget.pagingtoolbar"
  24609. ],
  24610. "Ext.data.association.Association": [],
  24611. "Ext.tree.ViewDropZone": [],
  24612. "Ext.grid.LockingView": [],
  24613. "Ext.toolbar.Toolbar": [
  24614. "widget.toolbar"
  24615. ],
  24616. "Ext.tip.ToolTip": [
  24617. "widget.tooltip"
  24618. ],
  24619. "Ext.chart.Highlight": [],
  24620. "Ext.state.Manager": [],
  24621. "Ext.util.Inflector": [],
  24622. "Ext.grid.Panel": [
  24623. "widget.gridpanel",
  24624. "widget.grid"
  24625. ],
  24626. "Ext.XTemplate": [],
  24627. "Ext.data.NodeStore": [
  24628. "store.node"
  24629. ],
  24630. "Ext.Shadow": [],
  24631. "Ext.form.action.Submit": [
  24632. "formaction.submit"
  24633. ],
  24634. "Ext.form.Panel": [
  24635. "widget.form"
  24636. ],
  24637. "Ext.chart.series.Series": [],
  24638. "Ext.perf.Accumulator": [],
  24639. "Ext.data.Request": [],
  24640. "Ext.dd.DD": [],
  24641. "Ext.dom.CompositeElementLite": [],
  24642. "Ext.toolbar.Fill": [
  24643. "widget.tbfill"
  24644. ],
  24645. "Ext.grid.RowNumberer": [
  24646. "widget.rownumberer"
  24647. ],
  24648. "Ext.data.proxy.WebStorage": [],
  24649. "Ext.util.Floating": [],
  24650. "Ext.form.action.DirectSubmit": [
  24651. "formaction.directsubmit"
  24652. ],
  24653. "Ext.util.Cookies": [],
  24654. "Ext.data.UuidGenerator": [
  24655. "idgen.uuid"
  24656. ],
  24657. "Ext.util.Point": [],
  24658. "Ext.fx.target.Component": [],
  24659. "Ext.form.CheckboxManager": [],
  24660. "Ext.form.field.Field": [],
  24661. "Ext.form.field.Display": [
  24662. "widget.displayfield"
  24663. ],
  24664. "Ext.layout.container.Anchor": [
  24665. "layout.anchor"
  24666. ],
  24667. "Ext.layout.component.field.Text": [
  24668. "layout.textfield"
  24669. ],
  24670. "Ext.data.DirectStore": [
  24671. "store.direct"
  24672. ],
  24673. "Ext.data.BufferStore": [
  24674. "store.buffer"
  24675. ],
  24676. "Ext.grid.ColumnLayout": [
  24677. "layout.gridcolumn"
  24678. ],
  24679. "Ext.chart.series.Column": [
  24680. "series.column"
  24681. ],
  24682. "Ext.Template": [],
  24683. "Ext.AbstractComponent": [],
  24684. "Ext.flash.Component": [
  24685. "widget.flash"
  24686. ],
  24687. "Ext.form.field.Base": [
  24688. "widget.field"
  24689. ],
  24690. "Ext.data.SequentialIdGenerator": [
  24691. "idgen.sequential"
  24692. ],
  24693. "Ext.grid.header.Container": [
  24694. "widget.headercontainer"
  24695. ],
  24696. "Ext.container.ButtonGroup": [
  24697. "widget.buttongroup"
  24698. ],
  24699. "Ext.grid.column.Action": [
  24700. "widget.actioncolumn"
  24701. ],
  24702. "Ext.layout.component.field.Trigger": [
  24703. "layout.triggerfield"
  24704. ],
  24705. "Ext.layout.component.field.FieldContainer": [
  24706. "layout.fieldcontainer"
  24707. ],
  24708. "Ext.chart.Shape": [],
  24709. "Ext.panel.DD": [],
  24710. "Ext.container.AbstractContainer": [],
  24711. "Ext.data.ArrayStore": [
  24712. "store.array"
  24713. ],
  24714. "Ext.window.Window": [
  24715. "widget.window"
  24716. ],
  24717. "Ext.picker.Color": [
  24718. "widget.colorpicker"
  24719. ],
  24720. "Ext.grid.feature.Feature": [
  24721. "feature.feature"
  24722. ],
  24723. "Ext.chart.theme.Theme": [],
  24724. "Ext.util.ClickRepeater": [],
  24725. "Ext.form.field.Spinner": [
  24726. "widget.spinnerfield"
  24727. ],
  24728. "Ext.container.DockingContainer": [],
  24729. "Ext.selection.DataViewModel": [],
  24730. "Ext.dd.DragTracker": [],
  24731. "Ext.dd.DragDropManager": [],
  24732. "Ext.selection.CheckboxModel": [
  24733. "selection.checkboxmodel"
  24734. ],
  24735. "Ext.layout.container.Column": [
  24736. "layout.column"
  24737. ],
  24738. "Ext.menu.KeyNav": [],
  24739. "Ext.draw.Matrix": [],
  24740. "Ext.form.field.Number": [
  24741. "widget.numberfield"
  24742. ],
  24743. "Ext.data.proxy.Direct": [
  24744. "proxy.direct"
  24745. ],
  24746. "Ext.chart.Navigation": [],
  24747. "Ext.slider.Tip": [
  24748. "widget.slidertip"
  24749. ],
  24750. "Ext.chart.theme.Base": [],
  24751. "Ext.form.field.TextArea": [
  24752. "widget.textareafield",
  24753. "widget.textarea"
  24754. ],
  24755. "Ext.form.field.Radio": [
  24756. "widget.radiofield",
  24757. "widget.radio"
  24758. ],
  24759. "Ext.layout.component.ProgressBar": [
  24760. "layout.progressbar"
  24761. ],
  24762. "Ext.chart.series.Pie": [
  24763. "series.pie"
  24764. ],
  24765. "Ext.view.TableChunker": [],
  24766. "Ext.tree.plugin.TreeViewDragDrop": [
  24767. "plugin.treeviewdragdrop"
  24768. ],
  24769. "Ext.direct.Provider": [
  24770. "direct.provider"
  24771. ],
  24772. "Ext.layout.Layout": [],
  24773. "Ext.toolbar.TextItem": [
  24774. "widget.tbtext"
  24775. ],
  24776. "Ext.dom.Helper": [],
  24777. "Ext.util.AbstractMixedCollection": [],
  24778. "Ext.data.JsonStore": [
  24779. "store.json"
  24780. ],
  24781. "Ext.button.Split": [
  24782. "widget.splitbutton"
  24783. ],
  24784. "Ext.dd.DropTarget": [],
  24785. "Ext.direct.RemotingEvent": [
  24786. "direct.rpc"
  24787. ],
  24788. "Ext.draw.Sprite": [],
  24789. "Ext.fx.target.Sprite": [],
  24790. "Ext.data.proxy.LocalStorage": [
  24791. "proxy.localstorage"
  24792. ],
  24793. "Ext.layout.component.Draw": [
  24794. "layout.draw"
  24795. ],
  24796. "Ext.AbstractPlugin": [],
  24797. "Ext.Editor": [
  24798. "widget.editor"
  24799. ],
  24800. "Ext.chart.axis.Radial": [
  24801. "axis.radial"
  24802. ],
  24803. "Ext.chart.Tip": [],
  24804. "Ext.layout.container.Table": [
  24805. "layout.table"
  24806. ],
  24807. "Ext.chart.axis.Abstract": [],
  24808. "Ext.data.proxy.Rest": [
  24809. "proxy.rest"
  24810. ],
  24811. "Ext.util.Queue": [],
  24812. "Ext.state.CookieProvider": [],
  24813. "Ext.Img": [
  24814. "widget.image",
  24815. "widget.imagecomponent"
  24816. ],
  24817. "Ext.dd.DragSource": [],
  24818. "Ext.grid.CellEditor": [],
  24819. "Ext.layout.ClassList": [],
  24820. "Ext.util.Sorter": [],
  24821. "Ext.resizer.SplitterTracker": [],
  24822. "Ext.panel.Table": [
  24823. "widget.tablepanel"
  24824. ],
  24825. "Ext.draw.Color": [],
  24826. "Ext.chart.series.Bar": [
  24827. "series.bar"
  24828. ],
  24829. "Ext.PluginManager": [],
  24830. "Ext.util.ComponentDragger": [],
  24831. "Ext.chart.series.Scatter": [
  24832. "series.scatter"
  24833. ],
  24834. "Ext.chart.Callout": [],
  24835. "Ext.data.Store": [
  24836. "store.store"
  24837. ],
  24838. "Ext.grid.feature.Summary": [
  24839. "feature.summary"
  24840. ],
  24841. "Ext.layout.component.Component": [],
  24842. "Ext.util.ProtoElement": [],
  24843. "Ext.direct.Manager": [],
  24844. "Ext.data.proxy.Proxy": [
  24845. "proxy.proxy"
  24846. ],
  24847. "Ext.menu.CheckItem": [
  24848. "widget.menucheckitem"
  24849. ],
  24850. "Ext.dom.AbstractElement": [],
  24851. "Ext.layout.container.Card": [
  24852. "layout.card"
  24853. ],
  24854. "Ext.draw.Component": [
  24855. "widget.draw"
  24856. ],
  24857. "Ext.toolbar.Item": [
  24858. "widget.tbitem"
  24859. ],
  24860. "Ext.form.RadioGroup": [
  24861. "widget.radiogroup"
  24862. ],
  24863. "Ext.slider.Thumb": [],
  24864. "Ext.grid.header.DragZone": [],
  24865. "Ext.form.action.DirectLoad": [
  24866. "formaction.directload"
  24867. ],
  24868. "Ext.picker.Time": [
  24869. "widget.timepicker"
  24870. ],
  24871. "Ext.resizer.BorderSplitter": [
  24872. "widget.bordersplitter"
  24873. ],
  24874. "Ext.ZIndexManager": [],
  24875. "Ext.menu.ColorPicker": [
  24876. "widget.colormenu"
  24877. ],
  24878. "Ext.menu.Menu": [
  24879. "widget.menu"
  24880. ],
  24881. "Ext.chart.LegendItem": [],
  24882. "Ext.toolbar.Spacer": [
  24883. "widget.tbspacer"
  24884. ],
  24885. "Ext.panel.Panel": [
  24886. "widget.panel"
  24887. ],
  24888. "Ext.util.Memento": [],
  24889. "Ext.data.proxy.Memory": [
  24890. "proxy.memory"
  24891. ],
  24892. "Ext.chart.axis.Time": [
  24893. "axis.time"
  24894. ],
  24895. "Ext.grid.plugin.DragDrop": [
  24896. "plugin.gridviewdragdrop"
  24897. ],
  24898. "Ext.layout.component.Tab": [
  24899. "layout.tab"
  24900. ],
  24901. "Ext.ComponentQuery": [],
  24902. "Ext.draw.engine.SvgExporter": [],
  24903. "Ext.grid.feature.Chunking": [
  24904. "feature.chunking"
  24905. ],
  24906. "Ext.layout.container.Auto": [
  24907. "layout.auto",
  24908. "layout.autocontainer"
  24909. ],
  24910. "Ext.view.AbstractView": [],
  24911. "Ext.util.Region": [],
  24912. "Ext.draw.Draw": [],
  24913. "Ext.fx.target.ElementCSS": [],
  24914. "Ext.grid.PagingScroller": [],
  24915. "Ext.layout.component.field.HtmlEditor": [
  24916. "layout.htmleditor"
  24917. ],
  24918. "Ext.data.proxy.SessionStorage": [
  24919. "proxy.sessionstorage"
  24920. ],
  24921. "Ext.app.EventBus": [],
  24922. "Ext.menu.Separator": [
  24923. "widget.menuseparator"
  24924. ],
  24925. "Ext.util.History": [],
  24926. "Ext.direct.Event": [
  24927. "direct.event"
  24928. ],
  24929. "Ext.direct.RemotingMethod": [],
  24930. "Ext.dd.ScrollManager": [],
  24931. "Ext.chart.Mask": [],
  24932. "Ext.selection.CellModel": [
  24933. "selection.cellmodel"
  24934. ],
  24935. "Ext.view.TableLayout": [
  24936. "layout.tableview"
  24937. ],
  24938. "Ext.state.Provider": [],
  24939. "Ext.layout.container.Editor": [
  24940. "layout.editor"
  24941. ],
  24942. "Ext.data.Errors": [],
  24943. "Ext.dom.AbstractQuery": [],
  24944. "Ext.selection.TreeModel": [
  24945. "selection.treemodel"
  24946. ],
  24947. "Ext.form.Labelable": [],
  24948. "Ext.grid.column.Number": [
  24949. "widget.numbercolumn"
  24950. ],
  24951. "Ext.draw.engine.Svg": [],
  24952. "Ext.grid.property.Grid": [
  24953. "widget.propertygrid"
  24954. ],
  24955. "Ext.FocusManager": [],
  24956. "Ext.AbstractManager": [],
  24957. "Ext.chart.series.Radar": [
  24958. "series.radar"
  24959. ],
  24960. "Ext.grid.property.Property": [],
  24961. "Ext.chart.TipSurface": [],
  24962. "Ext.grid.column.Boolean": [
  24963. "widget.booleancolumn"
  24964. ],
  24965. "Ext.direct.PollingProvider": [
  24966. "direct.pollingprovider"
  24967. ],
  24968. "Ext.grid.plugin.HeaderResizer": [
  24969. "plugin.gridheaderresizer"
  24970. ],
  24971. "Ext.data.writer.Xml": [
  24972. "writer.xml"
  24973. ],
  24974. "Ext.tree.Column": [
  24975. "widget.treecolumn"
  24976. ],
  24977. "Ext.slider.Multi": [
  24978. "widget.multislider"
  24979. ],
  24980. "Ext.panel.AbstractPanel": [],
  24981. "Ext.layout.component.field.Slider": [
  24982. "layout.sliderfield"
  24983. ],
  24984. "Ext.chart.axis.Numeric": [
  24985. "axis.numeric"
  24986. ],
  24987. "Ext.layout.container.boxOverflow.Scroller": [],
  24988. "Ext.data.Operation": [],
  24989. "Ext.layout.container.HBox": [
  24990. "layout.hbox"
  24991. ],
  24992. "Ext.resizer.Resizer": [],
  24993. "Ext.selection.RowModel": [
  24994. "selection.rowmodel"
  24995. ],
  24996. "Ext.layout.ContextItem": [],
  24997. "Ext.util.MixedCollection": [],
  24998. "Ext.perf.Monitor": []
  24999. });